Commit dae3f0f30f7b35912252c4d9a43e2ccd96ac36d7
1 parent
3c505247
clean-up to use TAG_W_INSTRATTR instead of constructing string during parsing
Showing
1 changed file
with
2 additions
and
1 deletions
oletools/msodde.py
| @@ -81,6 +81,7 @@ NS_WORD = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main' | @@ -81,6 +81,7 @@ NS_WORD = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main' | ||
| 81 | # XML tag for 'w:instrText' | 81 | # XML tag for 'w:instrText' |
| 82 | TAG_W_INSTRTEXT = '{%s}instrText' % NS_WORD | 82 | TAG_W_INSTRTEXT = '{%s}instrText' % NS_WORD |
| 83 | TAG_W_FLDSIMPLE = '{%s}fldSimple' % NS_WORD | 83 | TAG_W_FLDSIMPLE = '{%s}fldSimple' % NS_WORD |
| 84 | +TAG_W_INSTRATTR= '{%s}instr' % NS_WORD | ||
| 84 | 85 | ||
| 85 | # === FUNCTIONS ============================================================== | 86 | # === FUNCTIONS ============================================================== |
| 86 | 87 | ||
| @@ -115,7 +116,7 @@ def process_file(filepath): | @@ -115,7 +116,7 @@ def process_file(filepath): | ||
| 115 | for elem in root.iter(TAG_W_FLDSIMPLE): | 116 | for elem in root.iter(TAG_W_FLDSIMPLE): |
| 116 | # concatenate the attribute of the field, if present: | 117 | # concatenate the attribute of the field, if present: |
| 117 | if elem.attrib is not None: | 118 | if elem.attrib is not None: |
| 118 | - text += elem.attrib['{http://schemas.openxmlformats.org/wordprocessingml/2006/main}instr'] | 119 | + text += elem.attrib[TAG_W_INSTRATTR] |
| 119 | 120 | ||
| 120 | 121 | ||
| 121 | return text | 122 | return text |