Skip to content

Commit

Permalink
Dep updates, --directory option, and fixes (#495)
Browse files Browse the repository at this point in the history
* Requirements updates

* Added --directory, and extra error handling.
  • Loading branch information
nicfit authored Sep 14, 2022
1 parent 4e55ab6 commit 25a9d99
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
42 changes: 27 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
#
# This file is autogenerated by pip-compile
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
# pip-compile --output-file=./requirements.txt requirements.txt
#
attrs==19.3.0 # via nicfit.py
certifi==2020.4.5.1 # via requests
chardet==4.0.0 # via requests
deprecation==2.0.7 # via nicfit.py
idna==2.8 # via requests
nicfit.py==0.8.7 # via -r requirements.txt
packaging==20.8 # via deprecation
pillow==7.1.1 # via -r requirements.txt
pylast==3.2.0 # via -r requirements.txt
pyparsing==2.4.7 # via packaging
pyyaml==5.3.1 # via nicfit.py
requests==2.22.0 # via -r requirements.txt
six==1.14.0 # via packaging
urllib3==1.25.8 # via requests
attrs==22.1.0
# via nicfit-py
certifi==2022.6.15.2
# via requests
chardet==3.0.4
# via requests
deprecation==2.1.0
# via nicfit-py
idna==2.8
# via requests
nicfit-py==0.8.7
# via -r requirements.txt
packaging==21.3
# via deprecation
pillow==9.2.0
# via -r requirements.txt
pylast==3.2.0
# via -r requirements.txt
pyparsing==3.0.9
# via packaging
pyyaml==6.0
# via nicfit-py
requests==2.22.0
# via -r requirements.txt
urllib3==1.25.11
# via requests
8 changes: 4 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Sphinx==2.3.1
check-manifest==0.40
flake8==3.7.9
Sphinx
check-manifest
flake8
git+https://github.com/nicfit/gitchangelog.git
ipdb==0.11
nicfit.py[cookiecutter]==0.8.7
Expand All @@ -10,4 +10,4 @@ pyaml==19.12.0
sphinx_rtd_theme==0.4.0
tox==3.14.3
twine==1.13.0
wheel==0.36.2
wheel==0.36.2
2 changes: 1 addition & 1 deletion requirements/main.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pillow==7.1.0
nicfit.py==0.8.7
pylast==3.2.0
requests==2.20.1
requests==2.20.1
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest==6.2.1
pytest-asyncio==0.10.0
pytest-cov==2.5.1
pytest-runner==5.2
pytest-runner==5.2
10 changes: 7 additions & 3 deletions topfm/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import argparse
from pathlib import Path
from textwrap import dedent
from datetime import datetime

Expand Down Expand Up @@ -90,6 +91,10 @@ def _addArguments(self, parser: argparse.ArgumentParser):
"help": "Show # of listens with each result."},
(artists_parser, albums_parser, tracks_parser),
),
(("-d", "--directory"), {"type": Path, "default": Path("."),
"help": "Directory to write outtput."},
(artists_parser, albums_parser),
),

]:
for p in parsers:
Expand Down Expand Up @@ -117,13 +122,12 @@ async def _handleAlbumsCmd(args, lastfm_user):
print(str(err))
return 4

assert img
if args.collage_name is None:
args.collage_name = \
f"[{lastfm_user}]{args.subcommand}_collage-{args.collage}-{args.period}"

collage_path = "{}.png".format(args.collage_name)
print("\nWriting {}...".format(collage_path))
collage_path = args.directory / f"{args.collage_name}.png"
print(f"\nWriting {collage_path}...")
img.save(collage_path)

if not args.no_image_view:
Expand Down
4 changes: 2 additions & 2 deletions topfm/collage.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def _addCover(image, cover_src, x, y, w, h):
def _imageFromCache(obj):
try:
cache_id = obj.get_mbid()
except pylast.WSError:
except (pylast.WSError, AttributeError):
# Fall thru...
cache_id = None

if not cache_id:
if cache_id is None:
cache_id = obj.get_name()
if hasattr(obj, "artist"):
cache_id += f"_{obj.artist.name}"
Expand Down

0 comments on commit 25a9d99

Please sign in to comment.