/usr/lib/python3/dist-packages/pyicloud/utils.py is in python3-pyicloud 0.9.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import getpass
import keyring
import sys
from .exceptions import NoStoredPasswordAvailable
KEYRING_SYSTEM = 'pyicloud://icloud-password'
def get_password(username, interactive=sys.stdout.isatty()):
try:
return get_password_from_keyring(username)
except NoStoredPasswordAvailable:
if not interactive:
raise
return getpass.getpass(
'Enter iCloud password for {username}: '.format(
username=username,
)
)
def password_exists_in_keyring(username):
try:
get_password_from_keyring(username)
except NoStoredPasswordAvailable:
return False
return True
def get_password_from_keyring(username):
result = keyring.get_password(
KEYRING_SYSTEM,
username
)
if result is None:
raise NoStoredPasswordAvailable(
"No pyicloud password for {username} could be found "
"in the system keychain. Use the `--store-in-keyring` "
"command-line option for storing a password for this "
"username.".format(
username=username,
)
)
return result
def store_password_in_keyring(username, password):
return keyring.set_password(
KEYRING_SYSTEM,
username,
password,
)
def delete_password_in_keyring(username):
return keyring.delete_password(
KEYRING_SYSTEM,
username,
)
def underscore_to_camelcase(word, initial_capital=False):
words = [x.capitalize() or '_' for x in word.split('_')]
if not initial_capital:
words[0] = words[0].lower()
return ''.join(words)
|