How to use the b2sdk.sync.folder.B2Folder function in b2sdk

To help you get started, we’ve selected a few b2sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Backblaze / b2-sdk-python / test / v1 / test_policy.py View on Github external
def check_one_answer(self, has_source, id_relative_date_action_list, expected_actions):
        source_file = File('a', []) if has_source else None
        dest_file_versions = [
            FileVersion(id_, 'a', self.today + relative_date * self.one_day_millis, action, 100)
            for (id_, relative_date, action) in id_relative_date_action_list
        ]
        dest_file = File('a', dest_file_versions)
        bucket = MagicMock()
        api = MagicMock()
        api.get_bucket_by_name.return_value = bucket
        dest_folder = B2Folder('bucket-1', 'folder', api)
        actual_actions = list(
            make_b2_keep_days_actions(
                source_file, dest_file, dest_folder, dest_folder, self.keep_days, self.today
            )
        )
        actual_action_strs = [str(a) for a in actual_actions]
        self.assertEqual(expected_actions, actual_action_strs)
github Backblaze / b2-sdk-python / b2sdk / sync / folder_parser.py View on Github external
def _parse_bucket_and_folder(bucket_and_path, api):
    """
    Turns 'my-bucket/foo' into B2Folder(my-bucket, foo)
    """
    if '//' in bucket_and_path:
        raise CommandError("'//' not allowed in path names")
    if '/' not in bucket_and_path:
        bucket_name = bucket_and_path
        folder_name = ''
    else:
        (bucket_name, folder_name) = bucket_and_path.split('/', 1)
    if folder_name.endswith('/'):
        folder_name = folder_name[:-1]
    return B2Folder(bucket_name, folder_name, api)