moving data to new repo

master
elburg 1 year ago
parent 8d2bb67499
commit c94e713b1d

@ -14,7 +14,6 @@ __version__ = "0.0.0-alpha0"
def main() -> dict: def main() -> dict:
out=output.OutputObject() out=output.OutputObject()
try: try:

@ -1,44 +1,55 @@
from pathlib import Path
from sys import platform
from yaml import load, dump
import os
from re import search, IGNORECASE
import collections.abc
_config={} _config={}
_files=[] _files=[]
_configloaded = False
_locations={ _LOCATIONS = {
'_yamlmainconf':[ '_YAMLCONFPATH':{
# Check current dir '_DIR':[
'./owo.yaml', "{}/owo/".format(os.environ["XDG_CONFIG_HOME"]) if "XDG_CONFIG_HOME" in os.environ else str(Path.home())+"/.config/owo/",
'./owo.yml', "{}/".format(os.environ["XDG_CONFIG_HOME"]) if "XDG_CONFIG_HOME" in os.environ else str(Path.home())+"/.config/",
'./owo.conf', str(Path('~').resolve()),
'./owo.cfg', str(Path().resolve()) if str(Path.cwd()) not in self._DIRS else None
'./.owo.yaml', ],
'./.owo.yml', '_FNAME_RE':
'./.owo.conf', r"([ou^>]w[ou^<]|config)\.(ya?ml|c(on)?fi?g?)$"
'./.owo.cfg', }
# Check home dir
'~/owo.yaml',
'~/owo.yml',
'~/owo.conf',
'~/owo.cfg',
'~/.owo.yaml',
'~/.owo.yml',
'~/.owo.conf',
'~/.owo.cfg'
]
} }
from sys import platform def _updateConf(toAdd: dict):
for key, value in toAdd.items():
if isinstance(value, collections.abc.Mapping):
def _loadYAMLConf(path: str):
try:
conf = yaml.load(file.read_text())
except Exception as exc:
# do an err
else:
if not _config:
_config = conf
else:
_locations._yamlmainconf+={ def initConfig(path: str) -> bool:
'linux':[ if _configloaded:
'{env.HOME}/owo.yaml', return True# If config already loaded, do not reload.
'{env.HOME}/owo.yml', else:
'{env.HOME}/owo.conf', try:
'{env.HOME}/owo.cfg', file = Path(path)
'{env.HOME}/.owo.yaml',
'{env.HOME}/.owo.yml',
'{env.HOME}/.owo.conf',
'{env.HOME}/.owo.cfg'
],
'linux2':self.linux
}[platform]
def loadConfig(path: str) -> bool: if file.exists() and not file.is_dir():
try:
conf = yaml.load(file.read_text())
except Exception as exc:
# do an err
else:
if not _config

@ -0,0 +1,31 @@
_DEFAULT = {
'_DATETEMP':'%a, %d %b %Y %H:%M:%S %Z%z',
'_INCLUDE':[
'env',
]
}
def dateFormat(input: str = _DEFAULT._DATETEMP,use_local:bool=True) -> str:
from time import strftime
if use_local:
from time import localtime
return strftime(input,localtime())
else:
from time import gmtime
return strftime(input,gmtime())
def stringformat(
input: str,
include: list = _DEFAULT._INCLUDE
) -> str:
imap = {
'time': dateFormat()
}
if 'env' in include:
import os
imap['env'] = os.environ
del os
return input.format_map(imap)
Loading…
Cancel
Save