From bbb8b2131350775f6be7144e1a6c558eb62e8972 Mon Sep 17 00:00:00 2001 From: Jason Ward Date: Tue, 9 Jul 2013 17:27:28 -0400 Subject: [PATCH 1/3] refs #52: Added a test showing what should be done with files that are missing numbering.xml but still use lists. --- pydocx/fixtures/missing_numbering.docx | Bin 0 -> 3353 bytes pydocx/tests/test_docx.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 pydocx/fixtures/missing_numbering.docx diff --git a/pydocx/fixtures/missing_numbering.docx b/pydocx/fixtures/missing_numbering.docx new file mode 100644 index 0000000000000000000000000000000000000000..5034f52497f6f726aa2c8e83af5a479714c8fb22 GIT binary patch literal 3353 zcmaJ@2{@Ep8-DG~6hlNBi73p+AWI6_*DxsilAUQ7hWWC_6dFsmB3lfKh{~FfCD}7s z3t0*oKC)y>4FAyo{mS?M|9h_Yoa?==_rA_~?(;nNb0c(VXxRaPkr6oZWJYDWi|W)M z000Wq005?}wiqXrH(YFYE=thTrBOZ+xp#wW=T2S3K<58X2jf2NmG7-NqAU*#@b&V3aFNFa%%6c7*afCagJ$x?P z*`u7qeBDt+@pT@JCn3%2igfm9!m)x@P)wCifuz(7P5P3Y#&~QKpK)DK#1VK=Ud8d@ z^^x@pG33v^<}&sIM{33mj<+52=dqZ8M+T?c@?K9jq#nC@_yk90-1n>-1Ed15A}j1` zMnR!(W)Ff%xk{6vjEUw)HkR+a))#I#|Lp;030DD;8DeD7y?3v1OEtBmVkunvsz`O2)#!}VZ&E4fJ!Sec zv7C&4uUlN0W0I*p2qCkrI&(+IwKJ3+(dg~G{Cvi&Pmr`(+tlt@T?gN~LHGgQXX#AT zjEZ$TR-%Z)PAC-sKq+I7rJu>-h<3obJ9+r*Qni;jS1vOFG*!XFhPyA;7YtC*PSXIu z-c%IV0eUSCQU9<8Q&A+iaad{fdJOx($hc(vA$uEvoPj#olZqganAPZo#+1g(o&ByD z9OR6PoapjR8LSD968MrH^bD`IMR9yDYxe?I6o&Sc{k;5ul%W_GPBqTC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bP`L7eM;q}b+Nwm@BTqz`-c2|wX z^GEZW`&QU%rq~-#<}W)73g?m~|*#4ap#N9S40VbkX78JzU)e2XT~Mn5-7 z$<6B2TCE|)C^H2b;Vl0i{~Q5!Ca1DWQyN5|Mh-yD@uEA{cy*^;Nwm$f@kv`xlXv!St5_%pT;Gpv#EXPjo7Hk{DX zOl+$P^tBRYg=yL3I%XtnUQx_b*LEq5j*A8D7#|`|4EnFVxh36}8X)J{yZZbn%LQrF z-FT2~lEdnCmpO*t*({hmt^5at$*YtubA-aCr7FdWP`az_Wj{|RZ|mI*d3CRIm(S3J zpvYF!dzGF_jDj;%5vNuV#MW}zJ7GJMSl!LFLQ6d4BuH@FzU|xFz*56G|BCY50VTDs z){Vp`!mxVnXJwYsb9P>qHpS)_@;R#kv$*$mjX&@WJg0{7)^}@@ayTL?yqa#s z8Q9Zp*`I$k*;7p`mMHAe)8} zC;AvHHgwvFujm7K7NcpSgZ2E^43}aU!NpPtr!UV!YG=!6zkC@=c+~F2=g)*+X)DYR zpUx3vKFgvlu=8SLWJrw9=<^bZH#;`T_u@t+Pxuj7*@YpRULp`PHXgUhlTougO@rYl zr?6OJL=b|BjF7wAe3n0aUrYOLE|hGZ^)gx}M|IZ%2wf^_cHn>eT?)g$JioZ#gTR9} zaUVrZxvhVi#$Eggnx7m0(?D_U!6`tX3@1eCLI2-Q(fzbj2dvb=6CU&@`zM4^+}GX? zzq*x!@PqAeAHGRR#Xb0bb36z>C~Es)48t#q@NbDbh(4$w`)E~4Z~lj#9E2Y%nSFRX Y(|;`>gf1QZ?oW)A!9ihv9<=-QFZ;)mm;e9( literal 0 HcmV?d00001 diff --git a/pydocx/tests/test_docx.py b/pydocx/tests/test_docx.py index a0aa1909..f5b39995 100644 --- a/pydocx/tests/test_docx.py +++ b/pydocx/tests/test_docx.py @@ -735,6 +735,20 @@ def test_missing_style(): ''') +def test_missing_numbering(): + file_path = path.join( + path.abspath(path.dirname(__file__)), + '..', + 'fixtures', + 'missing_numbering.docx', + ) + actual_html = convert(file_path) + assert_html_equal(actual_html, BASE_HTML % ''' +

AAA

+

BBB

+ ''') + + def _converter(*args, **kwargs): # Having a converter that does nothing is the same as if abiword fails to # convert. From c5a24520c3c3629588169c32b633b2c3be044b36 Mon Sep 17 00:00:00 2001 From: Jason Ward Date: Tue, 9 Jul 2013 17:28:02 -0400 Subject: [PATCH 2/3] refs #52: Nothing can be a list now if there is no numbering.xml file. --- pydocx/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pydocx/utils.py b/pydocx/utils.py index 45beed0b..1d5cd8b9 100644 --- a/pydocx/utils.py +++ b/pydocx/utils.py @@ -168,7 +168,9 @@ def __init__( def perform_pre_processing(self, root, *args, **kwargs): self._add_parent(root) - self._set_list_attributes(root) + # If we don't have a numbering root there cannot be any lists. + if self.numbering_root is not None: + self._set_list_attributes(root) self._set_table_attributes(root) self._set_is_in_table(root) From 07eeeb3df5b84c0800bfb98e0e5b88ca74b27360 Mon Sep 17 00:00:00 2001 From: Jason Ward Date: Tue, 9 Jul 2013 17:29:29 -0400 Subject: [PATCH 3/3] refs #52: update note --- CHANGELOG | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 94035b11..f009a3b9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,16 @@ Changelog ========= +* 0.3.6 + * It is possible for a docx file to not contain a `numbering.xml` file but + still try to use lists. Now if this happens all lists get converted to + paragraphs. * 0.3.5 * Not all docx files contain a `styles.xml` file. We are no longer assuming they do. * 0.3.4 - * It is possible for `w:t` tags to have `text` set to `None`. This no longer causes an error when escaping that text. + * It is possible for `w:t` tags to have `text` set to `None`. This no + longer causes an error when escaping that text. * 0.3.3 * In the event that `cElementTree` has a problem parsing the document, a `MalformedDocxException` is raised instead of a `SyntaxError`