mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 21:24:15 +00:00
linting
This commit is contained in:
@@ -31,14 +31,9 @@ KEY = 'dotfiles'
|
|||||||
ENTRY = 'link'
|
ENTRY = 'link'
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def change_link(path, value, ignores):
|
||||||
"""entry point"""
|
"""change link value"""
|
||||||
args = docopt(USAGE)
|
with open(path, 'r', encoding='utf-8') as file:
|
||||||
path = os.path.expanduser(args['<config.yaml>'])
|
|
||||||
value = args['--value']
|
|
||||||
ignores = args['--ignore']
|
|
||||||
|
|
||||||
with open(path, 'r') as file:
|
|
||||||
content = yaml(typ='safe').load(file)
|
content = yaml(typ='safe').load(file)
|
||||||
for k, val in content[KEY].items():
|
for k, val in content[KEY].items():
|
||||||
if k in ignores:
|
if k in ignores:
|
||||||
@@ -54,5 +49,14 @@ def main():
|
|||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""entry point"""
|
||||||
|
args = docopt(USAGE)
|
||||||
|
path = os.path.expanduser(args['<config.yaml>'])
|
||||||
|
value = args['--value']
|
||||||
|
ignores = args['--ignore']
|
||||||
|
change_link(path, value, ignores)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
author: deadc0de6 (https://github.com/deadc0de6)
|
author: deadc0de6 (https://github.com/deadc0de6)
|
||||||
Copyright (c) 2022, deadc0de6
|
Copyright (c) 2022, deadc0de6
|
||||||
@@ -17,13 +16,13 @@ import toml
|
|||||||
def yaml_load(path):
|
def yaml_load(path):
|
||||||
"""load from yaml"""
|
"""load from yaml"""
|
||||||
with open(path, 'r', encoding='utf8') as file:
|
with open(path, 'r', encoding='utf8') as file:
|
||||||
data = yaml()
|
cont = yaml()
|
||||||
data.typ = 'rt'
|
cont.typ = 'rt'
|
||||||
content = data.load(file)
|
content = cont.load(file)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
def replace_None(content):
|
def replace_none(content):
|
||||||
"""replace any occurence of None with empty string"""
|
"""replace any occurence of None with empty string"""
|
||||||
n = {}
|
n = {}
|
||||||
for k in content:
|
for k in content:
|
||||||
@@ -35,7 +34,7 @@ def replace_None(content):
|
|||||||
n[k] = ""
|
n[k] = ""
|
||||||
continue
|
continue
|
||||||
if isinstance(content[k], dict):
|
if isinstance(content[k], dict):
|
||||||
n[k] = replace_None(content[k])
|
n[k] = replace_none(content[k])
|
||||||
continue
|
continue
|
||||||
n[k] = content[k]
|
n[k] = content[k]
|
||||||
return n
|
return n
|
||||||
@@ -48,11 +47,10 @@ def toml_dump(content):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print("usage: {} <yaml-config-path>".format(sys.argv[0]))
|
print(f"usage: {sys.argv[0]} <yaml-config-path>")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
path = sys.argv[1]
|
data = yaml_load(sys.argv[1])
|
||||||
content = yaml_load(path)
|
data = replace_none(data)
|
||||||
content = replace_None(content)
|
out = toml_dump(data)
|
||||||
out = toml_dump(content)
|
|
||||||
print(out)
|
print(out)
|
||||||
|
|||||||
14
test-syntax.sh
vendored
14
test-syntax.sh
vendored
@@ -28,6 +28,7 @@ pycodestyle scripts/
|
|||||||
echo "testing with pyflakes"
|
echo "testing with pyflakes"
|
||||||
pyflakes dotdrop/
|
pyflakes dotdrop/
|
||||||
pyflakes tests/
|
pyflakes tests/
|
||||||
|
pyflakes scripts/
|
||||||
|
|
||||||
# pylint
|
# pylint
|
||||||
echo "testing with pylint"
|
echo "testing with pylint"
|
||||||
@@ -51,6 +52,19 @@ pylint \
|
|||||||
--disable=R0904 \
|
--disable=R0904 \
|
||||||
dotdrop/
|
dotdrop/
|
||||||
|
|
||||||
|
# C0103: invalid-name
|
||||||
|
pylint \
|
||||||
|
--disable=R0902 \
|
||||||
|
--disable=R0913 \
|
||||||
|
--disable=R0903 \
|
||||||
|
--disable=R0914 \
|
||||||
|
--disable=R0915 \
|
||||||
|
--disable=R0912 \
|
||||||
|
--disable=R0911 \
|
||||||
|
--disable=R0904 \
|
||||||
|
--disable=C0103 \
|
||||||
|
scripts/
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
exceptions="save_uservariables_name\|@@\|diff_cmd\|original,\|modified,"
|
exceptions="save_uservariables_name\|@@\|diff_cmd\|original,\|modified,"
|
||||||
# f-string errors and missing f literal
|
# f-string errors and missing f literal
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from tests.helpers import create_dir, get_string, get_tempdir, \
|
|||||||
|
|
||||||
|
|
||||||
class TestListings(unittest.TestCase):
|
class TestListings(unittest.TestCase):
|
||||||
|
"""listing test"""
|
||||||
|
|
||||||
CONFIG_BACKUP = False
|
CONFIG_BACKUP = False
|
||||||
CONFIG_CREATE = True
|
CONFIG_CREATE = True
|
||||||
|
|||||||
Reference in New Issue
Block a user