first commit
This commit is contained in:
60
winreg.py
Normal file
60
winreg.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""Tiny non-Windows winreg compatibility shim.
|
||||
|
||||
The upstream Proxy God code is Windows-first and imports ``winreg`` in several
|
||||
modules. macOS does not ship that module. This shim keeps imports working and
|
||||
makes registry operations behave like unavailable keys.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
HKEY_CURRENT_USER = object()
|
||||
HKEY_LOCAL_MACHINE = object()
|
||||
KEY_QUERY_VALUE = 0x0001
|
||||
KEY_SET_VALUE = 0x0002
|
||||
KEY_ALL_ACCESS = 0xF003F
|
||||
REG_BINARY = 3
|
||||
REG_DWORD = 4
|
||||
REG_SZ = 1
|
||||
|
||||
|
||||
class HKEYType:
|
||||
def __enter__(self) -> "HKEYType":
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc, tb) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def OpenKey(*args, **kwargs) -> HKEYType:
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def CreateKeyEx(*args, **kwargs) -> HKEYType:
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def QueryValue(*args, **kwargs):
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def QueryValueEx(*args, **kwargs):
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def SetValueEx(*args, **kwargs) -> None:
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def DeleteValue(*args, **kwargs) -> None:
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def DeleteKey(*args, **kwargs) -> None:
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def EnumValue(*args, **kwargs):
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
|
||||
|
||||
def EnumKey(*args, **kwargs):
|
||||
raise OSError("winreg is unavailable on this platform")
|
||||
Reference in New Issue
Block a user