header.py

changeset 52
cd2b4f3c1189
parent 49
a1f5c12fa45c
child 54
0c686d10eb49
equal deleted inserted replaced
51:913ec927c95d 52:cd2b4f3c1189
87 self.cursor = -1 87 self.cursor = -1
88 self.model_body = model_body 88 self.model_body = model_body
89 self.skip_to_next() 89 self.skip_to_next()
90 result.description = self.current() 90 result.description = self.current()
91 self.skip_to_next() 91 self.skip_to_next()
92 result.name = self.parse_pattern('^Name: (.+)$', 'name')[0] 92 result.name = self.parse_pattern(r'^Name: (.+)$', 'name')[0]
93 self.skip_to_next() 93 self.skip_to_next()
94 result.author, result.username = self.parse_pattern(r'^Author: ([^\[]+)\s*(?:\[(.+)\])?$', 'author') 94 result.author, result.username = self.parse_pattern(r'^Author: ((?:\s*\w+)+) (?:\[([^\]]+)\])?', 'author')
95 for header_entry in self.get_more_header_stuff(): 95 for header_entry in self.get_more_header_stuff():
96 if self.try_to_match( 96 if self.try_to_match(
97 '^!LDRAW_ORG ' + 97 r'^!LDRAW_ORG ' \
98 r'((?:Unofficial_)?(?:' \ 98 r'((?:Unofficial_)?(?:' \
99 'Part|' \ 99 r'Part|' \
100 'Subpart|' \ 100 r'Subpart|' \
101 'Primitive|' \ 101 r'Primitive|' \
102 '8_Primitive|' \ 102 r'8_Primitive|' \
103 '48_Primitive|' \ 103 r'48_Primitive|' \
104 'Shortcut' \ 104 r'Shortcut' \
105 '))\s?' \ 105 r'))\s?' \
106 '(.*)$', 106 r'(.*)$',
107 'part type'): 107 'part type'):
108 result.filetype = self.groups[0] 108 result.filetype = self.groups[0]
109 result.qualifiers = re.findall(r'(?:Physical_Colour|Alias|ORIGINAL|UPDATE \d\d\d\d-\d\d)', self.groups[1]) 109 result.qualifiers = re.findall(r'(?:Physical_Colour|Alias|ORIGINAL|UPDATE \d\d\d\d-\d\d)', self.groups[1])
110 elif self.try_to_match( 110 elif self.try_to_match(
111 '^!LICENSE (.+)$', 111 r'^!LICENSE (.+)$',
112 'license'): 112 'license'):
113 result.license = self.groups[0] 113 result.license = self.groups[0]
114 elif self.try_to_match( 114 elif self.try_to_match(
115 'BFC (CERTIFY CW|CERTIFY CCW|NOCERTIFY)', 115 r'BFC (CERTIFY CW|CERTIFY CCW|NOCERTIFY)',
116 'bfc'): 116 'bfc'):
117 result.bfc = self.groups[0] 117 result.bfc = self.groups[0]
118 elif self.try_to_match( 118 elif self.try_to_match(
119 r'!HISTORY (\d{4}-\d{2}-\d{2}) ([\[{][^\]}]+[\]}]) (.+)$', 119 r'!HISTORY (\d{4}-\d{2}-\d{2}) ([\[{][^\]}]+[\]}]) (.+)$',
120 'history'): 120 'history'):

mercurial