Skip to content

Commit

Permalink
Added docstrings, minor cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjake committed Jan 7, 2025
1 parent 809d30e commit 18316e1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
28 changes: 28 additions & 0 deletions internetarchive/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]')
>>> account.lock(comment="Locked spam account")
>>> print(account.to_dict())
"""
locked: bool
verified: bool
email: str
Expand Down
19 changes: 12 additions & 7 deletions internetarchive/cli/ia_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,38 @@ 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"))

group = parser.add_mutually_exclusive_group()
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")

Expand Down

0 comments on commit 18316e1

Please sign in to comment.