當前位置: 首頁>>代碼示例>>Python>>正文


Python Windows.detect_registry_key方法代碼示例

本文整理匯總了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
開發者ID:jun-zhang,項目名稱:bleachbit,代碼行數:71,代碼來源:Winapp.py


注:本文中的Windows.detect_registry_key方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。