google / transitfeed

A Python library for reading, validating, and writing transit schedule information in the GTFS format.
https://github.com/google/transitfeed/wiki
Apache License 2.0
679 stars 254 forks source link

WIP: py2/3 compatibility for Load function in transitfeed/loader.py #497

Closed trevh3 closed 8 months ago

trevh3 commented 4 years ago

I realize this is broken, but I'm looking for a little insight/advice on the implementation. 1) Are we shooting for total py2/3 backwards compatibility? I'm assuming yes. 2) Assuming _GetUtf8Contents() should return a bytes object of utf-8 data. 3) Assuming EndOfLineChecker class should take in a bytes object of utf-8 data and return bytes objects "rows" of utf-8 data. 4) At this point, csv.reader in python3 only accepts strings, so I used codecs.iterdecode('utf-8') to decode the data before passing it to the reader.

@jarondl any thoughts about better ways to go about implementing this?

Again, realizing this is incomplete, just don't want to get too far down this road before getting feedback

trevh3 commented 4 years ago

Note: I'm keeping python 2 and python 3 differences separate by using if sys.version_info[0] < 3: so that I can mentally keep track of the differences between py2 and py3. Before final review, they will be merged together in a more elegant fashion.

olivierhill commented 4 years ago

Hello @trevh3 any reason this can't be merged? Let me know if I can help

trevh3 commented 4 years ago

would not merge. Never got a proper review or answers to my questions, so I couldn’t continue with confidence. Feel free to take it and run with it though.