_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q32500
AzInteractiveShell.example_repl
train
def example_repl(self, text, example, start_index, continue_flag): """ REPL for interactive tutorials """ if start_index: start_index = start_index + 1 cmd = ' '.join(text.split()[:start_index]) example_cli = CommandLineInterface( application=self.crea...
python
{ "resource": "" }
q32501
AzInteractiveShell.handle_jmespath_query
train
def handle_jmespath_query(self, args): """ handles the jmespath query for injection or printing """ continue_flag = False query_symbol = SELECT_SYMBOL['query'] symbol_len = len(query_symbol) try: if len(args) == 1: # if arguments start with query_symbo...
python
{ "resource": "" }
q32502
AzInteractiveShell.handle_scoping_input
train
def handle_scoping_input(self, continue_flag, cmd, text): """ handles what to do with a scoping gesture """ default_split = text.partition(SELECT_SYMBOL['scope'])[2].split() cmd = cmd.replace(SELECT_SYMBOL['scope'], '') continue_flag = True if not default_split: sel...
python
{ "resource": "" }
q32503
AzInteractiveShell.cli_execute
train
def cli_execute(self, cmd): """ sends the command to the CLI to be executed """ try: args = parse_quotes(cmd) if args and args[0] == 'feedback': self.config.set_feedback('yes') self.user_feedback = False azure_folder = get_config_dir...
python
{ "resource": "" }
q32504
AzInteractiveShell.progress_patch
train
def progress_patch(self, _=False): """ forces to use the Shell Progress """ from .progress import ShellProgressView self.cli_ctx.progress_controller.init_progress(ShellProgressView()) return self.cli_ctx.progress_controller
python
{ "resource": "" }
q32505
AzInteractiveShell.run
train
def run(self): """ starts the REPL """ from .progress import ShellProgressView self.cli_ctx.get_progress_controller().init_progress(ShellProgressView()) self.cli_ctx.get_progress_controller = self.progress_patch self.command_table_thread = LoadCommandTableThread(self.restart_com...
python
{ "resource": "" }
q32506
progress_view
train
def progress_view(shell): """ updates the view """ while not ShellProgressView.done: _, col = get_window_dim() col = int(col) progress = get_progress_message() if '\n' in progress: prog_list = progress.split('\n') prog_val = len(prog_list[-1]) else...
python
{ "resource": "" }
q32507
ShellProgressView.write
train
def write(self, args): # pylint: disable=no-self-use """ writes the progres """ ShellProgressView.done = False message = args.get('message', '') percent = args.get('percent', None) if percent: ShellProgressView.progress_bar = _format_value(message, percent) ...
python
{ "resource": "" }
q32508
sqlvm_list
train
def sqlvm_list( client, resource_group_name=None): ''' Lists all SQL virtual machines in a resource group or subscription. ''' if resource_group_name: # List all sql vms in the resource group return client.list_by_resource_group(resource_group_name=resource_group_name) ...
python
{ "resource": "" }
q32509
sqlvm_group_list
train
def sqlvm_group_list( client, resource_group_name=None): ''' Lists all SQL virtual machine groups in a resource group or subscription. ''' if resource_group_name: # List all sql vm groups in the resource group return client.list_by_resource_group(resource_group_name=resou...
python
{ "resource": "" }
q32510
sqlvm_group_create
train
def sqlvm_group_create(client, cmd, sql_virtual_machine_group_name, resource_group_name, location, sql_image_offer, sql_image_sku, domain_fqdn, cluster_operator_account, sql_service_account, storage_account_url, storage_account_key, cluster_bootstrap_account=None, ...
python
{ "resource": "" }
q32511
sqlvm_group_update
train
def sqlvm_group_update(instance, domain_fqdn=None, sql_image_sku=None, sql_image_offer=None, cluster_operator_account=None, sql_service_account=None, storage_account_url=None, storage_account_key=None, cluster_bootstrap_account=None, file_share_witnes...
python
{ "resource": "" }
q32512
sqlvm_aglistener_create
train
def sqlvm_aglistener_create(client, cmd, availability_group_listener_name, sql_virtual_machine_group_name, resource_group_name, availability_group_name, ip_address, subnet_resource_id, load_balancer_resource_id, probe_port, sql_virtual_machine_instances, port=1433...
python
{ "resource": "" }
q32513
sqlvm_update
train
def sqlvm_update(instance, sql_server_license_type=None, enable_auto_patching=None, day_of_week=None, maintenance_window_starting_hour=None, maintenance_window_duration=None, enable_auto_backup=None, enable_encryption=False, retention_period=None, storage_account_url=None, ...
python
{ "resource": "" }
q32514
add_sqlvm_to_group
train
def add_sqlvm_to_group(instance, sql_virtual_machine_group_resource_id, sql_service_account_password, cluster_operator_account_password, cluster_bootstrap_account_password=None): ''' Add a SQL virtual machine to a SQL virtual machine group. ''' if not is_valid_resource_id(sql_vir...
python
{ "resource": "" }
q32515
add_sqlvm_to_aglistener
train
def add_sqlvm_to_aglistener(instance, sqlvm_resource_id): ''' Add a SQL virtual machine to an availability group listener. ''' if not is_valid_resource_id(sqlvm_resource_id): raise CLIError("Invalid SQL virtual machine resource id.") vm_list = instance.load_balancer_configurations[0].sql_vi...
python
{ "resource": "" }
q32516
remove_sqlvm_from_aglistener
train
def remove_sqlvm_from_aglistener(instance, sqlvm_resource_id): ''' Remove a SQL virtual machine from an availability group listener. ''' if not is_valid_resource_id(sqlvm_resource_id): raise CLIError("Invalid SQL virtual machine resource id.") vm_list = instance.load_balancer_configurations...
python
{ "resource": "" }
q32517
publish_app
train
def publish_app(cmd, client, resource_group_name, resource_name, code_dir=None, proj_name=None, version='v3'): """Publish local bot code to Azure. This method is directly called via "bot publish" :param cmd: :param client: :param resource_group_name: :param resource_name: :param code_dir: ...
python
{ "resource": "" }
q32518
CommandTree.get_child
train
def get_child(self, child_name): # pylint: disable=no-self-use """ returns the object with the name supplied """ child = self.children.get(child_name, None) if child: return child raise ValueError("Value {} not in this tree".format(child_name))
python
{ "resource": "" }
q32519
CommandTree.in_tree
train
def in_tree(self, cmd_args): """ if a command is in the tree """ if not cmd_args: return True tree = self try: for datum in cmd_args: tree = tree.get_child(datum) except ValueError: return False return True
python
{ "resource": "" }
q32520
AliasExtensionTelemetrySession.generate_payload
train
def generate_payload(self): """ Generate a list of telemetry events as payload """ events = [] transformation_task = self._get_alias_transformation_properties() transformation_task.update(self._get_based_properties()) events.append(transformation_task) fo...
python
{ "resource": "" }
q32521
sort_completions
train
def sort_completions(completions_gen): """ sorts the completions """ from knack.help import REQUIRED_TAG def _get_weight(val): """ weights the completions with required things first the lexicographically""" priority = '' if val.display_meta and val.display_meta.startswith(REQUIRED_T...
python
{ "resource": "" }
q32522
AzCompleter.validate_param_completion
train
def validate_param_completion(self, param, leftover_args): """ validates that a param should be completed """ # validates param starts with unfinished word completes = self.validate_completion(param) # show parameter completions when started full_param = self.unfinished_word.sta...
python
{ "resource": "" }
q32523
AzCompleter.process_dynamic_completion
train
def process_dynamic_completion(self, completion): """ how to validate and generate completion for dynamic params """ if len(completion.split()) > 1: completion = '\"' + completion + '\"' if self.validate_completion(completion): yield Completion(completion, -len(self.unfi...
python
{ "resource": "" }
q32524
AzCompleter.gen_enum_completions
train
def gen_enum_completions(self, arg_name): """ generates dynamic enumeration completions """ try: # if enum completion for choice in self.cmdtab[self.current_command].arguments[arg_name].choices: if self.validate_completion(choice): yield Completion(choice...
python
{ "resource": "" }
q32525
AzCompleter.get_arg_name
train
def get_arg_name(self, param): """ gets the argument name used in the command table for a parameter """ if self.current_command in self.cmdtab: for arg in self.cmdtab[self.current_command].arguments: for name in self.cmdtab[self.current_command].arguments[arg].options_list: ...
python
{ "resource": "" }
q32526
AzCompleter.mute_parse_args
train
def mute_parse_args(self, text): """ mutes the parser error when parsing, then puts it back """ error = AzCliCommandParser.error _check_value = AzCliCommandParser._check_value AzCliCommandParser.error = error_pass AzCliCommandParser._check_value = _check_value_muted # N...
python
{ "resource": "" }
q32527
AzCompleter.gen_dynamic_completions
train
def gen_dynamic_completions(self, text): """ generates the dynamic values, like the names of resource groups """ try: # pylint: disable=too-many-nested-blocks param = self.leftover_args[-1] # command table specific name arg_name = self.get_arg_name(param) ...
python
{ "resource": "" }
q32528
AzCompleter.yield_param_completion
train
def yield_param_completion(self, param, last_word): """ yields a parameter """ return Completion(param, -len(last_word), display_meta=self.param_description.get( self.current_command + " " + str(param), '').replace(os.linesep, ''))
python
{ "resource": "" }
q32529
AzCompleter.gen_cmd_and_param_completions
train
def gen_cmd_and_param_completions(self): """ generates command and parameter completions """ if self.complete_command: for param in self.command_param_info.get(self.current_command, []): if self.validate_param_completion(param, self.leftover_args): yield s...
python
{ "resource": "" }
q32530
AzCompleter.has_description
train
def has_description(self, param): """ if a parameter has a description """ return param in self.param_description.keys() and \ not self.param_description[param].isspace()
python
{ "resource": "" }
q32531
AzCompleter.reformat_cmd
train
def reformat_cmd(self, text): """ reformat the text to be stripped of noise """ # remove az if there text = text.replace('az', '') # disregard defaulting symbols if text and SELECT_SYMBOL['scope'] == text[0:2]: text = text.replace(SELECT_SYMBOL['scope'], "") ...
python
{ "resource": "" }
q32532
_remove_nulls
train
def _remove_nulls(managed_clusters): """ Remove some often-empty fields from a list of ManagedClusters, so the JSON representation doesn't contain distracting null fields. This works around a quirk of the SDK for python behavior. These fields are not sent by the server, but get recreated by the CLI...
python
{ "resource": "" }
q32533
ArgsFinder.get_parsed_args
train
def get_parsed_args(self, comp_words): """ gets the parsed args from a patched parser """ active_parsers = self._patch_argument_parser() parsed_args = argparse.Namespace() self.completing = True if USING_PYTHON2: # Python 2 argparse only properly works with byte str...
python
{ "resource": "" }
q32534
get_alias_table
train
def get_alias_table(): """ Get the current alias table. """ try: alias_table = get_config_parser() alias_table.read(azext_alias.alias.GLOBAL_ALIAS_PATH) return alias_table except Exception: # pylint: disable=broad-except return get_config_parser()
python
{ "resource": "" }
q32535
is_alias_command
train
def is_alias_command(subcommands, args): """ Check if the user is invoking one of the comments in 'subcommands' in the from az alias . Args: subcommands: The list of subcommands to check through. args: The CLI arguments to process. Returns: True if the user is invoking 'az ali...
python
{ "resource": "" }
q32536
remove_pos_arg_placeholders
train
def remove_pos_arg_placeholders(alias_command): """ Remove positional argument placeholders from alias_command. Args: alias_command: The alias command to remove from. Returns: The alias command string without positional argument placeholder. """ # Boundary index is the index at...
python
{ "resource": "" }
q32537
filter_aliases
train
def filter_aliases(alias_table): """ Filter aliases that does not have a command field in the configuration file. Args: alias_table: The alias table. Yield: A tuple with [0] being the first word of the alias and [1] being the command that the alias points to. """ for al...
python
{ "resource": "" }
q32538
reduce_alias_table
train
def reduce_alias_table(alias_table): """ Reduce the alias table to a tuple that contains the alias and the command that the alias points to. Args: The alias table to be reduced. Yields A tuple that contains the alias and the command that the alias points to. """ for alias in al...
python
{ "resource": "" }
q32539
retrieve_file_from_url
train
def retrieve_file_from_url(url): """ Retrieve a file from an URL Args: url: The URL to retrieve the file from. Returns: The absolute path of the downloaded file. """ try: alias_source, _ = urlretrieve(url) # Check for HTTPError in Python 2.x with open(al...
python
{ "resource": "" }
q32540
filter_alias_create_namespace
train
def filter_alias_create_namespace(namespace): """ Filter alias name and alias command inside alias create namespace to appropriate strings. Args namespace: The alias create namespace. Returns: Filtered namespace where excessive whitespaces are removed in strings. """ def filter...
python
{ "resource": "" }
q32541
get_lexers
train
def get_lexers(main_lex, exam_lex, tool_lex): """ gets all the lexer wrappers """ if not main_lex: return None, None, None lexer = None if main_lex: if issubclass(main_lex, PromptLex): lexer = main_lex elif issubclass(main_lex, PygLex): lexer = PygmentsLex...
python
{ "resource": "" }
q32542
get_anyhline
train
def get_anyhline(config): """ if there is a line between descriptions and example """ if config.BOOLEAN_STATES[config.config.get('Layout', 'command_description')] or\ config.BOOLEAN_STATES[config.config.get('Layout', 'param_description')]: return Window( width=LayoutDimension.exact(1)...
python
{ "resource": "" }
q32543
get_example
train
def get_example(config, exam_lex): """ example description window """ if config.BOOLEAN_STATES[config.config.get('Layout', 'examples')]: return Window( content=BufferControl( buffer_name="examples", lexer=exam_lex)) return get_empty()
python
{ "resource": "" }
q32544
get_hline
train
def get_hline(): """ gets a horiztonal line """ return Window( width=LayoutDimension.exact(1), height=LayoutDimension.exact(1), content=FillControl('-', token=Token.Line))
python
{ "resource": "" }
q32545
get_descriptions
train
def get_descriptions(config, exam_lex, lexer): """ based on the configuration settings determines which windows to include """ if config.BOOLEAN_STATES[config.config.get('Layout', 'command_description')]: if config.BOOLEAN_STATES[config.config.get('Layout', 'param_description')]: return VSpl...
python
{ "resource": "" }
q32546
LayoutManager.get_prompt_tokens
train
def get_prompt_tokens(self, _): """ returns prompt tokens """ if self.shell_ctx.default_command: prompt = 'az {}>> '.format(self.shell_ctx.default_command) else: prompt = 'az>> ' return [(Token.Az, prompt)]
python
{ "resource": "" }
q32547
LayoutManager.create_tutorial_layout
train
def create_tutorial_layout(self): """ layout for example tutorial """ lexer, _, _ = get_lexers(self.shell_ctx.lexer, None, None) layout_full = HSplit([ FloatContainer( Window( BufferControl( input_processors=self.input_proce...
python
{ "resource": "" }
q32548
LayoutManager.create_layout
train
def create_layout(self, exam_lex, toolbar_lex): """ creates the layout """ lexer, exam_lex, toolbar_lex = get_lexers(self.shell_ctx.lexer, exam_lex, toolbar_lex) if not any(isinstance(processor, DefaultPrompt) for processor in self.input_processors): self.input_processors.append(Def...
python
{ "resource": "" }
q32549
ads_use_dev_spaces
train
def ads_use_dev_spaces(cluster_name, resource_group_name, update=False, space_name=None, do_not_prompt=False): """ Use Azure Dev Spaces with a managed Kubernetes cluster. :param cluster_name: Name of the managed cluster. :type cluster_name: String :param resource_group_name: Name of resource group....
python
{ "resource": "" }
q32550
ads_remove_dev_spaces
train
def ads_remove_dev_spaces(cluster_name, resource_group_name, do_not_prompt=False): """ Remove Azure Dev Spaces from a managed Kubernetes cluster. :param cluster_name: Name of the managed cluster. :type cluster_name: String :param resource_group_name: Name of resource group. You can configure the de...
python
{ "resource": "" }
q32551
get_query_targets
train
def get_query_targets(cli_ctx, apps, resource_group): """Produces a list of uniform GUIDs representing applications to query.""" if isinstance(apps, list): if resource_group: return [get_id_from_azure_resource(cli_ctx, apps[0], resource_group)] return list(map(lambda x: get_id_from_a...
python
{ "resource": "" }
q32552
get_linked_properties
train
def get_linked_properties(cli_ctx, app, resource_group, read_properties=None, write_properties=None): """Maps user-facing role names to strings used to identify them on resources.""" roles = { "ReadTelemetry": "api", "WriteAnnotations": "annotations", "AuthenticateSDKControlChannel": "ag...
python
{ "resource": "" }
q32553
transform_aglistener_output
train
def transform_aglistener_output(result): ''' Transforms the result of Availability Group Listener to eliminate unnecessary parameters. ''' from collections import OrderedDict from msrestazure.tools import parse_resource_id try: resource_group = getattr(result, 'resource_group', None) or ...
python
{ "resource": "" }
q32554
format_wsfc_domain_profile
train
def format_wsfc_domain_profile(result): ''' Formats the WSFCDomainProfile object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.cluster_bootstrap_account is not None: order_dic...
python
{ "resource": "" }
q32555
format_additional_features_server_configurations
train
def format_additional_features_server_configurations(result): ''' Formats the AdditionalFeaturesServerConfigurations object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.is_rservices_...
python
{ "resource": "" }
q32556
format_auto_backup_settings
train
def format_auto_backup_settings(result): ''' Formats the AutoBackupSettings object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.enable is not None: order_dict['enable'] = res...
python
{ "resource": "" }
q32557
format_auto_patching_settings
train
def format_auto_patching_settings(result): ''' Formats the AutoPatchingSettings object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.enable is not None: order_dict['enable'] =...
python
{ "resource": "" }
q32558
format_key_vault_credential_settings
train
def format_key_vault_credential_settings(result): ''' Formats the KeyVaultCredentialSettings object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.enable is not None: order_dic...
python
{ "resource": "" }
q32559
format_load_balancer_configuration
train
def format_load_balancer_configuration(result): ''' Formats the LoadBalancerConfiguration object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.private_ip_address is not None: ...
python
{ "resource": "" }
q32560
format_private_ip_address
train
def format_private_ip_address(result): ''' Formats the PrivateIPAddress object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.ip_address is not None: order_dict['ipAddress'] = ...
python
{ "resource": "" }
q32561
format_server_configuration_management_settings
train
def format_server_configuration_management_settings(result): ''' Formats the ServerConfigurationsManagementSettings object removing arguments that are empty ''' from collections import OrderedDict order_dict = OrderedDict([('sqlConnectivityUpdateSettings', format_sql_c...
python
{ "resource": "" }
q32562
format_sql_connectivity_update_settings
train
def format_sql_connectivity_update_settings(result): ''' Formats the SqlConnectivityUpdateSettings object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.connectivity_type is not None: ...
python
{ "resource": "" }
q32563
format_sql_storage_update_settings
train
def format_sql_storage_update_settings(result): ''' Formats the SqlStorageUpdateSettings object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.disk_count is not None: order_dic...
python
{ "resource": "" }
q32564
format_sql_workload_type_update_settings
train
def format_sql_workload_type_update_settings(result): ''' Formats the SqlWorkloadTypeUpdateSettings object removing arguments that are empty ''' from collections import OrderedDict # Only display parameters that have content order_dict = OrderedDict() if result.sql_workload_type is not None:...
python
{ "resource": "" }
q32565
aks_upgrades_table_format
train
def aks_upgrades_table_format(result): """Format get-upgrades results as a summary for display with "-o table".""" # pylint: disable=import-error from jmespath import compile as compile_jmes, Options # This expression assumes there is one node pool, and that the master and nodes upgrade in lockstep. ...
python
{ "resource": "" }
q32566
aks_versions_table_format
train
def aks_versions_table_format(result): """Format get-versions results as a summary for display with "-o table".""" # pylint: disable=import-error from jmespath import compile as compile_jmes, Options parsed = compile_jmes("""orchestrators[].{ kubernetesVersion: orchestratorVersion, upgr...
python
{ "resource": "" }
q32567
process_alias_create_namespace
train
def process_alias_create_namespace(namespace): """ Validate input arguments when the user invokes 'az alias create'. Args: namespace: argparse namespace object. """ namespace = filter_alias_create_namespace(namespace) _validate_alias_name(namespace.alias_name) _validate_alias_comman...
python
{ "resource": "" }
q32568
process_alias_import_namespace
train
def process_alias_import_namespace(namespace): """ Validate input arguments when the user invokes 'az alias import'. Args: namespace: argparse namespace object. """ if is_url(namespace.alias_source): alias_source = retrieve_file_from_url(namespace.alias_source) _validate_al...
python
{ "resource": "" }
q32569
process_alias_export_namespace
train
def process_alias_export_namespace(namespace): """ Validate input arguments when the user invokes 'az alias export'. Args: namespace: argparse namespace object. """ namespace.export_path = os.path.abspath(namespace.export_path) if os.path.isfile(namespace.export_path): raise CLI...
python
{ "resource": "" }
q32570
_validate_alias_name
train
def _validate_alias_name(alias_name): """ Check if the alias name is valid. Args: alias_name: The name of the alias to validate. """ if not alias_name: raise CLIError(EMPTY_ALIAS_ERROR) if not re.match('^[a-zA-Z]', alias_name): raise CLIError(INVALID_STARTING_CHAR_ERROR...
python
{ "resource": "" }
q32571
_validate_alias_command
train
def _validate_alias_command(alias_command): """ Check if the alias command is valid. Args: alias_command: The command to validate. """ if not alias_command: raise CLIError(EMPTY_ALIAS_ERROR) split_command = shlex.split(alias_command) boundary_index = len(split_command) ...
python
{ "resource": "" }
q32572
_validate_pos_args_syntax
train
def _validate_pos_args_syntax(alias_name, alias_command): """ Check if the positional argument syntax is valid in alias name and alias command. Args: alias_name: The name of the alias to validate. alias_command: The command to validate. """ pos_args_from_alias = get_placeholders(ali...
python
{ "resource": "" }
q32573
_validate_alias_command_level
train
def _validate_alias_command_level(alias, command): """ Make sure that if the alias is a reserved command, the command that the alias points to in the command tree does not conflict in levels. e.g. 'dns' -> 'network dns' is valid because dns is a level 2 command and network dns starts at level 1. Ho...
python
{ "resource": "" }
q32574
_validate_alias_file_path
train
def _validate_alias_file_path(alias_file_path): """ Make sure the alias file path is neither non-existant nor a directory Args: The alias file path to import aliases from. """ if not os.path.exists(alias_file_path): raise CLIError(ALIAS_FILE_NOT_FOUND_ERROR) if os.path.isdir(al...
python
{ "resource": "" }
q32575
_validate_alias_file_content
train
def _validate_alias_file_content(alias_file_path, url=''): """ Make sure the alias name and alias command in the alias file is in valid format. Args: The alias file path to import aliases from. """ alias_table = get_config_parser() try: alias_table.read(alias_file_path) ...
python
{ "resource": "" }
q32576
execute_query
train
def execute_query(cmd, client, application, analytics_query, start_time=None, end_time=None, offset='1h', resource_group_name=None): """Executes a query against the provided Application Insights application.""" from .vendored_sdks.applicationinsights.models import QueryBody targets = get_query_targets(cmd.c...
python
{ "resource": "" }
q32577
add_new_lines
train
def add_new_lines(long_phrase, line_min=None, tolerance=TOLERANCE): """ not everything fits on the screen, based on the size, add newlines """ if line_min is None: line_min = math.floor(int(_get_window_columns()) / 2 - 15) if long_phrase is None: return long_phrase line_min = int(line_m...
python
{ "resource": "" }
q32578
GatherCommands.add_exit
train
def add_exit(self): """ adds the exits from the application """ self.completable.append("quit") self.completable.append("exit") self.descrip["quit"] = "Exits the program" self.descrip["exit"] = "Exits the program" self.command_tree.add_child(CommandBranch("quit")) ...
python
{ "resource": "" }
q32579
GatherCommands._gather_from_files
train
def _gather_from_files(self, config): """ gathers from the files in a way that is convienent to use """ command_file = config.get_help_files() cache_path = os.path.join(config.get_config_dir(), 'cache') cols = _get_window_columns() with open(os.path.join(cache_path, command_file...
python
{ "resource": "" }
q32580
GatherCommands.get_all_subcommands
train
def get_all_subcommands(self): """ returns all the subcommands """ subcommands = [] for command in self.descrip: for word in command.split(): for kid in self.command_tree.children: if word != kid and word not in subcommands: ...
python
{ "resource": "" }
q32581
create_alias
train
def create_alias(alias_name, alias_command): """ Create an alias. Args: alias_name: The name of the alias. alias_command: The command that the alias points to. """ alias_name, alias_command = alias_name.strip(), alias_command.strip() alias_table = get_alias_table() if alias_...
python
{ "resource": "" }
q32582
export_aliases
train
def export_aliases(export_path=None, exclusions=None): """ Export all registered aliases to a given path, as an INI configuration file. Args: export_path: The path of the alias configuration file to export to. exclusions: Space-separated aliases excluded from export. """ if not expo...
python
{ "resource": "" }
q32583
import_aliases
train
def import_aliases(alias_source): """ Import aliases from a file or an URL. Args: alias_source: The source of the alias. It can be a filepath or an URL. """ alias_table = get_alias_table() if is_url(alias_source): alias_source = retrieve_file_from_url(alias_source) alias...
python
{ "resource": "" }
q32584
list_alias
train
def list_alias(): """ List all registered aliases. Returns: An array of dictionary containing the alias and the command that it points to. """ alias_table = get_alias_table() output = [] for alias in alias_table.sections(): if alias_table.has_option(alias, 'command'): ...
python
{ "resource": "" }
q32585
remove_alias
train
def remove_alias(alias_names): """ Remove an alias. Args: alias_name: The name of the alias to be removed. """ alias_table = get_alias_table() for alias_name in alias_names: if alias_name not in alias_table.sections(): raise CLIError(ALIAS_NOT_FOUND_ERROR.format(alia...
python
{ "resource": "" }
q32586
_commit_change
train
def _commit_change(alias_table, export_path=None, post_commit=True): """ Record changes to the alias table. Also write new alias config hash and collided alias, if any. Args: alias_table: The alias table to commit. export_path: The path to export the aliases to. Default: GLOBAL_ALIAS_PA...
python
{ "resource": "" }
q32587
applicationinsights_mgmt_plane_client
train
def applicationinsights_mgmt_plane_client(cli_ctx, _, subscription=None): """Initialize Log Analytics mgmt client for use with CLI.""" from .vendored_sdks.mgmt_applicationinsights import ApplicationInsightsManagementClient from azure.cli.core._profile import Profile profile = Profile(cli_ctx=cli_ctx) ...
python
{ "resource": "" }
q32588
alias_event_handler
train
def alias_event_handler(_, **kwargs): """ An event handler for alias transformation when EVENT_INVOKER_PRE_TRUNCATE_CMD_TBL event is invoked. """ try: telemetry.start() start_time = timeit.default_timer() args = kwargs.get('args') alias_manager = AliasManager(**kwargs) ...
python
{ "resource": "" }
q32589
enable_aliases_autocomplete
train
def enable_aliases_autocomplete(_, **kwargs): """ Enable aliases autocomplete by injecting aliases into Azure CLI tab completion list. """ external_completions = kwargs.get('external_completions', []) prefix = kwargs.get('cword_prefix', []) cur_commands = kwargs.get('comp_words', []) alias_t...
python
{ "resource": "" }
q32590
transform_cur_commands_interactive
train
def transform_cur_commands_interactive(_, **kwargs): """ Transform any aliases in current commands in interactive into their respective commands. """ event_payload = kwargs.get('event_payload', {}) # text_split = current commands typed in the interactive shell without any unfinished word # text ...
python
{ "resource": "" }
q32591
enable_aliases_autocomplete_interactive
train
def enable_aliases_autocomplete_interactive(_, **kwargs): """ Enable aliases autocomplete on interactive mode by injecting aliases in the command tree. """ subtree = kwargs.get('subtree', None) if not subtree or not hasattr(subtree, 'children'): return for alias, alias_command in filter...
python
{ "resource": "" }
q32592
_is_autocomplete_valid
train
def _is_autocomplete_valid(cur_commands, alias_command): """ Determine whether autocomplete can be performed at the current state. Args: parser: The current CLI parser. cur_commands: The current commands typed in the console. alias_command: The alias command. Returns: T...
python
{ "resource": "" }
q32593
_transform_cur_commands
train
def _transform_cur_commands(cur_commands, alias_table=None): """ Transform any aliases in cur_commands into their respective commands. Args: alias_table: The alias table. cur_commands: current commands typed in the console. """ transformed = [] alias_table = alias_table if alias...
python
{ "resource": "" }
q32594
help_text
train
def help_text(values): """ reformats the help text """ result = "" for key in values: result += key + ' '.join('' for x in range(GESTURE_LENGTH - len(key))) +\ ': ' + values[key] + '\n' return result
python
{ "resource": "" }
q32595
ask_user_for_telemetry
train
def ask_user_for_telemetry(): """ asks the user for if we can collect telemetry """ answer = " " while answer.lower() != 'yes' and answer.lower() != 'no': answer = prompt(u'\nDo you agree to sending telemetry (yes/no)? Default answer is yes: ') if answer == '': answer = 'yes' ...
python
{ "resource": "" }
q32596
Configuration.firsttime
train
def firsttime(self): """ sets it as already done""" self.config.set('DEFAULT', 'firsttime', 'no') if self.cli_config.getboolean('core', 'collect_telemetry', fallback=False): print(PRIVACY_STATEMENT) else: self.cli_config.set_value('core', 'collect_telemetry', ask_...
python
{ "resource": "" }
q32597
Configuration.set_val
train
def set_val(self, direct, section, val): """ set the config values """ if val is not None: self.config.set(direct, section, val) self.update()
python
{ "resource": "" }
q32598
Configuration.update
train
def update(self): """ updates the configuration settings """ with open(os.path.join(self.config_dir, CONFIG_FILE_NAME), 'w') as config_file: self.config.write(config_file)
python
{ "resource": "" }
q32599
execute_query
train
def execute_query(client, workspace, analytics_query, timespan=None, workspaces=None): """Executes a query against the provided Log Analytics workspace.""" from .vendored_sdks.loganalytics.models import QueryBody return client.query(workspace, QueryBody(query=analytics_query, timespan=timespan, workspaces=w...
python
{ "resource": "" }