From 18316e125804a8f068b815681187b872ffb6cc20 Mon Sep 17 00:00:00 2001 From: jake Date: Tue, 7 Jan 2025 11:09:58 -0800 Subject: [PATCH] Added docstrings, minor cleanups. --- internetarchive/account.py | 28 ++++++++++++++++++++++++++++ internetarchive/cli/ia_account.py | 19 ++++++++++++------- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/internetarchive/account.py b/internetarchive/account.py index bc643be2..0130c5aa 100644 --- a/internetarchive/account.py +++ b/internetarchive/account.py @@ -8,9 +8,37 @@ from internetarchive.exceptions import AccountAPIError from internetarchive.session import ArchiveSession +""" +internetarchive.account +~~~~~~~~~~~~~~~~~~~~~~~ + +:copyright: (C) 2012-2025 by Internet Archive. +:license: AGPL 3, see LICENSE for more details. + +This module provides the `Account` class for interacting with user accounts on the +Internet Archive. It requires administrative privileges. +""" + @dataclass class Account: + """ + A class for interacting with user accounts on the Internet Archive. + + Note: + This class requires administrative privileges. + + This class provides methods to: + - Fetch account details using various identifiers (e.g., email, screenname, itemname). + - Lock and unlock accounts. + - Convert account data to a dictionary for serialization. + + Example Usage: + >>> from internetarchive.account import Account + >>> account = Account.from_account_lookup('email', 'foo@example.com') + >>> account.lock(comment="Locked spam account") + >>> print(account.to_dict()) + """ locked: bool verified: bool email: str diff --git a/internetarchive/cli/ia_account.py b/internetarchive/cli/ia_account.py index fa40d64d..48a8704f 100644 --- a/internetarchive/cli/ia_account.py +++ b/internetarchive/cli/ia_account.py @@ -38,6 +38,11 @@ def setup(subparsers): """ parser = subparsers.add_parser("account", aliases=["ac"], + description=( + "Manage an archive.org account.\n\n" + "Note: This command requires administrative " + "privileges. " + ), help=("Manage an archive.org account. " "Note: requires admin privileges")) @@ -45,26 +50,26 @@ def setup(subparsers): parser.add_argument("user", help="Email address, screenname, or itemname " "for an archive.org account") - group.add_argument("--get-email", "-g", + group.add_argument("-g", "--get-email", action="store_true", help="Print the email address associated with the user and exit") - group.add_argument("--get-screenname", "-s", + group.add_argument("-s", "--get-screenname", action="store_true", help="Print the screenname associated with the user and exit") - group.add_argument("--get-itemname", "-i", + group.add_argument("-i", "--get-itemname", action="store_true", help="Print the itemname associated with the user and exit") - group.add_argument("--is-locked", "-l", + group.add_argument("-l", "--is-locked", action="store_true", help="Check if an account is locked") - group.add_argument("--lock", "-L", + group.add_argument("-L", "--lock", action="store_true", help="Lock an account") - group.add_argument("--unlock", "-u", + group.add_argument("-u", "--unlock", action="store_true", help="Unlock an account") - parser.add_argument("--comment", "-c", + parser.add_argument("-c", "--comment", type=str, help="Comment to include with lock/unlock action")