OLD | NEW |
1 #!/usr/local/bin/python | 1 #!/usr/local/bin/python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 import sys | 4 import sys |
5 import re | 5 import re |
6 | 6 |
7 # TODO(edisonn): put processed part of file in a new file | 7 # TODO(edisonn): put processed part of file in a new file |
8 # put unprocessed part, in a new file, so we see what we miss | 8 # put unprocessed part, in a new file, so we see what we miss |
9 # keep blank lines, and generate a version without the blank lines | 9 # keep blank lines, and generate a version without the blank lines |
10 | 10 |
11 #TODO (edisonn): deal manually with | 11 #TODO (edisonn): deal manually with tables that don't have "KEY TYPE VALUE' head
er, e.g. |
12 # TABLE 7.11 Restrictions on the entries in a soft-mask image dictionary | 12 # TABLE 7.11 Restrictions on the entries in a soft-mask image dictionary |
13 #KEY RESTRICTION | 13 #KEY RESTRICTION |
14 | 14 |
15 | 15 |
16 | 16 |
17 lines = 0 | 17 lines = 0 |
18 table = '' | 18 table = '' |
19 tableHeaderFound = False | 19 tableHeaderFound = False |
20 tableLine = 0 | 20 tableLine = 0 |
21 tableRow = 0 | 21 tableRow = 0 |
(...skipping 22 matching lines...) Expand all Loading... |
44 'tree', | 44 'tree', |
45 'number', | 45 'number', |
46 'rectangle', | 46 'rectangle', |
47 'stream', | 47 'stream', |
48 'string', | 48 'string', |
49 'text', | 49 'text', |
50 ',', | 50 ',', |
51 ' ' | 51 ' ' |
52 } | 52 } |
53 | 53 |
| 54 # TODO(edisonn): add a third element in the vector, the base class, by default i
t is Dictionary |
| 55 # TODO(edisonn): add overrides for types map<field_name, type_name> |
| 56 # e.g. ,{'Resources', 'ResourceDictionary'} |
| 57 # TODO(edisonn): can be added one by one, or extracted from documentation |
| 58 |
54 tableToClassName = { | 59 tableToClassName = { |
55 'TABLE 3.4': ['StreamDictionariesCommon', 'Entries common to all stream dictiona
ries'], | 60 'TABLE 3.4': ['StreamCommonDictionary', 'Entries common to all stream dictionari
es'], |
56 'TABLE 3.7': ['LzwdecodeAndFlatedecodeFiltersOptionalParameters', 'Optional para
meters for LZWDecode and FlateDecode filters'], | 61 'TABLE 3.7': ['LzwdecodeAndFlatedecodeFiltersDictionary', 'Optional parameters f
or LZWDecode and FlateDecode filters'], |
57 'TABLE 3.9': ['CcittfaxdecodeFilterOptionalParameters', 'Optional parameters for
the CCITTFaxDecode filter'], | 62 'TABLE 3.9': ['CcittfaxdecodeFilterDictionary', 'Optional parameters for the CCI
TTFaxDecode filter'], |
58 'TABLE 3.10': ['Jbig2DecodeFilterOptionalParameters', 'Optional parameter for th
e JBIG2Decode filter'], | 63 'TABLE 3.10': ['Jbig2DecodeFilterDictionary', 'Optional parameter for the JBIG2D
ecode filter'], |
59 'TABLE 3.11': ['DctdecodeFilterOptionalParameters', 'Optional parameter for the
DCTDecode filter'], | 64 'TABLE 3.11': ['DctdecodeFilterDictionary', 'Optional parameter for the DCTDecod
e filter'], |
60 'TABLE 3.12': ['FileTrailerDictionary', 'Entries in the file trailer dictionary'
], | 65 'TABLE 3.12': ['FileTrailerDictionary', 'Entries in the file trailer dictionary'
], |
61 'TABLE 3.13': ['EncryptionDictionariesCommon', 'Entries common to all encryption
dictionaries'], | 66 'TABLE 3.13': ['EncryptionCommonDictionary', 'Entries common to all encryption d
ictionaries'], |
62 'TABLE 3.14': ['DictionaryEntriesForTheStandardSecurityHandler', 'Additional enc
ryption dictionary entries for the standard security handler'], | 67 'TABLE 3.14': ['StandardSecurityHandlerDictionary', 'Additional encryption dicti
onary entries for the standard security handler'], |
63 'TABLE 3.16': ['CatalogDictionary', 'Entries in the catalog dictionary'], | 68 'TABLE 3.16': ['CatalogDictionary', 'Entries in the catalog dictionary'], |
64 'TABLE 3.17': ['PageTreeNodeDictionary', 'Required entries in a page tree node']
, | 69 'TABLE 3.17': ['PageTreeNodeDictionary', 'Required entries in a page tree node']
, |
65 'TABLE 3.18': ['PageObjectDictionary', 'Entries in a page object'], | 70 'TABLE 3.18': ['PageObjectDictionary', 'Entries in a page object'], |
66 'TABLE 3.19': ['NameDictionary', 'Entries in the name dictionary'], | 71 'TABLE 3.19': ['NameDictionary', 'Entries in the name dictionary'], |
67 'TABLE 3.21': ['ResourceDictionary', 'Entries in a resource dictionary'], | 72 'TABLE 3.21': ['ResourceDictionary', 'Entries in a resource dictionary'], |
68 'TABLE 3.23': ['NameTreeNodeDictionary', 'Entries in a name tree node dictionary
'], | 73 'TABLE 3.23': ['NameTreeNodeDictionary', 'Entries in a name tree node dictionary
'], |
69 'TABLE 3.25': ['NumberTreeNodeDictionary', 'Entries in a number tree node dictio
nary'], | 74 'TABLE 3.25': ['NumberTreeNodeDictionary', 'Entries in a number tree node dictio
nary'], |
70 'TABLE 3.26': ['FunctionDictionariesCommon', 'Entries common to all function dic
tionaries'], | 75 'TABLE 3.26': ['FunctionCommonDictionary', 'Entries common to all function dicti
onaries'], |
71 'TABLE 3.27': ['SpecificToAType0FunctionDictionary', 'Additional entries specifi
c to a type 0 function dictionary'], | 76 'TABLE 3.27': ['Type0FunctionDictionary', 'Additional entries specific to a type
0 function dictionary'], |
72 'TABLE 3.28': ['SpecificToAType2FunctionDictionary', 'Additional entries specifi
c to a type 2 function dictionary'], | 77 'TABLE 3.28': ['Type2FunctionDictionary', 'Additional entries specific to a type
2 function dictionary'], |
73 'TABLE 3.29': ['SpecificToAType3FunctionDictionary', 'Additional entries specifi
c to a type 3 function dictionary'], | 78 'TABLE 3.29': ['Type3FunctionDictionary', 'Additional entries specific to a type
3 function dictionary'], |
74 'TABLE 3.32': ['FileSpecificationDictionary', 'Entries in a file specification d
ictionary'], | 79 'TABLE 3.32': ['FileSpecificationDictionary', 'Entries in a file specification d
ictionary'], |
75 'TABLE 3.33': ['EmbeddedFileStreamDictionary', 'Additional entries in an embedde
d file stream dictionary'], | 80 'TABLE 3.33': ['EmbeddedFileStreamDictionary', 'Additional entries in an embedde
d file stream dictionary'], |
| 81 'TABLE 3.34': ['EmbeddedFileParameterDictionary', 'Entries in an embedded file p
arameter dictionary'], |
76 'TABLE 3.35': ['MacOsFileInformationDictionary', 'Entries in a Mac OS file infor
mation dictionary'], | 82 'TABLE 3.35': ['MacOsFileInformationDictionary', 'Entries in a Mac OS file infor
mation dictionary'], |
77 'TABLE 4.13': ['CalgrayColorSpaceDictionary', 'Entries in a CalGray color space
dictionary'], | 83 'TABLE 4.13': ['CalgrayColorSpaceDictionary', 'Entries in a CalGray color space
dictionary'], |
78 'TABLE 4.14': ['CalrgbColorSpaceDictionary', 'Entries in a CalRGB color space di
ctionary'], | 84 'TABLE 4.14': ['CalrgbColorSpaceDictionary', 'Entries in a CalRGB color space di
ctionary'], |
79 'TABLE 4.15': ['LabColorSpaceDictionary', 'Entries in a Lab color space dictiona
ry'], | 85 'TABLE 4.15': ['LabColorSpaceDictionary', 'Entries in a Lab color space dictiona
ry'], |
80 'TABLE 4.16': ['SpecificToAnIccProfileStreamDictionary', 'Additional entries spe
cific to an ICC profile stream dictionary'], | 86 'TABLE 4.16': ['IccProfileStreamDictionary', 'Additional entries specific to an
ICC profile stream dictionary'], |
81 'TABLE 4.20': ['DevicenColorSpaceAttributesDictionary', 'Entry in a DeviceN colo
r space attributes dictionary'], | 87 'TABLE 4.20': ['DeviceNColorSpaceDictionary', 'Entry in a DeviceN color space at
tributes dictionary'], |
82 'TABLE 4.22': ['SpecificToAType1PatternDictionary', 'Additional entries specific
to a type 1 pattern dictionary'], | 88 'TABLE 4.22': ['Type1PatternDictionary', 'Additional entries specific to a type
1 pattern dictionary'], |
83 'TABLE 4.23': ['Type2PatternDictionary', 'Entries in a type 2 pattern dictionary
'], | 89 'TABLE 4.23': ['Type2PatternDictionary', 'Entries in a type 2 pattern dictionary
'], |
84 'TABLE 4.25': ['ShadingDictionariesCommon', 'Entries common to all shading dicti
onaries'], | 90 'TABLE 4.25': ['ShadingDictionary', 'Entries common to all shading dictionaries'
], |
85 'TABLE 4.26': ['SpecificToAType1ShadingDictionary', 'Additional entries specific
to a type 1 shading dictionary'], | 91 'TABLE 4.26': ['Type1ShadingDictionary', 'Additional entries specific to a type
1 shading dictionary', 'ShadingDictionary'], |
86 'TABLE 4.27': ['SpecificToAType2ShadingDictionary', 'Additional entries specific
to a type 2 shading dictionary'], | 92 'TABLE 4.27': ['Type2ShadingDictionary', 'Additional entries specific to a type
2 shading dictionary', 'ShadingDictionary'], |
87 'TABLE 4.28': ['SpecificToAType3ShadingDictionary', 'Additional entries specific
to a type 3 shading dictionary'], | 93 'TABLE 4.28': ['Type3ShadingDictionary', 'Additional entries specific to a type
3 shading dictionary', 'ShadingDictionary'], |
88 'TABLE 4.29': ['SpecificToAType4ShadingDictionary', 'Additional entries specific
to a type 4 shading dictionary'], | 94 'TABLE 4.29': ['Type4ShadingDictionary', 'Additional entries specific to a type
4 shading dictionary', 'ShadingDictionary'], |
89 'TABLE 4.30': ['SpecificToAType5ShadingDictionary', 'Additional entries specific
to a type 5 shading dictionary'], | 95 'TABLE 4.30': ['Type5ShadingDictionary', 'Additional entries specific to a type
5 shading dictionary', 'ShadingDictionary'], |
90 'TABLE 4.31': ['SpecificToAType6ShadingDictionary', 'Additional entries specific
to a type 6 shading dictionary'], | 96 'TABLE 4.31': ['Type6ShadingDictionary', 'Additional entries specific to a type
6 shading dictionary', 'ShadingDictionary'], |
91 'TABLE 4.35': ['SpecificToAnImageDictionary', 'Additional entries specific to an
image dictionary'], | 97 'TABLE 4.35': ['ImageDictionary', 'Additional entries specific to an image dicti
onary', 'XObjectDictionary', {'Subtype': 'datatypes.PdfName(\'Image\')'}], |
92 'TABLE 4.37': ['AlternateImageDictionary', 'Entries in an alternate image dictio
nary'], | 98 'TABLE 4.37': ['AlternateImageDictionary', 'Entries in an alternate image dictio
nary'], |
93 'TABLE 4.41': ['SpecificToAType1FormDictionary', 'Additional entries specific to
a type 1 form dictionary'], | 99 'TABLE 4.41': ['Type1FormDictionary', 'Additional entries specific to a type 1 f
orm dictionary', 'XObjectDictionary', {'Subtype': 'datatypes.PdfName(\'Form\')'}
], |
94 'TABLE 4.42': ['GroupAttributesDictionariesCommon', 'Entries common to all group
attributes dictionaries'], | 100 'TABLE 4.42': ['GroupAttributesDictionary', 'Entries common to all group attribu
tes dictionaries'], |
95 'TABLE 4.43': ['ReferenceDictionary', 'Entries in a reference dictionary'], | 101 'TABLE 4.43': ['ReferenceDictionary', 'Entries in a reference dictionary'], |
96 'TABLE 4.44': ['SpecificToAPostscriptXobjectDictionary', 'Additional entries spe
cific to a PostScript XObject dictionary'], | 102 'TABLE 4.44': ['PSXobjectDictionary', 'Additional entries specific to a PostScri
pt XObject dictionary'], |
97 'TABLE 5.8': ['Type1FontDictionary', 'Entries in a Type 1 font dictionary'], | 103 'TABLE 5.8': ['Type1FontDictionary', 'Entries in a Type 1 font dictionary', 'Fon
tDictionary'], |
98 'TABLE 5.9': ['Type3FontDictionary', 'Entries in a Type 3 font dictionary'], | 104 'TABLE 5.9': ['Type3FontDictionary', 'Entries in a Type 3 font dictionary', 'Fon
tDictionary'], |
99 'TABLE 5.11': ['EncodingDictionary', 'Entries in an encoding dictionary'], | 105 'TABLE 5.11': ['EncodingDictionary', 'Entries in an encoding dictionary'], |
100 'TABLE 5.12': ['CidsysteminfoDictionary', 'Entries in a CIDSystemInfo dictionary
'], | 106 'TABLE 5.12': ['CIDSystemInfoDictionary', 'Entries in a CIDSystemInfo dictionary
'], |
101 'TABLE 5.13': ['CidfontDictionary', 'Entries in a CIDFont dictionary'], | 107 'TABLE 5.13': ['CIDFontDictionary', 'Entries in a CIDFont dictionary', 'FontDict
ionary'], |
102 'TABLE 5.16': ['CmapDictionary', 'Additional entries in a CMap dictionary'], | 108 'TABLE 5.16': ['CMapDictionary', 'Additional entries in a CMap dictionary'], |
103 'TABLE 5.17': ['Type0FontDictionary', 'Entries in a Type 0 font dictionary'], | 109 'TABLE 5.17': ['Type0FontDictionary', 'Entries in a Type 0 font dictionary', 'Fo
ntDictionary'], |
104 'TABLE 5.18': ['FontDescriptorsCommon', 'Entries common to all font descriptors'
], | 110 'TABLE 5.18': ['FontDescriptorDictionary', 'Entries common to all font descripto
rs'], |
105 'TABLE 5.20': ['DescriptorEntriesForCidfonts', 'Additional font descriptor entri
es for CIDFonts'], | 111 'TABLE 5.20': ['CIDFontDescriptorDictionary', 'Additional font descriptor entrie
s for CIDFonts'], |
106 'TABLE 5.23': ['EmbeddedFontStreamDictionary', 'Additional entries in an embedde
d font stream dictionary'], | 112 'TABLE 5.23': ['EmbeddedFontStreamDictionary', 'Additional entries in an embedde
d font stream dictionary'], |
107 'TABLE 6.3': ['Type1HalftoneDictionary', 'Entries in a type 1 halftone dictionar
y'], | 113 'TABLE 6.3': ['Type1HalftoneDictionary', 'Entries in a type 1 halftone dictionar
y'], |
108 'TABLE 6.4': ['SpecificToAType6HalftoneDictionary', 'Additional entries specific
to a type 6 halftone dictionary'], | 114 'TABLE 6.4': ['Type6HalftoneDictionary', 'Additional entries specific to a type
6 halftone dictionary'], |
109 'TABLE 6.5': ['SpecificToAType10HalftoneDictionary', 'Additional entries specifi
c to a type 10 halftone dictionary'], | 115 'TABLE 6.5': ['Type10HalftoneDictionary', 'Additional entries specific to a type
10 halftone dictionary'], |
110 'TABLE 6.6': ['SpecificToAType16HalftoneDictionary', 'Additional entries specifi
c to a type 16 halftone dictionary'], | 116 'TABLE 6.6': ['Type16HalftoneDictionary', 'Additional entries specific to a type
16 halftone dictionary'], |
111 'TABLE 6.7': ['Type5HalftoneDictionary', 'Entries in a type 5 halftone dictionar
y'], | 117 'TABLE 6.7': ['Type5HalftoneDictionary', 'Entries in a type 5 halftone dictionar
y'], |
112 'TABLE 7.10': ['Soft-MaskDictionary', 'Entries in a soft-mask dictionary'], | 118 'TABLE 7.10': ['SoftMaskDictionary', 'Entries in a soft-mask dictionary'], |
113 'TABLE 7.12': ['Soft-MaskImageDictionary', 'Additional entry in a soft-mask imag
e dictionary'], | 119 'TABLE 7.12': ['SoftMaskImageDictionary', 'Additional entry in a soft-mask image
dictionary'], |
114 'TABLE 7.13': ['SpecificToATransparencyGroupAttributesDictionary', 'Additional e
ntries specific to a transparency group attributes dictionary'], | 120 'TABLE 7.13': ['TransparencyGroupDictionary', 'Additional entries specific to a
transparency group attributes dictionary'], |
115 'TABLE 8.1': ['ViewerPreferencesDictionary', 'Entries in a viewer preferences di
ctionary'], | 121 'TABLE 8.1': ['ViewerPreferencesDictionary', 'Entries in a viewer preferences di
ctionary'], |
116 'TABLE 8.3': ['OutlineDictionary', 'Entries in the outline dictionary'], | 122 'TABLE 8.3': ['OutlineDictionary', 'Entries in the outline dictionary'], |
| 123 'TABLE 8.4': ['OutlineItemDictionary', 'Entries in an outline item dictionary'], |
117 'TABLE 8.6': ['PageLabelDictionary', 'Entries in a page label dictionary'], | 124 'TABLE 8.6': ['PageLabelDictionary', 'Entries in a page label dictionary'], |
118 'TABLE 8.7': ['ThreadDictionary', 'Entries in a thread dictionary'], | 125 'TABLE 8.7': ['ThreadDictionary', 'Entries in a thread dictionary'], |
| 126 'TABLE 8.8': ['BeadDictionary', 'Entries in a bead dictionary'], |
119 'TABLE 8.9': ['TransitionDictionary', 'Entries in a transition dictionary'], | 127 'TABLE 8.9': ['TransitionDictionary', 'Entries in a transition dictionary'], |
120 'TABLE 8.10': ['AnnotationDictionariesCommon', 'Entries common to all annotation
dictionaries'], | 128 'TABLE 8.10': ['AnnotationDictionary', 'Entries common to all annotation diction
aries'], |
121 'TABLE 8.12': ['BorderStyleDictionary', 'Entries in a border style dictionary'], | 129 'TABLE 8.12': ['BorderStyleDictionary', 'Entries in a border style dictionary'], |
122 'TABLE 8.13': ['AppearanceDictionary', 'Entries in an appearance dictionary'], | 130 'TABLE 8.13': ['AppearanceDictionary', 'Entries in an appearance dictionary'], |
123 'TABLE 8.15': ['SpecificToATextAnnotation', 'Additional entries specific to a te
xt annotation'], | 131 'TABLE 8.15': ['TextAnnotationDictionary', 'Additional entries specific to a tex
t annotation'], |
124 'TABLE 8.16': ['SpecificToALinkAnnotation', 'Additional entries specific to a li
nk annotation'], | 132 'TABLE 8.16': ['ALinkAnnotationDictionary', 'Additional entries specific to a li
nk annotation'], |
125 'TABLE 8.17': ['SpecificToAFreeTextAnnotation', 'Additional entries specific to
a free text annotation'], | 133 'TABLE 8.17': ['FreeTextAnnotationDictionary', 'Additional entries specific to a
free text annotation'], |
126 'TABLE 8.18': ['SpecificToALineAnnotation', 'Additional entries specific to a li
ne annotation'], | 134 'TABLE 8.18': ['LineAnnotationDictionary', 'Additional entries specific to a lin
e annotation'], |
127 'TABLE 8.20': ['SpecificToASquareOrCircleAnnotation', 'Additional entries specif
ic to a square or circle annotation'], | 135 'TABLE 8.20': ['SquareOrCircleAnnotation', 'Additional entries specific to a squ
are or circle annotation'], |
128 'TABLE 8.21': ['SpecificToMarkupAnnotations', 'Additional entries specific to ma
rkup annotations'], | 136 'TABLE 8.21': ['MarkupAnnotationsDictionary', 'Additional entries specific to ma
rkup annotations'], |
129 'TABLE 8.22': ['SpecificToARubberStampAnnotation', 'Additional entries specific
to a rubber stamp annotation'], | 137 'TABLE 8.22': ['RubberStampAnnotationDictionary', 'Additional entries specific t
o a rubber stamp annotation'], |
130 'TABLE 8.23': ['SpecificToAnInkAnnotation', 'Additional entries specific to an i
nk annotation'], | 138 'TABLE 8.23': ['InkAnnotationDictionary', 'Additional entries specific to an ink
annotation'], |
131 'TABLE 8.24': ['SpecificToAPop-UpAnnotation', 'Additional entries specific to a
pop-up annotation'], | 139 'TABLE 8.24': ['PopUpAnnotationDictionary', 'Additional entries specific to a po
p-up annotation'], |
132 'TABLE 8.26': ['SpecificToASoundAnnotation', 'Additional entries specific to a s
ound annotation'], | 140 'TABLE 8.25': ['FileAttachmentAnnotationDictionary', 'Additional entries specifi
c to a file attachment annotation'], |
133 'TABLE 8.27': ['SpecificToAMovieAnnotation', 'Additional entries specific to a m
ovie annotation'], | 141 'TABLE 8.26': ['SoundAnnotationDictionary', 'Additional entries specific to a so
und annotation'], |
134 'TABLE 8.28': ['SpecificToAWidgetAnnotation', 'Additional entries specific to a
widget annotation'], | 142 'TABLE 8.27': ['MovieAnnotationDictionary', 'Additional entries specific to a mo
vie annotation'], |
135 'TABLE 8.29': ['ActionDictionariesCommon', 'Entries common to all action diction
aries'], | 143 'TABLE 8.28': ['WidgetAnnotationDictionary', 'Additional entries specific to a w
idget annotation'], |
136 'TABLE 8.30': ['Annotation’SAdditional-ActionsDictionary', 'Entries in an annota
tion’s additional-actions dictionary'], | 144 'TABLE 8.29': ['ActionDictionary', 'Entries common to all action dictionaries'], |
137 'TABLE 8.35': ['SpecificToAGo-ToAction', 'Additional entries specific to a go-to
action'], | 145 'TABLE 8.30': ['AnnotationActionsDictionary', 'Entries in an annotation\'s addit
ional-actions dictionary'], |
138 'TABLE 8.36': ['SpecificToARemoteGo-ToAction', 'Additional entries specific to a
remote go-to action'], | 146 'TABLE 8.31': ['PageObjectActionsDictionary', 'Entries in a page object\'s addit
ional-actions dictionary'], |
139 'TABLE 8.37': ['SpecificToALaunchAction', 'Additional entries specific to a laun
ch action'], | 147 'TABLE 8.32': ['FormFieldActionsDictionary', 'Entries in a form field\'s additio
nal-actions dictionary'], |
140 'TABLE 8.39': ['SpecificToAThreadAction', 'Additional entries specific to a thre
ad action'], | 148 'TABLE 8.33': ['DocumentCatalogActionsDictionary', 'Entries in the document cata
log\'s additional-actions dictionary'], |
141 'TABLE 8.40': ['SpecificToAUriAction', 'Additional entries specific to a URI act
ion'], | 149 'TABLE 8.35': ['GoToActionDictionary', 'Additional entries specific to a go-to a
ction'], |
142 'TABLE 8.41': ['UriDictionary', 'Entry in a URI dictionary'], | 150 'TABLE 8.36': ['RemoteGoToActionDictionary', 'Additional entries specific to a r
emote go-to action'], |
143 'TABLE 8.42': ['SpecificToASoundAction', 'Additional entries specific to a sound
action'], | 151 'TABLE 8.37': ['LaunchActionDictionary', 'Additional entries specific to a launc
h action'], |
144 'TABLE 8.43': ['SpecificToAMovieAction', 'Additional entries specific to a movie
action'], | 152 'TABLE 8.38': ['WindowsLaunchActionDictionary', 'Entries in a Windows launch par
ameter dictionary'], |
145 'TABLE 8.44': ['SpecificToAHideAction', 'Additional entries specific to a hide a
ction'], | 153 'TABLE 8.39': ['ThreadActionDictionary', 'Additional entries specific to a threa
d action'], |
146 'TABLE 8.46': ['SpecificToNamedActions', 'Additional entries specific to named a
ctions'], | 154 'TABLE 8.40': ['URIActionDictionary', 'Additional entries specific to a URI acti
on'], |
| 155 'TABLE 8.41': ['URIDictionary', 'Entry in a URI dictionary'], |
| 156 'TABLE 8.42': ['SoundActionDictionary', 'Additional entries specific to a sound
action'], |
| 157 'TABLE 8.43': ['MovieActionDictionary', 'Additional entries specific to a movie
action'], |
| 158 'TABLE 8.44': ['HideActionDictionary', 'Additional entries specific to a hide ac
tion'], |
| 159 'TABLE 8.46': ['NamedActionsDictionary', 'Additional entries specific to named a
ctions'], |
147 'TABLE 8.47': ['InteractiveFormDictionary', 'Entries in the interactive form dic
tionary'], | 160 'TABLE 8.47': ['InteractiveFormDictionary', 'Entries in the interactive form dic
tionary'], |
148 'TABLE 8.49': ['FieldDictionariesCommon', 'Entries common to all field dictionar
ies'], | 161 'TABLE 8.49': ['FieldDictionary', 'Entries common to all field dictionaries'], |
149 'TABLE 8.51': ['CommonToAllFieldsContainingVariableText', 'Additional entries co
mmon to all fields containing variable text'], | 162 'TABLE 8.51': ['VariableTextFieldDictionary', 'Additional entries common to all
fields containing variable text'], |
150 'TABLE 8.52': ['AppearanceCharacteristicsDictionary', 'Entries in an appearance
characteristics dictionary'], | 163 'TABLE 8.52': ['AppearanceCharacteristicsDictionary', 'Entries in an appearance
characteristics dictionary'], |
151 'TABLE 8.54': ['SpecificToACheckboxField', 'Additional entry specific to a check
box field'], | 164 'TABLE 8.54': ['CheckboxFieldDictionary', 'Additional entry specific to a checkb
ox field'], |
152 'TABLE 8.55': ['SpecificToARadioButtonField', 'Additional entry specific to a ra
dio button field'], | 165 'TABLE 8.55': ['RadioButtonFieldDictionary', 'Additional entry specific to a rad
io button field'], |
153 'TABLE 8.57': ['SpecificToATextField', 'Additional entry specific to a text fiel
d'], | 166 'TABLE 8.57': ['TextFieldDictionary', 'Additional entry specific to a text field
'], |
154 'TABLE 8.59': ['SpecificToAChoiceField', 'Additional entries specific to a choic
e field'], | 167 'TABLE 8.59': ['ChoiceFieldDictionary', 'Additional entries specific to a choice
field'], |
155 'TABLE 8.60': ['SignatureDictionary', 'Entries in a signature dictionary'], | 168 'TABLE 8.60': ['SignatureDictionary', 'Entries in a signature dictionary'], |
156 'TABLE 8.61': ['SpecificToASubmit-FormAction', 'Additional entries specific to a
submit-form action'], | 169 'TABLE 8.61': ['SubmitFormActionDictionary', 'Additional entries specific to a s
ubmit-form action'], |
157 'TABLE 8.63': ['SpecificToAReset-FormAction', 'Additional entries specific to a
reset-form action'], | 170 'TABLE 8.63': ['ResetFormActionDictionary', 'Additional entries specific to a re
set-form action'], |
158 'TABLE 8.65': ['SpecificToAnImport-DataAction', 'Additional entries specific to
an import-data action'], | 171 'TABLE 8.65': ['ImportDataActionDictionary', 'Additional entries specific to an
import-data action'], |
159 'TABLE 8.66': ['SpecificToAJavascriptAction', 'Additional entries specific to a
JavaScript action'], | 172 'TABLE 8.66': ['JavascriptActionDictionary', 'Additional entries specific to a J
avaScript action'], |
160 'TABLE 8.67': ['FdfTrailerDictionary', 'Entry in the FDF trailer dictionary'], | 173 'TABLE 8.67': ['FDFTrailerDictionary', 'Entry in the FDF trailer dictionary'], |
161 'TABLE 8.68': ['FdfCatalogDictionary', 'Entries in the FDF catalog dictionary'], | 174 'TABLE 8.68': ['FDFCatalogDictionary', 'Entries in the FDF catalog dictionary'], |
162 'TABLE 8.70': ['EmbeddedFileStreamDictionary', 'Additional entry in an embedded
file stream dictionary for an encrypted FDF file'], | 175 'TABLE 8.69': ['FDFDictionary', 'Entries in the FDF dictionary'], |
| 176 'TABLE 8.70': ['EncryptedEmbeddedFileStreamDictionary', 'Additional entry in an
embedded file stream dictionary for an encrypted FDF file'], |
163 'TABLE 8.71': ['JavascriptDictionary', 'Entries in the JavaScript dictionary'], | 177 'TABLE 8.71': ['JavascriptDictionary', 'Entries in the JavaScript dictionary'], |
164 'TABLE 8.72': ['FdfFieldDictionary', 'Entries in an FDF field dictionary'], | 178 'TABLE 8.72': ['FDFFieldDictionary', 'Entries in an FDF field dictionary'], |
165 'TABLE 8.73': ['IconFitDictionary', 'Entries in an icon fit dictionary'], | 179 'TABLE 8.73': ['IconFitDictionary', 'Entries in an icon fit dictionary'], |
166 'TABLE 8.74': ['FdfPageDictionary', 'Entries in an FDF page dictionary'], | 180 'TABLE 8.74': ['FDFPageDictionary', 'Entries in an FDF page dictionary'], |
167 'TABLE 8.75': ['FdfTemplateDictionary', 'Entries in an FDF template dictionary']
, | 181 'TABLE 8.75': ['FDFTemplateDictionary', 'Entries in an FDF template dictionary']
, |
168 'TABLE 8.76': ['FdfNamedPageReferenceDictionary', 'Entries in an FDF named page
reference dictionary'], | 182 'TABLE 8.76': ['FDFNamedPageReferenceDictionary', 'Entries in an FDF named page
reference dictionary'], |
169 'TABLE 8.77': ['ForAnnotationDictionariesInAnFdfFile', 'Additional entry for ann
otation dictionaries in an FDF file'], | 183 'TABLE 8.77': ['FDFFileAnnotationDictionary', 'Additional entry for annotation d
ictionaries in an FDF file'], |
170 'TABLE 8.78': ['SpecificToASoundObject', 'Additional entries specific to a sound
object'], | 184 'TABLE 8.78': ['SoundObjectDictionary', 'Additional entries specific to a sound
object'], |
171 'TABLE 8.79': ['MovieDictionary', 'Entries in a movie dictionary'], | 185 'TABLE 8.79': ['MovieDictionary', 'Entries in a movie dictionary'], |
| 186 'TABLE 8.80': ['MovieActivationDictionary', 'Entries in a movie activation dicti
onary'], |
172 'TABLE 9.2': ['DocumentInformationDictionary', 'Entries in the document informat
ion dictionary'], | 187 'TABLE 9.2': ['DocumentInformationDictionary', 'Entries in the document informat
ion dictionary'], |
173 'TABLE 9.3': ['MetadataStreamDictionary', 'Additional entries in a metadata stre
am dictionary'], | 188 'TABLE 9.3': ['MetadataStreamDictionary', 'Additional entries in a metadata stre
am dictionary'], |
174 'TABLE 9.4': ['ForComponentsHavingMetadata', 'Additional entry for components ha
ving metadata'], | 189 'TABLE 9.4': ['ComponentsWithMetadataDictionary', 'Additional entry for componen
ts having metadata'], |
175 'TABLE 9.6': ['Page-PieceDictionary', 'Entries in a page-piece dictionary'], | 190 'TABLE 9.6': ['PagePieceDictionary', 'Entries in a page-piece dictionary'], |
176 'TABLE 9.7': ['ApplicationDataDictionary', 'Entries in an application data dicti
onary'], | 191 'TABLE 9.7': ['ApplicationDataDictionary', 'Entries in an application data dicti
onary'], |
177 'TABLE 9.9': ['StructureTreeRootDictionary', 'Entries in the structure tree root
'], | 192 'TABLE 9.9': ['StructureTreeRootDictionary', 'Entries in the structure tree root
'], |
178 'TABLE 9.11': ['Marked-ContentReferenceDictionary', 'Entries in a marked-content
reference dictionary'], | 193 'TABLE 9.10': ['StructureElementDictionary', 'Entries in a structure element dic
tionary'], |
| 194 'TABLE 9.11': ['MarkedContentReferenceDictionary', 'Entries in a marked-content
reference dictionary'], |
179 'TABLE 9.12': ['ObjectReferenceDictionary', 'Entries in an object reference dict
ionary'], | 195 'TABLE 9.12': ['ObjectReferenceDictionary', 'Entries in an object reference dict
ionary'], |
180 'TABLE 9.13': ['EntriesForStructureElementAccess', 'Additional dictionary entrie
s for structure element access'], | 196 'TABLE 9.13': ['StructureElementAccessDictionary', 'Additional dictionary entrie
s for structure element access'], |
181 'TABLE 9.14': ['AttributeObjectsCommon', 'Entry common to all attribute objects'
], | 197 'TABLE 9.14': ['AttributeObjectDictionary', 'Entry common to all attribute objec
ts'], |
182 'TABLE 9.15': ['MarkInformationDictionary', 'Entry in the mark information dicti
onary'], | 198 'TABLE 9.15': ['MarkInformationDictionary', 'Entry in the mark information dicti
onary'], |
183 'TABLE 9.16': ['ArtifactsDictionary', 'Property list entries for artifacts'], | 199 'TABLE 9.16': ['ArtifactsDictionary', 'Property list entries for artifacts'], |
184 'TABLE 9.27': ['StandardStructureTypesCommon', 'Standard layout attributes commo
n to all standard structure types'], | 200 'TABLE 9.27': ['StandardStructureDictionary', 'Standard layout attributes common
to all standard structure types'], |
185 'TABLE 9.28': ['LayoutAttributesSpecificToBlock-LevelStructureElements', 'Additi
onal standard layout attributes specific to block-level structure elements'], | 201 'TABLE 9.28': ['BlockLevelStructureElementsDictionary', 'Additional standard lay
out attributes specific to block-level structure elements'], |
186 'TABLE 9.29': ['LayoutAttributesSpecificToInline-LevelStructureElementsDictionar
y', 'Standard layout attributes specific to inline-level structure elements'], | 202 'TABLE 9.29': ['InlineLevelStructureElementsDictionary', 'Standard layout attrib
utes specific to inline-level structure elements'], |
187 'TABLE 9.30': ['ListAttributeDictionary', 'Standard list attribute'], | 203 'TABLE 9.30': ['ListAttributeDictionary', 'Standard list attribute'], |
188 'TABLE 9.31': ['TableAttributesDictionary', 'Standard table attributes'], | 204 'TABLE 9.31': ['TableAttributesDictionary', 'Standard table attributes'], |
189 'TABLE 9.32': ['WebCaptureInformationDictionary', 'Entries in the Web Capture in
formation dictionary'], | 205 'TABLE 9.32': ['WebCaptureInformationDictionary', 'Entries in the Web Capture in
formation dictionary'], |
190 'TABLE 9.33': ['WebCaptureContentSetsCommon', 'Entries common to all Web Capture
content sets'], | 206 'TABLE 9.33': ['WebCaptureDictionary', 'Entries common to all Web Capture conten
t sets'], |
191 'TABLE 9.35': ['SpecificToAWebCaptureImageSet', 'Additional entries specific to
a Web Capture image set'], | 207 'TABLE 9.34': ['WebCapturePageSetDictionary', 'Additional entries specific to a
Web Capture page set'], |
| 208 'TABLE 9.35': ['WebCaptureImageSetDictionary', 'Additional entries specific to a
Web Capture image set'], |
192 'TABLE 9.36': ['SourceInformationDictionary', 'Entries in a source information d
ictionary'], | 209 'TABLE 9.36': ['SourceInformationDictionary', 'Entries in a source information d
ictionary'], |
193 'TABLE 9.37': ['UrlAliasDictionary', 'Entries in a URL alias dictionary'], | 210 'TABLE 9.37': ['URLAliasDictionary', 'Entries in a URL alias dictionary'], |
194 'TABLE 9.38': ['WebCaptureCommandDictionary', 'Entries in a Web Capture command
dictionary'], | 211 'TABLE 9.38': ['WebCaptureCommandDictionary', 'Entries in a Web Capture command
dictionary'], |
195 'TABLE 9.40': ['WebCaptureCommandSettingsDictionary', 'Entries in a Web Capture
command settings dictionary'], | 212 'TABLE 9.40': ['WebCaptureCommandSettingsDictionary', 'Entries in a Web Capture
command settings dictionary'], |
196 'TABLE 9.41': ['BoxColorInformationDictionary', 'Entries in a box color informat
ion dictionary'], | 213 'TABLE 9.41': ['BoxColorInformationDictionary', 'Entries in a box color informat
ion dictionary'], |
197 'TABLE 9.43': ['SpecificToAPrinter’SMarkAnnotation', 'Additional entries specifi
c to a printer’s mark annotation'], | 214 'TABLE 9.42': ['BoxStyleDictionary', 'Entries in a box style dictionary'], |
198 'TABLE 9.44': ['SpecificToAPrinter’SMarkFormDictionary', 'Additional entries spe
cific to a printer’s mark form dictionary'], | 215 'TABLE 9.43': ['PrinterMarkAnnotationDictionary', 'Additional entries specific t
o a printer\'s mark annotation'], |
| 216 'TABLE 9.44': ['PrinterMarkFormDictionary', 'Additional entries specific to a pr
inter\'s mark form dictionary'], |
199 'TABLE 9.45': ['SeparationDictionary', 'Entries in a separation dictionary'], | 217 'TABLE 9.45': ['SeparationDictionary', 'Entries in a separation dictionary'], |
200 'TABLE 9.46': ['Pdf/XOutputIntentDictionary', 'Entries in a PDF/X output intent
dictionary'], | 218 'TABLE 9.46': ['PDF_XOutputIntentDictionary', 'Entries in a PDF/X output intent
dictionary'], |
201 'TABLE 9.47': ['SpecificToATrapNetworkAnnotation', 'Additional entries specific
to a trap network annotation'], | 219 'TABLE 9.47': ['TrapNetworkAnnotationDictionary', 'Additional entries specific t
o a trap network annotation'], |
202 'TABLE 9.48': ['SpecificToATrapNetworkAppearanceStream', 'Additional entries spe
cific to a trap network appearance stream'], | 220 'TABLE 9.48': ['TrapNetworkAppearanceStreamDictionary', 'Additional entries spec
ific to a trap network appearance stream'], |
203 'TABLE 9.49': ['OpiVersionDictionary', 'Entry in an OPI version dictionary'], | 221 'TABLE 9.49': ['OpiVersionDictionary', 'Entry in an OPI version dictionary'], |
204 } | 222 } |
205 | 223 |
206 | 224 |
207 def acceptType(val): | 225 def acceptType(val): |
208 global knownTypes | 226 global knownTypes |
209 | 227 |
210 ret = val | 228 ret = val |
211 | 229 |
212 for item in knownTypes: | 230 for item in knownTypes: |
(...skipping 10 matching lines...) Expand all Loading... |
223 global table | 241 global table |
224 table = desc.strip() | 242 table = desc.strip() |
225 | 243 |
226 def tableHasHeader(): | 244 def tableHasHeader(): |
227 global table | 245 global table |
228 global tableHeaderFound | 246 global tableHeaderFound |
229 | 247 |
230 tableHeaderFound = True | 248 tableHeaderFound = True |
231 #print table | 249 #print table |
232 | 250 |
| 251 def fix(val): |
| 252 ret = val |
| 253 |
| 254 # fix unicode chars |
| 255 ret = ret.replace(unicode('fi', 'utf8'), 'fi') |
| 256 ret = ret.replace(u'\u201c', '\"') |
| 257 ret = ret.replace(u'\u201d', '\"') |
| 258 ret = ret.replace(u'\u2019', '\'') |
| 259 ret = ret.replace(u'\ufb02', 'fl') |
| 260 ret = ret.replace(u'\xae', '(R)') |
| 261 ret = ret.replace(u'\u2026', '...') |
| 262 ret = ret.replace(u'\xd7', 'x') |
| 263 ret = ret.replace(u'\u2212', '-') |
| 264 ret = ret.replace(u'\u2264', '<=') |
| 265 ret = ret.replace(u'\u2014', '-') |
| 266 ret = ret.replace(u'\u2013', '\'') |
| 267 ret = ret.replace(u'\u2022', '*') |
| 268 ret = ret.replace(u'\xb5', 'mu') |
| 269 ret = ret.replace(u'\xf7', '/') |
| 270 |
| 271 |
| 272 # how enable to emit this a python string |
| 273 ret = ret.replace('\'', '\\\'') |
| 274 ret = ret.replace('\n', '\\n') |
| 275 |
| 276 |
| 277 return ret |
233 | 278 |
234 def commitRow(): | 279 def commitRow(): |
235 global columnValues | 280 global columnValues |
236 global emitedDitionaryName | 281 global emitedDitionaryName |
237 global table | 282 global table |
238 global tableToClassName | 283 global tableToClassName |
239 | 284 |
240 if columnValues == None: | 285 if columnValues == None: |
241 return | 286 return |
242 | 287 |
(...skipping 25 matching lines...) Expand all Loading... |
268 elif s != 'Required': | 313 elif s != 'Required': |
269 required = False | 314 required = False |
270 | 315 |
271 #print spec | 316 #print spec |
272 #print specs | 317 #print specs |
273 #print required | 318 #print required |
274 #print inheritable | 319 #print inheritable |
275 #print version | 320 #print version |
276 #print columnValues | 321 #print columnValues |
277 | 322 |
278 columnValues = [columnValues[0].replace(unicode('fi', 'utf8'), 'fi'), columnVal
ues[1].replace(unicode('fi', 'utf8'), 'fi'), columnValues[2].replace(unicode('fi',
'utf8'), 'fi')] | 323 columnValues = [fix(columnValues[0]), fix(columnValues[1]), fix(columnValues[2
])] |
279 | 324 |
| 325 tableKey = re.search('(TABLE [0-9].[0-9][0-9]?)', table).group(1) |
| 326 |
280 if emitedDitionaryName == '': | 327 if emitedDitionaryName == '': |
281 table = table.replace(unicode('fi', 'utf8'), 'fi') | 328 table = fix(table) |
282 | |
283 | 329 |
284 #print table | 330 #print table |
285 emitedDitionaryName = 'foo' | 331 emitedDitionaryName = 'foo' |
286 e = re.search('[Entries|Entry] in [a-z]* (.* dictionary)', table) | 332 e = re.search('[Entries|Entry] in [a-z]* (.* dictionary)', table) |
287 a = re.search('Additional [a-z]* in a[n]? (.* dictionary)', table) | 333 a = re.search('Additional [a-z]* in a[n]? (.* dictionary)', table) |
288 s = re.search('Additional [a-z]* (.*)', table) | 334 s = re.search('Additional [a-z]* (.*)', table) |
289 c = re.search('[Entries|Entry] common to all (.*)', table) | 335 c = re.search('[Entries|Entry] common to all (.*)', table) |
290 o1 = re.search('Optional parameter[s]? for the (.*)', table) | 336 o1 = re.search('Optional parameter[s]? for the (.*)', table) |
291 o2 = re.search('Optional parameter[s]? for (.*)', table) | 337 o2 = re.search('Optional parameter[s]? for (.*)', table) |
292 t = re.search('.*ntries in [a-z]* (.*)', table) | 338 t = re.search('.*ntries in [a-z]* (.*)', table) |
(...skipping 24 matching lines...) Expand all Loading... |
317 #print emitedDitionaryName | 363 #print emitedDitionaryName |
318 elif r: | 364 elif r: |
319 emitedDitionaryName = r.group(1).title().replace(' ', '') + 'Dictionary' | 365 emitedDitionaryName = r.group(1).title().replace(' ', '') + 'Dictionary' |
320 #print emitedDitionaryName | 366 #print emitedDitionaryName |
321 elif st: | 367 elif st: |
322 emitedDitionaryName = st.group(1).title().replace(' ', '') + 'Dictionary' | 368 emitedDitionaryName = st.group(1).title().replace(' ', '') + 'Dictionary' |
323 #print emitedDitionaryName | 369 #print emitedDitionaryName |
324 #else: | 370 #else: |
325 #print table | 371 #print table |
326 | 372 |
327 tableKey = re.search('(TABLE [0-9].[0-9][0-9]?)', table).group(1) | |
328 #print tableKey | 373 #print tableKey |
329 #print('\'' + tableKey + '\': [\'' + emitedDitionaryName + '\', \'' + table[
len(tableKey) + 1:] + '\'],') | 374 #print('\'' + tableKey + '\': [\'' + emitedDitionaryName + '\', \'' + table[
len(tableKey) + 1:] + '\'],') |
330 | 375 |
331 emitedDitionaryName = tableToClassName[tableKey][0] | 376 emitedDitionaryName = tableToClassName[tableKey][0] |
332 comment = tableToClassName[tableKey][1] | 377 comment = fix(tableToClassName[tableKey][1]) |
333 | 378 |
334 print(' all.addClass(\'' + emitedDitionaryName + '\', \'Dictionary\', \'' +
comment + '\')\\') | 379 if len(tableToClassName[tableKey]) >= 3 and tableToClassName[tableKey][2] !=
'': |
| 380 print(' pdfspec.addClass(\'' + emitedDitionaryName + '\', \'' + tableToCl
assName[tableKey][2] + '\', \'' + comment + '\')\\') |
| 381 else: |
| 382 print(' pdfspec.addClass(\'' + emitedDitionaryName + '\', \'Dictionary\',
\'' + comment + '\')\\') |
| 383 |
| 384 if len(tableToClassName[tableKey]) >= 4 and columnValues[0] in tableToClassNam
e[tableKey][3]: |
| 385 required = True |
335 | 386 |
336 if required: | 387 if required: |
337 print(' .required(\'NULL\')\\') | 388 print(' .required(\'NULL\')\\') |
338 else: | 389 else: |
339 print(' .optional()\\') | 390 print(' .optional()\\') |
340 | 391 |
341 print(' .field(\'' + columnValues[0] + '\')\\') | 392 print(' .field(\'' + columnValues[0] + '\')\\') |
342 print(' .name(\'' + columnValues[0] + '\')\\') | 393 print(' .name(\'' + columnValues[0] + '\')\\') |
343 print(' .type(\'' + columnValues[1] + '\')\\') | 394 print(' .type(\'' + columnValues[1] + '\')\\') |
344 print(' .comment(\'' + columnValues[2] + '\')\\') | 395 print(' .comment(\'' + columnValues[2] + '\')\\') |
| 396 |
| 397 if len(tableToClassName[tableKey]) >= 4 and columnValues[0] in tableToClassNam
e[tableKey][3]: |
| 398 print(' .must(' + tableToClassName[tableKey][3][columnValues[0]] +
')\\') |
| 399 |
345 print(' .done().done()\\') | 400 print(' .done().done()\\') |
346 | 401 |
347 | 402 |
348 columnValues = None | 403 columnValues = None |
349 | 404 |
350 def newRow(first, second, third): | 405 def newRow(first, second, third): |
351 global columnValues | 406 global columnValues |
352 columnValues = [first.rstrip(), second.rstrip(), third.rstrip()] | 407 columnValues = [first.rstrip(), second.rstrip(), third.rstrip()] |
353 | 408 |
354 def appendRow(second, third): | 409 def appendRow(second, third): |
355 global columnValues | 410 global columnValues |
356 if second.rstrip() != '': | 411 if second.rstrip() != '': |
357 columnValues[1] = columnValues[1] + ' ' + second.rstrip() | 412 columnValues[1] = columnValues[1] + ' ' + second.rstrip() |
358 if third.rstrip() != '': | 413 if third.rstrip() != '': |
359 columnValues[2] = columnValues[2] + ' ' + third.rstrip() | 414 columnValues[2] = columnValues[2] + '\n' + third.rstrip() |
360 | 415 |
361 def rebaseTable(line): | 416 def rebaseTable(line): |
362 global knownTypes | 417 global knownTypes |
363 global columnWidth | 418 global columnWidth |
364 | 419 |
365 words = line.split() | 420 words = line.split() |
366 | 421 |
367 if len(words) < 3: | 422 if len(words) < 3: |
368 return False | 423 return False |
369 | 424 |
(...skipping 11 matching lines...) Expand all Loading... |
381 if words[i].startswith('(Required'): | 436 if words[i].startswith('(Required'): |
382 columnWidth[1] = line.find('(Required') - columnWidth[0] | 437 columnWidth[1] = line.find('(Required') - columnWidth[0] |
383 return True | 438 return True |
384 | 439 |
385 return False | 440 return False |
386 | 441 |
387 | 442 |
388 def stopTable(): | 443 def stopTable(): |
389 global tableHeaderFound | 444 global tableHeaderFound |
390 global emitedDitionaryName | 445 global emitedDitionaryName |
| 446 |
| 447 if not inTable(): |
| 448 return |
| 449 |
391 commitRow() | 450 commitRow() |
392 tableHeaderFound = False | 451 tableHeaderFound = False |
393 emitedDitionaryName = '' | 452 emitedDitionaryName = '' |
394 print(' .done()') | 453 print(' .done()') |
395 print | 454 print |
396 | 455 |
397 | 456 |
398 def killTable(): | 457 def killTable(): |
399 return | 458 return |
400 | 459 |
401 def processLine(line): | 460 def processLine(line): |
402 global lines | 461 global lines |
403 global tableLine | 462 global tableLine |
404 global tableRow | 463 global tableRow |
405 global columnWidth | 464 global columnWidth |
406 global columnValues | 465 global columnValues |
407 global mustFollowTableHeader | 466 global mustFollowTableHeader |
408 | 467 |
409 lines = lines + 1 | 468 lines = lines + 1 |
410 | 469 |
411 line = unicode(line, 'utf8') | 470 line = unicode(line, 'utf8') |
412 | 471 |
413 striped = line.rstrip() | 472 striped = line.rstrip() |
414 | 473 |
415 words = line.split() | 474 words = line.split() |
416 if len(words) == 0: | 475 if len(words) == 0: |
| 476 stopTable() |
417 return | 477 return |
418 | 478 |
419 if words[0] == 'TABLE': | 479 isTableHeader = re.search('^[\s]*(TABLE [0-9].[0-9][0-9]?)', striped) |
| 480 if isTableHeader: |
| 481 stopTable() |
420 tableDescriptionFound(striped) | 482 tableDescriptionFound(striped) |
421 mustFollowTableHeader = True | 483 mustFollowTableHeader = True |
422 return | 484 return |
423 | 485 |
424 if mustFollowTableHeader: | 486 if mustFollowTableHeader: |
425 mustFollowTableHeader = False | 487 mustFollowTableHeader = False |
426 if len(words) != 3: | 488 if len(words) != 3: |
427 killTable() | 489 killTable() |
428 | 490 |
429 # TODO(edisonn): support for generic table! | 491 # TODO(edisonn): support for generic table! |
430 if words[0] != 'KEY' or words[1] != 'TYPE' or words[2] != 'VALUE': | 492 if words[0] != 'KEY' or words[1] != 'TYPE' or words[2] != 'VALUE': |
431 killTable() | 493 killTable() |
432 return | 494 return |
433 | 495 |
434 tableHasHeader() | 496 tableHasHeader() |
435 columnWidth = [0, 0, 0] | 497 columnWidth = [0, 0, 0] |
436 columnWidth[0] = striped.index('TYPE') | 498 columnWidth[0] = striped.index('TYPE') |
437 columnWidth[1] = striped.index('VALUE') - striped.index('TYPE') | 499 columnWidth[1] = striped.index('VALUE') - striped.index('TYPE') |
438 columnWidth[2] = 0 | 500 columnWidth[2] = 0 |
439 return | 501 return |
440 | 502 |
441 if inTable(): | 503 if inTable(): |
442 tableLine = tableLine + 1 | 504 tableLine = tableLine + 1 |
443 first = striped[0 : columnWidth[0]] | 505 first = striped[0 : columnWidth[0]] |
444 second = striped[columnWidth[0] : columnWidth[0] + columnWidth[1]] | 506 second = striped[columnWidth[0] : columnWidth[0] + columnWidth[1]] |
445 third = striped[columnWidth[0] + columnWidth[1] :] | 507 third = striped[columnWidth[0] + columnWidth[1] :] |
446 | 508 |
| 509 |
| 510 |
| 511 |
447 if tableLine == 1: | 512 if tableLine == 1: |
448 if third[0] != '(': | 513 if third[0] != '(': |
449 killTable() | 514 killTable() |
450 return | 515 return |
451 | 516 |
452 newRow(first, second, third) | 517 newRow(first, second, third) |
453 return | 518 return |
454 | 519 |
455 if rebaseTable(striped): | 520 if rebaseTable(striped): |
456 first = striped[0 : columnWidth[0]] | 521 first = striped[0 : columnWidth[0]] |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 return | 558 return |
494 | 559 |
495 if first != '' and second != '' and third[0] == '(': | 560 if first != '' and second != '' and third[0] == '(': |
496 commitRow() | 561 commitRow() |
497 newRow(first, second, third) | 562 newRow(first, second, third) |
498 return | 563 return |
499 | 564 |
500 | 565 |
501 def generateDef(): | 566 def generateDef(): |
502 global lines | 567 global lines |
| 568 |
| 569 print 'import datatypes' |
| 570 print |
| 571 |
| 572 print 'def buildPdfSpec(pdfspec):' |
| 573 |
503 for line in sys.stdin: | 574 for line in sys.stdin: |
504 processLine(line) | 575 processLine(line) |
| 576 |
| 577 # close last table if it was not closed already |
| 578 stopTable() |
| 579 |
| 580 print |
| 581 |
505 #print lines | 582 #print lines |
506 | 583 |
507 if '__main__' == __name__: | 584 if '__main__' == __name__: |
508 sys.exit(generateDef()) | 585 sys.exit(generateDef()) |
OLD | NEW |