summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2000-08-21 02:27:22 (GMT)
committerTim Peters <tim.peters@gmail.com>2000-08-21 02:27:22 (GMT)
commite82e7ccdbdaa9d352d872490283270562369567d (patch)
tree7d095d064e7075aa0741c73dd5cced7932d78a87 /Lib
parenta98e92bc1366ebfd062c2f20e21282fd72b466a4 (diff)
downloadcpython-e82e7ccdbdaa9d352d872490283270562369567d.zip
cpython-e82e7ccdbdaa9d352d872490283270562369567d.tar.gz
cpython-e82e7ccdbdaa9d352d872490283270562369567d.tar.bz2
Remove the winreg module from the project. I don't believe any
docs changes are needed (only reference to winreg I could find was in libwinreg.tex, which is documenting _winreg, and merely mentions that a higher-level winreg module *may* appear someday; that's still true).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/plat-win/winreg.py386
-rw-r--r--Lib/test/output/test_winreg277
-rw-r--r--Lib/test/test_winreg2.py350
3 files changed, 0 insertions, 813 deletions
diff --git a/Lib/plat-win/winreg.py b/Lib/plat-win/winreg.py
deleted file mode 100644
index 8da70e9..0000000
--- a/Lib/plat-win/winreg.py
+++ /dev/null
@@ -1,386 +0,0 @@
-"""
-Windows registry support.
-
-openKey( keyname )
- open existing key object
-
->>> key=openKey( r"HKLM\HARDWARE\DESCRIPTION\System" )
-
-createKey( keyname )
- create a key if it doesn't already exist
-
->>> key=createKey( r"HKLM\SOFTWARE\Python\Test" )
-
-deleteKey( keyname )
- delete a key if it exists
- Note: deleteKey may not be recursive on all platforms.
-
->>> key=deleteKey( r"HKLM\SOFTWARE\Python\Test" )
-
-RemoteKey( machine, top_level_key ):
- open a key on another machine.
- You can use the returned key as a basis for opens, creates and deletes
- on the other machine.
-
->>> key=RemoteKey( "somemachine", "HKLM" )
-
-For information on the key API, open a key and look at its docstring.
-
-
-"""
-
-import _winreg
-import sys
-import exceptions
-import array
-from types import *
-import string
-
-class RegType:
- "Represents one of the types that can go into the registry"
- def __init__( self, msname, friendlyname ):
- self.msname=msname
- self.friendlyname=friendlyname
- self.intval=getattr( _winreg, msname )
-
- def __repr__( self ):
- "Return a useful representation of the type object"
- return "<RegType %d: %s %s>" % \
- (self.intval, self.msname, self.friendlyname )
-
-_typeConstants={
- _winreg.REG_NONE:
- RegType( "REG_NONE", "None" ),
- _winreg.REG_SZ:
- RegType( "REG_SZ", "String" ),
- _winreg.REG_EXPAND_SZ:
- RegType("REG_EXPAND_SZ", "Expandable Template String" ),
- _winreg.REG_BINARY:
- RegType("REG_BINARY", "Binary Data"),
- _winreg.REG_DWORD :
- RegType("REG_DWORD", "Integer" ),
-# _winreg.REG_DWORD_LITTLE_ENDIAN :
-# RegType("REG_DWORD_LITTLE_ENDIAN", "Integer"),
- _winreg.REG_DWORD_BIG_ENDIAN :
- RegType("REG_DWORD_BIG_ENDIAN", "Big Endian Integer"),
- _winreg.REG_LINK :
- RegType("REG_LINK", "Link"),
- _winreg.REG_MULTI_SZ :
- RegType("REG_MULTI_SZ", "List of Strings"),
- _winreg.REG_RESOURCE_LIST :
- RegType("REG_RESOURCE_LIST", "Resource List"),
- _winreg.REG_FULL_RESOURCE_DESCRIPTOR :
- RegType( "REG_FULL_RESOURCE_DESCRIPTOR",
- "Full Resource Descriptor" ),
- _winreg.REG_RESOURCE_REQUIREMENTS_LIST:
- RegType( "REG_RESOURCE_REQUIREMENTS_LIST",
- "Resource Requirements List" )
-}
-
-regtypes={}
-for constant in _typeConstants.values():
- regtypes[constant.msname]=constant
-
-class _DictBase:
- "Base class for dictionary-type objects"
- def __init__( self, key ):
- self.key=key
-
- def clear( self ):
- "Clear the list of keys/data values, as in dictionaries"
- keys=list( self.keys() )
- map( self.__delitem__, keys )
-
- def get( self, item, defaultVal=None ):
- "Get a key/value by name or index"
- try:
- return self.__getitem__( item )
- except (IndexError, EnvironmentError, WindowsError):
- return defaultVal
-
- def has_key( self, item ):
- "Check if a key/data value with a particular name exists"
- try:
- self.__getitem__( item )
- return 1
- except (IndexError, EnvironmentError, WindowsError):
- return 0
-
- def keys( self ):
- "Get a list of key/data value names"
- keys=[]
- try:
- for i in xrange( 0, sys.maxint ):
- keyname = self._nameFromNum( i )
- keys.append( keyname )
- except (IndexError, EnvironmentError, WindowsError):
- pass
- return keys
-
- def values( self ):
- "Get a list of key objects or data values"
- values=[] # map() doesn't use the IndexError semantics...
- for i in self:
- values.append( i )
- return values
-
- def items( self ):
- "Get pairs of keyname/key object or valuename/value data"
- return map( None, self.keys(), self.values() )
-
- def __len__( self ):
- return len( self.keys() )
-
-def _getName( item, nameFromNum ):
- "Helper function -- don't use it directly"
- if type( item ) == IntType:
- try:
- keyname = nameFromNum( item )
- except (WindowsError, EnvironmentError):
- raise IndexError, item
-
- elif type( item ) in [StringType, UnicodeType]:
- keyname=item
- else:
- raise exceptions.TypeError, \
- "Requires integer index or string key name"
- return keyname
-
-
-class RegValuesDict( _DictBase ):
- "A dictionary of registry data values"
- def _nameFromNum( self, i ):
- return self.key._nameFromNum( i )
-
- def __getitem__( self, item ):
- return self.key.getValueNameDataAndType( item )
-
- def __setitem__( self, name, val):
- if type( val )==TupleType:
- data, datatype=val
- assert isinstance( datatype, RegType )
- self.key.setValue( name, data, datatype )
- else:
- self.key.setValue( name, val )
-
- def __delitem__( self, item ):
- valname=_getName( item, self._nameFromNum )
- self.key.deleteValue( valname )
-
-class RegKeysDict( _DictBase ):
- "A dictionary of registry keys"
- def _nameFromNum( self, item ):
- return _winreg.EnumKey( self.key.handle, item )
-
- def __getitem__( self, item ):
- keyname=_getName( item, self._nameFromNum )
- return self.key.openSubkey( keyname )
-
- def __delitem__( self, item ):
- keyname=_getName( item, self._nameFromNum )
- self.key.deleteSubkey( keyname )
-
-def openKey( keyname, samFlags=None ):
- "Open a key by name"
- lst=string.split( keyname, "\\", 1 )
- if len( lst )==2:
- hivename,path=lst
- return hives[hivename].openSubkey( path )
- else:
- hivename=lst[0]
- return hives[hivename]
-
-def createKey( keyname ):
- lst=string.split( keyname, "\\", 1 )
- assert len( lst )==2
- hivename,path=lst
- return hives[hivename].createSubkey( path )
-
-def deleteKey( keyname ):
- lst=string.split( keyname, "\\", 1 )
- assert len( lst )==2
- hivename,path=lst
- return hives[hivename].deleteSubkey( path )
-
-
-class RegKey:
- "A registry key object"
-
- def __init__( self, name, handle=None ):
- self.name=name
- self.handle=handle
-
- def _nameFromNum( self, item ):
- "internal"
- (name,data,datatype)=_winreg.EnumValue( self.handle, item )
- return name
-
- def __nonzero__(self):
- "Is the key open?"
- if self.handle:
- return 1
- else:
- return 0
-
- def __cmp__ (self, other ):
- "Compare two keys for equality"
- if hasattr( other, "handle" ) and hasattr( other, "name" ):
- return cmp( self.name, other.name )
- else:
- return cmp( self.handle, other )
-
- def __repr__( self ):
- return "<Windows RegKey: %s>"% self.name
-
- def close(self ):
- "Close the key"
- return _winreg.CloseKey( self.handle )
-
- def getSubkeyNames( self ):
- "Get a list of subkey names"
- return self.getSubkeys().keys()
-
- def getValueNames( self ):
- "Get a list of value names"
- return self.getValues().keys()
-
- def deleteSubkey( self, subkey ):
- "Delete a subkey by name"
- return _winreg.DeleteKey( self.handle, subkey )
-
- def deleteValue( self, valname ):
- "Delete a value by name"
- return _winreg.DeleteValue( self.handle, valname )
-
- def createSubkey( self, keyname ):
- "Create a subkey by name"
- handle=_winreg.CreateKey( self.handle, keyname )
- return RegKey( self.name+"\\"+keyname, handle)
-
- def openSubkey( self, keyname, samFlags=None ):
- "Open a named subkey"
- if samFlags:
- handle=_winreg.OpenKey( self.handle, keyname, 0, samFlags )
- else:
- handle=_winreg.OpenKey( self.handle, keyname, 0 )
- return RegKey( self.name+"\\"+keyname, handle )
-
- def getSubkeys( self ):
- "Get a dictionary-like mapping of subkeys"
- return RegKeysDict( self )
-
- def getValues( self ):
- "Get a dictionary-like mapping of data values"
- return RegValuesDict( self )
-
- def getValueNameDataAndType( self, valname ):
- "Get a data value's name, data and type all at one time"
- try:
- if type( valname )==IntType:
- (valname,data,datatype)=_winreg.EnumValue( self.handle, valname )
- else:
- keyname=_getName( valname, self._nameFromNum )
- (data,datatype)=_winreg.QueryValueEx( self.handle, keyname )
- except (WindowsError, EnvironmentError):
- raise IndexError, valname
-
- if datatype==_winreg.REG_BINARY:
- # use arrays for binary data
- data=array.array( 'c', data )
-
- return (valname, data, _typeConstants[datatype] )
-
- def getValueData( self, valname ):
- "Get a data value's data."
- name, data, type=self.getValueNameDataAndType( valname )
- return data
-
- def setValue( self, valname, data, regtype=None ):
- "Set a data value's data (and optionally type)"
- if regtype:
- typeint=regtype.intval
- else:
- if type( data ) in [StringType, UnicodeType]:
- typeint=_winreg.REG_SZ
- elif type( data )==ListType:
- # XXX - _winreg currently only supports lists
- # Also, probably should check each element is
- # string/unicode.
- typeint = _winreg.REG_MULTI_SZ
- elif type( data )==IntType:
- typeint=_winreg.REG_DWORD
- elif type( data )==array.ArrayType:
- typeint=_winreg.REG_BINARY
- _winreg.SetValueEx( self.handle, valname, 0, typeint, data )
-
- def flush(self ):
- "Make sure that all changes are written to the registry. "
- "Only use this if you know what you are doing. "
- "It isn't usually needed."
- _winreg.FlushKey( self.keyobbj )
-
- def save( self, filename ):
- "Save a key to a filename"
- _winreg.SaveKey( self.keyobj, filename )
-
- def load( self, subkey, filename ):
- "Load a key from a filename"
- return _winreg.RegLoadKey( self.handle, subkey, filename )
-
-
-class RemoteKey( RegKey ):
- "Open a key on a remote machine"
- def __init__( self, machine, topLevelKey ):
- assert topLevelKey in _hivenames
- self.handle = _winreg.ConnectRegistry( machine, parentKey )
- self.name=r"\\%s\%s" % (machine, topLevelKey )
-
-_hivenames = ["HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE",
- "HKEY_USERS","HKEY_CURRENT_CONFIG","HKEY_DYN_DATA",
- "HKEY_PERFORMANCE_DATA"]
-hives={}
-for name in _hivenames:
- hives[name]=RegKey( name, getattr( _winreg, name ) )
-hives["HKLM"]=hives["HKEY_LOCAL_MACHINE"]
-hives["HKCR"]=hives["HKEY_CLASSES_ROOT"]
-hives["HKCU"]=hives["HKEY_CURRENT_USER"]
-
-_flagnames = ["KEY_ALL_ACCESS","KEY_CREATE_LINK", "KEY_CREATE_SUB_KEY",
- "KEY_ENUMERATE_SUB_KEYS", "KEY_EXECUTE", "KEY_NOTIFY",
- "KEY_QUERY_VALUE", "KEY_READ", "KEY_SET_VALUE"]
-flags={}
-for name in _flagnames:
- flags[name]=getattr( _winreg, name )
-
-_RegNotifyChangeKeyValueOptions=[ "REG_NOTIFY_CHANGE_ATTRIBUTES",
- "REG_NOTIFY_CHANGE_SECURITY", "REG_NOTIFY_CHANGE_LAST_SET",
- "REG_NOTIFY_CHANGE_NAME", "REG_LEGAL_CHANGE_FILTER" ]
-
-_RegRestoreKeyOptions=["REG_WHOLE_HIVE_VOLATILE",
- "REG_NO_LAZY_FLUSH",
- "REG_OPTION_VOLATILE",
- "REG_REFRESH_HIVE",
- "REG_OPTION_NON_VOLATILE",
- "REG_OPTION_BACKUP_RESTORE" ]
-
-_RegCreateKeyExOptions=[
- "REG_LEGAL_OPTION",
- "REG_OPTION_RESERVED",
- "REG_OPTION_VOLATILE",
- "REG_OPTION_NON_VOLATILE",
- "REG_OPTION_BACKUP_RESTORE",
- "REG_CREATED_NEW_KEY",
- "REG_OPENED_EXISTING_KEY",
- "REG_OPTION_CREATE_LINK"]
-
-
-#unusednames=_RegNotifyChangeKeyValueOptions+_RegRestoreKeyOptions+_RegCreateKeyExOptions
-
-#typeConstantNames=map( lambda x: x.msname, typeConstants.values() )
-
-#allnames=_hivenames+_flagnames+typeConstantNames+unusednames
-#winregnames=_winreg.__dict__.keys()
-#for name in winregnames:
-# if name not in allnames:
-# print name
-
diff --git a/Lib/test/output/test_winreg2 b/Lib/test/output/test_winreg2
deleted file mode 100644
index 712d110..0000000
--- a/Lib/test/output/test_winreg2
+++ /dev/null
@@ -1,77 +0,0 @@
-test_winreg2
-Test Passed: testKeyDict_Values
-Test Passed: testKeyDict_Items
-Test Passed: testGetValueNames
-Test Passed: testSetDwordBigEndian
-Test Passed: testGetSubkeyNames
-Test Passed: testResourceRequirementsListType
-Test Passed: testLoad
-Test Passed: testDeleteKey
-Test Passed: testValueDict_Length
-Test Passed: testResourceDescriptionType
-Test Passed: testSetMultiSz
-Test Passed: testSetFullResourceDescription
-HKEY_CLASSES_ROOT
-HKEY_CURRENT_USER
-HKEY_LOCAL_MACHINE
-HKEY_USERS
-HKEY_CURRENT_CONFIG
-HKEY_DYN_DATA
-HKEY_PERFORMANCE_DATA
-Test Passed: testHives
-Test Passed: testDWordType
-Test Passed: testRemote
-Test Passed: testKeyDict_DelItem
-Test Passed: testSetIntValue
-Test Passed: testResourceLinkType
-Test Passed: testNoneType
-Test Passed: testValueDict_Map
-Test Passed: testSetResourceList
-Test Passed: testKeyDict_Length
-Test Passed: testKeyDict_ClearKeys
-Test Passed: testDWordBigEndianType
-Test Passed: testOpen
-Test Passed: testSetBinaryData
-Test Passed: testGetValueNameDataAndType
-Test Passed: testSetBinaryValue
-Test Passed: testSetResourceRequirementsList
-Test Passed: testUnicodeValueName
-Test Passed: testGetValueDataFromEnum
-Test Passed: testValueDict_Get
-Test Passed: testValueDict_GetItem
-Test Passed: testValueDict_Keys
-Test Passed: testKeyDict_HasKey
-Test Passed: testExpandStringType
-Test Passed: testValueDict_HasKey
-Test Passed: testCreateKey
-Test Passed: testGetBinaryData
-Test Passed: testKeyDict_Get
-Test Passed: testSave
-Test Passed: testValueDict_ClearKeys
-Test Passed: testCmp
-Test Passed: testLinkType
-Test Passed: testSetExpandString
-Test Passed: testKeyDict_GetItem
-Test Passed: testRepr
-Test Passed: testClose
-Test Passed: testSetLink
-Test Passed: testGetValueDataFromName
-Test Passed: testUnicodeKeyName
-Test Passed: testShortcuts
-Test Passed: testKeyDict_Map
-Test Passed: testStringType
-Test Passed: testOpenFailure
-Test Passed: testSetDword
-Test Passed: testOpenKeyWithFlags
-Test Passed: testSetNone
-Test Passed: testKeyDict_Keys
-Test Passed: testMultiStringType
-Test Passed: testSetStringValue
-Test Passed: testValueDict_Items
-Test Passed: testValueDict_DelItem
-Test Passed: testNonZero
-Test Passed: testFlush
-Test Passed: testGetSubkeys
-Test Passed: testDeleteValue
-Test Passed: testSetString
-Test Passed: testValueDict_Values
diff --git a/Lib/test/test_winreg2.py b/Lib/test/test_winreg2.py
deleted file mode 100644
index dd9229a..0000000
--- a/Lib/test/test_winreg2.py
+++ /dev/null
@@ -1,350 +0,0 @@
-from winreg import hives, createKey, openKey, flags, deleteKey, regtypes
-import sys, traceback
-import time
-import array
-
-def testHives():
- hivenames = ["HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE",
- "HKEY_USERS","HKEY_CURRENT_CONFIG"] #, #
- for hivename in hivenames:
- hive = hives[ hivename ]
- print hive.name
- assert hive.handle
- assert hive.getSubkeys()
- for hivename in ["HKEY_DYN_DATA", "HKEY_PERFORMANCE_DATA"]:
- hive = hives[ hivename ]
- print hive.name
- assert hive.handle
- assert not hive.getValues()
- assert not hive.getSubkeys()
-
-def testNonZero():
- key=hives["HKLM"].openSubkey( "SOFTWARE" )
- assert key.openSubkey( "Microsoft" )
- assert key
- key.close()
- assert not key
- try:
- key.openSubkey( "Microsoft" )
- assert 0
- except EnvironmentError:
- pass
-
-def testCmp():
- HKLM=hives["HKLM"]
- assert (openKey("HKLM\\SOFTWARE")==\
- HKLM.openSubkey("SOFTWARE"))
- assert not HKLM.openSubkey("SYSTEM")!=HKLM.openSubkey("SYSTEM")
- assert HKLM.openSubkey("SOFTWARE")!=HKLM.openSubkey("SYSTEM")
- assert not HKLM.openSubkey("SOFTWARE")==HKLM.openSubkey("SYSTEM")
- assert not HKLM.openSubkey("SOFTWARE")=="spam"
- assert ((HKLM.openSubkey("SOFTWARE")<"spam") !=
- (HKLM.openSubkey("SOFTWARE")>"spam"))
-
-def testClose():
- key=hives["HKLM"].openSubkey( "SOFTWARE" )
- assert key
- key.close()
- assert not key
-
-def testOpen():
- assert openKey( r"HKLM" )
- assert openKey( r"HKLM\HARDWARE" )
- assert openKey( r"HKLM\HARDWARE\DESCRIPTION\System" )
-
-def testOpenFailure():
- try:
- print openKey( r"HKCU\Software\Python\A\B\C\D" )
- assert 0 #
- except EnvironmentError:
- pass
-
-def testDeleteKey():
- createKey( r"HKCU\Software\Python\A\B\C\D" )
- deleteKey( r"HKCU\Software\Python\A\B\C\D" )
- deleteKey( r"HKCU\Software\Python\A\B\C" )
- deleteKey( r"HKCU\Software\Python\A\B" )
- assert "A" in \
- openKey(r"HKCU\Software\Python").getSubkeys().keys()
- openKey( r"HKCU\Software\Python" ).deleteSubkey( r"A" )
- assert "A" not in \
- openKey(r"HKCU\Software\Python").getSubkeys().keys()
-
-def testDeleteValue():
- key=createKey( r"HKCU\Software\Python\A" )
- key.setValue( "abcde", "fghij" )
- assert key.getValueData( "abcde" )=="fghij"
- assert "abcde" in key.getValues().keys()
- assert "fghij" in map( lambda x:x[1], key.getValues().values() )
- assert "abcde" in key.getValues().keys()
- key.deleteValue( "abcde" )
- assert "abcde" not in key.getValues().keys()
- assert "fghij" not in map( lambda x:x[1], key.getValues().values() )
- deleteKey( r"HKCU\Software\Python\A" )
-
-def testCreateKey():
- key=createKey( r"HKCU\Software\Python\A" )
- assert openKey( r"HKCU\Software\Python").getSubkeys().has_key( "A" )
- deleteKey( r"HKCU\Software\Python\A" )
- assert not openKey( r"HKCU\Software\Python").getSubkeys().\
- has_key( "A" )
- key=openKey( r"HKCU\Software\Python" ).createSubkey( "A" )
-
-def testOpenKeyWithFlags():
- assert openKey( r"HKCU\Software\Python",
- flags["KEY_READ"])
- assert openKey( r"HKCU\Software\Python",
- flags["KEY_ALL_ACCESS"])
-
-def testGetSubkeys():
- keys=openKey( r"HKCU\Software" ).getSubkeys()
- assert keys
- index=0
- for i in keys:
- index=index+1
- assert index==len( keys )
-
-def testGetValueNameDataAndType(): pass
-
-def testGetSubkeyNames():
- subkeyNames=hives["HKLM"].getSubkeyNames()
- assert len( subkeyNames )==len(hives["HKLM"].getSubkeys())
- for name in subkeyNames:
- assert type( name )==type("")
-
-def testGetValueNames():
- valNames=hives["HKLM"].getValueNames()
- assert len( valNames )==len(hives["HKLM"].getValues())
- for name in valNames:
- assert type( name )==type("")
-
-def testRepr():
- assert repr(hives["HKCU"])==str(hives["HKCU"])
-
-def testSetStringValue():
- hives["HKCU"].setValue( "Blah", "abc" )
- assert hives["HKCU"].getValueData( "Blah" )=="abc"
- assert hives["HKCU"].getValues().has_key( "Blah" )
- del hives["HKCU"].getValues()[ "Blah" ]
- assert not hives["HKCU"].getValues().has_key( "Blah" )
-
- # Ensure Unicode works as we expect
- hives["HKCU"].setValue( u"Blah", u"abc" )
- assert hives["HKCU"].getValueData( "Blah" )=="abc"
- assert hives["HKCU"].getValues().has_key( u"Blah" )
- del hives["HKCU"].getValues()[ u"Blah" ]
- assert not hives["HKCU"].getValues().has_key( u"Blah" )
-
-def testDeleteValue():
- hives["HKCU"].setValue( "Blah", "abc" )
- assert hives["HKCU"].getValues().has_key( "Blah" )
- del hives["HKCU"].getValues()[ "Blah" ]
- assert not hives["HKCU"].getValues().has_key( "Blah" )
- hives["HKCU"].setValue( "Blah", "abc" )
- hives["HKCU"].deleteValue( "Blah" )
- assert not hives["HKCU"].getValues().has_key( "Blah" )
-
-def testKeyDict_ClearKeys():
- createKey( "HKLM\\Software\\a\\b\\c\\d\\e" )
- createKey( "HKLM\\Software\\a\\b\\c\\d\\f" )
- createKey( "HKLM\\Software\\a\\b\\c\\d\\g" )
- createKey( "HKLM\\Software\\a\\b\\c\\d\\h" )
- createKey( "HKLM\\Software\\a\\b\\c\\d\\i" )
- key=openKey( "HKLM\\Software\\a\\b\\c\\d" )
- assert key.getSubkeys()
- key.getSubkeys().clear()
- assert not key.getSubkeys()
- assert not openKey( "HKLM\\Software\\a\\b\\c\\d").getSubkeys()
- deleteKey( "HKLM\\Software\\a\\b\\c\\d" )
- deleteKey( "HKLM\\Software\\a\\b\\c" )
- deleteKey( "HKLM\\Software\\a\\b" )
- deleteKey( "HKLM\\Software\\a" )
-
-def testUnicodeKeyName(): pass
-
-def testUnicodeValueName(): pass
-
-def testGetValueDataFromEnum(): pass
-
-def testGetValueDataFromName(): pass
-
-def testGetBinaryData(): pass
-
-
-def testSetIntValue():
- key=createKey( "HKLM\\Software\\a\\b")
- key.setValue( "abcd", 5 )
- assert key.getValueData( "abcd" )==5
- assert key.getValues()[ "abcd" ][1]==5
- key.deleteValue( "abcd" )
- key.getValues()["abcd"]=5
- assert key.getValues()[ "abcd" ][1]==5
- key.deleteValue( "abcd" )
- key.getValues()["abcd"]=(5,regtypes["REG_DWORD"])
- assert key.getValues()[ "abcd" ][1]==5
- key.deleteValue( "abcd" )
- deleteKey( "HKLM\\Software\\a\\b")
- deleteKey( "HKLM\\Software\\a")
-
-def testSetBinaryValue():
- key=createKey( "HKLM\\Software\\a\\b")
- key.setValue( "abcd", array.array( 'c', "PPPPPPPPPPPPPPP") )
- key.setValue( "abcde", array.array( 'c', "PPPPPPPPPPPPPPP"),
- regtypes["REG_BINARY"] )
- assert key.getValues()["abcd"][1]==key.getValues()["abcde"][1]
- key = None # Remove our reference.
- deleteKey( "HKLM\\Software\\a\\b")
- deleteKey( "HKLM\\Software\\a")
-
-def testSetNone(): pass
-
-def testSetString(): pass
-
-def testSetExpandString(): pass
-
-def testSetBinaryData(): pass
-
-def testSetDword(): pass
-
-def testSetDwordBigEndian(): pass
-
-def testSetLink(): pass
-
-def testSetMultiSz(): pass
-
-def testSetResourceList(): pass
-
-def testSetFullResourceDescription(): pass
-
-def testSetResourceRequirementsList(): pass
-
-
-
-def testFlush(): pass
-
-def testSave(): pass
-
-def testLoad(): pass
-
-
-
-
-
-def testNoneType(): pass
-
-def testStringType(): pass
-
-def testExpandStringType(): pass
-
-def testDWordType(): pass
-
-def testDWordBigEndianType(): pass
-
-def testLinkType(): pass
-
-def testMultiStringType(): pass
-
-def testResourceLinkType(): pass
-
-def testResourceDescriptionType(): pass
-
-def testResourceRequirementsListType(): pass
-
-
-def getSubkeysDict(): pass
-
-def testKeyDict_Get(): pass
-
-def testKeyDict_HasKey(): pass
-
-def testKeyDict_Keys(): pass
-
-def testKeyDict_Values(): pass
-
-def testKeyDict_Items(): pass
-
-def testKeyDict_Length(): pass
-
-def testKeyDict_Map(): pass
-
-def testKeyDict_GetItem(): pass
-
-def testKeyDict_DelItem(): pass
-
-def testRemote(): pass
-
-def testShortcuts(): pass
-
-
-
-def getValues(): pass
-
-def testValueDict_ClearKeys(): pass
-
-def testValueDict_Get(): pass
-
-def testValueDict_HasKey(): pass
-
-def testValueDict_Keys(): pass
-
-def testValueDict_Values(): pass
-
-def testValueDict_Items(): pass
-
-def testValueDict_Length(): pass
-
-def testValueDict_Map(): pass
-
-def testValueDict_GetItem(): pass
-
-def testValueDict_DelItem(): pass
-
-for name in globals().keys():
- if name[0:4]=="test":
- func=globals()[ name ]
- try:
- func()
- print "Test Passed: %s" % name
- except Exception, e:
- print "Test Failed: %s" % name
- traceback.print_exc()
-
-j=[0]*len( regtypes )
-
-k=0
-
-def test1( basekey ):
- global k
- for (name, data, type) in basekey.getValues():
- j[type.intval]=j[type.intval]+1
- if j[type.intval]==1:
- pass
- #print "[[%s]] %s [%s] = %s "% (type.msname, name, basekey, value)
- keys=basekey.getSubkeys()
- index=0
- k=k+1
- if(k%2500)==0:
- dump()
- while 1:
- try:
- test1( keys[index] )
- index=index+1
- except IndexError:
- break
- print "Done", basekey, index
- except (WindowsError, EnvironmentError):
- index=index+1
- dumpfile.write( "Skipping %s %s"% (basekey, index))
-
-def dump(dumpfile):
- for i in range( len( j )):
- dumpfile.write( "%s %s\n" %( i,j[i] ))
-
-def testRecursive():
- dumpfile=open( "foo.txt", "w" )
- start=time.time()
- for hive in hives.values():
- dumpfile.write( "Hive: %s\n" % hive )
- test1( hive )
- dump(dumpfile)
- print time.time()-start