Merge branch 'linter' into dev
Add pylint to the project and fix some of its reports.
This commit is contained in:
@@ -26,4 +26,6 @@ docs = [
|
||||
"sphinx (>=9.1.0,<10.0.0)",
|
||||
"sphinx-rtd-theme (>=3.0.2,<4.0.0)",
|
||||
]
|
||||
|
||||
dev = [
|
||||
"pylint (>=4.0.4,<5.0.0)"
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from configparser import UNNAMED_SECTION
|
||||
from dataclasses import dataclass, field
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
import ipaddress
|
||||
import configparser
|
||||
@@ -30,8 +30,8 @@ class ServerConfig:
|
||||
if self.ip != "":
|
||||
try:
|
||||
ipaddress.ip_address(self.ip)
|
||||
except ValueError:
|
||||
raise ValueError("The provided ip address is invalid")
|
||||
except ValueError as e:
|
||||
raise ValueError("The provided ip address is invalid") from e
|
||||
|
||||
@dataclass
|
||||
class RootsConfig:
|
||||
@@ -120,13 +120,13 @@ def load_config(config_path:str) -> Config:
|
||||
Path(config.get(other_section, "cache_dir_path", fallback=DEFAULT_MISC_CACHE_DIR_PATH)).expanduser()
|
||||
)
|
||||
|
||||
args_bool = list()
|
||||
args_val = dict()
|
||||
args_bool = []
|
||||
args_val = {}
|
||||
if "Unison" in config.sections():
|
||||
for key, val in config.items("Unison"):
|
||||
if key in config["DEFAULT"].keys():
|
||||
continue
|
||||
elif val == "" or val == None:
|
||||
if val in ("", None):
|
||||
args_bool.append(key)
|
||||
else:
|
||||
args_val[key] = val
|
||||
|
||||
@@ -7,7 +7,7 @@ from unisync.argparser import create_argparser
|
||||
from unisync.runners import unisync_sync, unisync_add, unisync_mount
|
||||
from unisync.config import load_config
|
||||
from unisync.synchroniser import Synchroniser
|
||||
from unisync.paths import *
|
||||
from unisync.paths import PathsManager
|
||||
|
||||
def main():
|
||||
parser = create_argparser(unisync_sync, unisync_add, unisync_mount)
|
||||
@@ -15,14 +15,13 @@ def main():
|
||||
|
||||
config_path: Path = Path("~/.config/unisync/config.ini").expanduser()
|
||||
# Check if --config is set
|
||||
if cli_args.config != None and Path(cli_args.config).is_file():
|
||||
if cli_args.config is not None and Path(cli_args.config).is_file():
|
||||
config = load_config(cli_args.config)
|
||||
elif config_path.is_file():
|
||||
config = load_config(str(config_path))
|
||||
else:
|
||||
# TODO replace the next line with something to do if no config file is found
|
||||
config = load_config(str(config_path))
|
||||
pass
|
||||
|
||||
# TODO: make the command line arguments work and override the config options
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class PathsManager:
|
||||
Writes a list of new paths to the file
|
||||
"""
|
||||
current_paths = self.get_paths_to_sync()
|
||||
paths_to_add = list()
|
||||
paths_to_add = []
|
||||
# Check if one of the parent is already being synchronised
|
||||
# If so there is no need to add the child path
|
||||
for new_path in paths:
|
||||
|
||||
@@ -6,6 +6,7 @@ from unisync.paths import PathsManager
|
||||
from unisync.config import Config
|
||||
|
||||
def unisync_sync(synchroniser:Synchroniser, paths_manager:PathsManager, config: Config):
|
||||
del config # The function signature must be the same for all runners
|
||||
if synchroniser.create_ssh_master_connection() != 0:
|
||||
print("Connection failed quitting")
|
||||
return 1
|
||||
@@ -14,7 +15,7 @@ def unisync_sync(synchroniser:Synchroniser, paths_manager:PathsManager, config:
|
||||
synchroniser.sync_files(paths_manager.get_paths_to_sync())
|
||||
synchroniser.sync_links(paths_manager.get_paths_to_sync())
|
||||
|
||||
# TODO: check the config options and do or don't do the following
|
||||
# TODO check the config options and do or don't do the following
|
||||
synchroniser.update_links()
|
||||
#synchroniser.mount_remote_dir()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user