Skip to content

Commit d25e0f2

Browse files
committed
Reformat files with black
1 parent deb4628 commit d25e0f2

File tree

8 files changed

+82
-25
lines changed

8 files changed

+82
-25
lines changed

RESTIC_SOURCE_FILES/update_restic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def download_restic_binaries(arch: str = "amd64") -> bool:
3737
if response.status_code != 200:
3838
print(f"ERROR: Cannot get latest restic release: {response.status_code}")
3939
print("RESPONSE TEXT: ", response.text)
40-
json_response = json.loads(response.text);
40+
json_response = json.loads(response.text)
4141
try:
4242
current_version = json_response["tag_name"].lstrip("v")
4343
except KeyError:
@@ -142,7 +142,9 @@ def download_restic_binaries_for_arch():
142142
if not download_restic_binaries("amd64") or not download_restic_binaries("386"):
143143
return False
144144
elif sys.platform.lower() == "darwin":
145-
if not download_restic_binaries("arm64") or not download_restic_binaries("amd64"):
145+
if not download_restic_binaries("arm64") or not download_restic_binaries(
146+
"amd64"
147+
):
146148
return False
147149
else:
148150
if (

bin/compile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ def compile(
372372
dry_run=args.dry_run,
373373
)
374374
else:
375-
print(f"ERROR: Cannot sign windows executable: {SIGN_EXTERNALY} {ev_cert_data}")
375+
print(
376+
f"ERROR: Cannot sign windows executable: {SIGN_EXTERNALY} {ev_cert_data}"
377+
)
376378
errors = True
377379

378380
if not onefile:

npbackup/configuration.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,8 @@ def _migrate_compression_3_0_0_to_3_0_4(
898898
f"{object_type} {object_name} has no compression, skipping migration"
899899
)
900900
return full_config
901-
902-
def _migrate_presets_3_0_4_to_3_1_0(
903-
full_config: dict
904-
):
901+
902+
def _migrate_presets_3_0_4_to_3_1_0(full_config: dict):
905903
if full_config.g("presets") is None:
906904
full_config.s("presets", get_default_config().g("presets"))
907905
logger.info("Migrated presets to new config structure")
@@ -952,9 +950,7 @@ def _load_config_file(config_file: Path) -> Union[bool, dict]:
952950
f"Config file {config_file} has no configuration version. Is this a valid npbackup config file?"
953951
)
954952
return False
955-
if conf_version < version_parse(
956-
MIN_MIGRATABLE_CONF_VERSION
957-
):
953+
if conf_version < version_parse(MIN_MIGRATABLE_CONF_VERSION):
958954
logger.critical(
959955
f"Config file {config_file} version {str(conf_version)} is not in required version range min={MIN_MIGRATABLE_CONF_VERSION}"
960956
)
@@ -963,7 +959,7 @@ def _load_config_file(config_file: Path) -> Union[bool, dict]:
963959
logger.critical(
964960
f"Config file {config_file} version {str(conf_version)} is not in required version range max={MAX_CONF_VERSION}. We will try to load it nevertheless."
965961
)
966-
962+
967963
if conf_version < version_parse(CURRENT_CONF_VERSION):
968964
full_config = _migrate_config_dict(
969965
full_config, str(conf_version), CURRENT_CONF_VERSION

npbackup/core/jobs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def _get_count(file: str) -> Optional[int]:
6565
# We may not have read privileges
6666
logger.error(f"Cannot read {job_name} counter file {file}: {exc}")
6767
except ValueError as exc:
68-
logger.error(f"Bogus {job_name} counter with value {count} in {file}: {exc}")
68+
logger.error(
69+
f"Bogus {job_name} counter with value {count} in {file}: {exc}"
70+
)
6971
return 0
7072

7173
path_list = [

npbackup/core/runner.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,9 @@ def restore(self, snapshot: str, target: str, restore_includes: List[str]) -> bo
16021602
except KeyError:
16031603
pass
16041604
except ValueError:
1605-
self.write_logs("Bogus additional restore parameters given", level="warning")
1605+
self.write_logs(
1606+
"Bogus additional restore parameters given", level="warning"
1607+
)
16061608

16071609
return self.restic_runner.restore(
16081610
snapshot=snapshot,
@@ -1637,7 +1639,9 @@ def forget(
16371639
f"Checking time against ntp server {ntp_server}", level="info"
16381640
)
16391641
offset = get_ntp_offset(ntp_server)
1640-
if offset in [False, None, ""] or offset > float(MAX_ALLOWED_NTP_OFFSET):
1642+
if offset in [False, None, ""] or offset > float(
1643+
MAX_ALLOWED_NTP_OFFSET
1644+
):
16411645
if offset in [False, None, ""]:
16421646
msg = f"Offset cannot be obtained from NTP server {ntp_server}"
16431647
elif offset > float(MAX_ALLOWED_NTP_OFFSET):

resources/customization.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,49 @@
3535
# SimpleGUI theme see with print(sg.theme_list())
3636
# Valid list: ['Black', 'BlueMono', 'BluePurple', 'BrightColors', 'BrownBlue', 'Dark', 'Dark2', 'DarkAmber', 'DarkBlack', 'DarkBlack1', 'DarkBlue', 'DarkBlue1', 'DarkBlue10', 'DarkBlue11', 'DarkBlue12', 'DarkBlue13', 'DarkBlue14', 'DarkBlue15', 'DarkBlue16', 'DarkBlue17', 'DarkBlue2', 'DarkBlue3', 'DarkBlue4', 'DarkBlue5', 'DarkBlue6', 'DarkBlue7', 'DarkBlue8', 'DarkBlue9', 'DarkBrown', 'DarkBrown1', 'DarkBrown2', 'DarkBrown3', 'DarkBrown4', 'DarkBrown5', 'DarkBrown6', 'DarkBrown7', 'DarkGreen', 'DarkGreen1', 'DarkGreen2', 'DarkGreen3', 'DarkGreen4', 'DarkGreen5', 'DarkGreen6', 'DarkGreen7', 'DarkGrey', 'DarkGrey1', 'DarkGrey10', 'DarkGrey11', 'DarkGrey12', 'DarkGrey13', 'DarkGrey14', 'DarkGrey15', 'DarkGrey2', 'DarkGrey3', 'DarkGrey4', 'DarkGrey5', 'DarkGrey6', 'DarkGrey7', 'DarkGrey8', 'DarkGrey9', 'DarkPurple', 'DarkPurple1', 'DarkPurple2', 'DarkPurple3', 'DarkPurple4', 'DarkPurple5', 'DarkPurple6', 'DarkPurple7', 'DarkRed', 'DarkRed1', 'DarkRed2', 'DarkTanBlue', 'DarkTeal', 'DarkTeal1', 'DarkTeal10', 'DarkTeal11', 'DarkTeal12', 'DarkTeal2', 'DarkTeal3', 'DarkTeal4', 'DarkTeal5', 'DarkTeal6', 'DarkTeal7', 'DarkTeal8', 'DarkTeal9', 'Default', 'Default1', 'DefaultNoMoreNagging', 'GrayGrayGray', 'Green', 'GreenMono', 'GreenTan', 'HotDogStand', 'Kayak', 'LightBlue', 'LightBlue1', 'LightBlue2', 'LightBlue3', 'LightBlue4', 'LightBlue5', 'LightBlue6', 'LightBlue7', 'LightBrown', 'LightBrown1', 'LightBrown10', 'LightBrown11', 'LightBrown12', 'LightBrown13', 'LightBrown2', 'LightBrown3', 'LightBrown4', 'LightBrown5', 'LightBrown6', 'LightBrown7', 'LightBrown8', 'LightBrown9', 'LightGray1', 'LightGreen', 'LightGreen1', 'LightGreen10', 'LightGreen2', 'LightGreen3', 'LightGreen4', 'LightGreen5', 'LightGreen6', 'LightGreen7', 'LightGreen8', 'LightGreen9', 'LightGrey', 'LightGrey1', 'LightGrey2', 'LightGrey3', 'LightGrey4', 'LightGrey5', 'LightGrey6', 'LightPurple', 'LightTeal', 'LightYellow', 'Material1', 'Material2', 'NeutralBlue', 'Purple', 'Python', 'PythonPlus', 'Reddit', 'Reds', 'SandyBeach', 'SystemDefault', 'SystemDefault1', 'SystemDefaultForReal', 'Tan', 'TanBlue', 'TealMono', 'Topanga']
3737
LOOK_AND_FEEL_TABLE = {
38-
'CLEAR': {'BACKGROUND': '#ffffff','TEXT': '#1a1a1b','INPUT': '#dae0e6','TEXT_INPUT': '#222222','SCROLL': '#a5a4a4','BUTTON': ('#333333', '#ffffff'),'PROGRESS': ('#015bbb', '#fed500'),'BORDER': 1,'SLIDER_DEPTH': 0,'PROGRESS_DEPTH': 0,'ACCENT1': '#ff5414','ACCENT2': '#33a8ff','ACCENT3': '#dbf0ff',},
39-
'CLEAR2' : {'BACKGROUND': '#ffffff','TEXT': '#1a1a1b','INPUT': '#dae0e6','TEXT_INPUT': '#222222','SCROLL': '#a5a4a4','BUTTON': ('#333333', "#097ad1"),'PROGRESS': ('#015bbb', '#fed500'),'BORDER': 1,'SLIDER_DEPTH': 0,'PROGRESS_DEPTH': 0,'ACCENT1': '#ff5414','ACCENT2': '#33a8ff','ACCENT3': '#dbf0ff',},
40-
'DARK': {'BACKGROUND': '#001d3c','TEXT': '#ffffff','INPUT': '#015bbb','TEXT_INPUT': '#fed500','SCROLL': '#015bbb','BUTTON': ('#fed500', '#001d3c'),'PROGRESS': ('#015bbb', '#fed500'),'BORDER': 1,'SLIDER_DEPTH': 1,'PROGRESS_DEPTH': 0,},
41-
}
38+
"CLEAR": {
39+
"BACKGROUND": "#ffffff",
40+
"TEXT": "#1a1a1b",
41+
"INPUT": "#dae0e6",
42+
"TEXT_INPUT": "#222222",
43+
"SCROLL": "#a5a4a4",
44+
"BUTTON": ("#333333", "#ffffff"),
45+
"PROGRESS": ("#015bbb", "#fed500"),
46+
"BORDER": 1,
47+
"SLIDER_DEPTH": 0,
48+
"PROGRESS_DEPTH": 0,
49+
"ACCENT1": "#ff5414",
50+
"ACCENT2": "#33a8ff",
51+
"ACCENT3": "#dbf0ff",
52+
},
53+
"CLEAR2": {
54+
"BACKGROUND": "#ffffff",
55+
"TEXT": "#1a1a1b",
56+
"INPUT": "#dae0e6",
57+
"TEXT_INPUT": "#222222",
58+
"SCROLL": "#a5a4a4",
59+
"BUTTON": ("#333333", "#097ad1"),
60+
"PROGRESS": ("#015bbb", "#fed500"),
61+
"BORDER": 1,
62+
"SLIDER_DEPTH": 0,
63+
"PROGRESS_DEPTH": 0,
64+
"ACCENT1": "#ff5414",
65+
"ACCENT2": "#33a8ff",
66+
"ACCENT3": "#dbf0ff",
67+
},
68+
"DARK": {
69+
"BACKGROUND": "#001d3c",
70+
"TEXT": "#ffffff",
71+
"INPUT": "#015bbb",
72+
"TEXT_INPUT": "#fed500",
73+
"SCROLL": "#015bbb",
74+
"BUTTON": ("#fed500", "#001d3c"),
75+
"PROGRESS": ("#015bbb", "#fed500"),
76+
"BORDER": 1,
77+
"SLIDER_DEPTH": 1,
78+
"PROGRESS_DEPTH": 0,
79+
},
80+
}
4281

4382
SIMPLEGUI_THEME = "CLEAR"
4483
SIMPLEGUI_DARK_THEME = "DARK"

resources/update_custom_resources.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ def update_custom_icons():
6868
print(f"Updating {var_name} with {file_path}")
6969
encoded_b64 = image_to_data_url(file_path)
7070
customization = re.sub(
71-
f'\n{var_name} = .*', f'\n{var_name} = b"{encoded_b64}"', customization, re.MULTILINE
71+
f"\n{var_name} = .*",
72+
f'\n{var_name} = b"{encoded_b64}"',
73+
customization,
74+
re.MULTILINE,
7275
)
7376
else:
7477
print("No file found for", var_name)

tests/test_npbackup-cli.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565

6666
# File we will request in dump mode
6767
DUMP_FILE = "__version__.py"
68-
DUMP_FILE_RESTORED = Path(tempfile.gettempdir()).absolute().joinpath("restored__version__.py")
68+
DUMP_FILE_RESTORED = (
69+
Path(tempfile.gettempdir()).absolute().joinpath("restored__version__.py")
70+
)
6971
DUMP_FILE_RESTIC_PATH = "/npbackup/npbackup/__version__.py"
7072

7173

@@ -92,7 +94,7 @@ def __str__(self):
9294
if self._bytes_io.getvalue():
9395
return self._bytes_io.getvalue()
9496
return self._string_io.getvalue()
95-
97+
9698

9799
def running_on_github_actions():
98100
"""
@@ -148,7 +150,9 @@ def test_download_restic_binaries():
148150
github_actions = running_on_github_actions()
149151
print(f"DOWNLOAD result: {result}, github actions: {github_actions}")
150152
if github_actions:
151-
assert True, "Allow restic download failure on github actions because of rate limiting"
153+
assert (
154+
True
155+
), "Allow restic download failure on github actions because of rate limiting"
152156
else:
153157
assert result is True, "Could not download restic binaries"
154158

@@ -202,6 +206,7 @@ def test_npbackup_cli_init():
202206
assert "Repo initialized successfully" in str(logs), "Repo init failed"
203207
os.environ["_DEBUG"] = "False"
204208

209+
205210
def test_npbackup_cli_has_no_recent_snapshots():
206211
"""
207212
After init, we should not have recent snapshots
@@ -215,7 +220,9 @@ def test_npbackup_cli_has_no_recent_snapshots():
215220
print(str(logs))
216221
json_logs = json.loads(str(logs))
217222
assert json_logs["result"] == False, "Should not have recent snapshots"
218-
assert json_logs["operation"] == "has_recent_snapshot", "Bogus operation name, probably failed somewhere earlier"
223+
assert (
224+
json_logs["operation"] == "has_recent_snapshot"
225+
), "Bogus operation name, probably failed somewhere earlier"
219226

220227

221228
def test_npbackup_cli_create_backup():
@@ -494,7 +501,6 @@ def test_npbackup_cli_raw():
494501
assert False, "Did not find dump file in raw ls output"
495502

496503

497-
498504
def test_npbackup_cli_dump():
499505
"""
500506
Don't use RedirectedStdout since dump will output binary data
@@ -512,7 +518,10 @@ def test_npbackup_cli_dump():
512518
original_sha = sha256sum(os.path.join("..", "npbackup", "npbackup", DUMP_FILE))
513519
restored_sha = sha256sum(DUMP_FILE_RESTORED)
514520

515-
assert original_sha == restored_sha, "Dumped file has different sha256sum than original file"
521+
assert (
522+
original_sha == restored_sha
523+
), "Dumped file has different sha256sum than original file"
524+
516525

517526
if __name__ == "__main__":
518527
test_download_restic_binaries()

0 commit comments

Comments
 (0)