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