зеркало из https://github.com/microsoft/azure-cli.git
Pylint fixes.
This commit is contained in:
Родитель
8c24d9c589
Коммит
de92ac6f55
|
@ -5,7 +5,6 @@ import json
|
|||
import logging
|
||||
import os
|
||||
import re
|
||||
from subprocess import check_output
|
||||
import sys
|
||||
try:
|
||||
import unittest.mock as mock
|
||||
|
@ -109,7 +108,7 @@ class CommandTestGenerator(object):
|
|||
io = StringIO()
|
||||
if expected is None:
|
||||
print('\n === RECORDING: {} ==='.format(test_name), file=sys.stderr)
|
||||
if type(action) is str:
|
||||
if isinstance(action, str):
|
||||
cli(action.split(), file=io)
|
||||
actual_result = io.getvalue()
|
||||
else:
|
||||
|
@ -185,9 +184,9 @@ class CommandTestGenerator(object):
|
|||
if command:
|
||||
test_functions[test_name] = gen_test(test_name, command, self.recording_dir)
|
||||
continue
|
||||
callable = test_def.get('script', None)
|
||||
if callable:
|
||||
test_functions[test_name] = gen_test(test_name, callable, self.recording_dir)
|
||||
func = test_def.get('script', None)
|
||||
if func:
|
||||
test_functions[test_name] = gen_test(test_name, func, self.recording_dir)
|
||||
continue
|
||||
return test_functions
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from azure.cli.commands._auto_command import build_operation, AutoCommandDefinit
|
|||
from azure.cli._locale import L
|
||||
|
||||
from ._params import PARAMETER_ALIASES, STORAGE_DATA_CLIENT_ARGS
|
||||
from ._validators import *
|
||||
from ._validators import validate_datetime, validate_key_value_pairs
|
||||
|
||||
command_table = CommandTable()
|
||||
|
||||
|
@ -265,7 +265,7 @@ build_operation(
|
|||
AutoCommandDefinition(BlockBlobService.list_blobs, '[Blob]', 'list'),
|
||||
AutoCommandDefinition(BlockBlobService.delete_blob, None, 'delete'),
|
||||
AutoCommandDefinition(BlockBlobService.generate_blob_shared_access_signature,
|
||||
'String', 'generate-sas'),
|
||||
'String', 'generate-sas'),
|
||||
AutoCommandDefinition(BlockBlobService.make_blob_url, 'URL', 'url'),
|
||||
AutoCommandDefinition(BlockBlobService.snapshot_blob, 'Something?', 'snapshot')
|
||||
], command_table, PARAMETER_ALIASES, STORAGE_DATA_CLIENT_ARGS)
|
||||
|
|
|
@ -3,7 +3,9 @@ from os import environ
|
|||
from azure.cli.commands import COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS
|
||||
from azure.cli._locale import L
|
||||
|
||||
from ._validators import *
|
||||
from ._validators import (
|
||||
validate_container_permission, validate_datetime, validate_id, validate_ip_range,
|
||||
validate_key_value_pairs, validate_resource_types, validate_services, validate_tags)
|
||||
|
||||
# HELPER METHODS
|
||||
|
||||
|
@ -103,7 +105,7 @@ PARAMETER_ALIASES.update({
|
|||
'lease_id': {
|
||||
'name': '--lease-id',
|
||||
'metavar': 'LEASE ID',
|
||||
'help': L('Lease ID in GUID format.')
|
||||
'help': L('Lease ID in GUID format.')
|
||||
},
|
||||
'metadata': {
|
||||
'name': '--metadata',
|
||||
|
@ -123,12 +125,12 @@ PARAMETER_ALIASES.update({
|
|||
'public_access': {
|
||||
'name': '--public-access',
|
||||
'metavar': 'SPECIFIERS',
|
||||
'choices': ['blob','container']
|
||||
#'type': validate_public_access
|
||||
'choices': ['blob', 'container']
|
||||
},
|
||||
'resource_types': {
|
||||
'name': '--resource-types',
|
||||
'help': L('the resource types the SAS is applicable for. Allowed values: (s)ervice (c)ontainer (o)bject. Can be combined.'),
|
||||
'help': L('the resource types the SAS is applicable for. Allowed values: (s)ervice ' + \
|
||||
'(c)ontainer (o)bject. Can be combined.'),
|
||||
'type': validate_resource_types
|
||||
},
|
||||
'sas_token': {
|
||||
|
@ -139,7 +141,8 @@ PARAMETER_ALIASES.update({
|
|||
},
|
||||
'services': {
|
||||
'name': '--services',
|
||||
'help': L('the storage services the SAS is applicable for. Allowed values: (b)lob (f)ile (q)ueue (t)able. Can be combined.'),
|
||||
'help': L('the storage services the SAS is applicable for. Allowed values: (b)lob ' + \
|
||||
'(f)ile (q)ueue (t)able. Can be combined.'),
|
||||
'type': validate_services
|
||||
},
|
||||
'share_name': {
|
||||
|
@ -150,8 +153,7 @@ PARAMETER_ALIASES.update({
|
|||
'signed_identifiers': {
|
||||
'name': '--signed-identifiers',
|
||||
'help': L(''),
|
||||
'metavar': 'IDENTIFIERS',
|
||||
'type': validate_signed_identifiers
|
||||
'metavar': 'IDENTIFIERS'
|
||||
},
|
||||
'start': {
|
||||
'name': '--start',
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from datetime import datetime
|
||||
import re
|
||||
from urllib.parse import unquote
|
||||
|
||||
from azure.storage.models import ResourceTypes, Services, AccessPolicy
|
||||
from azure.storage.blob.models import ContainerPermissions, PublicAccess
|
||||
from azure.storage.models import ResourceTypes, Services
|
||||
from azure.storage.blob.models import ContainerPermissions
|
||||
|
||||
def validate_container_permission(string):
|
||||
''' Validates that permission string contains only a combination
|
||||
|
@ -23,7 +22,7 @@ def validate_id(string):
|
|||
|
||||
def validate_ip_range(string):
|
||||
''' Validates an IP address or IP address range. '''
|
||||
ip_format = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
|
||||
ip_format = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
|
||||
if not re.match("^{}$".format(ip_format), string):
|
||||
if not re.match("^{}-{}$".format(ip_format, ip_format), string):
|
||||
raise ValueError
|
||||
|
@ -37,10 +36,6 @@ def validate_key_value_pairs(string):
|
|||
result = dict(x.split('=', 1) for x in kv_list)
|
||||
return result
|
||||
|
||||
def validate_public_access(string):
|
||||
# TODO: Implement if required.
|
||||
pass
|
||||
|
||||
def validate_resource_types(string):
|
||||
''' Validates that resource types string contains only a combination
|
||||
of (s)ervice, (c)ontainer, (o)bject '''
|
||||
|
@ -55,10 +50,6 @@ def validate_services(string):
|
|||
raise ValueError
|
||||
return Services(_str=''.join(set(string)))
|
||||
|
||||
def validate_signed_identifiers(string):
|
||||
# TODO: Implement if required
|
||||
pass
|
||||
|
||||
def validate_tags(string):
|
||||
''' Validates the string containers only key-value pairs and single
|
||||
tags in the format: a=b;c '''
|
||||
|
@ -67,4 +58,4 @@ def validate_tags(string):
|
|||
result = validate_key_value_pairs(string)
|
||||
s_list = [x for x in string.split(';') if '=' not in x] # single values
|
||||
result.update(dict((x, '') for x in s_list))
|
||||
return result
|
||||
return result
|
||||
|
|
Загрузка…
Ссылка в новой задаче