add options to further suppress output

This commit adds the ability to further suppress output for accounts
with no deleted toots using the `-qq` flag. It alsoadds the option
to completely suppress logging (excluding exceptions) by using the
`-qqq` flag
This commit is contained in:
Mohamad Safadieh 2020-09-09 19:00:46 -04:00
parent 0bd6831f44
commit 7aed1e8d1a
No known key found for this signature in database
GPG Key ID: 2F3FDF2EAE1E3C36
4 changed files with 32 additions and 12 deletions

View File

@ -69,7 +69,7 @@ If you skip a lot of items (e.g. you skip direct messages) it may clutter your l
### Hide everything (--quiet) ### Hide everything (--quiet)
Use the `--quiet` flag to suppress all logging except for the account name being checked and the number of toots deleted. Exception messages will not be suppressed. Use the `--quiet` or `-q` flag to suppress all logging except for the account name being checked and the number of toots deleted. Use the `-qq` flag to further suppress output for accounts with zero deleted toots. The `-qqq` flag will suppress all output. Exception messages will not be suppressed.
### Only archive deleted toots (--archive-deleted) ### Only archive deleted toots (--archive-deleted)

View File

@ -72,7 +72,12 @@ parser.add_argument(
action="store_true", action="store_true",
help="Slow deletion actions to match API rate limit to avoid pausing", help="Slow deletion actions to match API rate limit to avoid pausing",
) )
parser.add_argument("--quiet", action="store_true", help="Suppress most logging") parser.add_argument(
"-q",
"--quiet",
action="count",
help="Limits logging to one line per account. Use -qq to limit logging to accounts with deleted toots and -qqq to completely suppress logging.",
)
parser.add_argument( parser.add_argument(
"--retry-mins", "--retry-mins",
action="store", action="store",

View File

@ -437,7 +437,21 @@ def check_batch(config, options, mastodon, user_id, timeline, deleted_count=0):
if options.datestamp: if options.datestamp:
print("\n", datestamp_now(), end=" : ") print("\n", datestamp_now(), end=" : ")
print("Removed " + str(deleted_count) + " toots.\n") # options.quiet can be None
if (
(not options.quiet)
or options.quiet <= 1
or (options.quiet == 2 and deleted_count)
):
print(
"Removed "
+ str(deleted_count)
+ " toots for "
+ config["username"]
+ "@"
+ config["base_url"]
+ ".\n"
)
if not options.quiet: if not options.quiet:
print("---------------------------------------") print("---------------------------------------")
@ -471,6 +485,7 @@ def check_toots(config, options, retry_count=0):
The main function, uses the Mastodon API to check all toots in the user timeline, and delete any that do not meet any of the exclusion criteria from the config file. The main function, uses the Mastodon API to check all toots in the user timeline, and delete any that do not meet any of the exclusion criteria from the config file.
""" """
try: try:
if not options.quiet:
print( print(
"Fetching account details for @", "Fetching account details for @",
config["username"], config["username"],

View File

@ -239,7 +239,7 @@ def test_check_batch(capfd, monkeypatch):
ephemetoot.check_batch(config, options, mastodon, user_id, timeline, 0) ephemetoot.check_batch(config, options, mastodon, user_id, timeline, 0)
# deleted_count should be 10 # deleted_count should be 10
output = capfd.readouterr().out.split("\n") output = capfd.readouterr().out.split("\n")
assert output[0] == "Removed 10 toots." assert output[0] == "Removed 10 toots for alice@test.social."
def test_console_print(capfd): def test_console_print(capfd):