From 06356fc40fd814d9817a7aa7b44d99943e35acd9 Mon Sep 17 00:00:00 2001 From: JoeLametta Date: Wed, 26 May 2021 08:07:07 +0000 Subject: [PATCH] README update, code linting changes - PEP8 fix - Remove useless parens - Docstring fixes - RegEX: remove unneeded escape character - accuraterip-checksum: output usage to stderr in case of wrong invocation Signed-off-by: JoeLametta --- README.md | 8 ++++---- man/README.md | 2 +- scripts/accuraterip-checksum | 4 +++- whipper/common/config.py | 2 +- whipper/common/drive.py | 2 +- whipper/common/path.py | 4 ++-- whipper/common/program.py | 2 ++ whipper/test/test_result_logger.py | 4 ++-- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a0cc66b..d780576 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ alias whipper="docker run -ti --rm --device=/dev/cdrom \ whipperteam/whipper" ``` -You should put this e.g. into your `.bash_aliases`. Also keep in mind to substitute the path definitions to something that fits to your needs (e.g. replace `… -v ${PWD}/output:/output …` with `… -v ${HOME}/ripped:/output \ …`). +You should put this e.g. into your `.bash_aliases`. Also keep in mind to replace the path definitions to something that fits to your needs (e.g. replace `… -v ${PWD}/output:/output …` with `… -v ${HOME}/ripped:/output \ …`). Essentially, what this does is to map the /home/worker/.config/whipper and ${PWD}/output (or whatever other directory you specified) on your host system to locations inside the Docker container where the files can be written and read. These directories need to exist on your system before you can run the container: @@ -103,7 +103,7 @@ Essentially, what this does is to map the /home/worker/.config/whipper and ${PWD Please note that the example alias written above only provides access to a single disc drive: if you've got many you will need to customise it in order to use all of them in whipper's Docker container. -Finally you can test the correct installation as such: +Finally, you can test the correct installation as such: ``` whipper -v @@ -362,7 +362,7 @@ To make a good faith effort to ensure licensing criteria are met, this project r The Developer Certificate of Origin (DCO) is a document that certifies you own and/or have the right to contribute the work and license it appropriately. The DCO is used instead of a _much more annoying_ [CLA (Contributor License Agreement)](https://en.wikipedia.org/wiki/Contributor_License_Agreement). With the DCO, you retain copyright of your own work :). The DCO originated in the Linux community, and is used by other projects like Git and Docker. -The DCO agreement is shown below and it's also available online: [HERE](https://developercertificate.org/). +The DCO agreement is shown below, and it's also available online: [HERE](https://developercertificate.org/). ``` Developer Certificate of Origin @@ -425,7 +425,7 @@ WHIPPER_DEBUG=DEBUG WHIPPER_LOGFILE=whipper.log whipper offset find gzip whipper.log ``` -And attach the gzipped log file to your bug report. +Finally, attach the gzipped log file to your bug report. Without `WHIPPER_LOGFILE` set, logging messages will go to stderr. `WHIPPER_DEBUG` accepts a string of the [default python logging levels](https://docs.python.org/3/library/logging.html#logging-levels). diff --git a/man/README.md b/man/README.md index 637ec03..cbda9ef 100644 --- a/man/README.md +++ b/man/README.md @@ -3,7 +3,7 @@ line tool provided by the Python `docutils` project: rst2man whipper.rst whipper.1 -Alternatively, you can also build all of the man pages in this directory at the +Alternatively, you can also build all the man pages in this directory at the same time by running (requires `make`): make diff --git a/scripts/accuraterip-checksum b/scripts/accuraterip-checksum index 52a5ade..cf509e0 100644 --- a/scripts/accuraterip-checksum +++ b/scripts/accuraterip-checksum @@ -21,7 +21,9 @@ elif len(sys.argv) == 5: use_v1 = False if use_v1 is None: - print('Syntax: accuraterip-checksum [--version / --accuraterip-v1 / --accuraterip-v2 (default)] filename track_number total_tracks') + print('Syntax: accuraterip-checksum [--version / --accuraterip-v1 / ' + '--accuraterip-v2 (default)] filename track_number total_tracks', + file=sys.stderr) raise SystemExit(1) filename = sys.argv[offset + 1] diff --git a/whipper/common/config.py b/whipper/common/config.py index ae4b745..45744e2 100644 --- a/whipper/common/config.py +++ b/whipper/common/config.py @@ -37,7 +37,7 @@ class Config: self._path = path or directory.config_path() self._parser = configparser.ConfigParser( - inline_comment_prefixes=(';')) + inline_comment_prefixes=';') self.open() diff --git a/whipper/common/drive.py b/whipper/common/drive.py index 6da29bc..ee12ad8 100644 --- a/whipper/common/drive.py +++ b/whipper/common/drive.py @@ -88,7 +88,7 @@ def get_cdrom_drive_status(drive_path): - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/cdrom.h # noqa: E501 :param drive_path: path to the disc drive - :type device: str + :type drive_path: str :returns: return code of the 'CDROM_DRIVE_STATUS' ioctl :rtype: int """ diff --git a/whipper/common/path.py b/whipper/common/path.py index 94cad17..3dbb6ef 100644 --- a/whipper/common/path.py +++ b/whipper/common/path.py @@ -47,9 +47,9 @@ class PathFilter: if path[:1] == '.': # Slicing tolerant to empty strings path = R_CH + path[1:] if self._posix: - path = re.sub(r'[\/\x00]', R_CH, path) + path = re.sub(r'[/\x00]', R_CH, path) if self._vfat: - path = re.sub(r'[\x00-\x1F\x7F\"\*\/\:\<\>\?\\\|]', R_CH, path) + path = re.sub(r'[\x00-\x1F\x7F\"*/:<>?\\|]', R_CH, path) if self._whitespace: path = re.sub(r'\s', R_CH, path) if self._printable: diff --git a/whipper/common/program.py b/whipper/common/program.py index 6f6102b..5af4419 100644 --- a/whipper/common/program.py +++ b/whipper/common/program.py @@ -578,6 +578,8 @@ class Program: :type overread: bool :param what: a string representing what's being read; e.g. Track :type what: str or None + :param coverArtPath: path to the downloaded cover art file + :type coverArtPath: str or None """ if trackResult.number == 0: start, stop = self.getHTOA() diff --git a/whipper/test/test_result_logger.py b/whipper/test/test_result_logger.py index 33aeed9..3381aec 100644 --- a/whipper/test/test_result_logger.py +++ b/whipper/test/test_result_logger.py @@ -147,7 +147,7 @@ class LoggerTestCase(unittest.TestCase): ] created_by_re = re.compile(( r'Log created by: whipper ' - r'[\d]+\.[\d]+\.[\d]+(\+d\d{8}|\.dev[\w\.\+]+)? ' + r'[\d]+\.[\d]+\.[\d]+(\+d\d{8}|\.dev[\w.+]+)? ' r'\(internal logger\)' )) for versionScheme in versionSchemes: @@ -156,7 +156,7 @@ class LoggerTestCase(unittest.TestCase): actualLines[1], re.compile(( r'Log creation date: ' - r'20[\d]{2}\-[\d]{2}\-[\d]{2}T[\d]{2}:[\d]{2}:[\d]{2}Z' + r'20[\d]{2}-[\d]{2}-[\d]{2}T[\d]{2}:[\d]{2}:[\d]{2}Z' )) )