tulsawebdevs / django-multi-gtfs

Django app to import and export General Transit Feed Specification (GTFS)
http://tulsawebdevs.org/
Apache License 2.0
50 stars 32 forks source link

Do exact match when searching for file to import #104

Closed daliborpavlovic closed 2 years ago

daliborpavlovic commented 3 years ago

When searching the feed to import, endswith() is used to search for the file in the zip up to now. It causes problem when there are custom files like routes_stops.txt, confusing stops.txt with the former file with this approach. I suggest to replace the endswith() comparison with an exact match.

jwhitlock commented 3 years ago

I think an exact match on the filename is a good idea, but this change is failing on tests that work with multigtfs/tests/fixtures/test1.zip, such as:

https://github.com/tulsawebdevs/django-multi-gtfs/blob/345b39eb7f575961fe4f8d8f1fc83044ab789080/multigtfs/tests/test_feed.py#L61-L68

The issue is that the zip file has a folder, so the files are at dv/stops.txt rather than stops.txt. This matches with endswith and not with an exact match. The path needs to be processed first to extract the filename, then do the exact match.

daliborpavlovic commented 2 years ago

Thanks @jwhitlock , I have fixed the issue.

jwhitlock commented 2 years ago

Thanks @daliborpavlovic!