MCPcopy Create free account
hub / github.com/numpy/numpy / __init__

Method __init__

numpy/distutils/cpuinfo.py:480–518  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

478 # mean?
479
480 def __init__(self):
481 if self.info is not None:
482 return
483 info = []
484 try:
485 #XXX: Bad style to use so long `try:...except:...`. Fix it!
486 import winreg
487
488 prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
489 r"\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
490 chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
491 pnum=0
492 while True:
493 try:
494 proc=winreg.EnumKey(chnd, pnum)
495 except winreg.error:
496 break
497 else:
498 pnum+=1
499 info.append({"Processor":proc})
500 phnd=winreg.OpenKey(chnd, proc)
501 pidx=0
502 while True:
503 try:
504 name, value, vtpe=winreg.EnumValue(phnd, pidx)
505 except winreg.error:
506 break
507 else:
508 pidx=pidx+1
509 info[-1][name]=value
510 if name=="Identifier":
511 srch=prgx.search(value)
512 if srch:
513 info[-1]["Family"]=int(srch.group("FML"))
514 info[-1]["Model"]=int(srch.group("MDL"))
515 info[-1]["Stepping"]=int(srch.group("STP"))
516 except Exception as e:
517 print(e, '(ignoring)')
518 self.__class__.info = info
519
520 def _not_impl(self): pass
521

Callers

nothing calls this directly

Calls 2

printFunction · 0.85
compileMethod · 0.45

Tested by

no test coverage detected