diff --git a/owo/__init__.py b/owo/__init__.py new file mode 100644 index 0000000..2d9f559 --- /dev/null +++ b/owo/__init__.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +# from . import config +from . import output +import logging +import sys + +__author__ = "arris kathery" +__copyright__ = "copyright 2023 brendan berger" +__license__ = "" +__maintainer__ = "arris kathery" +__email__ = "whotookelburg@hotmail.com" +__version__ = "0.0.0-alpha0" + +DEBUG = True + +def main() -> dict: + try: + out=output.OutputObject() + except Exception as exc: + return { + '_err':True, + 'exception':exc, + 'vars':{ + 'globals': globals(), + 'locals': locals(), + 'dir': dir() + } + } + try: + pass + # do shit + except KeyboardInterrupt: + return {'_kbi':True} + diff --git a/owo/__main__.py b/owo/__main__.py new file mode 100644 index 0000000..af2f3dd --- /dev/null +++ b/owo/__main__.py @@ -0,0 +1,24 @@ +import sys + +if __package__ is None and not hasattr(sys, "frozen"): + import os.path + path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + sys.path.insert(0, os.path.realpath(path)) + +import owo + +if __name__ == "__main__": + output=owo.main() + del owo + if output.__contains__('_err'): + #from yaml import dump + #print("exception! check stderr!!") + #print(dump(output),file=sys.stderr) + from json import dumps + print(dumps(output)) + sys.exit(1) + if output.__contains__('_kb'): + print("interupted by keyboard") + sys.exit() + else: + pass # output results diff --git a/owo/config.py b/owo/config.py new file mode 100644 index 0000000..a340abe --- /dev/null +++ b/owo/config.py @@ -0,0 +1,6 @@ +confDict = {} + +def loadConfig(confLocation = "$HOME/.config/owo.yaml"): + from os import path + if not path.exists(confLocation): + diff --git a/owo/datafiles/__init__.py b/owo/datafiles/__init__.py new file mode 100644 index 0000000..665a9cb --- /dev/null +++ b/owo/datafiles/__init__.py @@ -0,0 +1,48 @@ +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 = { + '_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?)$" + } + +} + +def _updateConf(toAdd: dict): + _config = toAdd.update(_config) + +def initConfig(path: str) -> bool: + if _configloaded: + return True# If config already loaded, do not reload. + else: + try: + file = Path(path) + + if file.exists() and not file.is_dir(): + try: + conf = yaml.load(file.read_text()) + except Exception as exc: + raise exc + else: + if not _config: + _config = conf + else: + _updateConf(conf) + if file not in _files: + _files+str(file) + diff --git a/owo/format.py b/owo/format.py new file mode 100644 index 0000000..46ac9d7 --- /dev/null +++ b/owo/format.py @@ -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) diff --git a/owo/output/OutputObject.py b/owo/output/OutputObject.py new file mode 100644 index 0000000..3f36075 --- /dev/null +++ b/owo/output/OutputObject.py @@ -0,0 +1,24 @@ +import logging + +# outputDict={ +# 'status': 1, +# 'input': { +# 'argsRaw': sys.argv, +# 'streamObjects': [] +# }, +# 'output': [], +# 'errors': [] +# } + +class OutputObject: + + def __init__(self): + self.status = 1 + import sys + self.input = { + 'argsRaw': sys.argv, + 'streamObjects': [] + } + del sys + self.output = [] + self.errors = [] diff --git a/owo/output/__init__.py b/owo/output/__init__.py new file mode 100644 index 0000000..c9e1e71 --- /dev/null +++ b/owo/output/__init__.py @@ -0,0 +1 @@ +from . import OutputObject diff --git a/owo/source/__init__.py b/owo/source/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/owo/source/network/DownloadJob.py b/owo/source/network/DownloadJob.py new file mode 100644 index 0000000..ba35d50 --- /dev/null +++ b/owo/source/network/DownloadJob.py @@ -0,0 +1,10 @@ +from .NetworkPath import NetworkPath +from ...config.datafiles.owoDataFile import owoDataFile +from ...config import moduleConfig + +class DownloadJob: + + def __init__(self, + url: NetworkPath, + engine: string = moduleConfig.source.network.engine, + engineConfig: dict = moduleConfig.source.network.engineConfig diff --git a/scripts/test_debug.sh b/scripts/test_debug.sh new file mode 100644 index 0000000..0073955 --- /dev/null +++ b/scripts/test_debug.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +date="$(date +%Y-%j-%H-%M-%S)" + +python_args="-d -v" +owo_args="" + +_rst=$PWD +dir=".debug/runs/$date" +mkdir -p $dir + +touch $dir/stdout.term +touch $dir/stderr.term + +python3 $python_args owo/__main__.py $owo_args > $dir/stdout.term 2> $dir/stderr.term + +7z a -m0=LZMA2 -mx9 -sdel -ssw -t7z -- $dir.7z $dir/* +rm -rfv $dir + +printf "done"