path. GLModule can get all information about module, get its dependencies,
files, etc.'''
+ section_label_regex = '(?:Description:|Comment:|Status:|Notice:|Applicability:|\
+Files:|Depends-on:|configure\\.ac-early:|configure\\.ac:|Makefile\\.am:|\
+Include:|Link:|License:|Maintainer:)'
+
+ section_label_pattern = \
+ re.compile('^(Description|Comment|Status|Notice|Applicability|'
+ + 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
+ + 'Makefile\\.am|Include|Link|License|Maintainer):$')
+
def __init__(self, config, module, patched=False):
'''GLModule.__init__(config, module[, patched]) -> GLModule
self.modulesystem = GLModuleSystem(self.config)
with codecs.open(module, 'rb', 'UTF-8') as file:
self.content = file.read()
- self.regex = '(?:Description:|Comment:|Status:|Notice:|Applicability:|\
-Files:|Depends-on:|configure\\.ac-early:|configure\\.ac:|Makefile\\.am:|\
-Include:|Link:|License:|Maintainer:)'
def __eq__(self, module):
'''x.__eq__(y) <==> x==y'''
if section not in self.content:
result = ''
else: # if section in self.content
- pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
+ pattern = '^%s[\t ]*(.*?)%s' % (section, GLModule.section_label_regex)
pattern = re.compile(pattern, re.S | re.M)
result = pattern.findall(self.content)
if type(result) is list:
if section not in self.content:
result = ''
else: # if section in self.content
- pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
+ pattern = '^%s[\t ]*(.*?)%s' % (section, GLModule.section_label_regex)
pattern = re.compile(pattern, re.S | re.M)
result = pattern.findall(self.content)
if type(result) is list:
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
lines = [ '%s\n' % line
for line in snippet.split('\n') ]
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]
if section not in self.content:
result = ''
else: # if section in self.content
- pattern = '^%s[\t ]*(.*?)%s' % (section, self.regex)
+ pattern = '^%s[\t ]*(.*?)%s' % (section, GLModule.section_label_regex)
pattern = re.compile(pattern, re.S | re.M)
result = pattern.findall(self.content)
if type(result) is list:
for line in snippet.split('\n') ]
parts = list()
for line in lines:
- regex = '^(Description|Comment|Status|Notice|Applicability|'
- regex += 'Files|Depends-on|configure\\.ac-early|configure\\.ac|'
- regex += 'Makefile\\.am|Include|Link|License|Maintainer):$'
- pattern = re.compile(regex)
- findflag = pattern.findall(line)
+ findflag = GLModule.section_label_pattern.findall(line)
if findflag:
break
parts += [line]