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