initial commit

This commit is contained in:
Davidson Gomes
2024-10-30 11:19:09 -03:00
commit 8654a31a4d
3744 changed files with 585542 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
import contextlib
def suppress_exceptions(callables, exceptions=Exception):
"""
yield the results of calling each element of callables, suppressing
any indicated exceptions.
"""
for callable in callables:
with contextlib.suppress(exceptions):
yield callable()

View File

@@ -0,0 +1,40 @@
import os
import pathlib
import platform
def _data_root_Windows():
release, version, csd, ptype = platform.win32_ver()
root = pathlib.Path(
os.environ.get('LOCALAPPDATA', os.environ.get('ProgramData', '.'))
)
return root / 'Python Keyring'
def _data_root_Linux():
"""
Use freedesktop.org Base Dir Specification to determine storage
location.
"""
fallback = pathlib.Path.home() / '.local/share'
root = os.environ.get('XDG_DATA_HOME', None) or fallback
return pathlib.Path(root, 'python_keyring')
_config_root_Windows = _data_root_Windows
def _config_root_Linux():
"""
Use freedesktop.org Base Dir Specification to determine config
location.
"""
fallback = pathlib.Path.home() / '.config'
key = 'XDG_CONFIG_HOME'
root = os.environ.get(key, None) or fallback
return pathlib.Path(root, 'python_keyring')
# by default, use Unix convention
data_root = globals().get('_data_root_' + platform.system(), _data_root_Linux)
config_root = globals().get('_config_root_' + platform.system(), _config_root_Linux)