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:
out=output.OutputObject()
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={}
_files=[]
_configloaded = False
_locations={
'_yamlmainconf':[
# Check current dir
'./owo.yaml',
'./owo.yml',
'./owo.conf',
'./owo.cfg',
'./.owo.yaml',
'./.owo.yml',
'./.owo.conf',
'./.owo.cfg',
_LOCATIONS = {
'_YAMLCONFPATH':{
'_DIR':[
"{}/owo/".format(os.environ["XDG_CONFIG_HOME"]) if "XDG_CONFIG_HOME" in os.environ else str(Path.home())+"/.config/owo/",
"{}/".format(os.environ["XDG_CONFIG_HOME"]) if "XDG_CONFIG_HOME" in os.environ else str(Path.home())+"/.config/",
str(Path('~').resolve()),
str(Path().resolve()) if str(Path.cwd()) not in self._DIRS else None
],
'_FNAME_RE':
r"([ou^>]w[ou^<]|config)\.(ya?ml|c(on)?fi?g?)$"
}
# 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+={
'linux':[
'{env.HOME}/owo.yaml',
'{env.HOME}/owo.yml',
'{env.HOME}/owo.conf',
'{env.HOME}/owo.cfg',
'{env.HOME}/.owo.yaml',
'{env.HOME}/.owo.yml',
'{env.HOME}/.owo.conf',
'{env.HOME}/.owo.cfg'
],
'linux2':self.linux
}[platform]
def initConfig(path: str) -> bool:
if _configloaded:
return True# If config already loaded, do not reload.
else:
try:
file = Path(path)
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