Skip to content

Commit

Permalink
Formatting resulting from the latest version of yapf (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmaclean committed Jul 15, 2019
1 parent aff6cbb commit d2966ac
Show file tree
Hide file tree
Showing 22 changed files with 87 additions and 120 deletions.
4 changes: 1 addition & 3 deletions gslib/commands/bucketpolicyonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ class BucketPolicyOnlyCommand(Command):
gs_api_support=[ApiSelector.JSON],
gs_default_api=ApiSelector.JSON,
argparse_arguments={
'get': [
CommandArgument.MakeNCloudURLsArgument(1),
],
'get': [CommandArgument.MakeNCloudURLsArgument(1),],
'set': [
CommandArgument('mode', choices=['on', 'off']),
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument()
Expand Down
42 changes: 16 additions & 26 deletions gslib/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,38 +645,28 @@
#test_notification_url = https://yourdomain.url/notification-endpoint
""" % {
'hash_fast_else_fail':
CHECK_HASH_IF_FAST_ELSE_FAIL,
'hash_fast_else_skip':
CHECK_HASH_IF_FAST_ELSE_SKIP,
'hash_always':
CHECK_HASH_ALWAYS,
'hash_never':
CHECK_HASH_NEVER,
'resumable_threshold':
constants.RESUMABLE_THRESHOLD_B,
'parallel_process_count':
DEFAULT_PARALLEL_PROCESS_COUNT,
'parallel_thread_count':
DEFAULT_PARALLEL_THREAD_COUNT,
'hash_fast_else_fail': CHECK_HASH_IF_FAST_ELSE_FAIL,
'hash_fast_else_skip': CHECK_HASH_IF_FAST_ELSE_SKIP,
'hash_always': CHECK_HASH_ALWAYS,
'hash_never': CHECK_HASH_NEVER,
'resumable_threshold': constants.RESUMABLE_THRESHOLD_B,
'parallel_process_count': DEFAULT_PARALLEL_PROCESS_COUNT,
'parallel_thread_count': DEFAULT_PARALLEL_THREAD_COUNT,
'parallel_composite_upload_threshold':
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_THRESHOLD),
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_THRESHOLD),
'parallel_composite_upload_component_size':
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_COMPONENT_SIZE),
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_COMPONENT_SIZE),
'sliced_object_download_threshold':
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_THRESHOLD),
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_THRESHOLD),
'sliced_object_download_component_size':
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_COMPONENT_SIZE),
(DEFAULT_PARALLEL_COMPOSITE_UPLOAD_COMPONENT_SIZE),
'sliced_object_download_max_components':
(DEFAULT_SLICED_OBJECT_DOWNLOAD_MAX_COMPONENTS),
'max_component_count':
MAX_COMPONENT_COUNT,
'task_estimation_threshold':
DEFAULT_TASK_ESTIMATION_THRESHOLD,
(DEFAULT_SLICED_OBJECT_DOWNLOAD_MAX_COMPONENTS),
'max_component_count': MAX_COMPONENT_COUNT,
'task_estimation_threshold': DEFAULT_TASK_ESTIMATION_THRESHOLD,
'max_upload_compression_buffer_size':
(DEFAULT_MAX_UPLOAD_COMPRESSION_BUFFER_SIZE),
'gzip_compression_level':
DEFAULT_GZIP_COMPRESSION_LEVEL,
(DEFAULT_MAX_UPLOAD_COMPRESSION_BUFFER_SIZE),
'gzip_compression_level': DEFAULT_GZIP_COMPRESSION_LEVEL,
}

CONFIG_OAUTH2_CONFIG_CONTENT = """
Expand Down
4 changes: 1 addition & 3 deletions gslib/commands/cors.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ class CorsCommand(Command):
CommandArgument.MakeNFileURLsArgument(1),
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [
CommandArgument.MakeNCloudBucketURLsArgument(1),
]
'get': [CommandArgument.MakeNCloudBucketURLsArgument(1),]
})
# Help specification. See help_provider.py for documentation.
help_spec = Command.HelpSpec(
Expand Down
4 changes: 1 addition & 3 deletions gslib/commands/defstorageclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ class DefStorageClassCommand(Command):
CommandArgument.MakeFreeTextArgument(),
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),],
},
)
# Help specification. See help_provider.py for documentation.
Expand Down
4 changes: 1 addition & 3 deletions gslib/commands/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ class IamCommand(Command):
gs_api_support=[ApiSelector.JSON],
gs_default_api=ApiSelector.JSON,
argparse_arguments={
'get': [
CommandArgument.MakeNCloudURLsArgument(1),
],
'get': [CommandArgument.MakeNCloudURLsArgument(1),],
'set': [
CommandArgument.MakeNFileURLsArgument(1),
CommandArgument.MakeZeroOrMoreCloudURLsArgument(),
Expand Down
8 changes: 2 additions & 6 deletions gslib/commands/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,8 @@ class LabelCommand(Command):
CommandArgument.MakeNFileURLsArgument(1),
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [
CommandArgument.MakeNCloudURLsArgument(1),
],
'ch': [
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [CommandArgument.MakeNCloudURLsArgument(1),],
'ch': [CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),],
},
)
# Help specification. See help_provider.py for documentation.
Expand Down
4 changes: 1 addition & 3 deletions gslib/commands/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ class LifecycleCommand(Command):
CommandArgument.MakeNFileURLsArgument(1),
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [
CommandArgument.MakeNCloudBucketURLsArgument(1),
]
'get': [CommandArgument.MakeNCloudBucketURLsArgument(1),]
})
# Help specification. See help_provider.py for documentation.
help_spec = Command.HelpSpec(
Expand Down
4 changes: 1 addition & 3 deletions gslib/commands/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,7 @@ def _GetNotificationPathRegex(self):
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'stopchannel': [],
'list': [
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'list': [CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),],
'delete': [
# Takes a list of one of the following:
# notification: projects/_/buckets/bla/notificationConfigs/5,
Expand Down
4 changes: 1 addition & 3 deletions gslib/commands/requesterpays.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ class RequesterPaysCommand(Command):
CommandArgument('mode', choices=['on', 'off']),
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
]
'get': [CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),]
},
)
# Help specification. See help_provider.py for documentation.
Expand Down
4 changes: 1 addition & 3 deletions gslib/commands/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ class VersioningCommand(Command):
CommandArgument('mode', choices=['on', 'off']),
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument()
],
'get': [
CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),
],
'get': [CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(),],
},
)
# Help specification. See help_provider.py for documentation.
Expand Down
39 changes: 20 additions & 19 deletions gslib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ def GetAndValidateConfigValue(section, category, validation_fn):
('GSUtil', 'disable_analytics_prompt'),
('GSUtil', 'use_magicfile'),
('GSUtil', 'tab_completion_time_logs')):
GetAndValidateConfigValue(
section=section,
category=bool_category,
validation_fn=lambda val: str(val).lower() in ('true', 'false'))
GetAndValidateConfigValue(section=section,
category=bool_category,
validation_fn=lambda val: str(val).lower() in
('true', 'false'))

# Define a threshold for some config values which should be reasonably low.
small_int_threshold = 2000
Expand Down Expand Up @@ -264,8 +264,8 @@ def GetAndValidateConfigValue(section, category, validation_fn):
GetAndValidateConfigValue(
section='GSUtil',
category='check_hashes',
validation_fn=lambda val: val in (
'if_fast_else_fail', 'if_fast_else_skip', 'always', 'never'))
validation_fn=lambda val: val in
('if_fast_else_fail', 'if_fast_else_skip', 'always', 'never'))
# pylint: enable=g-long-lambda
GetAndValidateConfigValue(
section='GSUtil',
Expand All @@ -278,10 +278,10 @@ def GetAndValidateConfigValue(section, category, validation_fn):
GetAndValidateConfigValue(section='GSUtil',
category='prefer_api',
validation_fn=lambda val: val in ('json', 'xml'))
GetAndValidateConfigValue(
section='OAuth2',
category='token_cache',
validation_fn=lambda val: val in ('file_system', 'in_memory'))
GetAndValidateConfigValue(section='OAuth2',
category='token_cache',
validation_fn=lambda val: val in
('file_system', 'in_memory'))

return ','.join(
sorted([
Expand Down Expand Up @@ -620,7 +620,7 @@ def _CollectCommandAndErrorMetrics(self):
action=command_name,
**{
_GA_LABEL_MAP['Retryable Errors']:
sum(self.retryable_errors.values())
sum(self.retryable_errors.values())
})

# Collect the retryable errors.
Expand Down Expand Up @@ -704,18 +704,19 @@ def _CollectPerformanceSummaryMetric(self):
# This maps a transfer type to whether the condition has been met for it.
transfer_types = {
'CloudToCloud':
self.perf_sum_params.has_cloud_src and
self.perf_sum_params.has_cloud_dst,
self.perf_sum_params.has_cloud_src
and self.perf_sum_params.has_cloud_dst,
'CloudToFile':
self.perf_sum_params.has_cloud_src and
self.perf_sum_params.has_file_dst,
self.perf_sum_params.has_cloud_src
and self.perf_sum_params.has_file_dst,
'DaisyChain':
self.perf_sum_params.is_daisy_chain,
self.perf_sum_params.is_daisy_chain,
'FileToCloud':
self.perf_sum_params.has_file_src and
self.perf_sum_params.has_cloud_dst,
self.perf_sum_params.has_file_src
and self.perf_sum_params.has_cloud_dst,
'FileToFile':
self.perf_sum_params.has_file_src and self.perf_sum_params.has_file_dst,
self.perf_sum_params.has_file_src
and self.perf_sum_params.has_file_dst,
}
action = ','.join(
sorted([
Expand Down
6 changes: 2 additions & 4 deletions gslib/parallel_tracker_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,8 @@ def WriteParallelUploadTrackerFile(tracker_file_name,
tracker_components = []
for component in components:
tracker_components.append({
_CompositeUploadTrackerEntry.COMPONENT_NAME:
component.object_name,
_CompositeUploadTrackerEntry.COMPONENT_GENERATION:
component.generation
_CompositeUploadTrackerEntry.COMPONENT_NAME: component.object_name,
_CompositeUploadTrackerEntry.COMPONENT_GENERATION: component.generation
})
tracker_file_data = {
_CompositeUploadTrackerEntry.COMPONENTS_LIST: tracker_components,
Expand Down
6 changes: 3 additions & 3 deletions gslib/tests/test_command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def test_command_argument_parser_setup_invalid_completer(self):

command_map = {
FakeCommandWithInvalidCompleter.command_spec.command_name:
FakeCommandWithInvalidCompleter()
FakeCommandWithInvalidCompleter()
}

runner = CommandRunner(
Expand All @@ -347,7 +347,7 @@ def test_command_argument_parser_setup_invalid_completer(self):
def test_command_argument_parser_setup_nested_argparse_arguments(self):
command_map = {
FakeCommandWithNestedArguments.command_spec.command_name:
FakeCommandWithNestedArguments(),
FakeCommandWithNestedArguments(),
}
runner = CommandRunner(
bucket_storage_uri_class=self.mock_bucket_storage_uri,
Expand Down Expand Up @@ -382,7 +382,7 @@ def test_command_argument_parser_setup_completers(self):

command_map = {
FakeCommandWithCompleters.command_spec.command_name:
FakeCommandWithCompleters()
FakeCommandWithCompleters()
}

runner = CommandRunner(
Expand Down
18 changes: 9 additions & 9 deletions gslib/tests/test_daisy_chain_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,20 @@ def testDownloadWithPartialWrite(self):

write_values_dict = {
'First byte first chunk unaligned':
(one_byte, chunk_minus_one_byte, chunk, chunk),
(one_byte, chunk_minus_one_byte, chunk, chunk),
'Last byte first chunk unaligned': (chunk_minus_one_byte, chunk, chunk),
'First byte second chunk unaligned':
(chunk, one_byte, chunk_minus_one_byte, chunk),
(chunk, one_byte, chunk_minus_one_byte, chunk),
'Last byte second chunk unaligned':
(chunk, chunk_minus_one_byte, one_byte, chunk),
'First byte final chunk unaligned': (chunk, chunk, one_byte,
chunk_minus_one_byte),
'Last byte final chunk unaligned': (chunk, chunk, chunk_minus_one_byte,
one_byte),
(chunk, chunk_minus_one_byte, one_byte, chunk),
'First byte final chunk unaligned':
(chunk, chunk, one_byte, chunk_minus_one_byte),
'Last byte final chunk unaligned':
(chunk, chunk, chunk_minus_one_byte, one_byte),
'Half chunks': (half_chunk, half_chunk, half_chunk),
'Many unaligned':
(one_byte, half_chunk, one_byte, half_chunk, chunk,
chunk_minus_one_byte, chunk, one_byte, half_chunk, one_byte)
(one_byte, half_chunk, one_byte, half_chunk, chunk,
chunk_minus_one_byte, chunk, one_byte, half_chunk, one_byte)
}
upload_file = self.CreateTempFile()
for case_name, write_values in six.iteritems(write_values_dict):
Expand Down
3 changes: 1 addition & 2 deletions gslib/tests/test_iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,7 @@ def test_assert_has(self):
'role': 'roles/storage.admin'
}, {
'members': ['user:foo@bar.com', 'serviceAccount:bar@foo.com'],
'role':
IAM_BUCKET_READ_ROLE
'role': IAM_BUCKET_READ_ROLE
}]
}

Expand Down
2 changes: 1 addition & 1 deletion gslib/tests/testcase/integration_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def CreateObject(self,
key_uri.set_contents_from_string(contents,
headers={
'x-goog-if-generation-match':
str(gs_idempotent_generation)
str(gs_idempotent_generation)
})
except StorageResponseError as e:
if e.status == 412:
Expand Down
2 changes: 1 addition & 1 deletion gslib/tests/testcase/unit_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def RunCommand(self,
def MakeGsUtilApi(cls, debug=0):
gsutil_api_map = {
ApiMapConstants.API_MAP:
(cls.mock_gsutil_api_class_map_factory.GetClassMap()),
(cls.mock_gsutil_api_class_map_factory.GetClassMap()),
ApiMapConstants.SUPPORT_MAP: {
'gs': [ApiSelector.XML, ApiSelector.JSON],
's3': [ApiSelector.XML]
Expand Down
4 changes: 2 additions & 2 deletions gslib/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def GetUserGroups():
# Take the current user's UID and increment it by one, this counts as an
# invalid UID, as the metric used is if the UID matches the current user's,
# exactly.
INVALID_UID = LazyWrapper(lambda: sorted(
[user.pw_uid for user in pwd.getpwall()])[-1] + 1)
INVALID_UID = LazyWrapper(
lambda: sorted([user.pw_uid for user in pwd.getpwall()])[-1] + 1)

# Note that because the system's GID mapping can change mid-test, tests that
# check for specific errors should always re-fetch these GID-related values,
Expand Down
27 changes: 14 additions & 13 deletions gslib/utils/copy_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,19 +1322,20 @@ def _ShouldDoParallelCompositeUpload(logger,
file_size >= PARALLEL_COMPOSITE_SUGGESTION_THRESHOLD):
with suggested_sliced_transfers_lock:
if not suggested_sliced_transfers.get('suggested'):
logger.info('\n'.join(textwrap.wrap(
'==> NOTE: You are uploading one or more large file(s), which '
'would run significantly faster if you enable parallel composite '
'uploads. This feature can be enabled by editing the '
'"parallel_composite_upload_threshold" value in your .boto '
'configuration file. However, note that if you do this large files '
'will be uploaded as '
'`composite objects <https://cloud.google.com/storage/docs/composite-objects>`_,' # pylint: disable=line-too-long
'which means that any user who downloads such objects will need to '
'have a compiled crcmod installed (see "gsutil help crcmod"). This '
'is because without a compiled crcmod, computing checksums on '
'composite objects is so slow that gsutil disables downloads of '
'composite objects.')) + '\n')
logger.info('\n'.join(
textwrap.wrap(
'==> NOTE: You are uploading one or more large file(s), which '
'would run significantly faster if you enable parallel composite '
'uploads. This feature can be enabled by editing the '
'"parallel_composite_upload_threshold" value in your .boto '
'configuration file. However, note that if you do this large files '
'will be uploaded as '
'`composite objects <https://cloud.google.com/storage/docs/composite-objects>`_,' # pylint: disable=line-too-long
'which means that any user who downloads such objects will need to '
'have a compiled crcmod installed (see "gsutil help crcmod"). This '
'is because without a compiled crcmod, computing checksums on '
'composite objects is so slow that gsutil disables downloads of '
'composite objects.')) + '\n')
suggested_sliced_transfers['suggested'] = True

if not (all_factors_but_size and parallel_composite_upload_threshold > 0 and
Expand Down
10 changes: 5 additions & 5 deletions gslib/utils/encryption_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
from gslib.lazy_wrapper import LazyWrapper

MAX_DECRYPTION_KEYS = 100
VALID_CMEK_RE = LazyWrapper(lambda: re.compile(
'projects/([^/]+)/'
'locations/([a-zA-Z0-9_-]{1,63})/'
'keyRings/([a-zA-Z0-9_-]{1,63})/'
'cryptoKeys/([a-zA-Z0-9_-]{1,63})$'))
VALID_CMEK_RE = LazyWrapper(
lambda: re.compile('projects/([^/]+)/'
'locations/([a-zA-Z0-9_-]{1,63})/'
'keyRings/([a-zA-Z0-9_-]{1,63})/'
'cryptoKeys/([a-zA-Z0-9_-]{1,63})$'))


class CryptoKeyType(object):
Expand Down
Loading

0 comments on commit d2966ac

Please sign in to comment.