Skip to content

Commit

Permalink
various bug fixes and refinements ...
Browse files Browse the repository at this point in the history
- fix formatting but in due for times that end in 0.0.
- do not store bogus size in latest file when size is not known.
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Oct 23, 2023
1 parent ad1c6fa commit 3926be7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion emborg/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def run(cls, command, args, settings, options):

if cmdline["--fast"]:
# update the date file
update_latest('create', settings.date_file)
update_latest('create', settings.date_file, repo_size=False)
return create_status

# check and prune the archives if requested
Expand Down
11 changes: 7 additions & 4 deletions emborg/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def when(time, relative_to=None, as_past=None, as_future=None):
>>> print(when(now.shift(seconds=3.5*60), as_future="{} from now"))
3.5 minutes from now
>>> print(when(now.shift(days=-2*365), as_past="{} in the past"))
2 years in the past
>>> print(when(now.shift(days=-2*365), as_past="last run {} ago"))
last run 2 years ago
"""

if relative_to is None:
Expand All @@ -139,7 +139,9 @@ def when(time, relative_to=None, as_past=None, as_future=None):

def fmt(dt, prec, unit):
if prec:
num = f'{dt:0.1f}'.rstrip('.0')
num = f'{dt:0.1f}'
if num.endswith('.0'):
num = num[:-2]
else:
num = f'{dt:0.0f}'
if num == '1':
Expand Down Expand Up @@ -209,7 +211,8 @@ def update_latest(command, path, repo_size=None):
if repo_size:
latest['repository size'] = repo_size
elif 'repository size' in latest:
del latest['repository size']
if repo_size is False:
del latest['repository size']

try:
nt.dump(latest, path)
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ dependencies = [
"requests",
]

[project.optional-dependencies]
avendesora = [
'avendesora',
]

[project.scripts]
emborg = "emborg.main:main"
emborg-overdue = "emborg.overdue:main"
Expand Down

0 comments on commit 3926be7

Please sign in to comment.