diff --git a/bdfr/__main__.py b/bdfr/__main__.py index 3a4dce3..193015e 100644 --- a/bdfr/__main__.py +++ b/bdfr/__main__.py @@ -182,7 +182,7 @@ def cli_completion(shell: str, uninstall: bool): Completion(shell).uninstall() return if shell not in ("all", "bash", "fish", "zsh"): - print(f"{shell} is not a valid option.") + print(f"{shell!r} is not a valid option.") print("Options: all, bash, fish, zsh") return if click.confirm(f"Would you like to install {shell} completions for BDFR"): diff --git a/bdfr/archiver.py b/bdfr/archiver.py index dd4b06e..7118ba6 100644 --- a/bdfr/archiver.py +++ b/bdfr/archiver.py @@ -94,7 +94,7 @@ class Archiver(RedditConnector): elif self.args.format == "yaml": self._write_entry_yaml(archive_entry) else: - raise ArchiverError(f"Unknown format {self.args.format} given") + raise ArchiverError(f"Unknown format {self.args.format!r} given") logger.info(f"Record for entry item {praw_item.id} written to disk") def _write_entry_json(self, entry: BaseArchiveEntry): diff --git a/bdfr/configuration.py b/bdfr/configuration.py index 4aba15f..b7e7a25 100644 --- a/bdfr/configuration.py +++ b/bdfr/configuration.py @@ -63,7 +63,7 @@ class Configuration(Namespace): self.parse_yaml_options(context.params["opts"]) for arg_key in context.params.keys(): if not hasattr(self, arg_key): - logger.warning(f"Ignoring an unknown CLI argument: {arg_key}") + logger.warning(f"Ignoring an unknown CLI argument: {arg_key!r}") continue val = context.params[arg_key] if val is None or val == (): @@ -84,6 +84,6 @@ class Configuration(Namespace): return for arg_key, val in opts.items(): if not hasattr(self, arg_key): - logger.warning(f"Ignoring an unknown YAML argument: {arg_key}") + logger.warning(f"Ignoring an unknown YAML argument: {arg_key!r}") continue setattr(self, arg_key, val) diff --git a/bdfr/connector.py b/bdfr/connector.py index 2a87c18..f01c752 100644 --- a/bdfr/connector.py +++ b/bdfr/connector.py @@ -115,7 +115,7 @@ class RedditConnector(metaclass=ABCMeta): self.args.filename_restriction_scheme = self.cfg_parser.get( "DEFAULT", "filename_restriction_scheme", fallback=None ) - logger.debug(f"Setting filename restriction scheme to '{self.args.filename_restriction_scheme}'") + logger.debug(f"Setting filename restriction scheme to {self.args.filename_restriction_scheme!r}") # Update config on disk with Path(self.config_location).open(mode="w") as file: self.cfg_parser.write(file) @@ -239,7 +239,7 @@ class RedditConnector(metaclass=ABCMeta): pattern = re.compile(r"^(?:https://www\.reddit\.com/)?(?:r/)?(.*?)/?$") match = re.match(pattern, subreddit) if not match: - raise errors.BulkDownloaderException(f"Could not find subreddit name in string {subreddit}") + raise errors.BulkDownloaderException(f"Could not find subreddit name in string {subreddit!r}") return match.group(1) @staticmethod @@ -285,7 +285,7 @@ class RedditConnector(metaclass=ABCMeta): ) ) logger.debug( - f'Added submissions from subreddit {reddit} with the search term "{self.args.search}"' + f"Added submissions from subreddit {reddit} with the search term {self.args.search!r}" ) else: out.append(self.create_filtered_listing_generator(reddit)) diff --git a/bdfr/download_filter.py b/bdfr/download_filter.py index 5814669..518c666 100644 --- a/bdfr/download_filter.py +++ b/bdfr/download_filter.py @@ -35,7 +35,7 @@ class DownloadFilter: combined_extensions = "|".join(self.excluded_extensions) pattern = re.compile(rf".*({combined_extensions})$") if re.match(pattern, resource_extension): - logger.log(9, f'Url "{resource_extension}" matched with "{pattern}"') + logger.log(9, f"Url {resource_extension!r} matched with {pattern!r}") return False else: return True @@ -46,7 +46,7 @@ class DownloadFilter: combined_domains = "|".join(self.excluded_domains) pattern = re.compile(rf"https?://.*({combined_domains}).*") if re.match(pattern, url): - logger.log(9, f'Url "{url}" matched with "{pattern}"') + logger.log(9, f"Url {url!r} matched with {pattern!r}") return False else: return True diff --git a/bdfr/file_name_formatter.py b/bdfr/file_name_formatter.py index 1eac6d1..942d5b5 100644 --- a/bdfr/file_name_formatter.py +++ b/bdfr/file_name_formatter.py @@ -37,7 +37,7 @@ class FileNameFormatter: restriction_scheme: Optional[str] = None, ): if not self.validate_string(file_format_string): - raise BulkDownloaderException(f'"{file_format_string}" is not a valid format string') + raise BulkDownloaderException(f"{file_format_string!r} is not a valid format string") self.file_format_string = file_format_string self.directory_format_string: list[str] = directory_format_string.split("/") self.time_format_string = time_format_string diff --git a/bdfr/oauth2.py b/bdfr/oauth2.py index 1051e5c..3cd4951 100644 --- a/bdfr/oauth2.py +++ b/bdfr/oauth2.py @@ -33,7 +33,7 @@ class OAuth2Authenticator: known_scopes.append("*") for scope in wanted_scopes: if scope not in known_scopes: - raise BulkDownloaderException(f"Scope {scope} is not known to reddit") + raise BulkDownloaderException(f"Scope {scope!r} is not known to reddit") @staticmethod def split_scopes(scopes: str) -> set[str]: