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


Python winreg.error方法代碼示例

本文整理匯總了Python中winreg.error方法的典型用法代碼示例。如果您正苦於以下問題:Python winreg.error方法的具體用法?Python winreg.error怎麽用?Python winreg.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在winreg的用法示例。


在下文中一共展示了winreg.error方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __call__

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def __call__(self, env, source, ext=None):
        if ext is None:
            try:
                ext = source[0].get_suffix()
            except IndexError:
                ext = ""
        try:
            return self[ext]
        except KeyError:
            # Try to perform Environment substitution on the keys of
            # the dictionary before giving up.
            s_dict = {}
            for (k,v) in self.items():
                if k is not None:
                    s_k = env.subst(k)
                    if s_k in s_dict:
                        # We only raise an error when variables point
                        # to the same suffix.  If one suffix is literal
                        # and a variable suffix contains this literal,
                        # the literal wins and we don't raise an error.
                        raise KeyError(s_dict[s_k][0], k, s_k)
                    s_dict[s_k] = (k,v)
            try:
                return s_dict[ext][1]
            except KeyError:
                try:
                    return self[None]
                except KeyError:
                    return None 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:31,代碼來源:Util.py

示例2: test_struct_uint_bad_value_cp20039

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def test_struct_uint_bad_value_cp20039(self):
        class x(object):
            def __init__(self, value):
                self.value = value
            def __and__(self, other):
                global andCalled
                andCalled = True
                return self.value
            def __int__(self):
                raise Exception('foo')

        import _struct
        global andCalled
        andCalled = False

        self.assertRaisesRegex(_struct.error, "integer out of range for 'L' format code" if is_cli else "argument out of range",
                            _struct.Struct('L').pack, 4294967296)
        self.assertRaisesRegex(_struct.error, "integer out of range for 'L' format code" if is_cli else "argument out of range",
                            _struct.Struct('L').pack, -1)
        self.assertRaisesRegex(Exception, "foo" if is_cli else "required argument is not an integer", _struct.Struct('L').pack, x(0))
        self.assertRaisesRegex(Exception, "foo" if is_cli else "required argument is not an integer", _struct.Struct('L').pack, x(-1))

        self.assertRaisesRegex(_struct.error, "integer out of range for 'I' format code" if is_cli else "argument out of range",
                            _struct.Struct('I').pack, 4294967296)
        self.assertRaisesRegex(_struct.error, "integer out of range for 'I' format code" if is_cli else "argument out of range",
                            _struct.Struct('I').pack, -1)
        self.assertRaisesRegex(Exception, "foo" if is_cli else "required argument is not an integer", _struct.Struct('I').pack, x(0))
        self.assertRaisesRegex(Exception, "foo" if is_cli else "required argument is not an integer", _struct.Struct('I').pack, x(-1))

        # __and__ was called in Python2.6 check that this is no longer True
        self.assertTrue(not andCalled) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:33,代碼來源:test_regressions.py

示例3: test_winreg_error_cp17050

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def test_winreg_error_cp17050(self):
        import winreg
        self.assertEqual(winreg.error, WindowsError) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:5,代碼來源:test_regressions.py

示例4: __call__

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def __call__(self, env, source, ext=None):
        if ext is None:
            try:
                ext = source[0].suffix
            except IndexError:
                ext = ""
        try:
            return self[ext]
        except KeyError:
            # Try to perform Environment substitution on the keys of
            # the dictionary before giving up.
            s_dict = {}
            for (k,v) in self.items():
                if k is not None:
                    s_k = env.subst(k)
                    if s_k in s_dict:
                        # We only raise an error when variables point
                        # to the same suffix.  If one suffix is literal
                        # and a variable suffix contains this literal,
                        # the literal wins and we don't raise an error.
                        raise KeyError(s_dict[s_k][0], k, s_k)
                    s_dict[s_k] = (k,v)
            try:
                return s_dict[ext][1]
            except KeyError:
                try:
                    return self[None]
                except KeyError:
                    return None 
開發者ID:Autodesk,項目名稱:sitoa,代碼行數:31,代碼來源:Util.py

示例5: __init__

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def __init__(self):
        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as winreg

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
                              r"\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while True:
                try:
                    proc=winreg.EnumKey(chnd, pnum)
                except winreg.error:
                    break
                else:
                    pnum+=1
                    info.append({"Processor":proc})
                    phnd=winreg.OpenKey(chnd, proc)
                    pidx=0
                    while True:
                        try:
                            name, value, vtpe=winreg.EnumValue(phnd, pidx)
                        except winreg.error:
                            break
                        else:
                            pidx=pidx+1
                            info[-1][name]=value
                            if name=="Identifier":
                                srch=prgx.search(value)
                                if srch:
                                    info[-1]["Family"]=int(srch.group("FML"))
                                    info[-1]["Model"]=int(srch.group("MDL"))
                                    info[-1]["Stepping"]=int(srch.group("STP"))
        except Exception:
            print(sys.exc_info()[1], '(ignoring)')
        self.__class__.info = info 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:44,代碼來源:cpuinfo.py

示例6: __init__

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def __init__(self):
        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as winreg

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
                              r"\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while True:
                try:
                    proc=winreg.EnumKey(chnd, pnum)
                except winreg.error:
                    break
                else:
                    pnum+=1
                    info.append({"Processor":proc})
                    phnd=winreg.OpenKey(chnd, proc)
                    pidx=0
                    while True:
                        try:
                            name, value, vtpe=winreg.EnumValue(phnd, pidx)
                        except winreg.error:
                            break
                        else:
                            pidx=pidx+1
                            info[-1][name]=value
                            if name=="Identifier":
                                srch=prgx.search(value)
                                if srch:
                                    info[-1]["Family"]=int(srch.group("FML"))
                                    info[-1]["Model"]=int(srch.group("MDL"))
                                    info[-1]["Stepping"]=int(srch.group("STP"))
        except:
            print(sys.exc_info()[1], '(ignoring)')
        self.__class__.info = info 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:44,代碼來源:cpuinfo.py

示例7: __init__

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def __init__(self):
        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as winreg

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"\
                              "\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while True:
                try:
                    proc=winreg.EnumKey(chnd, pnum)
                except winreg.error:
                    break
                else:
                    pnum+=1
                    info.append({"Processor":proc})
                    phnd=winreg.OpenKey(chnd, proc)
                    pidx=0
                    while True:
                        try:
                            name, value, vtpe=winreg.EnumValue(phnd, pidx)
                        except winreg.error:
                            break
                        else:
                            pidx=pidx+1
                            info[-1][name]=value
                            if name=="Identifier":
                                srch=prgx.search(value)
                                if srch:
                                    info[-1]["Family"]=int(srch.group("FML"))
                                    info[-1]["Model"]=int(srch.group("MDL"))
                                    info[-1]["Stepping"]=int(srch.group("STP"))
        except:
            print(sys.exc_info()[1], '(ignoring)')
        self.__class__.info = info 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:44,代碼來源:cpuinfo.py

示例8: __init__

# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import error [as 別名]
def __init__(self):
        try:
            import _winreg
        except ImportError:  # Python 3
            import winreg as _winreg

        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
                              "\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum = 0
            while 1:
                try:
                    proc = _winreg.EnumKey(chnd, pnum)
                except _winreg.error:
                    break
                else:
                    pnum += 1
                    info.append({"Processor": proc})
                    phnd = _winreg.OpenKey(chnd, proc)
                    pidx = 0
                    while True:
                        try:
                            name, value, vtpe = _winreg.EnumValue(phnd, pidx)
                        except _winreg.error:
                            break
                        else:
                            pidx = pidx + 1
                            info[-1][name] = value
                            if name == "Identifier":
                                srch = prgx.search(value)
                                if srch:
                                    info[-1]["Family"] = int(srch.group("FML"))
                                    info[-1]["Model"] = int(srch.group("MDL"))
                                    info[-1]["Stepping"] = int(srch.group("STP"))
        except:
            print(sys.exc_value, '(ignoring)')
        self.__class__.info = info 
開發者ID:cics-nd,項目名稱:ar-pde-cnn,代碼行數:45,代碼來源:cpuinfo.py


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