mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 11:01:45 +00:00
refactor and linting
This commit is contained in:
2
docs/config/config-file.md
vendored
2
docs/config/config-file.md
vendored
@@ -335,7 +335,7 @@ Dotdrop should be able to handle `toml` config file however this
|
||||
feature hasn't been extensively tested.
|
||||
A base [config.toml](/config.toml) is available to get started.
|
||||
|
||||
The script [yaml-to-toml.py](https://github.com/deadc0de6/dotdrop/blob/master/scripts/yaml-to-toml.py) allows to convert a `yaml` dotdrop
|
||||
The script [yaml_to_toml.py](https://github.com/deadc0de6/dotdrop/blob/master/scripts/yaml_to_toml.py) allows to convert a `yaml` dotdrop
|
||||
config file to `toml`.
|
||||
|
||||
For more see issue [#343](https://github.com/deadc0de6/dotdrop/issues/343).
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# pylint: disable-msg=C0103
|
||||
"""
|
||||
author: deadc0de6 (https://github.com/deadc0de6)
|
||||
Copyright (c) 2018, deadc0de6
|
||||
2
scripts/check-syntax.sh
vendored
2
scripts/check-syntax.sh
vendored
@@ -67,7 +67,7 @@ find . -name "*.py" -not -path "./dotdrop/*" | while read -r script; do
|
||||
--disable=R0914 \
|
||||
--disable=R0915 \
|
||||
--disable=R0913 \
|
||||
--disable=R0201 \
|
||||
--load-plugins pylint.extensions.no_self_use \
|
||||
"${script}"
|
||||
done
|
||||
|
||||
|
||||
4
scripts/check-tests-ng.sh
vendored
4
scripts/check-tests-ng.sh
vendored
@@ -32,13 +32,13 @@ workdir_tmp_exists="no"
|
||||
if [ -z "${GITHUB_WORKFLOW}" ]; then
|
||||
## local
|
||||
export COVERAGE_FILE=
|
||||
tests-ng/tests-launcher.py
|
||||
tests-ng/tests_launcher.py
|
||||
else
|
||||
## CI/CD
|
||||
export COVERAGE_FILE="${cur}/.coverage"
|
||||
# running multiple jobs in parallel sometimes
|
||||
# messes with the results on remote servers
|
||||
tests-ng/tests-launcher.py 1
|
||||
tests-ng/tests_launcher.py 1
|
||||
fi
|
||||
|
||||
# clear workdir
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# pylint: disable-msg=C0103
|
||||
"""
|
||||
author: deadc0de6 (https://github.com/deadc0de6)
|
||||
Copyright (c) 2022, deadc0de6
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
# pylint: disable-msg=C0103
|
||||
"""
|
||||
author: deadc0de6 (https://github.com/deadc0de6)
|
||||
Copyright (c) 2020, deadc0de6
|
||||
@@ -15,7 +14,7 @@ from concurrent import futures
|
||||
from halo import Halo
|
||||
|
||||
|
||||
LOG_FILE = '/tmp/dotdrop-tests-launcher.log'
|
||||
LOG_FILE = '/tmp/dotdrop-tests_launcher.log'
|
||||
GITHUB_ENV = 'GITHUB_WORKFLOW'
|
||||
|
||||
|
||||
@@ -21,6 +21,42 @@ from dotdrop.utils import header
|
||||
from dotdrop.linktypes import LinkTypes
|
||||
|
||||
|
||||
def fake_config(path, dotfiles, profile,
|
||||
dotpath, actions, transs):
|
||||
"""Create a fake config file"""
|
||||
with open(path, 'w', encoding='utf-8') as file:
|
||||
file.write('actions:\n')
|
||||
for action in actions:
|
||||
file.write(f' {action.key}: {action.action}\n')
|
||||
file.write('trans:\n')
|
||||
for trans in transs:
|
||||
file.write(f' {trans.key}: {trans.action}\n')
|
||||
file.write('config:\n')
|
||||
file.write(' backup: true\n')
|
||||
file.write(' create: true\n')
|
||||
file.write(f' dotpath: {dotpath}\n')
|
||||
file.write('dotfiles:\n')
|
||||
for dotfile in dotfiles:
|
||||
linkval = dotfile.link.name.lower()
|
||||
file.write(f' {dotfile.key}:\n')
|
||||
file.write(f' dst: {dotfile.dst}\n')
|
||||
file.write(f' src: {dotfile.src}\n')
|
||||
file.write(f' link: {linkval}\n')
|
||||
if len(dotfile.actions) > 0:
|
||||
file.write(' actions:\n')
|
||||
for action in dotfile.actions:
|
||||
file.write(f' - {action.key}\n')
|
||||
if dotfile.trans_r:
|
||||
for trans in dotfile.trans_r:
|
||||
file.write(f' trans_read: {trans.key}\n')
|
||||
file.write('profiles:\n')
|
||||
file.write(f' {profile}:\n')
|
||||
file.write(' dotfiles:\n')
|
||||
for dotfile in dotfiles:
|
||||
file.write(f' - {dotfile.key}\n')
|
||||
return path
|
||||
|
||||
|
||||
class TestInstall(unittest.TestCase):
|
||||
"""test case"""
|
||||
|
||||
@@ -39,41 +75,6 @@ exec bspwm
|
||||
exec bspwm
|
||||
'''
|
||||
|
||||
def fake_config(self, path, dotfiles, profile,
|
||||
dotpath, actions, transs):
|
||||
"""Create a fake config file"""
|
||||
with open(path, 'w', encoding='utf-8') as file:
|
||||
file.write('actions:\n')
|
||||
for action in actions:
|
||||
file.write(f' {action.key}: {action.action}\n')
|
||||
file.write('trans:\n')
|
||||
for trans in transs:
|
||||
file.write(f' {trans.key}: {trans.action}\n')
|
||||
file.write('config:\n')
|
||||
file.write(' backup: true\n')
|
||||
file.write(' create: true\n')
|
||||
file.write(f' dotpath: {dotpath}\n')
|
||||
file.write('dotfiles:\n')
|
||||
for dotfile in dotfiles:
|
||||
linkval = dotfile.link.name.lower()
|
||||
file.write(f' {dotfile.key}:\n')
|
||||
file.write(f' dst: {dotfile.dst}\n')
|
||||
file.write(f' src: {dotfile.src}\n')
|
||||
file.write(f' link: {linkval}\n')
|
||||
if len(dotfile.actions) > 0:
|
||||
file.write(' actions:\n')
|
||||
for action in dotfile.actions:
|
||||
file.write(f' - {action.key}\n')
|
||||
if dotfile.trans_r:
|
||||
for trans in dotfile.trans_r:
|
||||
file.write(f' trans_read: {trans.key}\n')
|
||||
file.write('profiles:\n')
|
||||
file.write(f' {profile}:\n')
|
||||
file.write(' dotfiles:\n')
|
||||
for dotfile in dotfiles:
|
||||
file.write(f' - {dotfile.key}\n')
|
||||
return path
|
||||
|
||||
def test_install(self):
|
||||
"""Test the install function"""
|
||||
|
||||
@@ -186,8 +187,8 @@ exec bspwm
|
||||
dotfiles = [dotfile1, dotfile2, dotfile3, dotfile4,
|
||||
dotfile5, dotfile6, dotfile7, dotfile8,
|
||||
dotfile9, dotfile10, ddot]
|
||||
self.fake_config(confpath, dotfiles,
|
||||
profile, tmp, [act1], [the_trans])
|
||||
fake_config(confpath, dotfiles,
|
||||
profile, tmp, [act1], [the_trans])
|
||||
conf = Cfg(confpath, profile, debug=True)
|
||||
self.assertTrue(conf is not None)
|
||||
|
||||
|
||||
@@ -14,6 +14,24 @@ from dotdrop.dotfile import Dotfile
|
||||
from dotdrop.dotdrop import cmd_install
|
||||
|
||||
|
||||
def fake_config(path, dotfile, profile, dotpath):
|
||||
"""Create a fake config file"""
|
||||
with open(path, 'w', encoding='utf-8') as file:
|
||||
file.write('config:\n')
|
||||
file.write(' backup: true\n')
|
||||
file.write(' create: true\n')
|
||||
file.write(f' dotpath: {dotpath}\n')
|
||||
file.write('dotfiles:\n')
|
||||
file.write(f' {dotfile.key}:\n')
|
||||
file.write(f' dst: {dotfile.dst}\n')
|
||||
file.write(f' src: {dotfile.src}\n')
|
||||
file.write('profiles:\n')
|
||||
file.write(f' {profile}:\n')
|
||||
file.write(' dotfiles:\n')
|
||||
file.write(f' - {dotfile.key}\n')
|
||||
return path
|
||||
|
||||
|
||||
class TestJhelpers(unittest.TestCase):
|
||||
"""test case"""
|
||||
|
||||
@@ -56,23 +74,6 @@ basename: c
|
||||
dirname: /tmp/a/b
|
||||
'''
|
||||
|
||||
def fake_config(self, path, dotfile, profile, dotpath):
|
||||
"""Create a fake config file"""
|
||||
with open(path, 'w', encoding='utf-8') as file:
|
||||
file.write('config:\n')
|
||||
file.write(' backup: true\n')
|
||||
file.write(' create: true\n')
|
||||
file.write(f' dotpath: {dotpath}\n')
|
||||
file.write('dotfiles:\n')
|
||||
file.write(f' {dotfile.key}:\n')
|
||||
file.write(f' dst: {dotfile.dst}\n')
|
||||
file.write(f' src: {dotfile.src}\n')
|
||||
file.write('profiles:\n')
|
||||
file.write(f' {profile}:\n')
|
||||
file.write(' dotfiles:\n')
|
||||
file.write(f' - {dotfile.key}\n')
|
||||
return path
|
||||
|
||||
def test_jhelpers(self):
|
||||
"""Test the install function"""
|
||||
|
||||
@@ -96,7 +97,7 @@ dirname: /tmp/a/b
|
||||
# generate the config and stuff
|
||||
profile = get_string(5)
|
||||
confpath = os.path.join(tmp, self.CONFIG_NAME)
|
||||
self.fake_config(confpath, dotfile1, profile, tmp)
|
||||
fake_config(confpath, dotfile1, profile, tmp)
|
||||
conf = CfgAggregator(confpath, profile, debug=True)
|
||||
self.assertTrue(conf is not None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user