started project
This commit is contained in:
commit
67f465f7ed
4 changed files with 67 additions and 0 deletions
2
README.rst
Normal file
2
README.rst
Normal file
|
@ -0,0 +1,2 @@
|
|||
System Information Library for Python
|
||||
=====================================
|
5
src/__init__.py
Normal file
5
src/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
__all__ = ['platform']
|
||||
|
||||
_LIBMETA={
|
||||
'version': [0,0,0]
|
||||
}
|
27
src/platform/__init__.py
Normal file
27
src/platform/__init__.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
_rC = {
|
||||
0: None # osinfo.py 'osFamily'
|
||||
}
|
||||
|
||||
def _resetCache() -> bool:
|
||||
try:
|
||||
for x in _rC:
|
||||
x = None
|
||||
return True
|
||||
except IndexError as e:
|
||||
from warnings import warn
|
||||
warn('IndexError was unusually thrown whilst clearing cache ({}). ignoring it...'.format(e.message))
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def _reload():
|
||||
import osinfo
|
||||
_rC[0]=osinfo.getOSValue('osFamily')
|
||||
|
||||
def getAll() -> dict:
|
||||
return {
|
||||
'os': {
|
||||
'family': _rC[0]
|
||||
}
|
||||
}
|
||||
|
33
src/platform/osinfo.py
Normal file
33
src/platform/osinfo.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# from .._internal.methods import platform as _discover
|
||||
|
||||
def _match(x: int, y: int) -> str:
|
||||
try:
|
||||
if x==0: # Kernal Family
|
||||
return {
|
||||
0: 'Unknown',
|
||||
1: 'Unknown POSIX',
|
||||
2: 'Unix',
|
||||
3: 'Linux',
|
||||
4: 'Windows NT',
|
||||
5: 'BSD',
|
||||
6: 'Unknown BSD'
|
||||
}[y]
|
||||
else:
|
||||
raise RuntimeError('invalid x id from discovery methods')
|
||||
except IndexError:
|
||||
return {
|
||||
0: 'Unknown'
|
||||
}[x]
|
||||
except RuntimeError as e:
|
||||
raise e
|
||||
|
||||
def getOSValue(item: str) -> list:
|
||||
try:
|
||||
return {
|
||||
'osFamily': _match(0,_discover.find('OS_FAMILY'))
|
||||
}[item]
|
||||
except IndexError as e:
|
||||
return None
|
||||
|
||||
def dumpOSInfo() -> dict:
|
||||
return
|
Loading…
Reference in a new issue