コード例 #1
0
ファイル: pref_main.py プロジェクト: tinghitella/onedrive-d
def add_new_drive():
    puts(colored.green("Here are all the Drives belonging to the accounts you have linked and not yet added:\n"))
    drive_list = []
    for key, account in account_store.get_all_accounts().items():
        account_id, account_type = key
        puts(colored.magenta('{} Account "{}" ({})'.format(account_type.upper(), account_id, account.profile.name)))
        drive_root = drive_store.get_drive_root(account_id, account_type)
        all_drives = drive_root.get_all_drives()
        saved_drives = drive_store.get_all_drives()
        puts(
            columns(
                [(colored.green("Index")), 5],
                [(colored.cyan("Drive ID")), 18],
                [(colored.cyan("Type")), 8],
                [(colored.cyan("Default?")), 8],
                [(colored.cyan("State")), 7],
                [(colored.yellow("Total")), 10],
                [(colored.yellow("Used")), 8],
                [(colored.yellow("Free")), 10],
            )
        )
        for id, drive in all_drives.items():
            if drive_store.get_key(id, drive.root.account.profile.user_id, drive.root.account.TYPE) in saved_drives:
                continue
            quota = drive.quota
            puts(
                columns(
                    [str(len(drive_list)), 5],
                    [id, 18],
                    [drive.type, 8],
                    ["Yes" if drive.is_default else "", 8],
                    [quota.state, 7],
                    [pretty_print_bytes(quota.total), 10],
                    [pretty_print_bytes(quota.used), 8],
                    [pretty_print_bytes(quota.remaining), 10],
                )
            )
            drive_list.append(drive)
        puts()
    if len(drive_list) == 0:
        puts()
        puts(colored.red("It seems there is no more Drive to add."))
    else:
        try:
            prompt_add_drive(drive_list)
        except KeyboardInterrupt:
            puts(colored.green("Aborted."))
コード例 #2
0
ファイル: pref_main.py プロジェクト: rjmuniz/onedrive-d
def add_new_drive():
    puts(colored.green('Here are all the Drives belonging to the accounts you have linked and not yet added:\n'))
    drive_list = []
    for key, account in account_store.get_all_accounts().items():
        account_id, account_type = key
        puts(colored.magenta('{} Account "{}" ({})'.format(account_type.upper(), account_id, account.profile.name)))
        drive_root = drive_store.get_drive_root(account_id, account_type)
        all_drives = drive_root.get_all_drives()
        saved_drives = drive_store.get_all_drives()
        puts(columns(
                [(colored.green('Index')), 5],
                [(colored.cyan('Drive ID')), 18],
                [(colored.cyan('Type')), 8],
                [(colored.cyan('Default?')), 8],
                [(colored.cyan('State')), 7],
                [(colored.yellow('Total')), 10],
                [(colored.yellow('Used')), 8],
                [(colored.yellow('Free')), 10]))
        for id, drive in all_drives.items():
            if drive_store.get_key(id, drive.root.account.profile.user_id, drive.root.account.TYPE) in saved_drives:
                continue
            quota = drive.quota
            puts(columns(
                    [str(len(drive_list)), 5],
                    [id, 18],
                    [drive.type, 8],
                    ['Yes' if drive.is_default else '', 8],
                    [quota.state, 7],
                    [pretty_print_bytes(quota.total), 10],
                    [pretty_print_bytes(quota.used), 8],
                    [pretty_print_bytes(quota.remaining), 10]))
            drive_list.append(drive)
        puts()
    if len(drive_list) == 0:
        puts()
        puts(colored.red('It seems there is no more Drive to add.'))
    else:
        try:
            prompt_add_drive(drive_list)
        except KeyboardInterrupt:
            puts(colored.green('Aborted.'))
コード例 #3
0
ファイル: test_utils.py プロジェクト: GitGrezly/onedrive-d
 def test_print_kb(self):
     self.assertEqual('1024.00 KB', utils.pretty_print_bytes(1024 << 10, precision=2))
コード例 #4
0
ファイル: test_utils.py プロジェクト: GitGrezly/onedrive-d
 def test_print_bytes(self):
     self.assertEqual('1023.00 B', utils.pretty_print_bytes(1023, precision=2))
コード例 #5
0
ファイル: test_utils.py プロジェクト: rjmuniz/onedrive-d
 def test_print_bytes(self):
     self.assertEqual('1023.00 B',
                      utils.pretty_print_bytes(1023, precision=2))
コード例 #6
0
ファイル: test_utils.py プロジェクト: rjmuniz/onedrive-d
 def test_print_kb(self):
     self.assertEqual('1024.00 KB',
                      utils.pretty_print_bytes(1024 << 10, precision=2))