Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF]: For code readibility, consider Element Maker #128

Closed
blaggacao opened this issue Sep 26, 2019 · 2 comments
Closed

[REF]: For code readibility, consider Element Maker #128

blaggacao opened this issue Sep 26, 2019 · 2 comments
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@blaggacao
Copy link

blaggacao commented Sep 26, 2019

from lxml.builder import ElementMaker

...

        nsmap = {
            None: 'urn:oasis:names:specification:ubl:schema:xsd:' + doc_name,
            'cac': 'urn:oasis:names:specification:ubl:'
                   'schema:xsd:CommonAggregateComponents-2',
            'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:'
                   'CommonBasicComponents-2',
            }
        em = {
            'cac': ElementMaker(namespace=nsmap['cac'], nsmap=nsmap),
            'cbc': ElementMaker(namespace=nsmap['cbc'], nsmap=nsmap),
            }

        ...
        addresses = [
            em['cac'].Address('foo'), 
            em['cac'].Address('bar')
        ]
        locations = [
            em['cac'].PyhtiscalLocation('foo'), 
            em['cac'].PyhtiscalLocation('bar')
        ]
        em['cac'].PartyTaxScheme(
            em['cbc'].RegistrationName(registration_name),
            em['cbc'].CompanyID(commercial_partner.sanitized_vat, schemeID='11'),
            *addresses,
            *locations
        )
        ...
@blaggacao
Copy link
Author

Arguably, it is a cleaner syntax without any additional benefit 😄

@github-actions
Copy link

github-actions bot commented Jan 2, 2022

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jan 2, 2022
@github-actions github-actions bot closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

1 participant