wipo-gbd-transformation 1.1.105__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gbdtransformation/__init__.py +0 -0
- gbdtransformation/brands/__init__.py +44 -0
- gbdtransformation/brands/aetm/__init__.py +5 -0
- gbdtransformation/brands/aetm/filters.py +84 -0
- gbdtransformation/brands/aetm/schema +87 -0
- gbdtransformation/brands/aetm/template.yml +1 -0
- gbdtransformation/brands/aetm/tests/__init__.py +0 -0
- gbdtransformation/brands/altm/__init__.py +6 -0
- gbdtransformation/brands/altm/filters.py +107 -0
- gbdtransformation/brands/altm/schema +83 -0
- gbdtransformation/brands/altm/template.yml +1 -0
- gbdtransformation/brands/altm/tests/__init__.py +0 -0
- gbdtransformation/brands/altm/tests/altm.xml +93 -0
- gbdtransformation/brands/aptm/__init__.py +15 -0
- gbdtransformation/brands/aptm/filters.py +80 -0
- gbdtransformation/brands/aptm/schema +87 -0
- gbdtransformation/brands/aptm/template.yml +1 -0
- gbdtransformation/brands/aptm/tests/__init__.py +0 -0
- gbdtransformation/brands/attm/__init__.py +6 -0
- gbdtransformation/brands/attm/filters.py +76 -0
- gbdtransformation/brands/attm/schema +52 -0
- gbdtransformation/brands/attm/template.yml +85 -0
- gbdtransformation/brands/autm/__init__.py +2 -0
- gbdtransformation/brands/autm/filters.py +222 -0
- gbdtransformation/brands/autm/schema +91 -0
- gbdtransformation/brands/autm/template.yml +157 -0
- gbdtransformation/brands/bgtm/__init__.py +5 -0
- gbdtransformation/brands/bgtm/filters.py +112 -0
- gbdtransformation/brands/bgtm/schema +314 -0
- gbdtransformation/brands/bgtm/template.yml +154 -0
- gbdtransformation/brands/bhtm/__init__.py +12 -0
- gbdtransformation/brands/bhtm/filters.py +87 -0
- gbdtransformation/brands/bhtm/schema +87 -0
- gbdtransformation/brands/bhtm/template.yml +1 -0
- gbdtransformation/brands/bhtm/tests/__init__.py +0 -0
- gbdtransformation/brands/bntm/__init__.py +2 -0
- gbdtransformation/brands/bntm/filters.py +75 -0
- gbdtransformation/brands/bntm/schema +87 -0
- gbdtransformation/brands/bntm/template.yml +1 -0
- gbdtransformation/brands/bntm/tests/__init__.py +0 -0
- gbdtransformation/brands/brtm/__init__.py +3 -0
- gbdtransformation/brands/brtm/filters.py +169 -0
- gbdtransformation/brands/brtm/schema +86 -0
- gbdtransformation/brands/brtm/template.yml +22 -0
- gbdtransformation/brands/brtm/tests/__init__.py +0 -0
- gbdtransformation/brands/brtm/tests/test01.xml +53 -0
- gbdtransformation/brands/bttm/__init__.py +10 -0
- gbdtransformation/brands/bttm/filters.py +80 -0
- gbdtransformation/brands/bttm/schema +87 -0
- gbdtransformation/brands/bttm/template.yml +1 -0
- gbdtransformation/brands/bttm/tests/__init__.py +0 -0
- gbdtransformation/brands/bwtm/__init__.py +13 -0
- gbdtransformation/brands/bwtm/filters.py +90 -0
- gbdtransformation/brands/bwtm/schema +87 -0
- gbdtransformation/brands/bwtm/template.yml +1 -0
- gbdtransformation/brands/bwtm/tests/__init__.py +0 -0
- gbdtransformation/brands/bztm/__init__.py +16 -0
- gbdtransformation/brands/bztm/filters.py +77 -0
- gbdtransformation/brands/bztm/schema +87 -0
- gbdtransformation/brands/bztm/template.yml +1 -0
- gbdtransformation/brands/bztm/tests/__init__.py +0 -0
- gbdtransformation/brands/catm/__init__.py +10 -0
- gbdtransformation/brands/catm/filters.py +272 -0
- gbdtransformation/brands/catm/schema +804 -0
- gbdtransformation/brands/catm/template.yml +230 -0
- gbdtransformation/brands/chtm/__init__.py +6 -0
- gbdtransformation/brands/chtm/filters.py +161 -0
- gbdtransformation/brands/chtm/schema +79 -0
- gbdtransformation/brands/chtm/template.yml +121 -0
- gbdtransformation/brands/cltm/__init__.py +2 -0
- gbdtransformation/brands/cltm/filters.py +80 -0
- gbdtransformation/brands/cltm/schema +86 -0
- gbdtransformation/brands/cltm/template.yml +1 -0
- gbdtransformation/brands/cltm/tests/__init__.py +0 -0
- gbdtransformation/brands/crtm/__init__.py +5 -0
- gbdtransformation/brands/crtm/filters.py +196 -0
- gbdtransformation/brands/crtm/schema +86 -0
- gbdtransformation/brands/crtm/template.yml +1 -0
- gbdtransformation/brands/crtm/tests/__init__.py +0 -0
- gbdtransformation/brands/cutm/__init__.py +10 -0
- gbdtransformation/brands/cutm/filters.py +94 -0
- gbdtransformation/brands/cutm/schema +86 -0
- gbdtransformation/brands/cutm/template.yml +4 -0
- gbdtransformation/brands/cutm/tests/__init__.py +0 -0
- gbdtransformation/brands/detm/__init__.py +19 -0
- gbdtransformation/brands/detm/filters.py +75 -0
- gbdtransformation/brands/detm/schema +511 -0
- gbdtransformation/brands/detm/template.yml +151 -0
- gbdtransformation/brands/dktm/__init__.py +7 -0
- gbdtransformation/brands/dktm/filters.py +90 -0
- gbdtransformation/brands/dktm/schema +95 -0
- gbdtransformation/brands/dktm/template.yml +114 -0
- gbdtransformation/brands/dztm/__init__.py +10 -0
- gbdtransformation/brands/dztm/filters.py +81 -0
- gbdtransformation/brands/dztm/schema +87 -0
- gbdtransformation/brands/dztm/template.yml +1 -0
- gbdtransformation/brands/dztm/tests/__init__.py +0 -0
- gbdtransformation/brands/eetm/__init__.py +8 -0
- gbdtransformation/brands/eetm/filters.py +115 -0
- gbdtransformation/brands/eetm/schema +48 -0
- gbdtransformation/brands/eetm/template.yml +98 -0
- gbdtransformation/brands/egtm/__init__.py +5 -0
- gbdtransformation/brands/egtm/filters.py +73 -0
- gbdtransformation/brands/egtm/schema +87 -0
- gbdtransformation/brands/egtm/template.yml +1 -0
- gbdtransformation/brands/egtm/tests/__init__.py +0 -0
- gbdtransformation/brands/emtm/__init__.py +3 -0
- gbdtransformation/brands/emtm/filters.py +96 -0
- gbdtransformation/brands/emtm/schema +314 -0
- gbdtransformation/brands/emtm/template.yml +125 -0
- gbdtransformation/brands/estm/__init__.py +3 -0
- gbdtransformation/brands/estm/filters.py +110 -0
- gbdtransformation/brands/estm/schema +99 -0
- gbdtransformation/brands/estm/template.yml +144 -0
- gbdtransformation/brands/filters.py +125 -0
- gbdtransformation/brands/frtm/__init__.py +2 -0
- gbdtransformation/brands/frtm/filters.py +172 -0
- gbdtransformation/brands/frtm/schema +300 -0
- gbdtransformation/brands/frtm/template.yml +203 -0
- gbdtransformation/brands/gbtm/__init__.py +3 -0
- gbdtransformation/brands/gbtm/filters.py +122 -0
- gbdtransformation/brands/gbtm/schema +362 -0
- gbdtransformation/brands/gbtm/template.yml +147 -0
- gbdtransformation/brands/gdtm/__init__.py +5 -0
- gbdtransformation/brands/gdtm/filters.py +68 -0
- gbdtransformation/brands/gdtm/schema +87 -0
- gbdtransformation/brands/gdtm/template.yml +1 -0
- gbdtransformation/brands/gdtm/tests/__init__.py +0 -0
- gbdtransformation/brands/getm/__init__.py +3 -0
- gbdtransformation/brands/getm/filters.py +68 -0
- gbdtransformation/brands/getm/schema +209 -0
- gbdtransformation/brands/getm/template.yml +142 -0
- gbdtransformation/brands/ghtm/__init__.py +12 -0
- gbdtransformation/brands/ghtm/filters.py +74 -0
- gbdtransformation/brands/ghtm/schema +86 -0
- gbdtransformation/brands/ghtm/template.yml +1 -0
- gbdtransformation/brands/ghtm/tests/__init__.py +0 -0
- gbdtransformation/brands/gmtm/__init__.py +7 -0
- gbdtransformation/brands/gmtm/filters.py +70 -0
- gbdtransformation/brands/gmtm/schema +86 -0
- gbdtransformation/brands/gmtm/template.yml +1 -0
- gbdtransformation/brands/gmtm/tests/__init__.py +0 -0
- gbdtransformation/brands/gstm/__init__.py +2 -0
- gbdtransformation/brands/gstm/filters.py +75 -0
- gbdtransformation/brands/gstm/template.gs.yml +56 -0
- gbdtransformation/brands/gstm/template.yml +32 -0
- gbdtransformation/brands/hrtm/__init__.py +3 -0
- gbdtransformation/brands/hrtm/filters.py +158 -0
- gbdtransformation/brands/hrtm/schema +43 -0
- gbdtransformation/brands/hrtm/template.yml +205 -0
- gbdtransformation/brands/idtm/__init__.py +12 -0
- gbdtransformation/brands/idtm/filters.py +95 -0
- gbdtransformation/brands/idtm/schema +86 -0
- gbdtransformation/brands/idtm/template.yml +1 -0
- gbdtransformation/brands/idtm/tests/__init__.py +0 -0
- gbdtransformation/brands/idtm/tests/translation.xml +106 -0
- gbdtransformation/brands/idtm/tests/unicode.xml +120 -0
- gbdtransformation/brands/iltm/__init__.py +2 -0
- gbdtransformation/brands/iltm/filters.py +91 -0
- gbdtransformation/brands/iltm/schema +87 -0
- gbdtransformation/brands/iltm/template.yml +213 -0
- gbdtransformation/brands/iltm/tests/__init__.py +0 -0
- gbdtransformation/brands/iltm/tests/cancellations.xml +156 -0
- gbdtransformation/brands/iltm/tests/collcert.xml +51 -0
- gbdtransformation/brands/iltm/tests/eventdata.xml +83 -0
- gbdtransformation/brands/iltm/tests/international.xml +80 -0
- gbdtransformation/brands/iltm/tests/markfeature.xml +117 -0
- gbdtransformation/brands/iltm/tests/noevents.xml +44 -0
- gbdtransformation/brands/iltm/tests/opposition.xml +147 -0
- gbdtransformation/brands/iltm/tests/tlit.xml +77 -0
- gbdtransformation/brands/intm/__init__.py +6 -0
- gbdtransformation/brands/intm/filters.py +75 -0
- gbdtransformation/brands/intm/schema +127 -0
- gbdtransformation/brands/intm/template.yml +112 -0
- gbdtransformation/brands/ipas/__init__.py +0 -0
- gbdtransformation/brands/ipas/filters.py +203 -0
- gbdtransformation/brands/ipas/template.yml +185 -0
- gbdtransformation/brands/istm/__init__.py +10 -0
- gbdtransformation/brands/istm/filters.py +60 -0
- gbdtransformation/brands/istm/schema +53 -0
- gbdtransformation/brands/istm/template.yml +119 -0
- gbdtransformation/brands/ittm/__init__.py +6 -0
- gbdtransformation/brands/ittm/filters.py +114 -0
- gbdtransformation/brands/ittm/schema +104 -0
- gbdtransformation/brands/ittm/template.yml +107 -0
- gbdtransformation/brands/jotm/__init__.py +8 -0
- gbdtransformation/brands/jotm/filters.py +61 -0
- gbdtransformation/brands/jotm/schema +86 -0
- gbdtransformation/brands/jotm/template.yml +1 -0
- gbdtransformation/brands/jotm/tests/__init__.py +0 -0
- gbdtransformation/brands/jotm/tests/test.xml +84 -0
- gbdtransformation/brands/jptm/__init__.py +6 -0
- gbdtransformation/brands/jptm/filters.py +79 -0
- gbdtransformation/brands/jptm/schema +39 -0
- gbdtransformation/brands/jptm/template.yml +113 -0
- gbdtransformation/brands/ketm/__init__.py +9 -0
- gbdtransformation/brands/ketm/filters.py +77 -0
- gbdtransformation/brands/ketm/schema +86 -0
- gbdtransformation/brands/ketm/template.yml +1 -0
- gbdtransformation/brands/ketm/tests/__init__.py +0 -0
- gbdtransformation/brands/kgtm/__init__.py +6 -0
- gbdtransformation/brands/kgtm/filters.py +67 -0
- gbdtransformation/brands/kgtm/schema +27 -0
- gbdtransformation/brands/kgtm/template.yml +58 -0
- gbdtransformation/brands/khtm/__init__.py +14 -0
- gbdtransformation/brands/khtm/filters.py +134 -0
- gbdtransformation/brands/khtm/schema +86 -0
- gbdtransformation/brands/khtm/template.yml +1 -0
- gbdtransformation/brands/khtm/tests/__init__.py +0 -0
- gbdtransformation/brands/khtm/tests/khtm.xml +122 -0
- gbdtransformation/brands/krtm/__init__.py +6 -0
- gbdtransformation/brands/krtm/filters.py +136 -0
- gbdtransformation/brands/krtm/schema +179 -0
- gbdtransformation/brands/krtm/template.yml +186 -0
- gbdtransformation/brands/kwtm/__init__.py +2 -0
- gbdtransformation/brands/kwtm/filters.py +69 -0
- gbdtransformation/brands/kwtm/schema +86 -0
- gbdtransformation/brands/kwtm/template.yml +1 -0
- gbdtransformation/brands/kwtm/tests/__init__.py +0 -0
- gbdtransformation/brands/kwtm/tests/test.xml +84 -0
- gbdtransformation/brands/kztm/__init__.py +242 -0
- gbdtransformation/brands/kztm/filters.py +140 -0
- gbdtransformation/brands/kztm/schema +36 -0
- gbdtransformation/brands/kztm/template.yml +117 -0
- gbdtransformation/brands/latm/__init__.py +7 -0
- gbdtransformation/brands/latm/filters.py +93 -0
- gbdtransformation/brands/latm/schema +86 -0
- gbdtransformation/brands/latm/template.yml +1 -0
- gbdtransformation/brands/latm/tests/__init__.py +0 -0
- gbdtransformation/brands/latm/tests/test.xml +112 -0
- gbdtransformation/brands/lktm/__init__.py +5 -0
- gbdtransformation/brands/lktm/filters.py +83 -0
- gbdtransformation/brands/lktm/schema +87 -0
- gbdtransformation/brands/lktm/template.yml +1 -0
- gbdtransformation/brands/lktm/tests/__init__.py +0 -0
- gbdtransformation/brands/matm/__init__.py +3 -0
- gbdtransformation/brands/matm/filters.py +36 -0
- gbdtransformation/brands/matm/schema +33 -0
- gbdtransformation/brands/matm/template.yml +72 -0
- gbdtransformation/brands/mctm/__init__.py +3 -0
- gbdtransformation/brands/mctm/filters.py +65 -0
- gbdtransformation/brands/mctm/schema +128 -0
- gbdtransformation/brands/mctm/template.yml +122 -0
- gbdtransformation/brands/mdtm/__init__.py +3 -0
- gbdtransformation/brands/mdtm/filters.py +64 -0
- gbdtransformation/brands/mdtm/schema +128 -0
- gbdtransformation/brands/mdtm/template.yml +122 -0
- gbdtransformation/brands/metm/__init__.py +5 -0
- gbdtransformation/brands/metm/filters.py +87 -0
- gbdtransformation/brands/metm/schema +87 -0
- gbdtransformation/brands/metm/template.yml +1 -0
- gbdtransformation/brands/metm/tests/__init__.py +0 -0
- gbdtransformation/brands/mgtm/__init__.py +7 -0
- gbdtransformation/brands/mgtm/filters.py +73 -0
- gbdtransformation/brands/mgtm/schema +86 -0
- gbdtransformation/brands/mgtm/template.yml +1 -0
- gbdtransformation/brands/mgtm/tests/__init__.py +0 -0
- gbdtransformation/brands/mgtm/tests/test.xml +107 -0
- gbdtransformation/brands/mktm/__init__.py +6 -0
- gbdtransformation/brands/mktm/filters.py +63 -0
- gbdtransformation/brands/mktm/schema +80 -0
- gbdtransformation/brands/mktm/template.yml +112 -0
- gbdtransformation/brands/mntm/__init__.py +11 -0
- gbdtransformation/brands/mntm/filters.py +99 -0
- gbdtransformation/brands/mntm/schema +86 -0
- gbdtransformation/brands/mntm/template.yml +1 -0
- gbdtransformation/brands/mntm/tests/__init__.py +0 -0
- gbdtransformation/brands/mwtm/__init__.py +11 -0
- gbdtransformation/brands/mwtm/filters.py +80 -0
- gbdtransformation/brands/mwtm/schema +86 -0
- gbdtransformation/brands/mwtm/template.yml +1 -0
- gbdtransformation/brands/mwtm/tests/__init__.py +0 -0
- gbdtransformation/brands/mxtm/__init__.py +6 -0
- gbdtransformation/brands/mxtm/filters.py +77 -0
- gbdtransformation/brands/mxtm/schema +81 -0
- gbdtransformation/brands/mxtm/template.yml +127 -0
- gbdtransformation/brands/mytm/__init__.py +17 -0
- gbdtransformation/brands/mytm/filters.py +125 -0
- gbdtransformation/brands/mytm/schema +86 -0
- gbdtransformation/brands/mytm/template.yml +1 -0
- gbdtransformation/brands/mytm/tests/__init__.py +0 -0
- gbdtransformation/brands/mytm/tests/example.xml +132 -0
- gbdtransformation/brands/mytm/tests/mytm.xml +132 -0
- gbdtransformation/brands/mztm/__init__.py +14 -0
- gbdtransformation/brands/mztm/filters.py +89 -0
- gbdtransformation/brands/mztm/schema +86 -0
- gbdtransformation/brands/mztm/template.yml +1 -0
- gbdtransformation/brands/mztm/tests/__init__.py +0 -0
- gbdtransformation/brands/natm/__init__.py +11 -0
- gbdtransformation/brands/natm/filters.py +88 -0
- gbdtransformation/brands/natm/schema +86 -0
- gbdtransformation/brands/natm/template.yml +1 -0
- gbdtransformation/brands/natm/tests/__init__.py +0 -0
- gbdtransformation/brands/notm/__init__.py +5 -0
- gbdtransformation/brands/notm/filters.py +170 -0
- gbdtransformation/brands/notm/template.yml +289 -0
- gbdtransformation/brands/nztm/__init__.py +3 -0
- gbdtransformation/brands/nztm/filters.py +126 -0
- gbdtransformation/brands/nztm/schema +197 -0
- gbdtransformation/brands/nztm/template.yml +161 -0
- gbdtransformation/brands/oatm/__init__.py +18 -0
- gbdtransformation/brands/oatm/filters.py +82 -0
- gbdtransformation/brands/oatm/schema +87 -0
- gbdtransformation/brands/oatm/template.yml +1 -0
- gbdtransformation/brands/oatm/tests/__init__.py +0 -0
- gbdtransformation/brands/omtm/__init__.py +5 -0
- gbdtransformation/brands/omtm/filters.py +60 -0
- gbdtransformation/brands/omtm/schema +86 -0
- gbdtransformation/brands/omtm/template.yml +1 -0
- gbdtransformation/brands/omtm/tests/__init__.py +0 -0
- gbdtransformation/brands/omtm/tests/test.xml +84 -0
- gbdtransformation/brands/patm/__init__.py +8 -0
- gbdtransformation/brands/patm/filters.py +149 -0
- gbdtransformation/brands/patm/template.yml +40 -0
- gbdtransformation/brands/petm/__init__.py +6 -0
- gbdtransformation/brands/petm/filters.py +90 -0
- gbdtransformation/brands/petm/schema +114 -0
- gbdtransformation/brands/petm/template.yml +143 -0
- gbdtransformation/brands/pgtm/__init__.py +5 -0
- gbdtransformation/brands/pgtm/filters.py +76 -0
- gbdtransformation/brands/pgtm/schema +86 -0
- gbdtransformation/brands/pgtm/template.yml +1 -0
- gbdtransformation/brands/pgtm/tests/__init__.py +0 -0
- gbdtransformation/brands/pgtm/tests/pgtm.xml +128 -0
- gbdtransformation/brands/phtm/__init__.py +14 -0
- gbdtransformation/brands/phtm/filters.py +169 -0
- gbdtransformation/brands/phtm/schema +79 -0
- gbdtransformation/brands/phtm/schema.classic +50 -0
- gbdtransformation/brands/phtm/template.classic.yml +102 -0
- gbdtransformation/brands/phtm/template.yml +189 -0
- gbdtransformation/brands/pttm/__init__.py +0 -0
- gbdtransformation/brands/pttm/filters.py +0 -0
- gbdtransformation/brands/pttm/schema +0 -0
- gbdtransformation/brands/pttm/template.yml +0 -0
- gbdtransformation/brands/pytm/__init__.py +6 -0
- gbdtransformation/brands/pytm/filters.py +136 -0
- gbdtransformation/brands/pytm/template.yml +40 -0
- gbdtransformation/brands/qatm/__init__.py +5 -0
- gbdtransformation/brands/qatm/filters.py +81 -0
- gbdtransformation/brands/qatm/schema +87 -0
- gbdtransformation/brands/qatm/template.yml +1 -0
- gbdtransformation/brands/qatm/tests/__init__.py +0 -0
- gbdtransformation/brands/rotm/__init__.py +3 -0
- gbdtransformation/brands/rotm/filters.py +82 -0
- gbdtransformation/brands/rotm/schema +128 -0
- gbdtransformation/brands/rotm/template.yml +121 -0
- gbdtransformation/brands/rstm/__init__.py +5 -0
- gbdtransformation/brands/rstm/filters.py +88 -0
- gbdtransformation/brands/rstm/schema +86 -0
- gbdtransformation/brands/rstm/template.yml +1 -0
- gbdtransformation/brands/rstm/tests/__init__.py +0 -0
- gbdtransformation/brands/rutm/__init__.py +14 -0
- gbdtransformation/brands/rutm/filters.py +82 -0
- gbdtransformation/brands/rutm/schema +94 -0
- gbdtransformation/brands/rutm/template.yml +105 -0
- gbdtransformation/brands/sdtm/__init__.py +5 -0
- gbdtransformation/brands/sdtm/filters.py +59 -0
- gbdtransformation/brands/sdtm/schema +86 -0
- gbdtransformation/brands/sdtm/template.yml +1 -0
- gbdtransformation/brands/sdtm/tests/__init__.py +0 -0
- gbdtransformation/brands/sdtm/tests/test.xml +84 -0
- gbdtransformation/brands/sgtm/__init__.py +16 -0
- gbdtransformation/brands/sgtm/filters.py +177 -0
- gbdtransformation/brands/sgtm/schema +213 -0
- gbdtransformation/brands/sgtm/template.article6ter.yml +48 -0
- gbdtransformation/brands/sgtm/template.r13.yml +45 -0
- gbdtransformation/brands/sgtm/template.trademark.yml +148 -0
- gbdtransformation/brands/sgtm/template.yml +9 -0
- gbdtransformation/brands/smtm/__init__.py +6 -0
- gbdtransformation/brands/smtm/filters.py +77 -0
- gbdtransformation/brands/smtm/schema +86 -0
- gbdtransformation/brands/smtm/template.yml +1 -0
- gbdtransformation/brands/smtm/tests/__init__.py +0 -0
- gbdtransformation/brands/smtm/tests/test.xml +133 -0
- gbdtransformation/brands/solrjtm/__init__.py +1 -0
- gbdtransformation/brands/solrjtm/filters.py +85 -0
- gbdtransformation/brands/solrjtm/template.yml +195 -0
- gbdtransformation/brands/st66tm/__init__.py +1 -0
- gbdtransformation/brands/st66tm/filters.py +33 -0
- gbdtransformation/brands/st66tm/st66tm.tmpl +219 -0
- gbdtransformation/brands/sttm/__init__.py +18 -0
- gbdtransformation/brands/sttm/filters.py +72 -0
- gbdtransformation/brands/sttm/schema +83 -0
- gbdtransformation/brands/sttm/template.yml +1 -0
- gbdtransformation/brands/sttm/tests/__init__.py +0 -0
- gbdtransformation/brands/sztm/__init__.py +14 -0
- gbdtransformation/brands/sztm/filters.py +72 -0
- gbdtransformation/brands/sztm/schema +86 -0
- gbdtransformation/brands/sztm/template.yml +1 -0
- gbdtransformation/brands/sztm/tests/__init__.py +0 -0
- gbdtransformation/brands/thtm/__init__.py +2 -0
- gbdtransformation/brands/thtm/filters.py +86 -0
- gbdtransformation/brands/thtm/schema +86 -0
- gbdtransformation/brands/thtm/template.yml +175 -0
- gbdtransformation/brands/thtm/tests/__init__.py +0 -0
- gbdtransformation/brands/thtm/tests/test.xml +84 -0
- gbdtransformation/brands/tntm/__init__.py +16 -0
- gbdtransformation/brands/tntm/filters.py +89 -0
- gbdtransformation/brands/tntm/schema +87 -0
- gbdtransformation/brands/tntm/template.yml +1 -0
- gbdtransformation/brands/tntm/tests/__init__.py +0 -0
- gbdtransformation/brands/totm/__init__.py +5 -0
- gbdtransformation/brands/totm/filters.py +72 -0
- gbdtransformation/brands/totm/schema +86 -0
- gbdtransformation/brands/totm/template.yml +1 -0
- gbdtransformation/brands/totm/tests/__init__.py +0 -0
- gbdtransformation/brands/totm/tests/nofeature.xml +106 -0
- gbdtransformation/brands/totm/tests/syntax.xml +162 -0
- gbdtransformation/brands/totm/tests/test.xml +84 -0
- gbdtransformation/brands/tttm/__init__.py +17 -0
- gbdtransformation/brands/tttm/filters.py +79 -0
- gbdtransformation/brands/tttm/schema +87 -0
- gbdtransformation/brands/tttm/template.yml +1 -0
- gbdtransformation/brands/tttm/tests/__init__.py +0 -0
- gbdtransformation/brands/uatm/__init__.py +18 -0
- gbdtransformation/brands/uatm/filters.py +70 -0
- gbdtransformation/brands/uatm/schema +158 -0
- gbdtransformation/brands/uatm/template.yml +148 -0
- gbdtransformation/brands/ustm/__init__.py +187 -0
- gbdtransformation/brands/ustm/filters.py +227 -0
- gbdtransformation/brands/ustm/schema +2183 -0
- gbdtransformation/brands/ustm/template.yml +219 -0
- gbdtransformation/brands/uytm/__init__.py +3 -0
- gbdtransformation/brands/uytm/filters.py +64 -0
- gbdtransformation/brands/uytm/schema +106 -0
- gbdtransformation/brands/uytm/template.yml +137 -0
- gbdtransformation/brands/vctm/__init__.py +5 -0
- gbdtransformation/brands/vctm/filters.py +75 -0
- gbdtransformation/brands/vctm/schema +87 -0
- gbdtransformation/brands/vctm/template.yml +1 -0
- gbdtransformation/brands/vctm/tests/__init__.py +0 -0
- gbdtransformation/brands/vntm/__init__.py +9 -0
- gbdtransformation/brands/vntm/filters.py +84 -0
- gbdtransformation/brands/vntm/schema +86 -0
- gbdtransformation/brands/vntm/template.yml +1 -0
- gbdtransformation/brands/vntm/tests/__init__.py +0 -0
- gbdtransformation/brands/vutm/__init__.py +5 -0
- gbdtransformation/brands/vutm/filters.py +67 -0
- gbdtransformation/brands/vutm/schema +83 -0
- gbdtransformation/brands/vutm/template.yml +1 -0
- gbdtransformation/brands/vutm/tests/__init__.py +0 -0
- gbdtransformation/brands/whoinn/__init__.py +6 -0
- gbdtransformation/brands/whoinn/filters.py +46 -0
- gbdtransformation/brands/whoinn/schema +4 -0
- gbdtransformation/brands/whoinn/template.yml +45 -0
- gbdtransformation/brands/wo6ter/__init__.py +1 -0
- gbdtransformation/brands/wo6ter/filters.py +88 -0
- gbdtransformation/brands/wo6ter/template.yml +88 -0
- gbdtransformation/brands/woao/__init__.py +1 -0
- gbdtransformation/brands/woao/filters.py +107 -0
- gbdtransformation/brands/woao/schema +116 -0
- gbdtransformation/brands/woao/template.yml +90 -0
- gbdtransformation/brands/woptm/__init__.py +3 -0
- gbdtransformation/brands/woptm/filters.py +42 -0
- gbdtransformation/brands/woptm/template.yml +2 -0
- gbdtransformation/brands/wotm/__init__.py +3 -0
- gbdtransformation/brands/wotm/filters.py +127 -0
- gbdtransformation/brands/wotm/schema +218 -0
- gbdtransformation/brands/wotm/template.yml +220 -0
- gbdtransformation/brands/wstm/__init__.py +6 -0
- gbdtransformation/brands/wstm/filters.py +67 -0
- gbdtransformation/brands/wstm/schema +86 -0
- gbdtransformation/brands/wstm/template.yml +1 -0
- gbdtransformation/brands/wstm/tests/__init__.py +0 -0
- gbdtransformation/brands/wstm/tests/test.xml +132 -0
- gbdtransformation/brands/xxxx/__init__.py +6 -0
- gbdtransformation/brands/xxxx/filters.py +60 -0
- gbdtransformation/brands/xxxx/schema +4 -0
- gbdtransformation/brands/xxxx/template.yml +363 -0
- gbdtransformation/brands/zmtm/__init__.py +12 -0
- gbdtransformation/brands/zmtm/filters.py +79 -0
- gbdtransformation/brands/zmtm/schema +86 -0
- gbdtransformation/brands/zmtm/template.yml +1 -0
- gbdtransformation/brands/zmtm/tests/__init__.py +0 -0
- gbdtransformation/brands/zwtm/__init__.py +3 -0
- gbdtransformation/brands/zwtm/filters.py +86 -0
- gbdtransformation/brands/zwtm/schema +86 -0
- gbdtransformation/brands/zwtm/template.yml +1 -0
- gbdtransformation/brands/zwtm/tests/__init__.py +0 -0
- gbdtransformation/common/__init__.py +383 -0
- gbdtransformation/common/filters.py +418 -0
- gbdtransformation/common/jpap/__init__.py +1 -0
- gbdtransformation/common/jpap/filters.py +83 -0
- gbdtransformation/common/jpap/template.yml +37 -0
- gbdtransformation/common/jpbase/__init__.py +1 -0
- gbdtransformation/common/jpbase/filters.py +93 -0
- gbdtransformation/common/jpbase/template.yml +51 -0
- gbdtransformation/common/jprp/__init__.py +1 -0
- gbdtransformation/common/jprp/filters.py +86 -0
- gbdtransformation/common/jprp/template.yml +51 -0
- gbdtransformation/common/navigation.tmpl +12 -0
- gbdtransformation/commons/__init__.py +0 -0
- gbdtransformation/commons/emap/__init__.py +1 -0
- gbdtransformation/commons/emap/filters.py +16 -0
- gbdtransformation/commons/emap/template.yml +55 -0
- gbdtransformation/commons/emrp/__init__.py +1 -0
- gbdtransformation/commons/emrp/filters.py +14 -0
- gbdtransformation/commons/emrp/template.yml +53 -0
- gbdtransformation/commons/filters.py +3 -0
- gbdtransformation/designs/__init__.py +8 -0
- gbdtransformation/designs/alid/__init__.py +5 -0
- gbdtransformation/designs/alid/filters.py +69 -0
- gbdtransformation/designs/alid/schema +89 -0
- gbdtransformation/designs/alid/template.yml +1 -0
- gbdtransformation/designs/bnid/__init__.py +5 -0
- gbdtransformation/designs/bnid/filters.py +61 -0
- gbdtransformation/designs/bnid/schema +80 -0
- gbdtransformation/designs/bnid/template.yml +1 -0
- gbdtransformation/designs/bwid/__init__.py +6 -0
- gbdtransformation/designs/bwid/filters.py +64 -0
- gbdtransformation/designs/bwid/schema +101 -0
- gbdtransformation/designs/bwid/template.yml +1 -0
- gbdtransformation/designs/crid/__init__.py +5 -0
- gbdtransformation/designs/crid/filters.py +63 -0
- gbdtransformation/designs/crid/schema +94 -0
- gbdtransformation/designs/crid/template.yml +1 -0
- gbdtransformation/designs/cuid/__init__.py +5 -0
- gbdtransformation/designs/cuid/filters.py +60 -0
- gbdtransformation/designs/cuid/schema +98 -0
- gbdtransformation/designs/cuid/template.yml +1 -0
- gbdtransformation/designs/egid/__init__.py +5 -0
- gbdtransformation/designs/egid/filters.py +62 -0
- gbdtransformation/designs/egid/schema +82 -0
- gbdtransformation/designs/egid/template.yml +1 -0
- gbdtransformation/designs/filters.py +73 -0
- gbdtransformation/designs/idid/__init__.py +5 -0
- gbdtransformation/designs/idid/filters.py +67 -0
- gbdtransformation/designs/idid/schema +102 -0
- gbdtransformation/designs/idid/template.yml +1 -0
- gbdtransformation/designs/ipas/__init__.py +0 -0
- gbdtransformation/designs/ipas/filters.py +181 -0
- gbdtransformation/designs/ipas/template.yml +174 -0
- gbdtransformation/designs/joid/__init__.py +6 -0
- gbdtransformation/designs/joid/filters.py +62 -0
- gbdtransformation/designs/joid/schema +97 -0
- gbdtransformation/designs/joid/template.yml +1 -0
- gbdtransformation/designs/keid/__init__.py +5 -0
- gbdtransformation/designs/keid/filters.py +62 -0
- gbdtransformation/designs/keid/schema +99 -0
- gbdtransformation/designs/keid/template.yml +1 -0
- gbdtransformation/designs/khid/__init__.py +5 -0
- gbdtransformation/designs/khid/filters.py +63 -0
- gbdtransformation/designs/khid/schema +100 -0
- gbdtransformation/designs/khid/template.yml +1 -0
- gbdtransformation/designs/laid/__init__.py +5 -0
- gbdtransformation/designs/laid/filters.py +61 -0
- gbdtransformation/designs/laid/schema +94 -0
- gbdtransformation/designs/laid/template.yml +1 -0
- gbdtransformation/designs/mnid/__init__.py +6 -0
- gbdtransformation/designs/mnid/filters.py +62 -0
- gbdtransformation/designs/mnid/schema +98 -0
- gbdtransformation/designs/mnid/template.yml +1 -0
- gbdtransformation/designs/myid/__init__.py +5 -0
- gbdtransformation/designs/myid/filters.py +60 -0
- gbdtransformation/designs/myid/schema +95 -0
- gbdtransformation/designs/myid/template.yml +1 -0
- gbdtransformation/designs/phid/__init__.py +5 -0
- gbdtransformation/designs/phid/filters.py +70 -0
- gbdtransformation/designs/phid/schema +95 -0
- gbdtransformation/designs/phid/template.yml +1 -0
- gbdtransformation/designs/sgid/__init__.py +6 -0
- gbdtransformation/designs/sgid/filters.py +66 -0
- gbdtransformation/designs/sgid/schema +115 -0
- gbdtransformation/designs/sgid/template.yml +1 -0
- gbdtransformation/designs/thid/__init__.py +4 -0
- gbdtransformation/designs/thid/filters.py +64 -0
- gbdtransformation/designs/thid/schema +98 -0
- gbdtransformation/designs/thid/template.yml +1 -0
- gbdtransformation/designs/tnid/__init__.py +5 -0
- gbdtransformation/designs/tnid/filters.py +66 -0
- gbdtransformation/designs/tnid/schema +96 -0
- gbdtransformation/designs/tnid/template.yml +1 -0
- gbdtransformation/designs/vnid/__init__.py +5 -0
- gbdtransformation/designs/vnid/filters.py +62 -0
- gbdtransformation/designs/vnid/schema +97 -0
- gbdtransformation/designs/vnid/template.yml +1 -0
- gbdtransformation/designs/woid/__init__.py +2 -0
- gbdtransformation/designs/woid/filters.py +372 -0
- gbdtransformation/designs/woid/schema +592 -0
- gbdtransformation/designs/woid/template.yml +516 -0
- gbdtransformation/designs/xxid/__init__.py +2 -0
- gbdtransformation/designs/xxid/filters.py +60 -0
- gbdtransformation/designs/xxid/schema +4 -0
- gbdtransformation/designs/xxid/template.yml +358 -0
- gbdtransformation/execs-nico.py +709 -0
- gbdtransformation/execs.py +734 -0
- gbdtransformation/gbd-transform.exec.tgz +0 -0
- gbdtransformation/parser.py +190 -0
- gbdtransformation/renders.py +149 -0
- gbdtransformation/utilities/ISOCountryCodeType-V2006.xsd +1245 -0
- gbdtransformation/utilities/ISOCurrencyCodeType-V2001.xsd +855 -0
- gbdtransformation/utilities/ISOLanguageCodeType-V2002.xsd +715 -0
- gbdtransformation/utilities/WIPOST3CodeType-V2007.xsd +1151 -0
- gbdtransformation/utilities/__init__.py +0 -0
- gbdtransformation/utilities/st66.dot +2828 -0
- gbdtransformation/utilities/st66.pdf +0 -0
- gbdtransformation/utilities/st66.py +38700 -0
- gbdtransformation/utilities/st66.xsd +4174 -0
- schemas/ShazamConfig.py +35 -0
- schemas/__init__.py +0 -0
- schemas/schema_extractor.py +300 -0
- wipo_gbd_transformation-1.1.105.dist-info/LICENSE.md +687 -0
- wipo_gbd_transformation-1.1.105.dist-info/METADATA +25 -0
- wipo_gbd_transformation-1.1.105.dist-info/RECORD +607 -0
- wipo_gbd_transformation-1.1.105.dist-info/WHEEL +5 -0
- wipo_gbd_transformation-1.1.105.dist-info/entry_points.txt +6 -0
- wipo_gbd_transformation-1.1.105.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import time
|
|
3
|
+
import argparse
|
|
4
|
+
import random
|
|
5
|
+
import os
|
|
6
|
+
import traceback
|
|
7
|
+
import difflib
|
|
8
|
+
import gzip
|
|
9
|
+
import multiprocessing
|
|
10
|
+
import xml.etree.ElementTree as ET
|
|
11
|
+
import concurrent.futures
|
|
12
|
+
import pprint
|
|
13
|
+
|
|
14
|
+
from tabulate import tabulate
|
|
15
|
+
from gbdtransformation.parser import Parser
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_command_parser(options, doc):
|
|
19
|
+
"""Argparse builder
|
|
20
|
+
@param options: the dict of config options
|
|
21
|
+
@pram doc: the helper for the command
|
|
22
|
+
return parsed args"""
|
|
23
|
+
parser = argparse.ArgumentParser(description=doc,
|
|
24
|
+
formatter_class=argparse.RawTextHelpFormatter)
|
|
25
|
+
for config in options:
|
|
26
|
+
name = config.pop('name')
|
|
27
|
+
parser.add_argument(*name, **config)
|
|
28
|
+
return parser.parse_args()
|
|
29
|
+
|
|
30
|
+
parsers = {}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class bcolors:
|
|
34
|
+
HEADER = '\033[95m'
|
|
35
|
+
OKBLUE = '\033[94m'
|
|
36
|
+
OKGREEN = '\033[92m'
|
|
37
|
+
INFO = '\033[92m'
|
|
38
|
+
WARNING = '\033[93m'
|
|
39
|
+
FAIL = '\033[91m'
|
|
40
|
+
CRITICAL = '\033[91m'
|
|
41
|
+
ERROR = '\033[91m'
|
|
42
|
+
ENDC = '\033[0m'
|
|
43
|
+
BOLD = '\033[1m'
|
|
44
|
+
UNDERLINE = '\033[4m'
|
|
45
|
+
|
|
46
|
+
class progress:
|
|
47
|
+
def __init__(self, total):
|
|
48
|
+
self.total = total
|
|
49
|
+
self.done = 0
|
|
50
|
+
|
|
51
|
+
def start(self):
|
|
52
|
+
printProgressBar(0, self.total,
|
|
53
|
+
prefix='Progress:', suffix='Complete', length=50)
|
|
54
|
+
|
|
55
|
+
def advance(self, value):
|
|
56
|
+
self.done = value
|
|
57
|
+
printProgressBar(self.done, self.total,
|
|
58
|
+
prefix='Progress:', suffix='Complete', length=50)
|
|
59
|
+
|
|
60
|
+
def advance_with_step(self, value):
|
|
61
|
+
self.done += value
|
|
62
|
+
printProgressBar(self.done, self.total,
|
|
63
|
+
prefix='Progress:', suffix='Complete', length=50)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test():
|
|
67
|
+
doc = """
|
|
68
|
+
Runs regression tests
|
|
69
|
+
"""
|
|
70
|
+
configs = [{
|
|
71
|
+
'name': ['--junit'],
|
|
72
|
+
'dest': 'junit',
|
|
73
|
+
'help': 'saves in junit format',
|
|
74
|
+
'action': 'store_true',
|
|
75
|
+
'default': False
|
|
76
|
+
}]
|
|
77
|
+
args = build_command_parser(configs, doc)
|
|
78
|
+
pkg_folder = os.path.dirname(__file__)
|
|
79
|
+
test_to_run = []
|
|
80
|
+
for type in ['brands', 'designs']:
|
|
81
|
+
path = os.path.join(pkg_folder, type)
|
|
82
|
+
for root, dirs, files in os.walk(path):
|
|
83
|
+
if 'tests' in dirs:
|
|
84
|
+
template = os.path.basename(root)
|
|
85
|
+
for file in os.listdir(os.path.join(root, 'tests')):
|
|
86
|
+
if file.startswith('_'):
|
|
87
|
+
continue
|
|
88
|
+
if file.endswith('.out'):
|
|
89
|
+
continue
|
|
90
|
+
filename, ext = os.path.splitext(file)
|
|
91
|
+
input_file_path = os.path.join(root, 'tests', file)
|
|
92
|
+
out_file_path = input_file_path.replace(ext, '.out')
|
|
93
|
+
has_output = os.path.exists(out_file_path)
|
|
94
|
+
test_to_run.append({
|
|
95
|
+
'template': template,
|
|
96
|
+
'path': input_file_path,
|
|
97
|
+
'test_output': has_output,
|
|
98
|
+
'invalid_output': None
|
|
99
|
+
})
|
|
100
|
+
for test in test_to_run:
|
|
101
|
+
res, exceptions, error = _run_per_file(
|
|
102
|
+
test['template'], test['path'])
|
|
103
|
+
test['execution'] = res
|
|
104
|
+
test['errors'] = exceptions
|
|
105
|
+
filename, ext = os.path.splitext(test['path'])
|
|
106
|
+
if test['test_output']:
|
|
107
|
+
expected = ''
|
|
108
|
+
with open(test['path'].replace(ext, '.out'), 'r') as f:
|
|
109
|
+
expected = [e.replace('\n', '') for e in f.readlines()]
|
|
110
|
+
delta = difflib.ndiff(expected, res.split('\n'))
|
|
111
|
+
to_outup_diffs = []
|
|
112
|
+
for d in delta:
|
|
113
|
+
if d[0] != ' ':
|
|
114
|
+
to_outup_diffs.append(d)
|
|
115
|
+
else:
|
|
116
|
+
if to_outup_diffs:
|
|
117
|
+
break
|
|
118
|
+
to_outup_diffs = []
|
|
119
|
+
test['invalid_output'] = '\n'.join(to_outup_diffs)
|
|
120
|
+
display = [
|
|
121
|
+
['Nb.', 'Template', 'Input', 'Has run?', 'Errors', 'Valid output']
|
|
122
|
+
]
|
|
123
|
+
counter = 0
|
|
124
|
+
if args.junit:
|
|
125
|
+
total = 0
|
|
126
|
+
errors = 0
|
|
127
|
+
fail = 0
|
|
128
|
+
tests_run_xml = []
|
|
129
|
+
for test in test_to_run:
|
|
130
|
+
if test['errors']:
|
|
131
|
+
tmp = '''<failure type="Conversion error">
|
|
132
|
+
%s
|
|
133
|
+
</failure>''' % test['errors']
|
|
134
|
+
elif test['test_output'] and test['invalid_output']:
|
|
135
|
+
tmp = '''<failure type="Invalid output">
|
|
136
|
+
%s
|
|
137
|
+
</failure>''' % test['invalid_output']
|
|
138
|
+
else:
|
|
139
|
+
tmp = ''
|
|
140
|
+
current = '''
|
|
141
|
+
<testcase classname="%s" name="%s" time="0.001">
|
|
142
|
+
%s
|
|
143
|
+
</testcase>''' % (test['path'], test['template'], tmp)
|
|
144
|
+
total += 1
|
|
145
|
+
if test['errors']:
|
|
146
|
+
errors += 1
|
|
147
|
+
elif test['test_output']:
|
|
148
|
+
if test['invalid_output']:
|
|
149
|
+
fail += 1
|
|
150
|
+
tests_run_xml.append(current)
|
|
151
|
+
payload = '\n'.join(tests_run_xml)
|
|
152
|
+
xml = '''<?xml version="1.0" encoding="UTF-8"?>
|
|
153
|
+
<testsuite name="integration" tests="%s" errors="%s" failures="%s" skip="0">
|
|
154
|
+
%s
|
|
155
|
+
</testsuite>''' % (total, errors, fail, payload)
|
|
156
|
+
with open('tests.xml', 'w') as f:
|
|
157
|
+
f.write(xml)
|
|
158
|
+
for test in test_to_run:
|
|
159
|
+
counter += 1
|
|
160
|
+
has_run = u'\u2713'
|
|
161
|
+
color = ''
|
|
162
|
+
end_color = ''
|
|
163
|
+
valid_output = "No output to test"
|
|
164
|
+
if test['test_output']:
|
|
165
|
+
valid_output = u'\u2713'
|
|
166
|
+
if test['invalid_output']:
|
|
167
|
+
valid_output = test['invalid_output']
|
|
168
|
+
color = bcolors.WARNING
|
|
169
|
+
end_color = bcolors.ENDC
|
|
170
|
+
if test['errors']:
|
|
171
|
+
valid_output = u'\u2717'
|
|
172
|
+
has_run = u'\u2717'
|
|
173
|
+
color = bcolors.FAIL
|
|
174
|
+
end_color = bcolors.ENDC
|
|
175
|
+
test['errors'] = '\n'.join(['%s%s%s' % (color, e, end_color)
|
|
176
|
+
for e in test['errors'].split('\n')])
|
|
177
|
+
display.append([
|
|
178
|
+
'%s%s' % (color, counter), test['template'], os.path.basename(test['path']),
|
|
179
|
+
has_run, test['errors'], '%s%s%s' % (color,
|
|
180
|
+
valid_output, end_color)])
|
|
181
|
+
print(tabulate(display[1:], headers=display[0]))
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def _run_per_file(template, path, input_string=None, validate=False):
|
|
185
|
+
parser = Parser(template)
|
|
186
|
+
if input_string:
|
|
187
|
+
data = input_string
|
|
188
|
+
else:
|
|
189
|
+
data = path
|
|
190
|
+
try:
|
|
191
|
+
transformed = parser.run(data, raise_errors=True)
|
|
192
|
+
if validate:
|
|
193
|
+
transformed, errors = parser.validate(transformed, gbd_format=transformed)
|
|
194
|
+
return (transformed, None, errors)
|
|
195
|
+
return (transformed, None, None)
|
|
196
|
+
except Exception as e:
|
|
197
|
+
return (None, traceback.format_exc(), None)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def printProgressBar(iteration, total, prefix = '', suffix = '',
|
|
201
|
+
decimals=1, length = 100, fill = '█', printEnd = "\r"):
|
|
202
|
+
"""
|
|
203
|
+
Call in a loop to create terminal progress bar
|
|
204
|
+
@params:
|
|
205
|
+
iteration - Required : current iteration (Int)
|
|
206
|
+
total - Required : total iterations (Int)
|
|
207
|
+
prefix - Optional : prefix string (Str)
|
|
208
|
+
suffix - Optional : suffix string (Str)
|
|
209
|
+
decimals - Optional : positive number of decimals in percent complete (Int)
|
|
210
|
+
length - Optional : character length of bar (Int)
|
|
211
|
+
fill - Optional : bar fill character (Str)
|
|
212
|
+
printEnd - Optional : end character (e.g. "\r", "\r\n") (Str)
|
|
213
|
+
"""
|
|
214
|
+
return
|
|
215
|
+
# percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
|
|
216
|
+
# filledLength = int(length * iteration // total)
|
|
217
|
+
# bar = fill * filledLength + '-' * (length - filledLength)
|
|
218
|
+
# print(f'\r{prefix} |{bar}| {percent}% {suffix}', end=printEnd)
|
|
219
|
+
# Print New Line on Complete
|
|
220
|
+
# if iteration == total:
|
|
221
|
+
# print()
|
|
222
|
+
|
|
223
|
+
def do_transform(file, templates, validate=False):
|
|
224
|
+
raw_data = __read_file(file)
|
|
225
|
+
|
|
226
|
+
for template in templates.split(','):
|
|
227
|
+
parser = parsers.get(template)
|
|
228
|
+
ret = {'src': file}
|
|
229
|
+
ret['fmt'] = 'gbd'
|
|
230
|
+
# get return from transformation
|
|
231
|
+
if template == 'solrjtm':
|
|
232
|
+
ret['fmt'] = 'idx'
|
|
233
|
+
try:
|
|
234
|
+
transformed = parser.run(raw_data, raise_errors=True)
|
|
235
|
+
ret['out'] = transformed
|
|
236
|
+
except Exception as e:
|
|
237
|
+
ret['terror'] = {'message': e, 'stacktrace': traceback.format_exc()}
|
|
238
|
+
else:
|
|
239
|
+
|
|
240
|
+
if not validate or template == 'solrjtm':
|
|
241
|
+
try:
|
|
242
|
+
transformed = parser.run(raw_data, raise_errors=True)
|
|
243
|
+
ret['out'] = transformed
|
|
244
|
+
raw_data = transformed
|
|
245
|
+
except Exception as e:
|
|
246
|
+
ret['terror'] = {'message': e, 'stacktrace': traceback.format_exc()}
|
|
247
|
+
# get return from transformation and validation
|
|
248
|
+
else:
|
|
249
|
+
try:
|
|
250
|
+
transformed, errors = parser.validate(raw_data)
|
|
251
|
+
ret['out'] = transformed
|
|
252
|
+
ret['verrors'] = errors
|
|
253
|
+
raw_data = transformed
|
|
254
|
+
except Exception as e:
|
|
255
|
+
ret['terror'] = {'message': e, 'stacktrace': traceback.format_exc()}
|
|
256
|
+
return ret
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _sub_arry_offset(max_paralel, length, offset):
|
|
260
|
+
if offset + max_paralel < length:
|
|
261
|
+
return offset + max_paralel
|
|
262
|
+
return length
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def _paralel_process(path, xpath_lines):
|
|
266
|
+
|
|
267
|
+
max_parallel = 25
|
|
268
|
+
# Schedule an initial scan for each segment of the table. We read each
|
|
269
|
+
# segment in a separate thread, then look to see if there are more rows to
|
|
270
|
+
# read -- and if so, we schedule another scan.
|
|
271
|
+
tasks_to_do = []
|
|
272
|
+
for root, dirs, files in os.walk(path):
|
|
273
|
+
for f in files:
|
|
274
|
+
# TODO: match file name with regex
|
|
275
|
+
if f.endswith('.xml.gz'):
|
|
276
|
+
file2process = os.path.join(path, root, f)
|
|
277
|
+
tasks_to_do.append(file2process)
|
|
278
|
+
pbar = progress(len(tasks_to_do))
|
|
279
|
+
|
|
280
|
+
task_counter = 0
|
|
281
|
+
# Make the list an iterator, so the same tasks don't get run repeatedly.
|
|
282
|
+
|
|
283
|
+
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
284
|
+
|
|
285
|
+
# Schedule the initial batch of futures. Here we assume that
|
|
286
|
+
# max_scans_in_parallel < total_segments, so there's no risk that
|
|
287
|
+
# the queue will throw an Empty exception.
|
|
288
|
+
futures = {
|
|
289
|
+
executor.submit(_analyse_for_shazam, file2process, xpath_lines): file2process
|
|
290
|
+
for file2process in tasks_to_do[task_counter:_sub_arry_offset(max_parallel,
|
|
291
|
+
len(tasks_to_do),
|
|
292
|
+
task_counter)]
|
|
293
|
+
}
|
|
294
|
+
pbar.start()
|
|
295
|
+
task_counter = len(futures)
|
|
296
|
+
while futures:
|
|
297
|
+
# Wait for the first future to complete.
|
|
298
|
+
done, _ = concurrent.futures.wait(
|
|
299
|
+
futures, return_when=concurrent.futures.FIRST_COMPLETED
|
|
300
|
+
)
|
|
301
|
+
pbar.advance_with_step(len(done))
|
|
302
|
+
for fut in done:
|
|
303
|
+
res = fut.result()
|
|
304
|
+
file2process = futures.pop(fut)
|
|
305
|
+
yield xpath_lines
|
|
306
|
+
|
|
307
|
+
# Schedule the next batch of futures. At some point we might run out
|
|
308
|
+
# of entries in the queue if we've finished scanning the table, so
|
|
309
|
+
# we need to spot that and not throw.
|
|
310
|
+
for file2process in tasks_to_do[task_counter:_sub_arry_offset(len(done),
|
|
311
|
+
len(tasks_to_do),
|
|
312
|
+
task_counter)]:
|
|
313
|
+
task_counter += 1
|
|
314
|
+
futures[executor.submit(_analyse_for_shazam, file2process, xpath_lines)] = file2process
|
|
315
|
+
|
|
316
|
+
def _doc2xpath(el, path, lines, root=''):
|
|
317
|
+
lines.add(root + path)
|
|
318
|
+
path = root + path
|
|
319
|
+
# Print attributes
|
|
320
|
+
for name, val in el.items() :
|
|
321
|
+
lines.add(path + "[@" + _removeNS(name) + "=" + val+"]")
|
|
322
|
+
# Counter on the sibbling element names
|
|
323
|
+
counters = {}
|
|
324
|
+
# Loop on child elements
|
|
325
|
+
for childEl in el :
|
|
326
|
+
tag = _removeNS(childEl.tag)
|
|
327
|
+
# Tag name already encountered ?
|
|
328
|
+
if tag in counters:
|
|
329
|
+
continue
|
|
330
|
+
counters[tag] = 1
|
|
331
|
+
# Print child node recursively
|
|
332
|
+
_doc2xpath(childEl, '/' + tag, lines, root=path)
|
|
333
|
+
|
|
334
|
+
def _removeNS(tag) :
|
|
335
|
+
if tag.find('}') == -1 :
|
|
336
|
+
return tag
|
|
337
|
+
else:
|
|
338
|
+
return tag.split('}', 1)[1]
|
|
339
|
+
|
|
340
|
+
def _analyse_for_shazam(file2process, xpath_lines):
|
|
341
|
+
stream = __read_file(file2process)
|
|
342
|
+
tree = ET.ElementTree(ET.fromstring(stream))
|
|
343
|
+
troot = tree.getroot()
|
|
344
|
+
_doc2xpath(troot, _removeNS(troot.tag), xpath_lines)
|
|
345
|
+
|
|
346
|
+
def shazam():
|
|
347
|
+
doc = """
|
|
348
|
+
deduce xpath lines from a directory of xml files
|
|
349
|
+
"""
|
|
350
|
+
configs = [{
|
|
351
|
+
'name': ['path'],
|
|
352
|
+
'type': str,
|
|
353
|
+
'help': 'path to a file or a directory'
|
|
354
|
+
}, {
|
|
355
|
+
'name': ['-o'],
|
|
356
|
+
'dest': 'outfile',
|
|
357
|
+
'help': 'write output to a file',
|
|
358
|
+
'type': str,
|
|
359
|
+
'default': None,
|
|
360
|
+
}, ]
|
|
361
|
+
|
|
362
|
+
args = build_command_parser(configs, doc)
|
|
363
|
+
path = args.path
|
|
364
|
+
|
|
365
|
+
if os.path.isfile(path):
|
|
366
|
+
print('Expected a directory location.')
|
|
367
|
+
sys.exit(1)
|
|
368
|
+
# a set to contain the unique xpath lines
|
|
369
|
+
xpath_lines = set()
|
|
370
|
+
|
|
371
|
+
# in case the path passed is relative
|
|
372
|
+
if not os.path.isabs(path):
|
|
373
|
+
path = os.path.realpath(os.path.join(os.getcwd(), path))
|
|
374
|
+
# passed a directory
|
|
375
|
+
current_xplath_lines = None
|
|
376
|
+
for tmp in _paralel_process(path, xpath_lines):
|
|
377
|
+
current_xplath_lines = tmp
|
|
378
|
+
|
|
379
|
+
xpath_lines = current_xplath_lines
|
|
380
|
+
if(args.outfile):
|
|
381
|
+
with open(args.outfile, 'w') as fh:
|
|
382
|
+
for line in sorted(xpath_lines):
|
|
383
|
+
xpath = line.split('/')
|
|
384
|
+
leaf = xpath.pop()
|
|
385
|
+
fh.write(''.join(['__' for p in xpath]) + '/'+leaf)
|
|
386
|
+
fh.write('\n')
|
|
387
|
+
else:
|
|
388
|
+
pprint.pprint(xpath_lines)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def _paralel_run(tasks_to_do, templates, pbar, validate=False, max_parallel=25):
|
|
394
|
+
# Schedule an initial scan for each segment of the table. We read each
|
|
395
|
+
# segment in a separate thread, then look to see if there are more rows to
|
|
396
|
+
# read -- and if so, we schedule another scan.
|
|
397
|
+
|
|
398
|
+
task_counter = 0
|
|
399
|
+
# Make the list an iterator, so the same tasks don't get run repeatedly.
|
|
400
|
+
|
|
401
|
+
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
402
|
+
|
|
403
|
+
# Schedule the initial batch of futures. Here we assume that
|
|
404
|
+
# max_scans_in_parallel < total_segments, so there's no risk that
|
|
405
|
+
# the queue will throw an Empty exception.
|
|
406
|
+
futures = {
|
|
407
|
+
executor.submit(do_transform, file2process, templates, validate): file2process
|
|
408
|
+
for file2process in tasks_to_do[task_counter:_sub_arry_offset(max_parallel,
|
|
409
|
+
len(tasks_to_do),
|
|
410
|
+
task_counter)]
|
|
411
|
+
}
|
|
412
|
+
task_counter = len(futures)
|
|
413
|
+
while futures:
|
|
414
|
+
# Wait for the first future to complete.
|
|
415
|
+
processed, _ = concurrent.futures.wait(
|
|
416
|
+
futures, return_when=concurrent.futures.FIRST_COMPLETED
|
|
417
|
+
)
|
|
418
|
+
pbar.advance_with_step(len(processed))
|
|
419
|
+
for fut in processed:
|
|
420
|
+
res = fut.result()
|
|
421
|
+
file2process = futures.pop(fut)
|
|
422
|
+
yield res
|
|
423
|
+
|
|
424
|
+
# Schedule the next batch of futures. At some point we might run out
|
|
425
|
+
# of entries in the queue if we've finished scanning the table, so
|
|
426
|
+
# we need to spot that and not throw.
|
|
427
|
+
for file2process in tasks_to_do[task_counter:_sub_arry_offset(len(processed),
|
|
428
|
+
len(tasks_to_do),
|
|
429
|
+
task_counter)]:
|
|
430
|
+
task_counter += 1
|
|
431
|
+
futures[executor.submit(do_transform, file2process, templates, validate)] = file2process
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def do_multiprocess(files, settings):
|
|
435
|
+
(args, pbar, done) = settings
|
|
436
|
+
|
|
437
|
+
results = []
|
|
438
|
+
# create parsers
|
|
439
|
+
for template in args.template.split(','):
|
|
440
|
+
parsers[template] = Parser(template)
|
|
441
|
+
|
|
442
|
+
for file in files:
|
|
443
|
+
results.append(do_transform(file, args.template, validate=args.validate))
|
|
444
|
+
done.value += 1
|
|
445
|
+
pbar.advance(done.value)
|
|
446
|
+
# for tmp in _paralel_run(files, args.template, pbar, validate=args.validate,
|
|
447
|
+
# max_parallel=args.threads):
|
|
448
|
+
# results.append(tmp)
|
|
449
|
+
return results
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def run():
|
|
453
|
+
doc = """
|
|
454
|
+
transform input to output using a defined template name.
|
|
455
|
+
"""
|
|
456
|
+
configs = [{
|
|
457
|
+
'name': ['path'],
|
|
458
|
+
'type': str,
|
|
459
|
+
'help': 'path to a file or a directory'
|
|
460
|
+
}, {
|
|
461
|
+
'name': ['template'],
|
|
462
|
+
'type': str,
|
|
463
|
+
'help': 'the template used for transformation'
|
|
464
|
+
}, {
|
|
465
|
+
'name': ['-t'],
|
|
466
|
+
'dest': 'top',
|
|
467
|
+
'type': int,
|
|
468
|
+
'help': 'number of files to run the command onto',
|
|
469
|
+
'default': 0
|
|
470
|
+
}, {
|
|
471
|
+
'name': ['-r'],
|
|
472
|
+
'dest': 'random',
|
|
473
|
+
'type': int,
|
|
474
|
+
'help': 'number of *random* files to run the command onto',
|
|
475
|
+
'default': 0
|
|
476
|
+
}, {
|
|
477
|
+
'name': ['-w'],
|
|
478
|
+
'dest': 'workers',
|
|
479
|
+
'type': int,
|
|
480
|
+
'help': 'number of workers to run the command',
|
|
481
|
+
'default': 1
|
|
482
|
+
},{
|
|
483
|
+
'name': ['-th'],
|
|
484
|
+
'dest': 'threads',
|
|
485
|
+
'type': int,
|
|
486
|
+
'help': 'number of threads to run the command',
|
|
487
|
+
'default': 25
|
|
488
|
+
},{
|
|
489
|
+
'name': ['-o'],
|
|
490
|
+
'dest': 'outfile',
|
|
491
|
+
'help': 'write output to a file',
|
|
492
|
+
'type': str,
|
|
493
|
+
'default': None,
|
|
494
|
+
}, {
|
|
495
|
+
'name': ['-a'],
|
|
496
|
+
'dest': 'appendfile',
|
|
497
|
+
'help': 'append output to a file',
|
|
498
|
+
'type': str,
|
|
499
|
+
'default': None,
|
|
500
|
+
}, {
|
|
501
|
+
'name': ['--qc'],
|
|
502
|
+
'dest': 'validate',
|
|
503
|
+
'help': 'runs gbd-validate on output',
|
|
504
|
+
'action': 'store_true',
|
|
505
|
+
'default': False
|
|
506
|
+
}, {
|
|
507
|
+
'name': ['-q', '--quiet'],
|
|
508
|
+
'dest': 'quiet',
|
|
509
|
+
'help': 'perform transformation quietly (do not print result of transformation)',
|
|
510
|
+
'action': 'store_true',
|
|
511
|
+
'default': False
|
|
512
|
+
}, ]
|
|
513
|
+
args = build_command_parser(configs, doc)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def _walk_dir(root_path, nb):
|
|
517
|
+
buffer = []
|
|
518
|
+
for root, dirs, files in os.walk(root_path):
|
|
519
|
+
for f in files:
|
|
520
|
+
if f.endswith('.xml.gz'): # or f.endswith('.xml'):
|
|
521
|
+
buffer.append(os.path.join(root_path, root, f))
|
|
522
|
+
if len(buffer) == nb:
|
|
523
|
+
return buffer
|
|
524
|
+
return buffer
|
|
525
|
+
|
|
526
|
+
def _fish_dir(root_path, nb):
|
|
527
|
+
buffer = []
|
|
528
|
+
path = root_path
|
|
529
|
+
# go fishing
|
|
530
|
+
while len(buffer) < nb:
|
|
531
|
+
sea = os.listdir(path)
|
|
532
|
+
# skip empty directories
|
|
533
|
+
if not len(sea):
|
|
534
|
+
path = root_path
|
|
535
|
+
continue
|
|
536
|
+
fish = os.path.join(path, random.choice(sea))
|
|
537
|
+
if os.path.isdir(fish):
|
|
538
|
+
path = fish
|
|
539
|
+
elif os.path.isfile(fish) and fish.endswith('.xml.gz'):
|
|
540
|
+
buffer.append(fish)
|
|
541
|
+
path = root_path
|
|
542
|
+
return buffer
|
|
543
|
+
|
|
544
|
+
path = args.path
|
|
545
|
+
# in case the path passed is relative
|
|
546
|
+
if not os.path.isabs(path):
|
|
547
|
+
path = os.path.realpath(os.path.join(os.getcwd(), path))
|
|
548
|
+
|
|
549
|
+
files = []
|
|
550
|
+
# passed a file
|
|
551
|
+
if os.path.isfile(path):
|
|
552
|
+
files.append(path)
|
|
553
|
+
# passed a directory
|
|
554
|
+
elif os.path.isdir(path):
|
|
555
|
+
if args.random:
|
|
556
|
+
files = _fish_dir(path, args.random)
|
|
557
|
+
else:
|
|
558
|
+
files = _walk_dir(path, args.top)
|
|
559
|
+
else:
|
|
560
|
+
raise Exception('invalid path %s. try again.' % path)
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
workers = min(multiprocessing.cpu_count() - 4, args.workers)
|
|
565
|
+
|
|
566
|
+
# print('Running template [%s] * [%s files] with [%s workers]' % (args.template,
|
|
567
|
+
# len(files), workers))
|
|
568
|
+
files_per_worker_len = len(files) / workers
|
|
569
|
+
|
|
570
|
+
files_per_worker = []
|
|
571
|
+
tmp = []
|
|
572
|
+
for el in files:
|
|
573
|
+
if len(tmp) >= files_per_worker_len:
|
|
574
|
+
files_per_worker.append(tmp)
|
|
575
|
+
tmp = []
|
|
576
|
+
tmp.append(el)
|
|
577
|
+
files_per_worker.append(tmp)
|
|
578
|
+
|
|
579
|
+
pbar = progress(len(files))
|
|
580
|
+
pbar.start()
|
|
581
|
+
|
|
582
|
+
# a way to share state among workers
|
|
583
|
+
mpmanager = multiprocessing.Manager()
|
|
584
|
+
done = mpmanager.Value('i', 0)
|
|
585
|
+
|
|
586
|
+
with multiprocessing.Pool(processes=workers) as pool: # auto closing workers
|
|
587
|
+
raw_results = pool.starmap(do_multiprocess, zip(files_per_worker, [(args, pbar, done) for x in files]))
|
|
588
|
+
results = []
|
|
589
|
+
for result in raw_results:
|
|
590
|
+
results.extend(result)
|
|
591
|
+
|
|
592
|
+
_print_transformation_out(results, args)
|
|
593
|
+
_print_transformation_err(results, args)
|
|
594
|
+
_print_validation_err(results, args)
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def _print_transformation_out(results, args):
|
|
599
|
+
output_storage = args.outfile or args.appendfile or '/dev/null'
|
|
600
|
+
output_mode = 'a' if args.appendfile else 'w'
|
|
601
|
+
# fh = open(output_storage, output_mode)
|
|
602
|
+
|
|
603
|
+
dirFiles = {}
|
|
604
|
+
for r in results:
|
|
605
|
+
if r.get('out', None):
|
|
606
|
+
dir = os.path.dirname(r.get('src'))
|
|
607
|
+
parentDir = os.path.dirname(dir)
|
|
608
|
+
# print("dir: ", dir, " parent " , parentDir)
|
|
609
|
+
destFile = os.path.join(parentDir, r.get('fmt')+".json")
|
|
610
|
+
if destFile not in dirFiles:
|
|
611
|
+
dirFiles[parentDir] = destFile
|
|
612
|
+
# no support for append
|
|
613
|
+
dirHandles = {}
|
|
614
|
+
for dir in dirFiles:
|
|
615
|
+
dirHandles[dir] = open(dirFiles[dir],'w')
|
|
616
|
+
print("Creating this file: ", dirFiles[dir])
|
|
617
|
+
dirHandles[dir].write("[\n")
|
|
618
|
+
|
|
619
|
+
for result in results:
|
|
620
|
+
if result.get('out', None):
|
|
621
|
+
if not args.quiet:
|
|
622
|
+
print(result['out'])
|
|
623
|
+
childDir = os.path.dirname(result.get('src'))
|
|
624
|
+
dir = os.path.dirname(childDir)
|
|
625
|
+
#dirHandles[dir]#with open(dirFiles.get(dir), 'a') as df:
|
|
626
|
+
dirHandles[dir].write(result['out'])
|
|
627
|
+
dirHandles[dir].write(",\n")
|
|
628
|
+
# fh.write(result['out'])
|
|
629
|
+
# fh.write('\n')
|
|
630
|
+
for dh in dirHandles.values():
|
|
631
|
+
dh.write("{}]\n")
|
|
632
|
+
dh.close()
|
|
633
|
+
|
|
634
|
+
# fh.close()
|
|
635
|
+
|
|
636
|
+
def _print_validation_err(results, args):
|
|
637
|
+
if not args.validate:
|
|
638
|
+
return
|
|
639
|
+
|
|
640
|
+
display_lines = []
|
|
641
|
+
|
|
642
|
+
for result in results:
|
|
643
|
+
verrors = result.get('verrors', [])
|
|
644
|
+
if not len(verrors):
|
|
645
|
+
continue
|
|
646
|
+
|
|
647
|
+
display_line = {}
|
|
648
|
+
display_line['QC Invalid File'] = __format_color(result['src'], bcolors.FAIL)
|
|
649
|
+
display_line['Severity'] = []
|
|
650
|
+
display_line['Field'] = []
|
|
651
|
+
display_line['Message'] = []
|
|
652
|
+
|
|
653
|
+
for i, verror in enumerate(verrors):
|
|
654
|
+
severity = __format_color(verror['severity'], getattr(bcolors, verror['severity']))
|
|
655
|
+
field = verror['field']
|
|
656
|
+
message = verror['type']
|
|
657
|
+
|
|
658
|
+
display_line['Severity'].append(severity)
|
|
659
|
+
display_line['Field'].append(field)
|
|
660
|
+
display_line['Message'].append(message)
|
|
661
|
+
|
|
662
|
+
display_line['Severity'] = '\n'.join(display_line['Severity'])
|
|
663
|
+
display_line['Field'] = '\n'.join(display_line['Field'])
|
|
664
|
+
display_line['Message'] = '\n'.join(display_line['Message'])
|
|
665
|
+
display_lines.append(display_line)
|
|
666
|
+
|
|
667
|
+
if len(display_lines):
|
|
668
|
+
print('\n')
|
|
669
|
+
print(tabulate(display_lines, headers='keys', showindex='always', tablefmt='psql'))
|
|
670
|
+
|
|
671
|
+
def _print_transformation_err(results, args):
|
|
672
|
+
# a single file
|
|
673
|
+
if(len(results) == 1):
|
|
674
|
+
result = results[0]
|
|
675
|
+
if result.get('terror', None):
|
|
676
|
+
print(__format_color(result['terror']['stacktrace'], bcolors.FAIL))
|
|
677
|
+
return
|
|
678
|
+
|
|
679
|
+
# multi file
|
|
680
|
+
display_lines = []
|
|
681
|
+
|
|
682
|
+
for result in results:
|
|
683
|
+
if not result.get('terror', None):
|
|
684
|
+
continue
|
|
685
|
+
|
|
686
|
+
display_line = {}
|
|
687
|
+
display_line['Transformation Failed File'] = __format_color(result['src'], bcolors.FAIL)
|
|
688
|
+
display_line['Error Message'] = result['terror']['message']
|
|
689
|
+
|
|
690
|
+
display_lines.append(display_line)
|
|
691
|
+
|
|
692
|
+
if len(display_lines):
|
|
693
|
+
print('\n')
|
|
694
|
+
print(tabulate(display_lines, headers='keys', showindex='always', tablefmt='psql'))
|
|
695
|
+
|
|
696
|
+
def __format_color(value, color):
|
|
697
|
+
return '%s%s%s' % (color, value, bcolors.ENDC)
|
|
698
|
+
|
|
699
|
+
def __read_file(file):
|
|
700
|
+
if file.endswith('.xml.gz'):
|
|
701
|
+
with gzip.open(file, 'rb') as f:
|
|
702
|
+
raw_data = f.read()
|
|
703
|
+
return raw_data
|
|
704
|
+
else:
|
|
705
|
+
with open(file, 'r') as f:
|
|
706
|
+
raw_data = f.read()
|
|
707
|
+
return raw_data
|
|
708
|
+
|
|
709
|
+
|