text
stringlengths
81
112k
Provides completions based on the document words. :param code: code to complete :param args: additional (unused) arguments. def complete(self, code, *args): """ Provides completions based on the document words. :param code: code to complete :param args: additional (unu...
Converts a message status to a string. :param status: Status to convert (p yqode.core.modes.CheckerMessages) :return: The status string. :rtype: str def status_to_string(cls, status): """ Converts a message status to a string. :param status: Status to convert (p yqode....
Adds a message or a list of message. :param messages: A list of messages or a single message def add_messages(self, messages): """ Adds a message or a list of message. :param messages: A list of messages or a single message """ # remove old messages if len(mess...
Removes a message. :param message: Message to remove def remove_message(self, message): """ Removes a message. :param message: Message to remove """ import time _logger(self.__class__).log(5, 'removing message %s' % message) t = time.time() usd ...
Clears all messages. def clear_messages(self): """ Clears all messages. """ while len(self._messages): msg = self._messages.pop(0) usd = msg.block.userData() if usd and hasattr(usd, 'messages'): usd.messages[:] = [] if msg....
Display results. :param status: Response status :param results: Response data, messages. def _on_work_finished(self, results): """ Display results. :param status: Response status :param results: Response data, messages. """ messages = [] for msg...
Requests an analysis. def request_analysis(self): """ Requests an analysis. """ if self._finished: _logger(self.__class__).log(5, 'running analysis') self._job_runner.request_job(self._request) elif self.editor: # retry later _logg...
Requests a checking of the editor content. def _request(self): """ Requests a checking of the editor content. """ try: self.editor.toPlainText() except (TypeError, RuntimeError): return try: max_line_length = self.editor.modes.get( 'Ri...
openpty() -> (master_fd, slave_fd) Open a pty master/slave pair, using os.openpty() if possible. def openpty(): """openpty() -> (master_fd, slave_fd) Open a pty master/slave pair, using os.openpty() if possible.""" try: return os.openpty() except (AttributeError, OSError): pass ...
master_open() -> (master_fd, slave_name) Open a pty master and return the fd, and the filename of the slave end. Deprecated, use openpty() instead. def master_open(): """master_open() -> (master_fd, slave_name) Open a pty master and return the fd, and the filename of the slave end. Deprecated, use ...
Open pty master and return (master_fd, tty_name). def _open_terminal(): """Open pty master and return (master_fd, tty_name).""" for x in 'pqrstuvwxyzPQRST': for y in '0123456789abcdef': pty_name = '/dev/pty' + x + y try: fd = os.open(pty_name, os.O_RDWR) ...
slave_open(tty_name) -> slave_fd Open the pty slave and acquire the controlling terminal, returning opened filedescriptor. Deprecated, use openpty() instead. def slave_open(tty_name): """slave_open(tty_name) -> slave_fd Open the pty slave and acquire the controlling terminal, returning opened f...
fork() -> (pid, master_fd) Fork and make the child a session leader with a controlling terminal. def fork(): """fork() -> (pid, master_fd) Fork and make the child a session leader with a controlling terminal.""" try: pid, fd = os.forkpty() except (AttributeError, OSError): pass ...
Write all the data to a descriptor. def _writen(fd, data): """Write all the data to a descriptor.""" while data: n = os.write(fd, data) data = data[n:]
Parent copy loop. Copies pty master -> standard output (master_read) standard input -> pty master (stdin_read) def _copy(master_fd, master_read=_read, stdin_read=_read): """Parent copy loop. Copies pty master -> standard output (master_read) standard i...
Create a spawned process. def spawn(argv, master_read=_read, stdin_read=_read): """Create a spawned process.""" if type(argv) == type(''): argv = (argv,) pid, master_fd = fork() if pid == CHILD: try: os.execlp(argv[0], *argv) except: # If we wanted to be ...
This function only gets called if the decorated property doesn't have a value in the cache. def _get_dataobject(self, name, multivalued): """This function only gets called if the decorated property doesn't have a value in the cache.""" logger.debug("Querying server for uncached data obj...
This function only gets called if the decorated property doesn't have a value in the cache. def _get_mor(self, name, multivalued): """This function only gets called if the decorated property doesn't have a value in the cache.""" logger.debug("Querying server for uncached MOR %s", name) ...
Flushes the cache being held for this instance. :param properties: The list of properties to flush from the cache. :type properties: list or None (default). If None, flush entire cache. def flush_cache(self, properties=None): """Flushes the cache being held for this instance. :param p...
Updates the properties being held for this instance. :param properties: The list of properties to update. :type properties: list or None (default). If None, update all currently cached properties. def update(self, properties=None): """Updates the properties being held for this instance...
Update the local object from the server-side object. >>> vm = VirtualMachine.find_one(client, filter={"name": "genesis"}) >>> # Update all properties >>> vm.update_view_data() >>> # Update the config and summary properties >>> vm.update_view_data(properties=["config", "s...
Pre-loads the requested properties for each object in the "name" attribute. :param name: The name of the attribute containing the list to preload. :type name: str :param properties: The properties to preload on the objects or the string all to preload all properties. ...
Update the local object from the passed in object_content. def _set_view_data(self, object_content): """Update the local object from the passed in object_content.""" # A debugging convenience, allows inspection of the object_content # that was used to create the object logger.info("Sett...
Initialize the repository cache used for scraping. Retrieves a list of repositories with their provider and last scraping time from Elasticsearch. This list can be used to check which repos need to be scraped (e.g. after a specific amount of time). def _initialize_repo_cache(): """Initialize the r...
Obtains supported features from the license manager def main(options): """Obtains supported features from the license manager""" client = Client(server=options.server, username=options.username, password=options.password) print('Successfully connected to %s' % client.server) lm_info...
Adds a mode to the editor. :param mode: The mode instance to append. def append(self, mode): """ Adds a mode to the editor. :param mode: The mode instance to append. """ _logger().log(5, 'adding mode %r', mode.name) self._modes[mode.name] = mode mode.o...
Removes a mode from the editor. :param name_or_klass: The name (or class) of the mode to remove. :returns: The removed mode. def remove(self, name_or_klass): """ Removes a mode from the editor. :param name_or_klass: The name (or class) of the mode to remove. :returns: ...
Gets a mode by name (or class) :param name_or_klass: The name or the class of the mode to get :type name_or_klass: str or type :rtype: pyqode.core.api.Mode def get(self, name_or_klass): """ Gets a mode by name (or class) :param name_or_klass: The name or the class of t...
Extends :meth:`pyqode.core.api.Mode.on_install` method to set the editor instance as the parent widget. .. warning:: Don't forget to call **super** if you override this method! :param editor: editor instance :type editor: pyqode.core.api.CodeEdit def on_install(self, edito...
Shows/Hides the panel Automatically call CodeEdit.refresh_panels. :param visible: Visible state def setVisible(self, visible): """ Shows/Hides the panel Automatically call CodeEdit.refresh_panels. :param visible: Visible state """ _logger().log(5, '%s...
Adds a text decoration on a CodeEdit instance :param decoration: Text decoration to add :type decoration: pyqode.core.api.TextDecoration def append(self, decoration): """ Adds a text decoration on a CodeEdit instance :param decoration: Text decoration to add :type deco...
Removes a text decoration from the editor. :param decoration: Text decoration to remove :type decoration: pyqode.core.api.TextDecoration def remove(self, decoration): """ Removes a text decoration from the editor. :param decoration: Text decoration to remove :type deco...
Removes all text decoration from the editor. def clear(self): """ Removes all text decoration from the editor. """ self._decorations[:] = [] try: self.editor.setExtraSelections(self._decorations) except RuntimeError: pass
Resets editor font size to the default font size :param event: wheelEvent :type event: QKeyEvent def _on_key_pressed(self, event): """ Resets editor font size to the default font size :param event: wheelEvent :type event: QKeyEvent """ if (int(event.mod...
Increments or decrements editor fonts settings on mouse wheel event if ctrl modifier is on. :param event: wheel event :type event: QWheelEvent def _on_wheel_event(self, event): """ Increments or decrements editor fonts settings on mouse wheel event if ctrl modifier is o...
Changes the writer function to handle writing to the text edit. A writer function must have the following prototype: .. code-block:: python def write(text_edit, text, color) :param writer: write function as described above. def set_writer(self, writer): """ Chang...
Starts a process interactively. :param process: Process to run :type process: str :param args: List of arguments (list of str) :type args: list :param cwd: Working directory :type cwd: str :param env: environment variables (dict). def start_process(self, proc...
Stop the process (by killing it). def stop_process(self): """ Stop the process (by killing it). """ if self.process is not None: self._user_stop = True self.process.kill() self.setReadOnly(True) self._running = False
Default write function. Move the cursor to the end and insert text with the specified color. :param text_edit: QInteractiveConsole instance :type text_edit: pyqode.widgets.QInteractiveConsole :param text: Text to write :type text: str :param color: Desired text color ...
Apply a pygments color scheme to the console. As there is not a 1 to 1 mapping between color scheme formats and console formats, we decided to make the following mapping (it usually looks good for most of the available pygments styles): - stdout_color = normal color - s...
Normalize code key value (encoding codecs must be lower case and must not contain any dashes). :param value: value to convert. def convert_to_codec_key(value): """ Normalize code key value (encoding codecs must be lower case and must not contain any dashes). :param value: value to convert. ...
Processes a block and setup its folding info. This method call ``detect_fold_level`` and handles most of the tricky corner cases so that all you have to do is focus on getting the proper fold level foreach meaningful block, skipping the blank ones. :param current_block: current block t...
Detects fold level by looking at the block indentation. :param prev_block: previous text block :param block: current block to highlight def detect_fold_level(self, prev_block, block): """ Detects fold level by looking at the block indentation. :param prev_block: previous text ...
Reads pylintrc config into native ConfigParser object. Args: contents (str): The contents of the file containing the INI config. Returns: ConfigParser.ConfigParser: The parsed configuration. def read_config(contents): """Reads pylintrc config into native ConfigParser object. Args: ...
Loads the pylint.config.py file. Args: filename (str): The python file containing the local configuration. Returns: module: The loaded Python module. def load_local_config(filename): """Loads the pylint.config.py file. Args: filename (str): The python file containing the loca...
Determines the final additions and replacements. Combines the config module with the defaults. Args: config_module: The loaded local configuration module. Returns: Config: the final configuration. def determine_final_config(config_module): """Determines the final additions and replac...
Lints a group of files using a given rcfile. Keyword arguments are * ``rc_filename`` (``str``): The name of the Pylint config RC file. * ``description`` (``str``): A description of the files and configuration currently being run. Args: dirnames (tuple): Direct...
Combines a base rc and additions into single file. Args: base_cfg (ConfigParser.ConfigParser): The configuration we are merging into. target_filename (str): The filename where the new configuration will be saved. additions (dict): (Optional) The values added to the c...
Script entry point. Lints both sets of files. def run_command(args): """Script entry point. Lints both sets of files.""" library_rc = 'pylintrc' test_rc = 'pylintrc.test' if os.path.exists(library_rc): os.remove(library_rc) if os.path.exists(test_rc): os.remove(test_rc) defau...
Open a connection. @param u2request: A urllib2 request. @type u2request: urllib2.Requet. @return: The opened file-like urllib2 object. @rtype: fp def u2open(self, u2request): """ Open a connection. @param u2request: A urllib2 request. @type u2request: url...
Login to a vSphere server. >>> client.login(username='Administrator', password='strongpass') :param username: The username to authenticate as. :type username: str :param password: The password to authenticate with. :type password: str def login(self, username=None, password=No...
Logout of a vSphere server. def logout(self): """Logout of a vSphere server.""" if self._logged_in is True: self.si.flush_cache() self.sc.sessionManager.Logout() self._logged_in = False
Invoke a method on the server. >>> client.invoke('CurrentTime', client.si) :param method: The method to invoke, as found in the SDK. :type method: str :param _this: The managed object reference against which to invoke \ the method. :type _this: ManagedObject :pa...
Converts a MOR to a psphere object. def _mor_to_pobject(self, mo_ref): """Converts a MOR to a psphere object.""" kls = classmapper(mo_ref._type) new_object = kls(mo_ref, self) return new_object
Walks an object and marshals any psphere object into MORs. def _marshal(self, obj): """Walks an object and marshals any psphere object into MORs.""" logger.debug("Checking if %s needs to be marshalled", obj) if isinstance(obj, ManagedObject): logger.debug("obj is a psphere object, c...
Walks an object and unmarshals any MORs into psphere objects. def _unmarshal(self, obj): """Walks an object and unmarshals any MORs into psphere objects.""" if isinstance(obj, suds.sudsobject.Object) is False: logger.debug("%s is not a suds instance, skipping", obj) return obj ...
Create a SOAP object of the requested type. >>> client.create('VirtualE1000') :param type_: The type of SOAP object to create. :type type_: str :param kwargs: TODO :type kwargs: TODO def create(self, type_, **kwargs): """Create a SOAP object of the requested type. ...
Get a view of a vSphere managed object. :param mo_ref: The MOR to get a view of :type mo_ref: ManagedObjectReference :param properties: A list of properties to retrieve from the \ server :type properties: list :returns: A view representing the ManagedObjectRefere...
Get a list of local view's for multiple managed objects. :param mo_refs: The list of ManagedObjectReference's that views are \ to be created for. :type mo_refs: ManagedObjectReference :param properties: The properties to retrieve in the views. :type properties: list :ret...
Build a PropertyFilterSpec capable of full inventory traversal. By specifying all valid traversal specs we are creating a PFS that can recursively select any object under the given entity. :param begin_entity: The place in the MOB to start the search. :type begin_entity: Manage...
Execute a \*_Task method and wait for it to complete. :param method: The \*_Task method to invoke. :type method: str :param kwargs: The arguments to pass to the method. :type kwargs: TODO def invoke_task(self, method, **kwargs): """Execute a \*_Task method and wait for ...
Find all ManagedEntity's of the requested type. :param view_type: The type of ManagedEntity's to find. :type view_type: str :param begin_entity: The MOR to start searching for the entity. \ The default is to start the search at the root folder. :type begin_entity: ManagedObjectR...
Find a ManagedEntity of the requested type. Traverses the MOB looking for an entity matching the filter. :param view_type: The type of ManagedEntity to find. :type view_type: str :param begin_entity: The MOR to start searching for the entity. \ The default is to start the searc...
Loads a template of the specified name. Templates are placed in the <template_dir> directory in YAML format with a .yaml extension. If no name is specified then the function will return the default template (<template_dir>/default.yaml) if it exists. :param name: The name of the template to l...
Returns a list of all templates. def list_templates(): """Returns a list of all templates.""" templates = [f for f in glob.glob(os.path.join(template_path, '*.yaml'))] return templates
Create a virtual machine using the specified values. :param name: The name of the VM to create. :type name: str :param compute_resource: The name of a ComputeResource in which to \ create the VM. :type compute_resource: str :param datastore: The name of the datastore on which to create ...
Return a NIC spec def create_nic(client, target, nic): """Return a NIC spec""" # Iterate through the networks and look for one matching # the requested name for network in target.network: if network.name == nic["network_name"]: net = network break else: retur...
The main method for this script. :param name: The name of the VM to create. :type name: str :param template_name: The name of the template to use for creating \ the VM. :type template_name: str def main(name, options): """The main method for this script. :param name: The name of t...
Adds an ignore pattern to the list for ignore patterns. Ignore patterns are used to filter out unwanted files or directories from the file system model. A pattern is a Unix shell-style wildcards. See :mod:`fnmatch` for a deeper explanation about the shell-style wildcards. def add_igno...
Sets the context menu of the tree view. :param context_menu: QMenu def set_context_menu(self, context_menu): """ Sets the context menu of the tree view. :param context_menu: QMenu """ self.context_menu = context_menu self.context_menu.tree_view = self s...
Sets the root path to watch :param path: root path - str :param hide_extra_columns: Hide extra column (size, paths,...) def set_root_path(self, path, hide_extra_columns=True): """ Sets the root path to watch :param path: root path - str :param hide_extra_columns: Hide ex...
Gets the file path of the item at the specified ``index``. :param index: item index - QModelIndex :return: str def filePath(self, index): """ Gets the file path of the item at the specified ``index``. :param index: item index - QModelIndex :return: str """ ...
Gets the file info of the item at the specified ``index``. :param index: item index - QModelIndex :return: QFileInfo def fileInfo(self, index): """ Gets the file info of the item at the specified ``index``. :param index: item index - QModelIndex :return: QFileInfo ...
Copies the selected items to the clipboard :param copy: True to copy, False to cut. def copy_to_clipboard(self, copy=True): """ Copies the selected items to the clipboard :param copy: True to copy, False to cut. """ urls = self.selected_urls() if not urls: ...
Gets the list of selected items file path (url) def selected_urls(self): """ Gets the list of selected items file path (url) """ urls = [] debug('gettings urls') for proxy_index in self.tree_view.selectedIndexes(): finfo = self.tree_view.fileInfo(proxy_index)...
Pastes files from clipboard. def paste_from_clipboard(self): """ Pastes files from clipboard. """ to = self.get_current_path() if os.path.isfile(to): to = os.path.abspath(os.path.join(to, os.pardir)) mime = QtWidgets.QApplication.clipboard().mimeData() ...
Copies the files listed in ``sources`` to destination. Source are removed if copy is set to False. def _paste(self, sources, destination, copy): """ Copies the files listed in ``sources`` to destination. Source are removed if copy is set to False. """ for src in sources:...
Returns the list of files contained in path (recursively). def _get_files(path): """ Returns the list of files contained in path (recursively). """ ret_val = [] for root, _, files in os.walk(path): for f in files: ret_val.append(os.path.join(root, f))...
Deletes the selected items. def delete(self): """ Deletes the selected items. """ urls = self.selected_urls() rep = QtWidgets.QMessageBox.question( self.tree_view, _('Confirm delete'), _('Are you sure about deleting the selected files/directories?'), ...
Gets the path of the currently selected item. def get_current_path(self): """ Gets the path of the currently selected item. """ path = self.tree_view.fileInfo( self.tree_view.currentIndex()).filePath() # https://github.com/pyQode/pyQode/issues/6 if not path: ...
Copies the file path to the clipboard def copy_path_to_clipboard(self): """ Copies the file path to the clipboard """ path = self.get_current_path() QtWidgets.QApplication.clipboard().setText(path) debug('path copied: %s' % path)
Renames the selected item in the tree view def rename(self): """ Renames the selected item in the tree view """ src = self.get_current_path() pardir, name = os.path.split(src) new_name, status = QtWidgets.QInputDialog.getText( self.tree_view, _('Rename '), _(...
Creates a directory under the selected directory (if the selected item is a file, the parent directory is used). def create_directory(self): """ Creates a directory under the selected directory (if the selected item is a file, the parent directory is used). """ src = sel...
Creates a file under the current directory. def create_file(self): """ Creates a file under the current directory. """ src = self.get_current_path() name, status = QtWidgets.QInputDialog.getText( self.tree_view, _('Create new file'), _('File name:'), QtWi...
Guesses the mime type of a file. If mime type cannot be detected, plain text is assumed. :param path: path of the file :return: the corresponding mime type. def get_mimetype(path): """ Guesses the mime type of a file. If mime type cannot be detected, plain text is assum...
Open a file and set its content on the editor widget. pyqode does not try to guess encoding. It's up to the client code to handle encodings. You can either use a charset detector to detect encoding or rely on a settings in your application. It is also up to you to handle UnicodeDecodeEr...
Reload the file with another encoding. :param encoding: the new encoding to use to reload the file. def reload(self, encoding): """ Reload the file with another encoding. :param encoding: the new encoding to use to reload the file. """ assert os.path.exists(self.path) ...
Save the editor content to a file. :param path: optional file path. Set it to None to save using the current path (save), set a new path to save as. :param encoding: optional encoding, will use the current file encoding if None. :param fallback_enco...
Close the file open in the editor: - clear editor content - reset file attributes to their default values :param clear: True to clear the editor content. Default is True. def close(self, clear=True): """ Close the file open in the editor: - clear editor cont...
Connects/Disconnects to the painted event of the editor :param state: Enable state def on_state_changed(self, state): """ Connects/Disconnects to the painted event of the editor :param state: Enable state """ if state: self.editor.painted.connect(self._pain...
Paints the right margin after editor paint event. def _paint_margin(self, event): """ Paints the right margin after editor paint event. """ font = QtGui.QFont(self.editor.font_name, self.editor.font_size + self.editor.zoom_level) metrics = QtGui.QFontMetricsF(font) ...
Updates modif time def _update_mtime(self): """ Updates modif time """ try: self._mtime = os.path.getmtime(self.editor.file.path) except OSError: # file_path does not exists. self._mtime = 0 self._timer.stop() except (TypeError, AttributeE...
Checks watched file moficiation time and permission changes. def _check_file(self): """ Checks watched file moficiation time and permission changes. """ try: self.editor.toPlainText() except RuntimeError: self._timer.stop() return if s...
Notify user from external event def _notify(self, title, message, expected_action=None): """ Notify user from external event """ if self.editor is None: return inital_value = self.editor.save_on_focus_out self.editor.save_on_focus_out = False self._fl...
Notify user from external change if autoReloadChangedFiles is False then reload the changed file in the editor def _notify_change(self): """ Notify user from external change if autoReloadChangedFiles is False then reload the changed file in the editor """ def inner_actio...
Checks if a notification is pending. def _check_for_pending(self, *args, **kwargs): """ Checks if a notification is pending. """ if self._notification_pending and not self._processing: self._processing = True args, kwargs = self._data self._notify(*ar...
Notify user from external file deletion. def _notify_deleted_file(self): """ Notify user from external file deletion. """ self.file_deleted.emit(self.editor) # file deleted, disable file watcher self.enabled = False
Gets a list of all of the available Python SDK versions, sorted with the newest last. def get_gae_versions(): """Gets a list of all of the available Python SDK versions, sorted with the newest last.""" r = requests.get(SDK_RELEASES_URL) r.raise_for_status() releases = r.json().get('items', {})...
Returns False if there is no existing install or if the existing install is out of date. Otherwise, returns True. def is_existing_up_to_date(destination, latest_version): """Returns False if there is no existing install or if the existing install is out of date. Otherwise, returns True.""" version_path...
Downloads the SDK and returns a file-like object for the zip content. def download_sdk(url): """Downloads the SDK and returns a file-like object for the zip content.""" r = requests.get(url) r.raise_for_status() return StringIO(r.content)