INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Returns list of strings with dependency metadata from Dapi
def get_dependency_metadata(): '''Returns list of strings with dependency metadata from Dapi''' link = os.path.join(_api_url(), 'meta.txt') return _process_req_txt(requests.get(link)).split('\n')
This function creates a frame
def create_frame(self): """ This function creates a frame """ frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.IN) return frame
Function creates box. Based on orientation it can be either HORIZONTAL or VERTICAL
def create_box(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0): """ Function creates box. Based on orientation it can be either HORIZONTAL or VERTICAL """ h_box = Gtk.Box(orientation=orientation, spacing=spacing) h_box.set_homogeneous(False) retur...
Function creates a button with lave. If assistant is specified then text is aligned
def button_with_label(self, description, assistants=None): """ Function creates a button with lave. If assistant is specified then text is aligned """ btn = self.create_button() label = self.create_label(description) if assistants is not None: ...
The function creates a image from name defined in image_name
def create_image(self, image_name=None, scale_ratio=1, window=None): """ The function creates a image from name defined in image_name """ size = 48 * scale_ratio pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(image_name, -1, size, True) image = Gtk.Image() ...
The function creates a button with image
def button_with_image(self, description, image=None, sensitive=True): """ The function creates a button with image """ btn = self.create_button() btn.set_sensitive(sensitive) h_box = self.create_box() try: img = self.create_image(image_name=image, ...
The function creates a checkbutton with label
def checkbutton_with_label(self, description): """ The function creates a checkbutton with label """ act_btn = Gtk.CheckButton(description) align = self.create_alignment() act_btn.add(align) return align
Function creates a checkbox with his name
def create_checkbox(self, name, margin=10): """ Function creates a checkbox with his name """ chk_btn = Gtk.CheckButton(name) chk_btn.set_margin_right(margin) return chk_btn
Function creates an Entry with corresponding text
def create_entry(self, text="", sensitive="False"): """ Function creates an Entry with corresponding text """ text_entry = Gtk.Entry() text_entry.set_sensitive(sensitive) text_entry.set_text(text) return text_entry
Function creates a link button with corresponding text and URI reference
def create_link_button(self, text="None", uri="None"): """ Function creates a link button with corresponding text and URI reference """ link_btn = Gtk.LinkButton(uri, text) return link_btn
This is generalized method for creating Gtk. Button
def create_button(self, style=Gtk.ReliefStyle.NORMAL): """ This is generalized method for creating Gtk.Button """ btn = Gtk.Button() btn.set_relief(style) return btn
Function creates a menu item with an image
def create_image_menu_item(self, text, image_name): """ Function creates a menu item with an image """ menu_item = Gtk.ImageMenuItem(text) img = self.create_image(image_name) menu_item.set_image(img) return menu_item
The function is used for creating lable with HTML text
def create_label(self, name, justify=Gtk.Justification.CENTER, wrap_mode=True, tooltip=None): """ The function is used for creating lable with HTML text """ label = Gtk.Label() name = name.replace('|', '\n') label.set_markup(name) label.set_justify(justify) ...
The function is used for creating button with all features like signal on tooltip and signal on clicked The function does not have any menu. Button is add to the Gtk. Grid on specific row and column
def add_button(self, grid_lang, ass, row, column): """ The function is used for creating button with all features like signal on tooltip and signal on clicked The function does not have any menu. Button is add to the Gtk.Grid on specific row and column """ #print ...
Add button that opens the window for installing more assistants
def add_install_button(self, grid_lang, row, column): """ Add button that opens the window for installing more assistants """ btn = self.button_with_label('<b>Install more...</b>') if row == 0 and column == 0: grid_lang.add(btn) else: grid_lang.att...
The function creates a menu item and assigns signal like select and button - press - event for manipulation with menu_item. sub_assistant and path
def menu_item(self, sub_assistant, path): """ The function creates a menu item and assigns signal like select and button-press-event for manipulation with menu_item. sub_assistant and path """ if not sub_assistant[0].icon_path: menu_item = self.create_menu_ite...
Function generates menu from based on ass parameter
def generate_menu(self, ass, text, path=None, level=0): """ Function generates menu from based on ass parameter """ menu = self.create_menu() for index, sub in enumerate(sorted(ass[1], key=lambda y: y[0].fullname.lower())): if index != 0: text += "|" ...
The function is used for creating button with menu and submenu. Also signal on tooltip and signal on clicked are specified Button is add to the Gtk. Grid
def add_submenu(self, grid_lang, ass, row, column): """ The function is used for creating button with menu and submenu. Also signal on tooltip and signal on clicked are specified Button is add to the Gtk.Grid """ text = "Available subassistants:\n" # Generate menu...
Function creates a scrolled window with layout manager
def create_scrolled_window(self, layout_manager, horizontal=Gtk.PolicyType.NEVER, vertical=Gtk.PolicyType.ALWAYS): """ Function creates a scrolled window with layout manager """ scrolled_window = Gtk.ScrolledWindow() scrolled_window.add(layout_manager) scrolled_window.set...
Function creates a Gtk Grid with spacing and homogeous tags
def create_gtk_grid(self, row_spacing=6, col_spacing=6, row_homogenous=False, col_homogenous=True): """ Function creates a Gtk Grid with spacing and homogeous tags """ grid_lang = Gtk.Grid() grid_lang.set_column_spacing(row_spacing) grid_lang.set_row_spacing(col_s...
Function creates a notebook
def create_notebook(self, position=Gtk.PositionType.TOP): """ Function creates a notebook """ notebook = Gtk.Notebook() notebook.set_tab_pos(position) notebook.set_show_border(True) return notebook
Function creates a message dialog with text and relevant buttons
def create_message_dialog(self, text, buttons=Gtk.ButtonsType.CLOSE, icon=Gtk.MessageType.WARNING): """ Function creates a message dialog with text and relevant buttons """ dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.DESTROY_WITH_PARENT, ...
Function creates a question dialog with title text and second_text
def create_question_dialog(self, text, second_text): """ Function creates a question dialog with title text and second_text """ dialog = self.create_message_dialog( text, buttons=Gtk.ButtonsType.YES_NO, icon=Gtk.MessageType.QUESTION ) dialog.format_sec...
Function executes a dialog
def execute_dialog(self, title): """ Function executes a dialog """ msg_dlg = self.create_message_dialog(title) msg_dlg.run() msg_dlg.destroy() return
Function creates a file chooser dialog with title text
def create_file_chooser_dialog(self, text, parent, name=Gtk.STOCK_OPEN): """ Function creates a file chooser dialog with title text """ text = None dialog = Gtk.FileChooserDialog( text, parent, Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CA...
Function creates an alignment
def create_alignment(self, x_align=0, y_align=0, x_scale=0, y_scale=0): """ Function creates an alignment """ align = Gtk.Alignment() align.set(x_align, y_align, x_scale, y_scale) return align
Function creates a text view with wrap_mode and justification
def create_textview(self, wrap_mode=Gtk.WrapMode.WORD_CHAR, justify=Gtk.Justification.LEFT, visible=True, editable=True): """ Function creates a text view with wrap_mode and justification """ text_view = Gtk.TextView() text_view.set_wrap_mode(wrap_mode) text_view....
Function creates a tree_view with model
def create_tree_view(self, model=None): """ Function creates a tree_view with model """ tree_view = Gtk.TreeView() if model is not None: tree_view.set_model(model) return tree_view
Function creates a CellRendererText with title
def create_cell_renderer_text(self, tree_view, title="title", assign=0, editable=False): """ Function creates a CellRendererText with title """ renderer = Gtk.CellRendererText() renderer.set_property('editable', editable) column = Gtk.TreeViewColumn(title, renderer, text=...
Function creates a CellRendererCombo with title model
def create_cell_renderer_combo(self, tree_view, title="title", assign=0, editable=False, model=None, function=None): """' Function creates a CellRendererCombo with title, model """ renderer_combo = Gtk.CellRendererCombo() renderer_combo.set_property('editable', editable) ...
Function creates a clipboard
def create_clipboard(self, text, selection=Gdk.SELECTION_CLIPBOARD): """ Function creates a clipboard """ clipboard = Gtk.Clipboard.get(selection) clipboard.set_text('\n'.join(text), -1) clipboard.store() return clipboard
Runs a command from string e. g. cp foo bar Args: cmd_str: the command to run as string log_level: level at which to log command output ( DEBUG by default ) ignore_sigint: should we ignore sigint during this command ( False by default ) output_callback: function that gets called with every line of output as argument as...
def run_command(cls, cmd_str, log_level=logging.DEBUG, ignore_sigint=False, output_callback=None, as_user=None, log_secret=False, env=None): """Runs a command from string, ...
Returns the password typed by user as a string or None if user cancels the request ( e. g. presses Ctrl + D on commandline or presses Cancel in GUI.
def ask_for_password(cls, ui, prompt='Provide your password:', **options): """Returns the password typed by user as a string or None if user cancels the request (e.g. presses Ctrl + D on commandline or presses Cancel in GUI. """ # optionally set title, that may be used by some helpers li...
Returns True if user agrees False otherwise
def ask_for_confirm_with_message(cls, ui, prompt='Do you agree?', message='', **options): """Returns True if user agrees, False otherwise""" return cls.get_appropriate_helper(ui).ask_for_confirm_with_message(prompt, message)
Ask user for written input with prompt
def ask_for_input_with_prompt(cls, ui, prompt='', **options): """Ask user for written input with prompt""" return cls.get_appropriate_helper(ui).ask_for_input_with_prompt(prompt=prompt, **options)
Used by cli to add this as an argument to argparse parser.
def add_argument_to(self, parser): """Used by cli to add this as an argument to argparse parser. Args: parser: parser to add this argument to """ from devassistant.cli.devassistant_argparse import DefaultIffUsedActionFactory if isinstance(self.kwargs.get('action', ''...
Returns the value for specified gui hint ( or a sensible default value if this argument doesn t specify the hint ).
def get_gui_hint(self, hint): """Returns the value for specified gui hint (or a sensible default value, if this argument doesn't specify the hint). Args: hint: name of the hint to get value for Returns: value of the hint specified in yaml or a sensible default ...
Construct an argument from name and params ( dict loaded from assistant/ snippet ).
def construct_arg(cls, name, params): """Construct an argument from name, and params (dict loaded from assistant/snippet). """ use_snippet = params.pop('use', None) if use_snippet: # if snippet is used, take this parameter from snippet and update # it with current...
Return list of instantiated subassistants.
def get_subassistants(self): """Return list of instantiated subassistants. Usually, this needs not be overriden in subclasses, you should just override get_subassistant_classes Returns: list of instantiated subassistants """ if not hasattr(self, '_subassista...
Returns a tree - like structure representing the assistant hierarchy going down from this assistant to leaf assistants.
def get_subassistant_tree(self): """Returns a tree-like structure representing the assistant hierarchy going down from this assistant to leaf assistants. For example: [(<This Assistant>, [(<Subassistant 1>, [...]), (<Subassistant 2>, [...])] ...
Recursively searches self. _tree - has format of ( Assistant: [ list_of_subassistants ] ) - for specific path from first to last selected subassistants.
def get_selected_subassistant_path(self, **kwargs): """Recursively searches self._tree - has format of (Assistant: [list_of_subassistants]) - for specific path from first to last selected subassistants. Args: kwargs: arguments containing names of the given assistants in form of ...
Returns True if this assistant was run as last in path False otherwise.
def is_run_as_leaf(self, **kwargs): """Returns True if this assistant was run as last in path, False otherwise.""" # find the last subassistant_N i = 0 while i < len(kwargs): # len(kwargs) is maximum of subassistant_N keys if settings.SUBASSISTANT_N_STRING.format(i) in kwarg...
Loads yaml files from all given directories.
def load_all_yamls(cls, directories): """Loads yaml files from all given directories. Args: directories: list of directories to search Returns: dict of {fullpath: loaded_yaml_structure} """ yaml_files = [] loaded_yamls = {} for d in direc...
Load a yaml file with path that is relative to one of given directories.
def load_yaml_by_relpath(cls, directories, rel_path, log_debug=False): """Load a yaml file with path that is relative to one of given directories. Args: directories: list of directories to search name: relative path of the yaml file to load log_debug: log all message...
Load a yaml file that is at given path if the path is not a string it is assumed it s a file - like object
def load_yaml_by_path(cls, path, log_debug=False): """Load a yaml file that is at given path, if the path is not a string, it is assumed it's a file-like object""" try: if isinstance(path, six.string_types): return yaml.load(open(path, 'r'), Loader=Loader) or {} ...
Installs dependencies from the leaf assistant. Raises: devassistant. exceptions. DependencyException with a cause if something goes wrong
def _run_path_dependencies(self, parsed_args): """Installs dependencies from the leaf assistant. Raises: devassistant.exceptions.DependencyException with a cause if something goes wrong """ deps = self.path[-1].dependencies(parsed_args) lang.Command('dependencies', d...
Runs all errors dependencies and run methods of all * Assistant objects in self. path. Raises: devassistant. exceptions. ExecutionException with a cause if something goes wrong
def run(self): """Runs all errors, dependencies and run methods of all *Assistant objects in self.path. Raises: devassistant.exceptions.ExecutionException with a cause if something goes wrong """ error = None # run 'pre_run', 'logging', 'dependencies' and 'run' ...
Return the maximum length of the provided strings that have a nice variant in DapFormatter. _nice_strings
def calculate_offset(cls, labels): '''Return the maximum length of the provided strings that have a nice variant in DapFormatter._nice_strings''' used_strings = set(cls._nice_strings.keys()) & set(labels) return max([len(cls._nice_strings[s]) for s in used_strings])
Format the line with DAPI user rating and number of votes
def format_dapi_score(cls, meta, offset): '''Format the line with DAPI user rating and number of votes''' if 'average_rank' and 'rank_count' in meta: label = (cls._nice_strings['average_rank'] + ':').ljust(offset + 2) score = cls._format_field(meta['average_rank']) vo...
Return all information from a given meta dictionary in a list of lines
def format_meta_lines(cls, meta, labels, offset, **kwargs): '''Return all information from a given meta dictionary in a list of lines''' lines = [] # Name and underline name = meta['package_name'] if 'version' in meta: name += '-' + meta['version'] if 'custom...
Format the list of files ( e. g. assistants or snippets
def _format_files(cls, files, kind): '''Format the list of files (e. g. assistants or snippets''' lines = [] if files: lines.append('The following {kind} are contained in this DAP:'.format(kind=kind.title())) for f in files: lines.append('* ' + strip_prefi...
Return formatted assistants from the given list in human readable form.
def format_assistants_lines(cls, assistants): '''Return formatted assistants from the given list in human readable form.''' lines = cls._format_files(assistants, 'assistants') # Assistant help if assistants: lines.append('') assistant = strip_prefix(random.choice...
Formats supported platforms in human readable form
def format_platforms(cls, platforms): '''Formats supported platforms in human readable form''' lines = [] if platforms: lines.append('This DAP is only supported on the following platforms:') lines.extend([' * ' + platform for platform in platforms]) return lines
Checks if the dap is valid reports problems
def check(cls, dap, network=False, yamls=True, raises=False, logger=logger): '''Checks if the dap is valid, reports problems Parameters: network -- whether to run checks that requires network connection output -- where to write() problems, might be None raises -- whe...
Check the meta. yaml in the dap.
def check_meta(cls, dap): '''Check the meta.yaml in the dap. Return a list of DapProblems.''' problems = list() # Check for non array-like metadata for datatype in (Dap._required_meta | Dap._optional_meta) - Dap._array_meta: if not dap._isvalid(datatype): ...
Check that everything is in the correct top - level directory.
def check_topdir(cls, dap): '''Check that everything is in the correct top-level directory. Return a list of DapProblems''' problems = list() dirname = os.path.dirname(dap._meta_location) if not dirname: msg = 'meta.yaml is not in top-level directory' pr...
Check that the package does not depend on itself.
def check_no_self_dependency(cls, dap): '''Check that the package does not depend on itself. Return a list of problems.''' problems = list() if 'package_name' in dap.meta and 'dependencies' in dap.meta: dependencies = set() for dependency in dap.meta['dependenc...
Check that the package_name is not registered on Dapi.
def check_name_not_on_dapi(cls, dap): '''Check that the package_name is not registered on Dapi. Return list of problems.''' problems = list() if dap.meta['package_name']: from . import dapicli d = dapicli.metadap(dap.meta['package_name']) if d: ...
Check that there are only those files the standard accepts.
def check_files(cls, dap): '''Check that there are only those files the standard accepts. Return list of DapProblems.''' problems = list() dirname = os.path.dirname(dap._meta_location) if dirname: dirname += '/' files = [f for f in dap.files if f.startswith(...
Check that all assistants and snippets are valid.
def check_yamls(cls, dap): '''Check that all assistants and snippets are valid. Return list of DapProblems.''' problems = list() for yaml in dap.assistants_and_snippets: path = yaml + '.yaml' parsed_yaml = YamlLoader.load_yaml_by_path(dap._get_file(path, prepend...
Strip leading directory name from the given path
def _strip_leading_dirname(self, path): '''Strip leading directory name from the given path''' return os.path.sep.join(path.split(os.path.sep)[1:])
Get all assistants in this DAP
def assistants(self): '''Get all assistants in this DAP''' return [strip_suffix(f, '.yaml') for f in self._stripped_files if self._assistants_pattern.match(f)]
Get all snippets in this DAP
def snippets(self): '''Get all snippets in this DAP''' return [strip_suffix(f, '.yaml') for f in self._stripped_files if self._snippets_pattern.match(f)]
Get all icons in this DAP optionally strip extensions
def icons(self, strip_ext=False): '''Get all icons in this DAP, optionally strip extensions''' result = [f for f in self._stripped_files if self._icons_pattern.match(f)] if strip_ext: result = [strip_suffix(f, '\.({ext})'.format(ext=self._icons_ext), regex=True) for f in result] ...
Fill self. _badmeta with meta datatypes that are invalid
def _find_bad_meta(self): '''Fill self._badmeta with meta datatypes that are invalid''' self._badmeta = dict() for datatype in self.meta: for item in self.meta[datatype]: if not Dap._meta_valid[datatype].match(item): if datatype not in self._badme...
Extracts a file from dap to a file - like object
def _get_file(self, path, prepend=False): '''Extracts a file from dap to a file-like object''' if prepend: path = os.path.join(self._dirname(), path) extracted = self._tar.extractfile(path) if extracted: return extracted raise DapFileError(('Could not read...
Load data from meta. yaml to a dictionary
def _load_meta(self, meta): '''Load data from meta.yaml to a dictionary''' meta = yaml.load(meta, Loader=Loader) # Versions are often specified in a format that is convertible to an # int or a float, so we want to make sure it is interpreted as a str. # Fix for the bug #300. ...
Report a given problem
def _report_problem(self, problem, level=logging.ERROR): '''Report a given problem''' problem = self.basename + ': ' + problem if self._logger.isEnabledFor(level): self._problematic = True if self._check_raises: raise DapInvalid(problem) self._logger.log(l...
Checks if the given datatype is valid in meta
def _isvalid(self, datatype): '''Checks if the given datatype is valid in meta''' if datatype in self.meta: return bool(Dap._meta_valid[datatype].match(self.meta[datatype])) else: return datatype in Dap._optional_meta
Checks if the given datatype is valid in meta ( for array - like types )
def _arevalid(self, datatype): '''Checks if the given datatype is valid in meta (for array-like types)''' # Datatype not specified if datatype not in self.meta: return datatype in Dap._optional_meta, [] # Required datatype empty if datatype in self._required_meta and...
Check if the given in - dap file is a directory
def _is_dir(self, f): '''Check if the given in-dap file is a directory''' return self._tar.getmember(f).type == tarfile.DIRTYPE
Find empty directories and return them Only works for actual files in dap
def _get_emptydirs(self, files): '''Find empty directories and return them Only works for actual files in dap''' emptydirs = [] for f in files: if self._is_dir(f): empty = True for ff in files: if ff.startswith(f + '/'): ...
Load all configuration from file
def load_configuration_file(self): """ Load all configuration from file """ if not os.path.exists(self.config_file): return try: with open(self.config_file, 'r') as file: csvreader = csv.reader(file, delimiter='=', ...
Save all configuration into file Only if config file does not yet exist or configuration was changed
def save_configuration_file(self): """ Save all configuration into file Only if config file does not yet exist or configuration was changed """ if os.path.exists(self.config_file) and not self.config_changed: return dirname = os.path.dirname(self.config_file) ...
Set configuration value with given name. Value can be string or boolean type.
def set_config_value(self, name, value): """ Set configuration value with given name. Value can be string or boolean type. """ if value is True: value = "True" elif value is False: if name in self.config_dict: del self.config_dict[n...
The function is used for setting tooltip on menus and submenus
def tooltip_queries(self, item, x_coord, y_coord, key_mode, tooltip, text): """ The function is used for setting tooltip on menus and submenus """ tooltip.set_text(text) return True
This function is used for create tab page for notebook. Input arguments are: assistant - used for collecting all info about assistants and subassistants
def _create_notebook_page(self, assistant): """ This function is used for create tab page for notebook. Input arguments are: assistant - used for collecting all info about assistants and subassistants """ #frame = self._create_frame() grid_lang = self.gui_helper.c...
Hides this window and opens path window. Passes all needed data and kwargs.
def _open_path_window(self): """ Hides this window and opens path window. Passes all needed data and kwargs. """ self.data['top_assistant'] = self.top_assistant self.data['current_main_assistant'] = self.get_current_main_assistant() self.data['kwargs'] = self.kwar...
Function serves for getting full assistant path and collects the information from GUI
def sub_menu_pressed(self, widget, event): """ Function serves for getting full assistant path and collects the information from GUI """ for index, data in enumerate(self.dev_assistant_path): index += 1 if settings.SUBASSISTANT_N_STRING.format(index) in se...
Function return current assistant
def get_current_main_assistant(self): """ Function return current assistant """ current_page = self.notebook.get_nth_page(self.notebook.get_current_page()) return current_page.main_assistant
Function is used for case that assistant does not have any subassistants
def btn_clicked(self, widget, data=None): """ Function is used for case that assistant does not have any subassistants """ self.kwargs['subassistant_0'] = self.get_current_main_assistant().name self.kwargs['subassistant_1'] = data if 'subassistant_2' in self.kwarg...
Function opens Main Window and in case of previously created project is switches to/ home directory This is fix in case that da creats a project and project was deleted and GUI was not closed yet
def open_window(self, widget, data=None): """ Function opens Main Window and in case of previously created project is switches to /home directory This is fix in case that da creats a project and project was deleted and GUI was not closed yet """ if data is not Non...
Function is used for showing Popup menu
def btn_press_event(self, widget, event): """ Function is used for showing Popup menu """ if event.type == Gdk.EventType.BUTTON_PRESS: if event.button.button == 1: widget.popup(None, None, None, None, event.button.button, event.tim...
Function for running DevAssistant GUI
def run_gui(): """ Function for running DevAssistant GUI """ try: from gi.repository import Gtk except ImportError as ie: pass except RuntimeError as e: sys.stderr.write(GUI_MESSAGE) sys.stderr.write("%s: %r" % (e.__class__.__name__, utils.exc_as_decoded_string(e)...
Wraps all publicly callable methods of YamlAssistant. If the assistant was loaded from cache this decorator will fully load it first time a publicly callable method is used.
def needs_fully_loaded(method): """Wraps all publicly callable methods of YamlAssistant. If the assistant was loaded from cache, this decorator will fully load it first time a publicly callable method is used. """ @functools.wraps(method) def inner(self, *args, **kwargs): if not self.ful...
Returns default path to icon of this assistant.
def default_icon_path(self): """Returns default path to icon of this assistant. Assuming self.path == "/foo/assistants/crt/python/django.yaml" For image format in [png, svg]: 1) Take the path of this assistant and strip it of load path (=> "crt/python/django.yaml") ...
Returns kwargs updated with proper meta variables ( like __assistant__ ). If this method is run repeatedly with the same section and the same kwargs it always modifies kwargs in the same way.
def proper_kwargs(self, section, kwargs): """Returns kwargs updated with proper meta variables (like __assistant__). If this method is run repeatedly with the same section and the same kwargs, it always modifies kwargs in the same way. """ kwargs['__section__'] = section ...
Returns all dependencies of this assistant with regards to specified kwargs.
def dependencies(self, kwargs=None, expand_only=False): """Returns all dependencies of this assistant with regards to specified kwargs. If expand_only == False, this method returns list of mappings of dependency types to actual dependencies (keeps order, types can repeat), e.g. Example:...
Return text for prompt ( do you want to install... ) to install given packages.
def get_perm_prompt(cls, package_list): """ Return text for prompt (do you want to install...), to install given packages. """ if cls == PackageManager: raise NotImplementedError() ln = len(package_list) plural = 's' if ln > 1 else '' return cls.permis...
Try to detect a package manager used in a current Gentoo system.
def _try_get_current_manager(cls): """ Try to detect a package manager used in a current Gentoo system. """ if utils.get_distro_name().find('gentoo') == -1: return None if 'PACKAGE_MANAGER' in os.environ: pm = os.environ['PACKAGE_MANAGER'] if pm == 'paludis': ...
Returns True if this package manager is usable False otherwise.
def is_current_manager_equals_to(cls, pm): """Returns True if this package manager is usable, False otherwise.""" if hasattr(cls, 'works_result'): return cls.works_result is_ok = bool(cls._try_get_current_manager() == pm) setattr(cls, 'works_result', is_ok) return is_...
Choose proper package manager and return it.
def get_package_manager(self, dep_t): """Choose proper package manager and return it.""" mgrs = managers.get(dep_t, []) for manager in mgrs: if manager.works(): return manager if not mgrs: err = 'No package manager for dependency type "{dep_t}"'.fo...
Add dependencies into self. dependencies possibly also adding system packages that contain non - distro package managers ( e. g. if someone wants to install dependencies with pip and pip is not present it will get installed through RPM on RPM based systems etc.
def _process_dependency(self, dep_t, dep_l): """Add dependencies into self.dependencies, possibly also adding system packages that contain non-distro package managers (e.g. if someone wants to install dependencies with pip and pip is not present, it will get installed through RPM on RPM ...
Return True if user wants to install packages False otherwise
def _ask_to_confirm(self, ui, pac_man, *to_install): """ Return True if user wants to install packages, False otherwise """ ret = DialogHelper.ask_for_package_list_confirm( ui, prompt=pac_man.get_perm_prompt(to_install), package_list=to_install, ) return bool(ret)
Install missing dependencies
def _install_dependencies(self, ui, debug): """Install missing dependencies""" for dep_t, dep_l in self.dependencies: if not dep_l: continue pkg_mgr = self.get_package_manager(dep_t) pkg_mgr.works() to_resolve = [] for dep in de...
This is the only method that should be called from outside. Call it like: DependencyInstaller ( struct ) and it will install packages which are not present on system ( it uses package managers specified by struct structure )
def install(self, struct, ui, debug=False): """ This is the only method that should be called from outside. Call it like: `DependencyInstaller(struct)` and it will install packages which are not present on system (it uses package managers specified by `struct` structure) ...
Checks and refreshes ( if needed ) all assistants with given role.
def refresh_role(self, role, file_hierarchy): """Checks and refreshes (if needed) all assistants with given role. Args: role: role of assistants to refresh file_hierarchy: hierarchy as returned by devassistant.yaml_assistant_loader.\ YamlAssistantLoad...
Recursively goes through given corresponding hierarchies from cache and filesystem and adds/ refreshes/ removes added/ changed/ removed assistants.
def _refresh_hierarchy_recursive(self, cached_hierarchy, file_hierarchy): """Recursively goes through given corresponding hierarchies from cache and filesystem and adds/refreshes/removes added/changed/removed assistants. Args: cached_hierarchy: the respective hierarchy part from cur...
Checks if assistant needs refresh.
def _ass_needs_refresh(self, cached_ass, file_ass): """Checks if assistant needs refresh. Assistant needs refresh iff any of following conditions is True: - stored source file is different than given source file - stored assistant ctime is lower than current source file ctime - ...
Completely refreshes cached assistant from file.
def _ass_refresh_attrs(self, cached_ass, file_ass): """Completely refreshes cached assistant from file. Args: cached_ass: an assistant from cache hierarchy (for format see Cache class docstring) file_ass: the respective assistant from filesystem hierarchy...