main : Use pathlib instead of os.path
Removes every use of os.path and replaces it with the equivalent pathlib method. Allows to avoid importing os.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
# Copyright (C) 2025-2026 Paul Retourné
|
# Copyright (C) 2025-2026 Paul Retourné
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from unisync.argparser import create_argparser
|
from unisync.argparser import create_argparser
|
||||||
@@ -14,15 +13,15 @@ def main():
|
|||||||
parser = create_argparser(unisync_sync, unisync_add, unisync_mount)
|
parser = create_argparser(unisync_sync, unisync_add, unisync_mount)
|
||||||
cli_args = parser.parse_args()
|
cli_args = parser.parse_args()
|
||||||
|
|
||||||
config_path = os.path.expanduser("~/.config/unisync/config.ini")
|
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 os.path.isfile(cli_args.config):
|
if cli_args.config != None and Path(cli_args.config).is_file():
|
||||||
config = load_config(cli_args.config)
|
config = load_config(cli_args.config)
|
||||||
elif os.path.isfile(config_path):
|
elif config_path.is_file():
|
||||||
config = load_config(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(config_path)
|
config = load_config(str(config_path))
|
||||||
pass
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user