desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'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...
'Silent error message'
def error(self, message):
raise InvalidLineException(message)
'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...
'gets the parsed args from a patched parser'
def get_parsed_args(self, comp_words):
active_parsers = self._patch_argument_parser() parsed_args = argparse.Namespace() self.completing = True if USING_PYTHON2: comp_words = [ensure_bytes(word) for word in comp_words] try: active_parsers[0].parse_known_args(comp_words, namespace=parsed_args) except BaseException: ...
'writes the progres'
def write(self, args):
global PROGRESS, PROGRESS_BAR, DONE DONE = False message = args.get('message', '') percent = args.get('percent', None) if percent: PROGRESS_BAR = self._format_value(message, percent) if (int(percent) == 1): PROGRESS_BAR = None PROGRESS = message
'validates that a param should be completed'
def validate_completion(self, param, words, text_before_cursor, check_double=True):
position = (param.lower().startswith(words.lower()) and (not text_before_cursor[(-1)].isspace())) canceling_positions = ((param.lower() != words.lower()) and (param not in text_before_cursor.split())) found_double = True if check_double: for double_sets in self.same_param_doubles.get(self.curr_c...
'generates dynamic enumeration completions'
def gen_enum_completions(self, arg_name, text, started_param, prefix):
try: for choice in self.cmdtab[self.curr_command].arguments[arg_name].choices: if started_param: if (choice.lower().startswith(prefix.lower()) and (choice not in text.split())): (yield Completion(choice, (- len(prefix)))) else: (yie...
'gets the argument name used in the command table for a parameter'
def get_arg_name(self, is_param, param):
if ((self.curr_command in self.cmdtab) and is_param): for arg in self.cmdtab[self.curr_command].arguments: for name in self.cmdtab[self.curr_command].arguments[arg].options_list: if (name == param): return arg
'mutes the parser error when parsing, the puts it back'
def mute_parse_args(self, text):
error = AzCliCommandParser.error AzCliCommandParser.error = error_pass parse_args = self.argsfinder.get_parsed_args(parse_quotes(text, quotes=False, string=False)) AzCliCommandParser.error = error return parse_args
'generates the dynamic values, like the names of resource groups'
def gen_dynamic_completions(self, text):
try: (is_param, started_param, prefix, param) = dynamic_param_logic(text) arg_name = self.get_arg_name(is_param, param) if (arg_name and ((text.split()[(-1)].startswith(u'-') and text[(-1)].isspace()) or text.split()[(-2)].startswith(u'-'))): for comp in self.gen_enum_completions...
'whether is a space or no text typed, send the current branch'
def gen_cmd_completions(self, text):
if ((not text.split()) and self._is_command): if (self.branch.children is not None): for com in self.branch.children: (yield Completion(com.data)) elif ((len(text.split()) > 0) and text[(-1)].isspace() and self._is_command): if (self.branch is not self.command_tree): ...
'yields a parameter'
def yield_param_completion(self, param, last_word):
return Completion(param, (- len(last_word)), display_meta=self.param_description.get(((self.curr_command + u' ') + str(param)), u'').replace(u'\n', u''))
'generates command and parameter completions'
def gen_cmd_and_param_completions(self, text):
temp_command = str(u'') txtspt = text.split() for word in txtspt: if word.startswith(u'-'): self._is_command = False elif self._is_command: temp_command += ((u' ' + str(word)) if temp_command else str(word)) mid_val = (text.find(word) + len(word)) i...
'Global parameter stuff hard-coded in'
def gen_global_param_completions(self, text):
txtspt = text.split() if (txtspt and (len(txtspt) > 0)): for param in self.global_param: if (txtspt[(-1)].startswith(u'-') and (not txtspt[(-1)].startswith(u'--')) and param.startswith(u'-') and (not param.startswith(u'--')) and self.validate_completion(param, txtspt[(-1)], text, check_doubl...
'whether the word can be completed as a command or parameter'
def is_completable(self, symbol):
return ((symbol in self.command_parameters) or (symbol in self.param_description.keys()))
'if a parameter has a description'
def has_description(self, param):
return ((param in self.param_description.keys()) and (not self.param_description[param].isspace()))
'returns the history'
def get_history(self):
return self.config.get('Help Files', 'history')
'returns where the command table is cached'
def get_help_files(self):
return self.config.get('Help Files', 'command')
'returns the name of the frequency file'
def get_frequency(self):
return self.config.get('Help Files', 'frequency')
'loads the configuration settings'
def load(self, path):
self.config.read(path)
'sets it as already done'
def firsttime(self):
self.config.set('DEFAULT', 'firsttime', 'no') if az_config.getboolean('core', 'collect_telemetry', fallback=False): print(PRIVACY_STATEMENT) else: set_global_config_value('core', 'collect_telemetry', ask_user_for_telemetry()) self.update()
'gets the last style they used'
def get_style(self):
return self.config.get('DEFAULT', 'style')
'returns whether user has given feedback'
def has_feedback(self):
return az_config.getboolean('core', 'given feedback', fallback='false')
'sets the feedback in the config'
def set_feedback(self, value):
set_global_config_value('core', 'given feedback', value)
'sets the style they used'
def set_style(self, val):
self.set_val('DEFAULT', 'style', val)
'set the config values'
def set_val(self, direct, section, val):
self.config.set(direct, section, val) self.update()
'updates the configuration settings'
def update(self):
with open(os.path.join(get_config_dir(), CONFIG_FILE_NAME), 'w') as config_file: self.config.write(config_file)
'loads all the extra information from help files'
def load_help_files(self, data):
for cmd in helps: diction_help = yaml.load(helps[cmd]) if ('short-summary' in diction_help): if (cmd in data): data[cmd]['help'] = diction_help['short-summary'] else: data[cmd] = {'help': diction_help['short-summary'], 'parameters': {}} ...
'dumps the command table'
def dump_command_table(self):
self.command_table = APPLICATION.configuration.get_command_table() command_file = config.CONFIGURATION.get_help_files() self.install_modules() add_id_parameters(self.command_table) data = {} for cmd in self.command_table: com_descrip = {} param_descrip = {} try: ...
'Makes the interface or refreshes it'
@property def cli(self):
if ((self._cli is None) or self.refresh_cli): self._cli = self.create_interface() self.refresh_cli = False return self._cli
'changes dir'
def handle_cd(self, cmd):
if (len(cmd) != 2): print(u'Invalid syntax: cd path', file=self.output) return path = os.path.expandvars(os.path.expanduser(cmd[1])) try: os.chdir(path) except OSError as ex: print((u'cd: %s\n' % ex), file=self.output)
'brings up the metadata for the command if there is a valid command already typed'
def on_input_timeout(self, cli):
document = cli.current_buffer.document text = document.text text = text.replace(u'az ', u'') if self.default_command: text = ((self.default_command + u' ') + text) (param_info, example) = self.generate_help_text(text) self.param_docs = u'{}'.format(param_info) self.example_docs...
'generates the help text based on commands typed'
def generate_help_text(self, text):
command = param_descrip = example = u'' any_documentation = False is_command = True (rows, _) = get_window_dim() rows = int(rows) if (not self.completer): return (param_descrip, example) for word in text.split(): if word.startswith(u'-'): is_command = False ...
'makes the application object and the buffers'
def create_application(self, full_layout=True):
if full_layout: layout = create_layout(self.lexer, ExampleLexer, ToolbarLexer) else: layout = create_tutorial_layout(self.lexer) buffers = {DEFAULT_BUFFER: Buffer(is_multiline=True), u'description': Buffer(is_multiline=True, read_only=True), u'parameter': Buffer(is_multiline=True, read_only=...
'instantiates the intereface'
def create_interface(self):
return CommandLineInterface(application=self.create_application(), eventloop=create_eventloop())
'writes the prompt line'
def set_prompt(self, prompt_command=u'', position=0):
self.description_docs = u'{}'.format(prompt_command) self.cli.current_buffer.reset(initial_document=Document(self.description_docs, cursor_position=position)) self.cli.request_redraw()
'narrows the scopes the commands'
def set_scope(self, value):
set_scope(value) if self.default_command: self.default_command += (u' ' + value) else: self.default_command += value return value
'parses for the tutorial'
def handle_example(self, text, continue_flag):
cmd = text.partition(SELECT_SYMBOL[u'example'])[0].rstrip() num = text.partition(SELECT_SYMBOL[u'example'])[2].strip() example = u'' try: num = (int(num) - 1) except ValueError: print(u'An Integer should follow the colon', file=self.output) return u'' if (c...
'REPL for interactive tutorials'
def example_repl(self, text, example, start_index, continue_flag):
if start_index: start_index = (start_index + 1) cmd = u' '.join(text.split()[:start_index]) example_cli = CommandLineInterface(application=self.create_application(full_layout=False), eventloop=create_eventloop()) example_cli.buffers[u'example_line'].reset(initial_document=Document...
'handles the jmespath query for injection or printing'
def handle_jmespath_query(self, args, continue_flag):
if hasattr(self.last.result, u'__dict__'): input_dict = dict(self.last.result) else: input_dict = self.last.result try: queries = [] results = [] injected_command = [] for arg in args: if arg.startswith(SELECT_SYMBOL[u'query']): que...
'handles what to do with a scoping gesture'
def handle_scoping_input(self, continue_flag, cmd, text):
default_split = text.partition(SELECT_SYMBOL[u'scope'])[2].split() cmd = cmd.replace(SELECT_SYMBOL[u'scope'], u'') continue_flag = True if (not default_split): self.default_command = u'' set_scope(u'', add=False) print(u'unscoping all', file=self.output) return (contin...
'sends the command to the CLI to be executed'
def cli_execute(self, cmd):
try: args = parse_quotes(cmd) azlogging.configure_logging(args) if ((len(args) > 0) and (args[0] == u'feedback')): SHELL_CONFIGURATION.set_feedback(u'yes') self.user_feedback = False azure_folder = get_config_dir() if (not os.path.exists(azure_folder))...
'forces to use the Shell Progress'
def progress_patch(self, _=False):
from azure.cli.core.application import APPLICATION from azclishell.progress import ShellProgressView APPLICATION.progress_controller.init_progress(ShellProgressView()) return APPLICATION.progress_controller
'starts the REPL'
def run(self):
telemetry.start() from azure.cli.core.application import APPLICATION APPLICATION.get_progress_controller = self.progress_patch self.command_table_thread = LoadCommandTableThread(restart_completer, self) self.command_table_thread.start() from azclishell.configuration import SHELL_HELP self.cl...
'adds the exits from the application'
def add_exit(self):
self.completable.append('quit') self.completable.append('exit') self.descrip['quit'] = 'Exits the program' self.descrip['exit'] = 'Exits the program' self.command_tree.children.append(CommandBranch('quit')) self.command_tree.children.append(CommandBranch('exit')) self.command_par...
'gathers from the files in a way that is convienent to use'
def gather_from_files(self):
command_file = CONFIGURATION.get_help_files() cache_path = os.path.join(azclishell.configuration.get_config_dir(), 'cache') cols = _get_window_columns() with open(os.path.join(cache_path, command_file), 'r') as help_file: data = json.load(help_file) self.add_exit() commands = data.keys()...
'returns all the subcommands'
def get_all_subcommands(self):
subcommands = [] for command in self.descrip: for word in command.split(): for kid in self.command_tree.children: if ((word != kid.data) and (word not in subcommands)): subcommands.append(word) return subcommands
'returns the object with the name supplied'
def get_child(self, child_name, kids):
for kid in kids: if (kid.data == child_name): return kid raise ValueError('Value not in this tree')
'adds a child to this branch'
def add_child(self, child):
assert isinstance(child, CommandTree) if (not self.children): self.children = [] self.children.append(child)
'whether this has a child'
def has_child(self, name):
if (not self.children): return False return any(((kid.data == name) for kid in self.children))
'returns the subbranch of a command'
def get_subbranch(self, data):
data_split = data.split() kids = self.children for word in data_split: kid = self.get_child(word, kids) kids = kid.children return self._get_subbranch_help(kids, [])
'tracks the telemetry events and pushes them out'
def _track_event(self, name, properties=None, measurements=None):
self.track_event(name, properties, measurements) start_new_thread(self.flush, ())
'track shell specific gestures'
@_user_agrees_to_telemetry def track_ssg(self, gesture, cmd):
self._track_event('az/interactive/gesture', {gesture: scrub(cmd)})
'tracks the special key bindings'
@_user_agrees_to_telemetry def track_key(self, key):
self._track_event('az/interactive/key/{}'.format(key))
'starts recording stuff'
@_user_agrees_to_telemetry def start(self):
self.start_time = str(datetime.datetime.now())
'concludings recording stuff'
@_user_agrees_to_telemetry def conclude(self):
self.end_time = str(datetime.datetime.now()) properties = {} set_custom_properties(properties, 'starttime', str(self.start_time)) set_custom_properties(properties, 'endtime', str(self.end_time)) subprocess.Popen([sys.executable, os.path.realpath(__file__), json.dumps(properties)])
'tests building the help text'
def test_generate_help_text(self):
self.shell.completer = None (description, example) = self.shell.generate_help_text('') self.assertEqual(description, '') self.assertEqual(example, '') self.shell.completer = TestCompleter() (description, example) = self.shell.generate_help_text('friendship --calls') self.assertEqual(descr...
'tests handling of example repl'
def test_handle_examples(self):
temp_function = self.shell.example_repl self.shell.example_repl = mock_pass text = 'guess :: h' c_flag = False self.shell.handle_example(text, c_flag) self.assertEqual(self.out_stream.getvalue(), 'An Integer should follow the colon\n') self.out_stream.truncate(0) sel...
'tests the running'
def test_install_modules(self):
dump.install_modules()
'tests the cache dir is in the right place'
def test_cache_dir(self):
path = dump.get_cache_dir() self.assertEqual(path, self.path)
'tests dumping the command table'
def test_dump_commands(self):
dump.dump_command_table() self.assertTrue(os.path.exists(os.path.join(self.path, self.command_file_name)))
'tests the examples spacing'
def test_space_examples(self):
up_down_text = ' CTRL+Y (^) CTRL+N (v)' loe1 = [[]] row1 = 0 section1 = 1 self.assertEqual(space_examples(loe1, row1, section1), up_down_text) loe1 = [['start', 'end']] row1 = 0 section1 = 1 self.assertEqual(space_examples(loe1, row1, section1), ('[1] startend' + up_do...
'tests the toolbar spacing'
def test_space_toolbar(self):
setting1 = [] empty_space1 = '' (settings, empty_space) = space_toolbar(setting1, empty_space1) self.assertEqual(settings, '') self.assertEqual(empty_space, '') setting1 = ['friendship'] empty_space1 = (' ' * 15) (settings, empty_space) = space_toolbar(setting1, empty_space1) self...
'tests whether the validation function knows if there is a query'
def test_validate_contains_query(self):
args1 = [] symbol1 = '?' self.assertFalse(validate_contains_query(args1, symbol1)) args1 = ['vm', 'create', '-g=?[].group'] self.assertTrue(validate_contains_query(args1, symbol1)) args1 = ['hello', 'alexander', '--groups=?[?group == cj]'] self.assertTrue(validate_contains_query(args1,...
'a variation of initializing'
def init1(self):
com_tree1 = tree.generate_tree('command can') com_tree2 = tree.generate_tree('create') com_tree3 = tree.CommandHead() com_tree3.add_child(com_tree2) com_tree3.add_child(com_tree1) command_description = {'create': '', 'command can': ''} commands = _Commands(command_tree=com_tree3, descr...
'a variation of initializing'
def init2(self):
com_tree1 = tree.generate_tree('command can') com_tree2 = tree.generate_tree('create') com_tree3 = tree.CommandHead() com_tree3.add_child(com_tree2) com_tree3.add_child(com_tree1) command_param = {'create': ['-funtime']} completable_param = ['-helloworld', '-funtime'] param_descript =...
'a variation of initializing'
def init3(self):
com_tree1 = tree.generate_tree('command can') com_tree2 = tree.generate_tree('create') com_tree3 = tree.CommandHead() com_tree3.add_child(com_tree2) com_tree3.add_child(com_tree1) command_param = {'create': ['--funtimes', '-f', '--fun', '--helloworld']} completable_param = ['--helloworld'...
'a variation of initializing'
def init4(self):
com_tree1 = tree.generate_tree('createmore can') com_tree2 = tree.generate_tree('create') com_tree3 = tree.CommandHead() com_tree3.add_child(com_tree2) com_tree3.add_child(com_tree1) command_param = {'create': ['--funtimes', '-f', '--helloworld']} completable_param = ['--helloworld', '--f...
'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...