Transfer changes

oop-refactor
Thor 4 years ago
parent 75c3913563
commit df3b3efc8f
  1. 6
      .gitmodules
  2. 14
      .pylintrc
  3. 1
      dependencies.txt
  4. 1
      packages/apscheduler
  5. 1
      packages/ptpython
  6. 9
      src/test.py
  7. 2
      src/zasd/__init__.py
  8. 0
      src/zasd/config/__init__.py
  9. 24
      src/zasd/config/loader.py
  10. 6
      src/zasd/repl.py
  11. 8
      vs.code-workspace

6
.gitmodules vendored

@ -0,0 +1,6 @@
[submodule "packages/apscheduler"]
path = packages/apscheduler
url = https://github.com/agronholm/apscheduler
[submodule "packages/ptpython"]
path = packages/ptpython
url = https://github.com/prompt-toolkit/ptpython.git

@ -0,0 +1,14 @@
[MASTER]
init-hook=
import sys;
sys.path.insert(0, '${workspaceFolder}/src')
sys.path.insert(1, '${workspaceFolder}/packages');
disable=
invalid-name,
useless-super-delegation,
pointless-string-statement,
exec-used,
bad-whitespace,
missing-final-newline

@ -0,0 +1 @@
Subproject commit cb50f0dab93fccf39c091062f48899ab4ac53a51

@ -0,0 +1 @@
Subproject commit 89017ba158ed1d95319233fa5aedf3931c3b8b77

@ -1,12 +1,13 @@
import os import os
import sys import sys
import pprint import pprint
import dateutil
from zasd.filesystems.zfs import ZFSFilesystem #from zasd.filesystems.zfs import ZFSFilesystem
from zasd.apsched import AsyncIOPriorityScheduler #from zasd.apsched import AsyncIOPriorityScheduler
fs = ZFSFilesystem() #fs = ZFSFilesystem()
fs.label() #fs.label()
pprint.pprint(dict(os.environ), indent=2) pprint.pprint(dict(os.environ), indent=2)
pprint.pprint(sys.path) pprint.pprint(sys.path)

@ -15,7 +15,7 @@ from apscheduler.triggers.interval import IntervalTrigger # type: ignore
from zasd.apsched import AsyncIOPriorityScheduler, \ from zasd.apsched import AsyncIOPriorityScheduler, \
AsyncIOPriorityExecutor AsyncIOPriorityExecutor
from zasd.config_loader import load_config from zasd.config.loader import load_config
import zasd.config as config import zasd.config as config
from zasd.filesystems.zfs import ZFSFilesystem from zasd.filesystems.zfs import ZFSFilesystem
from zasd.filesystem import FilesystemRegistry from zasd.filesystem import FilesystemRegistry

@ -2,7 +2,7 @@
from typing import MutableMapping, Any from typing import MutableMapping, Any
from sys import argv, executable from sys import argv, executable, stdout
from os import environ, getcwd, sep as psep from os import environ, getcwd, sep as psep
from os.path import dirname, abspath, join as joinpath, \ from os.path import dirname, abspath, join as joinpath, \
expanduser, splitdrive, isfile expanduser, splitdrive, isfile
@ -28,6 +28,9 @@ import zasd.config as _config
_CONFIG_BASENAME = 'zasd.conf.py' _CONFIG_BASENAME = 'zasd.conf.py'
_CONFIG_FILENAMES = [_CONFIG_BASENAME, '.' + _CONFIG_BASENAME] _CONFIG_FILENAMES = [_CONFIG_BASENAME, '.' + _CONFIG_BASENAME]
_WARNING_WAIT = 3
#_WARNING_WAIT = 10
# Default configuration # Default configuration
_DEFAULT_CONFIG = dict( _DEFAULT_CONFIG = dict(
zfs_path = '/usr/local/bin/zfs', zfs_path = '/usr/local/bin/zfs',
@ -142,20 +145,23 @@ async def load_config():
log.debug('Loaded configuration') log.debug('Loaded configuration')
#if _config.get('log_level') <= logging.DEBUG: if _config.get('log_level') <= logging.DEBUG:
log.debug('') log.debug('')
for line in pprint.pformat(_config.reference()).split('\n'): for line in pprint.pformat(_config).split('\n'):
logging.debug(_config.get('tab_size') * ' ' + line) logging.debug(_config.get('tab_size') * ' ' + line)
log.debug('') log.debug('')
async def _warn_default(): async def _warn_default():
log.warning('') log.warning('')
log.warning('Waiting 10 seconds before loading default configuration...') log.warning(
'Waiting %s seconds before loading default configuration...',
_WARNING_WAIT)
log.warning('') log.warning('')
await asyncio.sleep(10) await asyncio.sleep(_WARNING_WAIT)
stdout.write('\r')
log.warning('Loading default configuration') log.warning('Loading default configuration')
log.warning('') log.warning('')
return deepcopy(_DEFAULT_CONFIG) _config.change(deepcopy(_DEFAULT_CONFIG))
# pylint: disable=dangerous-default-value # pylint: disable=dangerous-default-value
def _merge_configs(base, diff, path=[]): def _merge_configs(base, diff, path=[]):

@ -50,13 +50,13 @@ class DictObject:
@asyncio.coroutine @asyncio.coroutine
def repl(): def repl():
globals = dict( _globals = dict(
config = DictObject(config.reference(), 'config') config = DictObject(config.reference(), 'config')
) )
locals = dict() _locals = dict()
try: try:
yield from ptpython.repl.embed( yield from ptpython.repl.embed(
globals=globals, locals=locals, return_asyncio_coroutine=True, globals=_globals, locals=_locals, return_asyncio_coroutine=True,
patch_stdout=True, vi_mode=True) patch_stdout=True, vi_mode=True)
except EOFError: except EOFError:
asyncio.get_event_loop().stop() asyncio.get_event_loop().stop()

@ -7,13 +7,9 @@
"settings": { "settings": {
"editor.rulers": [80], "editor.rulers": [80],
"terminal.integrated.env.osx": { "terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}/src", "PYTHONPATH": "${workspaceFolder}/src:${workspaceFolder}/packages/apscheduler",
"MYPYPATH": "${workspaceFolder}/src" "MYPYPATH": "${workspaceFolder}/src:${workspaceFolder}/packages"
}, },
"python.linting.pylintArgs": [
"--init-hook", "import sys; sys.path.insert(0, '${workspaceFolder}/src')",
"-d", "invalid-name,useless-super-delegation,pointless-string-statement,exec-used,bad-whitespace,missing-final-newline"
],
"python.pythonPath": "/usr/local/bin/python" "python.pythonPath": "/usr/local/bin/python"
} }
} }
Loading…
Cancel
Save