Skip to content

Gtfs export fixes#109

Closed
bovine3dom wants to merge 2 commits intoMMTIS:mainfrom
bovine3dom:gtfs_export_fixes
Closed

Gtfs export fixes#109
bovine3dom wants to merge 2 commits intoMMTIS:mainfrom
bovine3dom:gtfs_export_fixes

Conversation

@bovine3dom
Copy link

Hi, I was trying to convert the Trenitalia NetEx export - https://api.transitous.org/gtfs/it_Toscana-Trenitalia.gtfs.zip - to GTFS following the instructions on the readme

uv run python -m conv.netex_to_db data/it_trenitalia.netex.zip data/it_trenitalia.lmdb
uv run python -m conv.gtfs_db_to_db data/it_trenitalia.lmdb data/it_trenitalia_gtfs.lmdb
uv run python -m conv.gtfs_db_to_gtfs data/it_trenitalia_gtfs.lmdb it_trenitalia_badger.gtfs.zip

and I hit the following errors:

 ~/p/badger (main|✚1) $ uv run python -m conv.gtfs_db_to_gtfs data/it_trenitalia_gtfs.lmdb it_trenitalia_badger.gtfs.zip
 Traceback (most recent call last):
   File "<frozen runpy>", line 198, in _run_module_as_main
   File "<frozen runpy>", line 88, in _run_code
   File "/home/olie/projects/badger/conv/gtfs_db_to_gtfs.py", line 8, in <module>
     from transformers.gtfsprofile import GtfsProfile
   File "/home/olie/projects/badger/transformers/gtfsprofile.py", line 15, in <module>
     from netex import (
     ...<43 lines>...
     )
 ImportError: cannot import name 'AllVehicleModesOfTransportEnumeration' from 'netex' (/home/olie/projects/badger/netex/__init__.py)
$ uv run python -m conv.gtfs_db_to_gtfs data/it_trenitalia_gtfs.lmdb it_trenitalia_badger.gtfs.zip

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/olie/projects/badger/conv/gtfs_db_to_gtfs.py", line 333, in <module>
    main(args.netex, args.gtfs)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/olie/projects/badger/conv/gtfs_db_to_gtfs.py", line 322, in main
    extract(archive, netex)
    ~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/olie/projects/badger/conv/gtfs_db_to_gtfs.py", line 68, in extract
    agency = GtfsProfile.projectOperatorToAgency(operator)
  File "/home/olie/projects/badger/transformers/gtfsprofile.py", line 280, in projectOperatorToAgency
    "agency_name": GtfsProfile.getOptionalMultilingualString(operator.name)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/olie/projects/badger/transformers/gtfsprofile.py", line 155, in getOptionalMultilingualString
    return multilingual_string.value
           ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MultilingualString' object has no attribute 'value'

This PR is an attempt to fix those errors. And indeed the project does seem to now work for my purposes and I now have some nice Trenitalia GTFS to play with :)

@skinkie
Copy link
Contributor

skinkie commented Feb 18, 2026

Hi, thanks for your contribution. Our current work happens against the binary serializer branch, which replaced lmdb with mdbx, which makes a lot of things better, but certainly does not cleanly apply your patch. Multilingual string in NeTEx 2.0 has some particularities because it supports the 'old' interface, and 'new' interface having embedded translations.

My suggestion try out the other branch, and the gtfs conversion. If that does not work, open a issue.

@bovine3dom
Copy link
Author

Thanks! Yep, you're right, that worked fine. Closing in favour of #110

@bovine3dom bovine3dom closed this Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants