本文整理汇总了Python中Windows.detect_registry_key方法的典型用法代码示例。如果您正苦于以下问题:Python Windows.detect_registry_key方法的具体用法?Python Windows.detect_registry_key怎么用?Python Windows.detect_registry_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows
的用法示例。
在下文中一共展示了Windows.detect_registry_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_section
# 需要导入模块: import Windows [as 别名]
# 或者: from Windows import detect_registry_key [as 别名]
def handle_section(self, section):
"""Parse a section"""
def detect_file(rawpath):
pathname = os.path.expandvars(preexpand(rawpath))
return os.path.exists(pathname)
# if simple detection fails then discard the section
if self.parser.has_option(section, 'detect'):
key = self.parser.get(section, 'detect')
if not Windows.detect_registry_key(key):
return
if self.parser.has_option(section, 'detectfile'):
if not detect_file(self.parser.get(section, 'detectfile')):
return
if self.parser.has_option(section, 'detectos'):
required_ver = self.parser.get(section, 'detectos')
if not detectos(required_ver):
return
# in case of multiple detection, discard if none match
if self.parser.has_option(section, 'detectfile1'):
matches = 0
for n in range(1, MAX_DETECT):
option_id = 'detectfile%d' % n
if self.parser.has_option(section, option_id):
if detect_file(self.parser.get(section, option_id)):
matches = matches + 1
if 0 == matches:
return
if self.parser.has_option(section, 'detect1'):
matches = 0
for n in range(1, MAX_DETECT):
option_id = 'detect%d' % n
if self.parser.has_option(section, option_id):
if Windows.detect_registry_key(self.parser.get(section, option_id)):
matches = matches + 1
if 0 == matches:
return
# not yet implemented
if self.parser.has_option(section, 'excludekey'):
print 'ERROR: ExcludeKey not implemented, section=', section
return
# there are two ways to specify sections: langsecref= and section=
if self.parser.has_option(section, 'langsecref'):
# verify the langsecref number is known
# langsecref_num is 3021, games, etc.
langsecref_num = self.parser.get(section, 'langsecref')
elif self.parser.has_option(section, 'section'):
langsecref_num = self.parser.get(section, 'section')
else:
print 'ERROR: neither option LangSecRef nor Section found in section %s' % (section)
return
# find the BleachBit internal cleaner ID
lid = self.section_to_cleanerid(langsecref_num)
self.cleaners[lid].add_option(
section2option(section), section.replace('*', ''), '')
for option in self.parser.options(section):
if option.startswith('filekey'):
self.handle_filekey(lid, section, option)
elif option.startswith('regkey'):
self.handle_regkey(lid, section, option)
elif option == 'warning':
self.cleaners[lid].set_warning(
section2option(section), self.parser.get(section, 'warning'))
elif option in ('default', 'detectfile', 'detect', 'langsecref', 'section') \
or ['detect%d' % x for x in range(1, MAX_DETECT)] \
or ['detectfile%d' % x for x in range(1, MAX_DETECT)]:
pass
else:
print 'WARNING: unknown option %s in section %s' % (option, section)
return