invalid syntax generated for an ubl invoice 2.1 #48

Closed
cb-malik opened this Issue Nov 30, 2015 · 1 comment

Projects

None yet

2 participants

@cb-malik

Hi,

First good job setting up such a nice tool.

I have an issue with the schema for ubl invoices, it works for ubl 2.0 but not ubl 2.1

here you have the schema http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/

and I have this exception when I try to import the module generated by pyxbgen

  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl_reader.py", line 1, in <module>
    from utils.ubl.ubl21 import invoice as ubl_invoice
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/invoice.py", line 27, in <module>
    import utils.ubl.ubl21._cac as _ImportedBinding_utils_ubl_ubl21__cac
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/_cac.py", line 27, in <module>
    import utils.ubl.ubl21._cbc as _ImportedBinding_utils_ubl_ubl21__cbc
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/_cbc.py", line 28, in <module>
    import utils.ubl.ubl21._udt as _ImportedBinding_utils_ubl_ubl21__udt
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/_udt.py", line 27
    import utils.ubl.ubl21._ccts-cct as _ImportedBinding_utils_ubl_ubl21__ccts_cct
                                ^
SyntaxError: invalid syntax

I generated this module this way:

pyxbgen -u ../extra/docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd -m invoice --module-prefix=utils.ubl.ubl21
WARNING:pyxb.binding.generate:Complex type {urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2}ContractingPartyType renamed to ContractingPartyType_
Python for urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 requires 13 modules

is it safe to just rename the module ?
if yes how does it impact the rest of the generated code ?

thanks

ps: I renamed it with an underscore instead of the dash and it seems to work fine

@pabigot pabigot self-assigned this Nov 30, 2015
@pabigot
Owner
pabigot commented Nov 30, 2015

Yes, if you rename the module in the file system and in all import statements it should work fine. Next time I'm working PyXB I'll get a patch in to do this automatically. Thanks for reporting the problem.

For my reference when replicating:

wget -r -l2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd
@pabigot pabigot added this to the PyXB 1.2.5 milestone Feb 11, 2016
@pabigot pabigot added a commit that closed this issue Sep 18, 2016
@pabigot fix #48: invalid import syntax
Ensure that all components of a module path are valid as Python
identifiers so that the module can be imported.
7a93171
@pabigot pabigot closed this in 7a93171 Sep 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment