Skip to content

Commit c7d8670

Browse files
Ken KundertKen Kundert
authored andcommitted
remove debugging code
1 parent 9a00d53 commit c7d8670

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

src/borg/helpers/parseformat.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,20 @@ def interval(s):
134134
seconds_in_a_month = 31 * seconds_in_a_day
135135
seconds_in_a_year = 365 * seconds_in_a_day
136136
multiplier = dict(
137-
S = 1,
138-
M = seconds_in_a_minute,
139-
H = seconds_in_an_hour,
140-
d = seconds_in_a_day,
141-
w = seconds_in_a_week,
142-
m = seconds_in_a_month,
143-
y = seconds_in_a_year,
137+
y=seconds_in_a_year,
138+
m=seconds_in_a_month,
139+
w=seconds_in_a_week,
140+
d=seconds_in_a_day,
141+
H=seconds_in_an_hour,
142+
M=seconds_in_a_minute,
143+
S=1,
144144
)
145145

146146
if s.endswith(tuple(multiplier.keys())):
147147
number = s[:-1]
148148
suffix = s[-1]
149149
else:
150-
raise argparse.ArgumentTypeError(
151-
f'Unexpected time unit "{s[-1]}": choose from {", ".join(multiplier)}'
152-
)
150+
raise argparse.ArgumentTypeError(f'Unexpected time unit "{s[-1]}": choose from {", ".join(multiplier)}')
153151

154152
try:
155153
seconds = int(number) * multiplier[suffix]
@@ -579,10 +577,7 @@ def with_timestamp(self, timestamp):
579577
def location_validator(proto=None, other=False):
580578
def validator(text):
581579
try:
582-
try:
583-
loc = Location(text, other=other)
584-
except Exception as e:
585-
assert False
580+
loc = Location(text, other=other)
586581
except ValueError as err:
587582
raise argparse.ArgumentTypeError(str(err)) from None
588583
if proto is not None and loc.proto != proto:

src/borg/testsuite/helpers_test.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,18 @@ def test_prune_split_no_archives():
553553
assert kept_because == {}
554554

555555

556-
@pytest.mark.parametrize("timeframe, num_hours", [
557-
("5S", 5),
558-
("2M", 120),
559-
("1H", 3600),
560-
("1d", 86_400),
561-
("1w", 604_800),
562-
("1m", 2_678_400),
563-
("1y", 31_536_000)
564-
])
556+
@pytest.mark.parametrize(
557+
"timeframe, num_hours",
558+
[
559+
("5S", 5),
560+
("2M", 2 * 60),
561+
("1H", 60 * 60),
562+
("1d", 24 * 60 * 60),
563+
("1w", 7 * 24 * 68 * 60),
564+
("1m", 31 * 24 * 68 * 60),
565+
("1y", 365 * 24 * 68 * 60),
566+
],
567+
)
565568
def test_interval(timeframe, num_secs):
566569
assert interval(timeframe) == num_secs
567570

@@ -571,7 +574,7 @@ def test_interval(timeframe, num_secs):
571574
[
572575
("H", ('Unexpected number "": expected positive integer',)),
573576
("-1d", ('Unexpected number "-1": expected positive integer',)),
574-
("food", ('Unexpectedinterval number "foo": expected positive integer',)),
577+
("food", ('Unexpected number "foo": expected positive integer',)),
575578
],
576579
)
577580
def test_interval_time_unit(invalid_interval, error_tuple):

0 commit comments

Comments
 (0)