desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'This method sets up CD for an Azure Web App thru Team Services'
def setup_continuous_delivery(self, resource_group_name, name, repo_url, branch, git_token, slot, cd_app_type, cd_account, cd_create_account, location):
profile = Profile() subscription = profile.get_subscription() user = profile.get_current_account_user() (cred, _, _) = profile.get_login_credentials(subscription_id=None) cd_manager = ContinuousDeliveryManager(self._update_progress) auth_token = profile.get_access_token_for_resource(user, None, ...
'To be Implemented'
def remove_continuous_delivery(self):
pass
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Creates a new device identity in the identity registry of an IoT Hub. Creates a new device identity in the identity registry of an IoT Hub. :param device_id: Device Id. :type device_id: str :param device_description: request. :type device_description: :class:`DeviceDescription <iothubdeviceclient.models.DeviceDescript...
def create_or_update(self, device_id, device_description, if_match='*', custom_headers=None, raw=False, **operation_config):
url = '/devices/{deviceId}' path_format_arguments = {'deviceId': self._serialize.url('device_id', device_id, 'str', max_length=128, min_length=1)} url = self._client.format_url(url, **path_format_arguments) query_parameters = {} query_parameters['api-version'] = self._serialize.query('self.config.ap...
'Get device identity from the identity registry of an IoT Hub. Get device identity from the identity registry of an IoT Hub. :param device_id: Device Id. :type device_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized res...
def get(self, device_id, custom_headers=None, raw=False, **operation_config):
url = '/devices/{deviceId}' path_format_arguments = {'deviceId': self._serialize.url('device_id', device_id, 'str', max_length=128, min_length=1)} url = self._client.format_url(url, **path_format_arguments) query_parameters = {} query_parameters['api-version'] = self._serialize.query('self.config.ap...
'Delete a device identity in the identity registry of an IoT Hub. Delete a device identity in the identity registry of an IoT Hub. :param device_id: Device Id. :type device_id: str :param if_match: Specify the ETag for the device identity. :type if_match: str :param dict custom_headers: headers that will be added to th...
def delete(self, device_id, if_match='*', custom_headers=None, raw=False, **operation_config):
url = '/devices/{deviceId}' path_format_arguments = {'deviceId': self._serialize.url('device_id', device_id, 'str', max_length=128, min_length=1)} url = self._client.format_url(url, **path_format_arguments) query_parameters = {} query_parameters['api-version'] = self._serialize.query('self.config.ap...
'List device identities from the identity registry of an IoT Hub. List device identities from the identity registry of an IoT Hub. :param top: Maximum number of device identities to return. :type top: int :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response ...
def list(self, top, custom_headers=None, raw=False, **operation_config):
url = '/devices' query_parameters = {} query_parameters['api-version'] = self._serialize.query('self.config.api_version', self.config.api_version, 'str') query_parameters['top'] = self._serialize.query('top', top, 'int', maximum=1000, minimum=1) header_parameters = {} header_parameters['Content-...
'Send a device-to-cloud message. Send a device-to-cloud message. :param device_id: Device Id. :type device_id: str :param message: Message body. :type message: str :param iot_hub_message_id: Message Id. :type iot_hub_message_id: str :param iot_hub_correlation_id: Message correlation Id. :type iot_hub_correlation_id: st...
def send_message(self, device_id, message, iot_hub_message_id=None, iot_hub_correlation_id=None, iot_hub_user_id=None, custom_headers=None, raw=False, **operation_config):
url = '/devices/{deviceId}/messages/events' path_format_arguments = {'deviceId': self._serialize.url('device_id', device_id, 'str', max_length=128, min_length=1)} url = self._client.format_url(url, **path_format_arguments) query_parameters = {} query_parameters['api-version'] = self._serialize.query...
'Receive a device-to-cloud message. Receive a device-to-cloud message. :param device_id: Device Id. :type device_id: str :param iot_hub_message_lock_timeout: In case a message returned to this call, this specifies the amount of time, the message will be invisible to other receive calls. :type iot_hub_message_lock_timeo...
def receive_message(self, device_id, iot_hub_message_lock_timeout=None, custom_headers=None, raw=False, **operation_config):
url = '/devices/{deviceId}/messages/devicebound' path_format_arguments = {'deviceId': self._serialize.url('device_id', device_id, 'str', max_length=128, min_length=1)} url = self._client.format_url(url, **path_format_arguments) query_parameters = {} query_parameters['api-version'] = self._serialize....
'Complete or reject a cloud-to-device message. Complete or reject a cloud-to-device message. :param device_id: Device Id. :type device_id: str :param lock_token: Message etag. :type lock_token: str :param reject: Reject message flag. :type reject: str :param dict custom_headers: headers that will be added to the reques...
def complete_or_reject_message(self, device_id, lock_token, reject=None, custom_headers=None, raw=False, **operation_config):
url = '/devices/{deviceId}/messages/devicebound/{lockToken}' path_format_arguments = {'deviceId': self._serialize.url('device_id', device_id, 'str', max_length=128, min_length=1), 'lockToken': self._serialize.url('lock_token', lock_token, 'str')} url = self._client.format_url(url, **path_format_arguments) ...
'Abandon a cloud-to-device message. Abandon a cloud-to-device message. :param device_id: Device Id. :type device_id: str :param lock_token: Message etag. :type lock_token: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized re...
def abandon_message(self, device_id, lock_token, custom_headers=None, raw=False, **operation_config):
url = '/devices/{deviceId}/messages/devicebound/{lockToken}/abandon' path_format_arguments = {'deviceId': self._serialize.url('device_id', device_id, 'str', max_length=128, min_length=1), 'lockToken': self._serialize.url('lock_token', lock_token, 'str')} url = self._client.format_url(url, **path_format_argu...
'Cancel a job. Cancel a job. :param job_id: Job Id. :type job_id: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rt...
def cancel_job(self, job_id, custom_headers=None, raw=False, **operation_config):
url = '/jobs/{jobId}' path_format_arguments = {'jobId': self._serialize.url('job_id', job_id, 'str')} url = self._client.format_url(url, **path_format_arguments) query_parameters = {} query_parameters['api-version'] = self._serialize.query('self.config.api_version', self.config.api_version, 'str') ...
'Create requests session with SAS auth headers. :rtype: requests.Session.'
def signed_session(self):
session = super(SasTokenAuthentication, self).signed_session() session.headers['Authorization'] = self.generate_sas_token() return session
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Returns the batch account name, key, and endpoint in a tuple.'
def get_account_info(self, account_name, group_name):
key = (self.get_account_key(account_name, group_name),) endpoint = self.get_account_endpoint(account_name, group_name) return (account_name, key, endpoint)
'Iterate over arguments'
def __iter__(self):
for (arg, details) in self._arg_tree.items(): (yield (arg, details))
'Whether argument should not be exposed'
def _is_silent(self, name):
arg = self._arg_tree[name] full_path = full_name(arg) return ((arg['path'] in self._silent_args) or (full_path in self._silent_args))
'Whether argument value is a boolean'
def _is_bool(self, name):
return (self._arg_tree[name]['type'] == 'bool')
'Whether argument value is a list'
def _is_list(self, name):
return self._arg_tree[name]['type'].startswith('[')
'Whether argument value is a timestamp'
def _is_datetime(self, name):
return (self._arg_tree[name]['type'] in ['iso-8601', 'rfc-1123'])
'Whether argument is value is a duration'
def _is_duration(self, name):
return (self._arg_tree[name]['type'] == 'duration')
'Append phrase to existing help text'
def _help(self, name, text):
self._arg_tree[name]['options']['help'] += (' ' + text)
'Find all the arguments under to a specific complex argument group. :param str group: The namespace of the complex parameter. :returns: The names of the related arugments.'
def _get_children(self, group):
return [arg for (arg, value) in self._arg_tree.items() if value['path'].startswith(group)]
'Find all the arguments at the same level of a specific complex argument group. :param str group: The namespace of the complex parameter. :returns: The names of the related arugments.'
def _get_siblings(self, group):
return [arg for (arg, value) in self._arg_tree.items() if (value['path'] == group)]
'Parse dependency tree to list all required command line arguments based on current inputs. :param namespace: The namespace container all current argument inputs :param path: The current complex object path :param required: Whether the args in this object path are required'
def _parse(self, namespace, path, required):
required_args = [] children = self._get_children(path) if (not required): if (not any([getattr(namespace, n) for n in children])): return [] siblings = self._get_siblings(path) if (not siblings): raise ValueError('Invalid argmuent dependency tree') dependenci...
'Set the name of the parameter that will be serialized for the request body. :param str name: The name of the parameter :param str model: The name of the class'
def set_request_param(self, name, model):
self._request_param['name'] = name self._request_param['model'] = model.split('.')[(-1)]
'Deserialize the contents of a JSON file into the request body parameter. :param client: An Azure Batch SDK client :param dict kwargs: The request kwargs :param dict json_obj: The loaded JSON content'
def deserialize_json(self, client, kwargs, json_obj):
from msrest.exceptions import DeserializationError message = 'Failed to deserialized JSON file into object {}' try: kwargs[self._request_param['name']] = client._deserialize(self._request_param['model'], json_obj) except DeserializationError as error: message += ': ...
'Add pending command line argument :param str name: The name of the command line argument. :param str path: The complex object path to the parameter. :param str root: The original name of the parameter. :param dict options: The kwargs to be used to instantiate CliCommandArgument. :param list dependencies: A list of com...
def queue_argument(self, name=None, path=None, root=None, options=None, type=None, dependencies=None):
self._arg_tree[name] = {'path': path, 'root': root, 'options': options, 'type': type, 'dependencies': ['.'.join([path, arg]) for arg in dependencies]}
'Remove pending command line argument for modification :param str name: The command line argument to remove. :returns: The details of the argument.'
def dequeue_argument(self, name):
return self._arg_tree.pop(name, {})
'Generator to convert pending arguments into CliCommandArgument objects.'
def compile_args(self):
for (name, details) in self._arg_tree.items(): if self._is_bool(name): if self._request_param['name'].endswith('patch_parameter'): self._help(name, "Specify either 'true' or 'false' to update the property.") else: details['optio...
'Whether the argument name is already used by a pending argument. :param str name: The name of the argument to check. :returns: bool'
def existing(self, name):
return (name in self._arg_tree)
'Validate whether two or more mutually exclusive arguments or argument groups have been set correctly. :param bool required: Whether one of the parameters must be set. :param list params: List of namespace paths for mutually exclusive request properties.'
def parse_mutually_exclusive(self, namespace, required, params):
argtree = self._arg_tree.items() ex_arg_names = [a for (a, v) in argtree if (full_name(v) in params)] ex_args = [getattr(namespace, a) for (a, v) in argtree if (a in ex_arg_names)] ex_args = [x for x in ex_args if (x is not None)] ex_group_names = [] ex_groups = [] for arg_group in params: ...
'Parse all arguments in the namespace to validate whether all required arguments have been set. :param namespace: The namespace object. :raises: ValueError if a require argument was not set.'
def parse(self, namespace):
if self._custom_validator: try: self._custom_validator(namespace, self) except TypeError: raise ValueError('Custom validator must be a function that takes two arguments.') try: if namespace.json_file: try: wit...
'Whether to cancel the current operation because user declined the confirmation prompt. :param dict kwargs: The request arguments. :returns: bool'
def _cancel_operation(self, kwargs, config, user):
return (not ((not self.confirmation) or kwargs.get(CONFIRM_PARAM_NAME) or config.getboolean('core', 'disable_confirm_prompt', fallback=False) or user(self.confirmation, kwargs)))
'Recursively build request parameter dictionary from command line args. :param str arg_path: Current parameter namespace. :param dict kwargs: The request arguments being built. :param param: The name of the request parameter. :param value: The value of the request parameter.'
def _build_parameters(self, path, kwargs, param, value):
keys = path.split('.') if (keys[0] not in kwargs): kwargs[keys[0]] = {} if (len(keys) < 2): kwargs[keys[0]][param] = value else: self._build_parameters('.'.join(keys[1:]), kwargs[keys[0]], param, value) path = param[0] return path.split('.')[0]
'Build request options model from command line arguments. :param dict kwargs: The request arguments being built.'
def _build_options(self, kwargs):
kwargs[self._options_param] = self._options_model for param in self._options_attrs: if (param in IGNORE_OPTIONS): continue param_value = kwargs.pop(param) if (param_value is None): continue setattr(kwargs[self._options_param], param, param_value)
'Load the request headers options model to gather arguments. :param func func_obj: The request function.'
def _load_options_model(self, func_obj):
option_type = find_param_type(func_obj, self._options_param) option_type = class_name(option_type) self._options_model = _load_model(option_type)() self._options_attrs = list(self._options_model.__dict__.keys())
'Check whether the current parameter object should be flattened. :param str param: The parameter name with complete namespace. :returns: bool'
def _should_flatten(self, param):
return ((param.count('.') < self.flatten) and (param not in self.ignore))
'Get all the attributes from the complex parameter model that should be exposed as command line arguments. :param class model: The parameter model class. :param str path: Request parameter namespace.'
def _get_attrs(self, model, path):
for (attr, details) in model._attribute_map.items(): conditions = [] conditions.append(model._validation.get(attr, {}).get('readonly')) conditions.append(model._validation.get(attr, {}).get('constant')) conditions.append(('.'.join([path, attr]) in self.ignore)) conditions.app...
'Process the request options parameter to expose as arguments.'
def _process_options(self):
for param in [o for o in self._options_attrs if (o not in IGNORE_OPTIONS)]: options = {} options['required'] = False options['arg_group'] = 'Pre-condition and Query' if (param in ['if_modified_since', 'if_unmodified_since']): options['type'] = validators.datetime_fo...
'Resolve conflicting command line arguments. :param str arg: Name of the command line argument. :param str param: Original request parameter name. :param str path: Request parameter namespace. :param dict options: The kwargs to be used to instantiate CliCommandArgument. :param list dependencies: A list of complete path...
def _resolve_conflict(self, arg, param, path, options, typestr, dependencies, conflicting):
if self.parser.existing(arg): conflicting.append(arg) existing = self.parser.dequeue_argument(arg) existing['name'] = _build_prefix(arg, existing['root'], existing['path']) existing['options']['options_list'] = [arg_name(existing['name'])] self.parser.queue_argument(**existin...
'Flatten a complex parameter object into command line arguments. :param str path: The complex parameter namespace. :param class param_model: The complex parameter class. :param list conflict_name: List of argument names that conflict.'
def _flatten_object(self, path, param_model, conflict_names=None):
conflict_names = (conflict_names or []) if self._should_flatten(path): validations = param_model._validation.items() required_attrs = [key for (key, val) in validations if val.get('required')] for (param_attr, details) in self._get_attrs(param_model, path): if (param_attr in ...
'Load all the command line arguments from the request parameters. :param func handler: The operation function.'
def _load_transformed_arguments(self, handler):
from azure.cli.core.commands.parameters import file_type from argcomplete.completers import FilesCompleter, DirectoriesCompleter self.parser = BatchArgumentTree(self.validator, self.silent) self._load_options_model(handler) for arg in extract_args_from_signature(handler): arg_type = find_par...
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Return distribution full name with - replaced with _'
@property def wheel_dist_name(self):
return '-'.join((safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())))
'Return archive name without extension'
def get_archive_basename(self):
(impl_tag, abi_tag, plat_tag) = self.get_tag() archive_basename = ('%s-%s-%s-%s' % (self.wheel_dist_name, impl_tag, abi_tag, plat_tag)) return archive_basename
'Return license filename from a license-file key in setup.cfg, or None.'
def license_file(self):
metadata = self.distribution.get_option_dict('metadata') if (not ('license_file' in metadata)): return None return metadata['license_file'][1]
'Generate requirements from setup.cfg as (\'Requires-Dist\', \'requirement; qualifier\') tuples. From a metadata section in setup.cfg: [metadata] provides-extra = extra1 extra2 requires-dist = requirement; qualifier another; qualifier2 unqualified Yields (\'Provides-Extra\', \'extra1\'), (\'Provides-Extra\', \'extra2\'...
def setupcfg_requirements(self):
metadata = self.distribution.get_option_dict('metadata') for (key, title) in (('provides_extra', 'Provides-Extra'), ('requires_dist', 'Requires-Dist')): if (not (key in metadata)): continue field = metadata[key] for line in field[1].splitlines(): line = line.strip...
'Add additional requirements from setup.cfg to file metadata_path'
def add_requirements(self, metadata_path):
additional = list(self.setupcfg_requirements()) if (not additional): return pkg_info = read_pkg_info(metadata_path) if (('Provides-Extra' in pkg_info) or ('Requires-Dist' in pkg_info)): warnings.warn('setup.cfg requirements overwrite values from setup.py') del pkg_...
'Convert an .egg-info directory into a .dist-info directory'
def egg2dist(self, egginfo_path, distinfo_path):
def adios(p): 'Appropriately delete directory, file or link.' if (os.path.exists(p) and (not os.path.islink(p)) and os.path.isdir(p)): shutil.rmtree(p) elif os.path.exists(p): os.unlink(p) adios(distinfo_path) if (not os.path.exists(egginfo_path...
'Create requests session with any required auth headers applied. :rtype: requests.Session.'
def signed_session(self):
session = super(ClientCertAuthentication, self).signed_session() if (self.cert is not None): session.cert = self.cert if (self.ca_cert is not None): session.verify = self.ca_cert if self.no_verify: session.verify = False return session