signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
@property<EOL><INDENT>def default_project(self):<DEDENT> | return self.__default_project<EOL> | Property for **self.__default_project** attribute.
:return: self.__default_project.
:rtype: unicode | f13128:c0:m1 |
@default_project.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def default_project(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is unicode,"<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__default_project = value<EOL> | Setter for **self.__default_project** attribute.
:param value: Attribute value.
:type value: unicode | f13128:c0:m2 |
@default_project.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_project(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__default_project** attribute. | f13128:c0:m3 |
@property<EOL><INDENT>def default_project_node(self):<DEDENT> | return self.__default_project_node<EOL> | Property for **self.__default_project_node** attribute.
:return: self.__default_project_node.
:rtype: unicode | f13128:c0:m4 |
@default_project_node.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_project_node(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__default_project_node** attribute.
:param value: Attribute value.
:type value: unicode | f13128:c0:m5 |
@default_project_node.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_project_node(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__default_project_node** attribute. | f13128:c0:m6 |
def __initialize_model(self): | LOGGER.debug("<STR_LIT>")<EOL>self.beginResetModel()<EOL>self.root_node = umbra.ui.nodes.DefaultNode(name="<STR_LIT>")<EOL>self.__default_project_node = ProjectNode(name=self.__default_project,<EOL>parent=self.root_node,<EOL>node_flags=int(Qt.ItemIsEnabled),<EOL>attributes_flags=int(Qt.ItemIsEnabled))<EOL>self.enable_model_triggers(True)<EOL>self.endResetModel()<EOL> | Initializes the Model. | f13128:c0:m7 |
def list_editor_nodes(self, node=None): | return self.find_family("<STR_LIT>", node=node or self.__default_project_node)<EOL> | Returns the Model :class:`umbra.components.factory.script_editor.nodes.EditorNode` class nodes.
:param node: Node to start walking from.
:type node: AbstractNode or AbstractCompositeNode or Object
:return: EditorNode nodes.
:rtype: list | f13128:c0:m8 |
def list_file_nodes(self, node=None): | return self.find_family("<STR_LIT>", node=node or self.__default_project_node)<EOL> | Returns the Model :class:`umbra.components.factory.script_editor.nodes.FileNode` class nodes.
:param node: Node to start walking from.
:type node: AbstractNode or AbstractCompositeNode or Object
:return: FileNode nodes.
:rtype: list | f13128:c0:m9 |
def list_directory_nodes(self): | return self.find_family("<STR_LIT>")<EOL> | Returns the Model :class:`umbra.components.factory.script_editor.nodes.DirectoryNode` class nodes.
:return: DirectoryNode nodes.
:rtype: list | f13128:c0:m10 |
def list_project_nodes(self, ignore_default_project_node=True): | project_nodes = self.find_family("<STR_LIT>")<EOL>return filter(lambda x: x != self.__default_project_node, project_nodes)if ignore_default_project_node else project_nodes<EOL> | Returns the Model :class:`umbra.components.factory.script_editor.nodes.ProjectNode` class nodes.
:param ignore_default_project_node: Default ProjectNode will be ignored.
:type ignore_default_project_node: bool
:return: ProjectNode nodes.
:rtype: list | f13128:c0:m11 |
def list_editors(self, node=None): | return [editor_node.editor for editor_node in self.list_editor_nodes(node) if editor_node.editor]<EOL> | Returns the Model editors.
:param node: Node to start walking from.
:type node: AbstractNode or AbstractCompositeNode or Object
:return: Editors.
:rtype: list | f13128:c0:m12 |
def list_files(self, node=None): | return [file_node.path for file_node in self.list_file_nodes(node) if file_node.path]<EOL> | Returns the Model files.
:param node: Node to start walking from.
:type node: AbstractNode or AbstractCompositeNode or Object
:return: FileNode nodes.
:rtype: list | f13128:c0:m13 |
def list_directories(self): | return [directory_node.path for directory_node in self.list_directory_nodes() if directory_node.path]<EOL> | Returns the Model directories.
:return: DirectoryNode nodes.
:rtype: list | f13128:c0:m14 |
def list_projects(self, ignore_default_project_node=True): | return [project_node.path for project_node in self.list_project_nodes(ignore_default_project_node) if<EOL>project_node.path]<EOL> | Returns the Model projects.
:param ignore_default_project_node: Default ProjectNode will be ignored.
:type ignore_default_project_node: bool
:return: ProjectNode nodes.
:rtype: list | f13128:c0:m15 |
def get_editor_nodes(self, editor, node=None): | return [editor_node for editor_node in self.list_editor_nodes(node) if editor_node.editor == editor]<EOL> | Returns the :class:`umbra.components.factory.script_editor.nodes.EditorNode` class Nodes with given editor.
:param node: Node to start walking from.
:type node: AbstractNode or AbstractCompositeNode or Object
:param editor: Editor.
:type editor: Editor
:return: EditorNode nodes.
:rtype: list | f13128:c0:m16 |
def get_file_nodes(self, path, node=None): | return [file_node for file_node in self.list_file_nodes(node) if file_node.path == path]<EOL> | Returns the :class:`umbra.components.factory.script_editor.nodes.FileNode` class Nodes with given path.
:param node: Node to start walking from.
:type node: AbstractNode or AbstractCompositeNode or Object
:param path: File path.
:type path: unicode
:return: FileNode nodes.
:rtype: list | f13128:c0:m17 |
def get_directory_nodes(self, path): | return [directory_node for directory_node in self.list_directory_nodes() if directory_node.path == path]<EOL> | Returns the :class:`umbra.components.factory.script_editor.nodes.DirectoryNode` class Nodes with given path.
:param path: Directory path.
:type path: unicode
:return: DirectoryNode nodes.
:rtype: list | f13128:c0:m18 |
def get_project_nodes(self, path): | return [project_node for project_node in self.list_project_nodes() if project_node.path == path]<EOL> | Returns the :class:`umbra.components.factory.script_editor.nodes.ProjectNode` class Nodes with given path.
:param path: Project path.
:type path: unicode
:return: ProjectNode nodes.
:rtype: list | f13128:c0:m19 |
def move_node(self, parent, from_index, to_index): | <EOL>if not from_index >= <NUM_LIT:0> ornot from_index < parent.children_count() ornot to_index >= <NUM_LIT:0> ornot to_index < parent.children_count():<EOL><INDENT>return False<EOL><DEDENT>parent_index = self.get_node_index(parent)<EOL>self.beginRemoveRows(parent_index, from_index, from_index)<EOL>child = parent.remove_child(from_index)<EOL>self.endRemoveRows()<EOL>start_index = parent.children_count() - <NUM_LIT:1><EOL>end_index = to_index - <NUM_LIT:1><EOL>tail = []<EOL>for i in range(start_index, end_index, -<NUM_LIT:1>):<EOL><INDENT>self.beginRemoveRows(parent_index, i, i)<EOL>tail.append(parent.remove_child(i))<EOL>self.endRemoveRows()<EOL><DEDENT>tail = list(reversed(tail))<EOL>tail.insert(<NUM_LIT:0>, child)<EOL>for node in tail:<EOL><INDENT>row = parent.children_count()<EOL>self.beginInsertRows(parent_index, row, row)<EOL>parent.add_child(node)<EOL>self.endInsertRows()<EOL><DEDENT>return True<EOL> | Moves given parent child to given index.
:param to_index: Index to.
:type to_index: int
:param from_index: Index from.
:type from_index: int
:return: Method success.
:rtype: bool | f13128:c0:m20 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def register_file(self, file, parent, ensure_uniqueness=False):<DEDENT> | if ensure_uniqueness:<EOL><INDENT>if self.get_file_nodes(file):<EOL><INDENT>raise foundations.exceptions.ProgrammingError("<STR_LIT>".format(<EOL>self.__class__.__name__, file))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(file))<EOL>row = parent.children_count()<EOL>self.beginInsertRows(self.get_node_index(parent), row, row)<EOL>file_node = FileNode(name=os.path.basename(file),<EOL>path=file,<EOL>parent=parent)<EOL>self.endInsertRows()<EOL>self.file_registered.emit(file_node)<EOL>return file_node<EOL> | Registers given file in the Model.
:param file: File to register.
:type file: unicode
:param parent: FileNode parent.
:type parent: GraphModelNode
:param ensure_uniqueness: Ensure registrar uniqueness.
:type ensure_uniqueness: bool
:return: FileNode.
:rtype: FileNode | f13128:c0:m21 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def unregister_file(self, file_node, raise_exception=False):<DEDENT> | if raise_exception:<EOL><INDENT>if not file_node in self.list_file_nodes():<EOL><INDENT>raise foundations.exceptions.ProgrammingError("<STR_LIT>".format(<EOL>self.__class__.__name__, file_node))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(file_node))<EOL>parent = file_node.parent<EOL>row = file_node.row()<EOL>self.beginRemoveRows(self.get_node_index(parent), row, row)<EOL>parent.remove_child(row)<EOL>self.endRemoveRows()<EOL>self.file_unregistered.emit(file_node)<EOL>return file_node<EOL> | Unregisters given :class:`umbra.components.factory.script_editor.nodes.FileNode` class Node from the Model.
:param file_node: FileNode to unregister.
:type file_node: FileNode
:param raise_exception: Raise the exception.
:type raise_exception: bool
:return: FileNode.
:rtype: FileNode | f13128:c0:m22 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def register_directory(self, directory, parent, ensure_uniqueness=False):<DEDENT> | if ensure_uniqueness:<EOL><INDENT>if self.get_directory_nodes(directory):<EOL><INDENT>raise foundations.exceptions.ProgrammingError("<STR_LIT>".format(<EOL>self.__class__.__name__, directory))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(directory))<EOL>row = parent.children_count()<EOL>self.beginInsertRows(self.get_node_index(parent), row, row)<EOL>directory_node = DirectoryNode(name=os.path.basename(directory),<EOL>path=directory,<EOL>parent=parent)<EOL>self.endInsertRows()<EOL>self.directory_registered.emit(directory_node)<EOL>return directory_node<EOL> | Registers given directory in the Model.
:param directory: Directory to register.
:type directory: unicode
:param parent: DirectoryNode parent.
:type parent: GraphModelNode
:param ensure_uniqueness: Ensure registrar uniqueness.
:type ensure_uniqueness: bool
:return: DirectoryNode.
:rtype: DirectoryNode | f13128:c0:m23 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def unregister_directory(self, directory_node, raise_exception=False):<DEDENT> | if raise_exception:<EOL><INDENT>if not directory_node in self.list_directory_nodes():<EOL><INDENT>raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(<EOL>self.__class__.__name__, directory_node))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(directory_node))<EOL>parent = directory_node.parent<EOL>row = directory_node.row()<EOL>self.beginRemoveRows(self.get_node_index(parent), row, row)<EOL>parent.remove_child(row)<EOL>self.endRemoveRows()<EOL>self.directory_unregistered.emit(directory_node)<EOL>return directory_node<EOL> | Unregisters given :class:`umbra.components.factory.script_editor.nodes.DirectoryNode` class Node from the Model.
:param directory_node: DirectoryNode to unregister.
:type directory_node: DirectoryNode
:param raise_exception: Raise the exception.
:type raise_exception: bool
:return: DirectoryNode.
:rtype: DirectoryNode | f13128:c0:m24 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def register_editor(self, editor, parent, ensure_uniqueness=False):<DEDENT> | if ensure_uniqueness:<EOL><INDENT>if self.get_editor_nodes(editor):<EOL><INDENT>raise foundations.exceptions.ProgrammingError("<STR_LIT>".format(<EOL>self.__class__.__name__, editor))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(editor))<EOL>row = parent.children_count()<EOL>self.beginInsertRows(self.get_node_index(parent), row, row)<EOL>editor_node = EditorNode(editor=editor,<EOL>parent=parent)<EOL>self.endInsertRows()<EOL>self.editor_registered.emit(editor_node)<EOL>return editor_node<EOL> | Registers given :class:`umbra.components.factory.script_editor.editor.Editor` class editor in the Model.
:param editor: Editor to register.
:type editor: Editor
:param parent: EditorNode parent.
:type parent: GraphModelNode
:param ensure_uniqueness: Ensure registrar uniqueness.
:type ensure_uniqueness: bool
:return: EditorNode.
:rtype: EditorNode | f13128:c0:m25 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def unregister_editor(self, editor_node, raise_exception=False):<DEDENT> | if raise_exception:<EOL><INDENT>if not editor_node in self.list_editor_nodes():<EOL><INDENT>raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(<EOL>self.__class__.__name__, editor_node))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(editor_node))<EOL>parent = editor_node.parent<EOL>row = editor_node.row()<EOL>self.beginRemoveRows(self.get_node_index(parent), row, row)<EOL>parent.remove_child(row)<EOL>self.endRemoveRows()<EOL>self.editor_unregistered.emit(editor_node)<EOL>return editor_node<EOL> | Unregisters given :class:`umbra.components.factory.script_editor.nodes.EditorNode` class Node from the Model.
:param editor_node: EditorNode to unregister.
:type editor_node: EditorNode
:param raise_exception: Raise the exception.
:type raise_exception: bool
:return: EditorNode.
:rtype: EditorNode | f13128:c0:m26 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def register_project(self, path, ensure_uniqueness=False):<DEDENT> | if ensure_uniqueness:<EOL><INDENT>if self.get_project_nodes(path):<EOL><INDENT>raise foundations.exceptions.ProgrammingError("<STR_LIT>".format(<EOL>self.__class__.__name__, path))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(path))<EOL>row = self.root_node.children_count()<EOL>self.beginInsertRows(self.get_node_index(self.root_node, ), row, row)<EOL>project_node = ProjectNode(name=os.path.basename(path),<EOL>path=path,<EOL>parent=self.root_node)<EOL>self.endInsertRows()<EOL>self.project_registered.emit(project_node)<EOL>return project_node<EOL> | Registers given path in the Model as a project.
:param path: Project path to register.
:type path: unicode
:param ensure_uniqueness: Ensure registrar uniqueness.
:type ensure_uniqueness: bool
:return: ProjectNode.
:rtype: ProjectNode | f13128:c0:m27 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def unregister_project(self, project_node, raise_exception=False):<DEDENT> | if raise_exception:<EOL><INDENT>if not project_node in self.list_project_nodes():<EOL><INDENT>raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(<EOL>self.__class__.__name__, project_node))<EOL><DEDENT><DEDENT>LOGGER.debug("<STR_LIT>".format(project_node))<EOL>parent = project_node.parent<EOL>row = project_node.row()<EOL>self.beginRemoveRows(self.get_node_index(parent), row, row)<EOL>parent.remove_child(row)<EOL>self.endRemoveRows()<EOL>self.project_unregistered.emit(project_node)<EOL>return project_node<EOL> | Unregisters given :class:`umbra.components.factory.scriptProject.nodes.ProjectNode` class Node from the Model.
:param project_node: ProjectNode to unregister.
:type project_node: ProjectNode
:param raise_exception: Raise the exception.
:type raise_exception: bool
:return: ProjectNode.
:rtype: ProjectNode | f13128:c0:m28 |
def is_authoring_node(self, node): | for parent_node in foundations.walkers.nodes_walker(node, ascendants=True):<EOL><INDENT>if parent_node is self.__default_project_node:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL> | Returns if given Node is an authoring node.
:param node: Node.
:type node: ProjectNode or DirectoryNode or FileNode
:return: Is authoring node.
:rtype: bool | f13128:c0:m29 |
def set_authoring_nodes(self, editor): | project_node = self.default_project_node<EOL>file_node = self.register_file(editor.file, project_node)<EOL>editor_node = self.register_editor(editor, file_node)<EOL>return True<EOL> | Sets the Model authoring Nodes using given editor.
:param editor: Editor to set.
:type editor: Editor
:return: Method success.
:rtype: bool | f13128:c0:m30 |
def delete_authoring_nodes(self, editor): | editor_node = foundations.common.get_first_item(self.get_editor_nodes(editor))<EOL>file_node = editor_node.parent<EOL>self.unregister_editor(editor_node)<EOL>self.unregister_file(file_node, raise_exception=False)<EOL>return True<EOL> | Deletes the Model authoring Nodes associated with given editor.
:param editor: Editor.
:type editor: Editor
:return: Method success.
:rtype: bool | f13128:c0:m31 |
def update_authoring_nodes(self, editor): | editor_node = foundations.common.get_first_item(self.get_editor_nodes(editor))<EOL>file_node = editor_node.parent<EOL>file = editor.file<EOL>file_node.name = editor_node.name = os.path.basename(file)<EOL>file_node.path = editor_node.path = file<EOL>self.node_changed(file_node)<EOL>return True<EOL> | Updates given editor Model authoring nodes.
:param editor: Editor.
:type editor: Editor
:return: Method success.
:rtype: bool | f13128:c0:m32 |
def set_project_nodes(self, root_node, maximum_depth=<NUM_LIT:1>): | root_directory = root_node.path<EOL>for parent_directory, directories, files in foundations.walkers.depth_walker(root_directory, maximum_depth):<EOL><INDENT>if parent_directory == root_directory:<EOL><INDENT>parent_node = root_node<EOL><DEDENT>else:<EOL><INDENT>parent_node = foundations.common.get_first_item(<EOL>[node for node in foundations.walkers.nodes_walker(root_node)<EOL>if node.family == "<STR_LIT>" and node.path == parent_directory])<EOL><DEDENT>if not parent_node:<EOL><INDENT>continue<EOL><DEDENT>paths = [node.path for node in parent_node.children]<EOL>for directory in sorted(directories):<EOL><INDENT>if directory.startswith("<STR_LIT:.>"):<EOL><INDENT>continue<EOL><DEDENT>path = os.path.join(parent_directory, directory)<EOL>if path in paths:<EOL><INDENT>continue<EOL><DEDENT>directory_node = self.register_directory(path, parent_node)<EOL><DEDENT>for file in sorted(files):<EOL><INDENT>if file.startswith("<STR_LIT:.>"):<EOL><INDENT>continue<EOL><DEDENT>path = os.path.join(parent_directory, file)<EOL>if path in paths:<EOL><INDENT>continue<EOL><DEDENT>if foundations.io.is_readable(path):<EOL><INDENT>if foundations.io.is_binary_file(path):<EOL><INDENT>continue<EOL><DEDENT><DEDENT>file_node = self.register_file(path, parent_node)<EOL><DEDENT><DEDENT> | Sets the project Model children Nodes using given root node.
:param root_node: Root node.
:type root_node: ProjectNode or DirectoryNode
:param maximum_depth: Maximum nodes nesting depth.
:type maximum_depth: int | f13128:c0:m33 |
def delete_project_nodes(self, node): | self.unregister_project_nodes(node)<EOL>self.unregister_project(node)<EOL> | Deletes the Model project Nodes associated with given node.
:param node: Node.
:type node: ProjectNode | f13128:c0:m34 |
def unregister_project_nodes(self, node): | for node in reversed(list(foundations.walkers.nodes_walker(node))):<EOL><INDENT>if node.family == "<STR_LIT>":<EOL><INDENT>self.unregister_directory(node)<EOL><DEDENT>elif node.family == "<STR_LIT>":<EOL><INDENT>self.unregister_file(node)<EOL><DEDENT><DEDENT> | Unregisters given Node children.
:param node: Node.
:type node: ProjectNode or DirectoryNode | f13128:c0:m35 |
def update_project_nodes(self, node): | self.unregister_project_nodes(node)<EOL>self.set_project_nodes(node)<EOL> | Updates given root Node children.
:param node: Node.
:type node: ProjectNode or DirectoryNode | f13128:c0:m36 |
def __init__(self, parent=None, languages=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QAbstractListModel.__init__(self, parent)<EOL>self.__languages = []<EOL>self.languages = languages<EOL> | Initializes the class.
:param parent: Parent object.
:type parent: QObject
:param languages: Languages.
:type languages: list | f13128:c1:m0 |
@property<EOL><INDENT>def languages(self):<DEDENT> | return self.__languages<EOL> | Property for **self.__languages** attribute.
:return: self.__languages.
:rtype: list | f13128:c1:m1 |
@languages.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def languages(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is list, "<STR_LIT>".format("<STR_LIT>", value)<EOL>for element in value:<EOL><INDENT>assert type(element) is Language, "<STR_LIT>".format(<EOL>"<STR_LIT>", element)<EOL><DEDENT><DEDENT>self.beginResetModel()<EOL>self.__languages = value<EOL>self.endResetModel()<EOL> | Setter for **self.__languages** attribute.
:param value: Attribute value.
:type value: list | f13128:c1:m2 |
@languages.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def languages(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__languages** attribute. | f13128:c1:m3 |
def rowCount(self, parent=QModelIndex()): | return len(self.__languages)<EOL> | Reimplements the :meth:`QAbstractListModel.rowCount` method.
:param parent: Parent.
:type parent: QModelIndex
:return: Row count.
:rtype: int | f13128:c1:m4 |
def data(self, index, role=Qt.DisplayRole): | if not index.isValid():<EOL><INDENT>return QVariant()<EOL><DEDENT>if role == Qt.DisplayRole:<EOL><INDENT>return QVariant(self.__languages[index.row()].name)<EOL><DEDENT>return QVariant()<EOL> | Reimplements the :meth:`QAbstractListModel.data` method.
:param index: Index.
:type index: QModelIndex
:param role: Role.
:type role: int
:return: Data.
:rtype: QVariant | f13128:c1:m5 |
def sort_languages(self, order=Qt.AscendingOrder): | self.beginResetModel()<EOL>self.__languages = sorted(self.__languages, key=lambda x: (x.name), reverse=order)<EOL>self.endResetModel()<EOL> | Sorts the Model languages.
:param order: Order. ( Qt.SortOrder ) | f13128:c1:m6 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def register_language(self, language):<DEDENT> | if self.get_language(language):<EOL><INDENT>raise foundations.exceptions.ProgrammingError("<STR_LIT>".format(<EOL>self.__class__.__name__, language.name))<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(language.name))<EOL>self.__languages.append(language)<EOL>self.sort_languages()<EOL>return True<EOL> | Registers given language in the :obj:`LanguagesModel.languages` class property.
:param language: Language to register.
:type language: Language
:return: Method success.
:rtype: bool | f13128:c1:m7 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL><INDENT>def unregister_language(self, name):<DEDENT> | if not self.get_language(name):<EOL><INDENT>raise foundations.exceptions.ProgrammingError("<STR_LIT>".format(<EOL>self.__class__.__name__, name))<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(name))<EOL>for i, language in enumerate(self.__languages):<EOL><INDENT>if not language.name == name:<EOL><INDENT>continue<EOL><DEDENT>del (self.__languages[i])<EOL>self.sort_languages()<EOL>return True<EOL><DEDENT> | Unregisters language with given name from the :obj:`LanguagesModel.languages` class property.
:param name: Language to unregister.
:type name: unicode
:return: Method success.
:rtype: bool | f13128:c1:m8 |
def get_language(self, name): | for language in self.__languages:<EOL><INDENT>if language.name == name:<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(name, language))<EOL>return language<EOL><DEDENT><DEDENT> | Returns the language with given name.
:param name: Language name.
:type name: unicode
:return: File language.
:rtype: Language | f13128:c1:m9 |
def get_file_language(self, file): | for language in self.__languages:<EOL><INDENT>if re.search(language.extensions, file):<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(file, language.name))<EOL>return language<EOL><DEDENT><DEDENT> | Returns the language of given file.
:param file: File to get language of.
:type file: unicode
:return: File language.
:rtype: Language | f13128:c1:m10 |
def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>umbra.ui.models.GraphModel.__init__(self, parent, root_node, horizontal_headers, vertical_headers, PatternNode)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param root_node: Root node.
:type root_node: AbstractCompositeNode
:param horizontal_headers: Headers.
:type horizontal_headers: OrderedDict
:param vertical_headers: Headers.
:type vertical_headers: OrderedDict | f13128:c2:m0 |
def initialize_model(self, root_node): | LOGGER.debug("<STR_LIT>".format(root_node))<EOL>self.beginResetModel()<EOL>self.root_node = root_node<EOL>self.enable_model_triggers(True)<EOL>self.endResetModel()<EOL>return True<EOL> | Initializes the Model using given root node.
:param root_node: Graph root node.
:type root_node: DefaultNode
:return: Method success
:rtype: bool | f13128:c2:m1 |
def insert_pattern(self, pattern, index): | LOGGER.debug("<STR_LIT>".format(pattern, index))<EOL>self.remove_pattern(pattern)<EOL>self.beginInsertRows(self.get_node_index(self.root_node), index, index)<EOL>pattern_node = PatternNode(name=pattern)<EOL>self.root_node.insert_child(pattern_node, index)<EOL>self.endInsertRows()<EOL>self.pattern_inserted.emit(pattern_node)<EOL>return True<EOL> | Inserts given pattern into the Model.
:param pattern: Pattern.
:type pattern: unicode
:param index: Insertion index.
:type index: int
:return: Method success.
:rtype: bool | f13128:c2:m2 |
def remove_pattern(self, pattern): | for index, node in enumerate(self.root_node.children):<EOL><INDENT>if node.name != pattern:<EOL><INDENT>continue<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(pattern, index))<EOL>self.beginRemoveRows(self.get_node_index(self.root_node), index, index)<EOL>pattern_node = self.root_node.child(index)<EOL>self.root_node.remove_child(index)<EOL>self.endRemoveRows()<EOL>self.pattern_removed.emit(pattern_node)<EOL>return True<EOL><DEDENT> | Removes given pattern from the Model.
:param pattern: Pattern.
:type pattern: unicode
:return: Method success.
:rtype: bool | f13128:c2:m3 |
def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>umbra.ui.models.GraphModel.__init__(<EOL>self, parent, root_node, horizontal_headers, vertical_headers, default_node)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param root_node: Root node.
:type root_node: AbstractCompositeNode
:param horizontal_headers: Headers.
:type horizontal_headers: OrderedDict
:param vertical_headers: Headers.
:type vertical_headers: OrderedDict
:param default_node: Default node.
:type default_node: GraphModelNode | f13128:c3:m0 |
def initialize_model(self, root_node): | LOGGER.debug("<STR_LIT>".format(root_node))<EOL>self.beginResetModel()<EOL>self.root_node = root_node<EOL>self.enable_model_triggers(True)<EOL>self.endResetModel()<EOL>return True<EOL> | Initializes the Model using given root node.
:param root_node: Graph root node.
:type root_node: DefaultNode
:return: Method success
:rtype: bool | f13128:c3:m1 |
def get_metrics(self): | search_file_nodes_count = search_occurence_nodesCount = <NUM_LIT:0><EOL>for node in foundations.walkers.nodes_walker(self.root_node):<EOL><INDENT>if node.family == "<STR_LIT>":<EOL><INDENT>search_file_nodes_count += <NUM_LIT:1><EOL><DEDENT>elif node.family == "<STR_LIT>":<EOL><INDENT>search_occurence_nodesCount += <NUM_LIT:1><EOL><DEDENT><DEDENT>return {"<STR_LIT>": search_file_nodes_count, "<STR_LIT>": search_occurence_nodesCount}<EOL> | Returns the Model metrics.
:return: Nodes metrics.
:rtype: dict | f13128:c3:m2 |
def __init__(self, parent=None, file=None, language=PYTHON_LANGUAGE, *args, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>CodeEditor_QPlainTextEdit.__init__(self, parent, language, *args, **kwargs)<EOL>self.__file = None<EOL>self.file = file<EOL>self.__default_fonts_settings = {"<STR_LIT>": ("<STR_LIT>", <NUM_LIT:10>),<EOL>"<STR_LIT>": ("<STR_LIT>", <NUM_LIT:12>),<EOL>"<STR_LIT>": ("<STR_LIT>", <NUM_LIT:10>)}<EOL>self.__tab_width = None<EOL>self.__title = None<EOL>self.__is_untitled = True<EOL>self.__default_file_name = "<STR_LIT>"<EOL>self.__default_file_extension = "<STR_LIT>"<EOL>Editor.__initialize_ui(self)<EOL>file and self.load_file(file)<EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param file: File path.
:type file: unicode
:param language: Editor language.
:type language: Language
:param \*args: Arguments.
:type \*args: \*
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | f13129:c0:m0 |
@property<EOL><INDENT>def file(self):<DEDENT> | return self.__file<EOL> | Property for **self.__file** attribute.
:return: self.__file.
:rtype: unicode | f13129:c0:m1 |
@file.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def file(self, value):<DEDENT> | if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format("<STR_LIT:file>", value)<EOL><DEDENT>self.__file = value<EOL> | Setter for **self.__file** attribute.
:param value: Attribute value.
:type value: unicode | f13129:c0:m2 |
@file.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def file(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT:file>"))<EOL> | Deleter for **self.__file** attribute. | f13129:c0:m3 |
@property<EOL><INDENT>def default_fonts_settings(self):<DEDENT> | return self.__default_fonts_settings<EOL> | Property for **self.__default_fonts_settings** attribute.
:return: self.__default_fonts_settings.
:rtype: dict | f13129:c0:m4 |
@default_fonts_settings.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_fonts_settings(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__default_fonts_settings** attribute.
:param value: Attribute value.
:type value: dict | f13129:c0:m5 |
@default_fonts_settings.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_fonts_settings(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__default_fonts_settings** attribute. | f13129:c0:m6 |
@property<EOL><INDENT>def tab_width(self):<DEDENT> | return self.__tab_width<EOL> | Property for **self.__tab_width** attribute.
:return: self.__tab_width.
:rtype: int | f13129:c0:m7 |
@tab_width.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def tab_width(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__tab_width** attribute.
:param value: Attribute value.
:type value: int | f13129:c0:m8 |
@tab_width.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def tab_width(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__tab_width** attribute. | f13129:c0:m9 |
@property<EOL><INDENT>def title(self):<DEDENT> | return self.__title<EOL> | Property for **self.__title** attribute.
:return: self.__title.
:rtype: unicode | f13129:c0:m10 |
@title.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def title(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT:title>"))<EOL> | Setter for **self.__title** attribute.
:param value: Attribute value.
:type value: unicode | f13129:c0:m11 |
@title.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def title(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT:title>"))<EOL> | Deleter for **self.__title** attribute. | f13129:c0:m12 |
@property<EOL><INDENT>def is_untitled(self):<DEDENT> | return self.__is_untitled<EOL> | Property for **self.__is_untitled** attribute.
:return: self.__is_untitled.
:rtype: bool | f13129:c0:m13 |
@is_untitled.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def is_untitled(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__is_untitled** attribute.
:param value: Attribute value.
:type value: bool | f13129:c0:m14 |
@is_untitled.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def is_untitled(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__is_untitled** attribute. | f13129:c0:m15 |
@property<EOL><INDENT>def default_file_name(self):<DEDENT> | return self.__default_file_name<EOL> | Property for **self.__default_file_name** attribute.
:return: self.__default_file_name.
:rtype: unicode | f13129:c0:m16 |
@default_file_name.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_file_name(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__default_file_name** attribute.
:param value: Attribute value.
:type value: unicode | f13129:c0:m17 |
@default_file_name.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_file_name(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__default_file_name** attribute. | f13129:c0:m18 |
@property<EOL><INDENT>def default_file_extension(self):<DEDENT> | return self.__default_file_extension<EOL> | Property for **self.__default_file_extension** attribute.
:return: self.__default_file_extension.
:rtype: unicode | f13129:c0:m19 |
@default_file_extension.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_file_extension(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__default_file_extension** attribute.
:param value: Attribute value.
:type value: unicode | f13129:c0:m20 |
@default_file_extension.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def default_file_extension(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__default_file_extension** attribute. | f13129:c0:m21 |
def __initialize_ui(self): | self.setAttribute(Qt.WA_DeleteOnClose)<EOL>self.setWordWrapMode(QTextOption.NoWrap)<EOL>self.setAcceptDrops(True)<EOL>if platform.system() == "<STR_LIT>" or platform.system() == "<STR_LIT>":<EOL><INDENT>fontFamily, fontSize = self.__default_fonts_settings["<STR_LIT>"]<EOL><DEDENT>elif platform.system() == "<STR_LIT>":<EOL><INDENT>fontFamily, fontSize = self.__default_fonts_settings["<STR_LIT>"]<EOL><DEDENT>elif platform.system() == "<STR_LIT>":<EOL><INDENT>fontFamily, fontSize = self.__default_fonts_settings["<STR_LIT>"]<EOL><DEDENT>font = QFont(fontFamily)<EOL>font.setPointSize(fontSize)<EOL>self.setFont(font)<EOL> | Initializes the Widget ui. | f13129:c0:m22 |
def __document__contents_changed(self): | self.set_title()<EOL> | Defines the slot triggered by the editor when document content changes. | f13129:c0:m23 |
def __document__modification_changed(self, changed): | self.set_title()<EOL> | Defines the slot triggered by the editor when document is modified.
:param changed: File modification state.
:type changed: bool | f13129:c0:m24 |
def __set_document_signals(self): | <EOL>self.document().contentsChanged.connect(self.contents_changed.emit)<EOL>self.document().contentsChanged.connect(self.__document__contents_changed)<EOL>self.document().modificationChanged.connect(self.modification_changed.emit)<EOL>self.document().modificationChanged.connect(self.__document__modification_changed)<EOL> | Connects the editor document signals. | f13129:c0:m25 |
def set_title(self, title=None): | if not title:<EOL><INDENT>title = self.get_file_short_name()<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(title))<EOL>self.__title = title<EOL>self.setWindowTitle(title)<EOL>self.title_changed.emit()<EOL>return True<EOL> | Sets the editor title.
:param title: Editor title.
:type title: unicode
:return: Method success.
:rtype: bool | f13129:c0:m26 |
def set_file(self, file=None, is_modified=False, is_untitled=False): | LOGGER.debug("<STR_LIT>".format(file))<EOL>self.__file = file<EOL>self.__is_untitled = is_untitled<EOL>self.set_modified(is_modified)<EOL>self.set_title()<EOL>return True<EOL> | Sets the editor file.
:param File: File to set.
:type File: unicode
:param is_modified: File modified state.
:type is_modified: bool
:param is_untitled: File untitled state.
:type is_untitled: bool
:return: Method success.
:rtype: bool | f13129:c0:m27 |
def get_file_short_name(self): | if not self.__file:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>return os.path.basename(self.__file)<EOL> | Returns the current editor file short name.
:return: File short name.
:rtype: unicode | f13129:c0:m28 |
def get_untitled_file_name(self): | name = "<STR_LIT>".format(<EOL>self.__default_file_name, Editor._Editor__untitled_name_id, self.default_file_extension)<EOL>Editor._Editor__untitled_name_id += <NUM_LIT:1><EOL>LOGGER.debug("<STR_LIT>".format(name))<EOL>return name<EOL> | Returns an untitled editor file name.
:return: Untitled file name.
:rtype: unicode | f13129:c0:m29 |
def load_document(self, document, file=None, language=None): | document.setDocumentLayout(QPlainTextDocumentLayout(document))<EOL>self.setDocument(document)<EOL>self.set_file(file)<EOL>self.set_language(language)<EOL>self.__set_document_signals()<EOL>self.file_loaded.emit()<EOL>return True<EOL> | Loads given document into the editor.
:param document: Document to load.
:type document: QTextDocument
:param file: File.
:type file: unicode
:param language: Editor language.
:type language: unicode
:return: Method success.
:rtype: bool | f13129:c0:m30 |
def new_file(self): | file = self.get_untitled_file_name()<EOL>LOGGER.debug("<STR_LIT>".format(file))<EOL>self.set_file(file, is_modified=False, is_untitled=True)<EOL>self.__set_document_signals()<EOL>return file<EOL> | Creates a new editor file.
:return: File name.
:rtype: unicode | f13129:c0:m31 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError)<EOL><INDENT>def load_file(self, file):<DEDENT> | if not foundations.common.path_exists(file):<EOL><INDENT>raise foundations.exceptions.FileExistsError(<EOL>"<STR_LIT>".format(self.__class__.__name__,<EOL>file))<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(file))<EOL>reader = foundations.io.File(file)<EOL>self.setPlainText(reader.read())<EOL>self.set_file(file)<EOL>self.__set_document_signals()<EOL>self.file_loaded.emit()<EOL>return True<EOL> | Reads and loads given file into the editor.
:param File: File to load.
:type File: unicode
:return: Method success.
:rtype: bool | f13129:c0:m32 |
@foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError)<EOL><INDENT>def reload_file(self, is_modified=True):<DEDENT> | if not foundations.common.path_exists(self.__file):<EOL><INDENT>raise foundations.exceptions.FileExistsError("<STR_LIT>".format(<EOL>self.__class__.__name__, self.__file))<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(self.__file))<EOL>reader = foundations.io.File(self.__file)<EOL>if reader.cache():<EOL><INDENT>self.set_content(reader.content)<EOL>self.set_file(self.__file, is_modified=is_modified)<EOL>self.file_reloaded.emit()<EOL>return True<EOL><DEDENT> | Reloads the current editor file.
:param is_modified: File modified state.
:type is_modified: bool
:return: Method success.
:rtype: bool | f13129:c0:m33 |
def save_file(self): | if not self.__is_untitled and foundations.common.path_exists(self.__file):<EOL><INDENT>return self.write_file(self.__file)<EOL><DEDENT>else:<EOL><INDENT>return self.save_fileAs()<EOL><DEDENT> | Saves the editor file content.
:return: Method success.
:rtype: bool | f13129:c0:m34 |
def save_fileAs(self, file=None): | file = file or umbra.ui.common.store_last_browsed_path(<EOL>QFileDialog.getSaveFileName(self, "<STR_LIT>", self.__file))<EOL>if not file:<EOL><INDENT>return False<EOL><DEDENT>return self.write_file(foundations.strings.to_string(file))<EOL> | Saves the editor file content either using given file or user chosen file.
:return: Method success.
:rtype: bool
:note: May require user interaction. | f13129:c0:m35 |
def write_file(self, file): | LOGGER.debug("<STR_LIT>".format(file))<EOL>writer = foundations.io.File(file)<EOL>writer.content = [self.toPlainText().toUtf8()]<EOL>if writer.write():<EOL><INDENT>self.set_file(file)<EOL>self.file_saved.emit()<EOL>return True<EOL><DEDENT> | Writes the editor file content into given file.
:param file: File to write.
:type file: unicode
:return: Method success.
:rtype: bool | f13129:c0:m36 |
def close_file(self): | if not self.is_modified():<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(self.__file))<EOL>self.file_closed.emit()<EOL>return True<EOL><DEDENT>choice = message_box.message_box("<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>".format(<EOL>self.get_file_short_name()),<EOL>buttons=QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)<EOL>if choice == QMessageBox.Save:<EOL><INDENT>if self.save_file():<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(self.__file))<EOL>return True<EOL><DEDENT><DEDENT>elif choice == QMessageBox.Discard:<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(self.__file))<EOL>self.file_closed.emit()<EOL>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | Closes the editor file.
:return: Method success.
:rtype: bool | f13129:c0:m37 |
def handle(self): | all_data = []<EOL>while True:<EOL><INDENT>data = self.request.recv(<NUM_LIT>)<EOL>if not data:<EOL><INDENT>break<EOL><DEDENT>if self.codes.server_shutdown in data:<EOL><INDENT>return self.__server_shutdown()<EOL><DEDENT>if self.codes.request_end in data:<EOL><INDENT>all_data.append(data[:data.find(self.codes.request_end)])<EOL>break<EOL><DEDENT>all_data.append(data)<EOL>if len(all_data) >= <NUM_LIT:2>:<EOL><INDENT>tail = all_data[-<NUM_LIT:2>] + all_data[-<NUM_LIT:1>]<EOL>if self.codes.server_shutdown in tail:<EOL><INDENT>return self.__server_shutdown()<EOL><DEDENT>if self.codes.request_end in tail:<EOL><INDENT>all_data[-<NUM_LIT:2>] = tail[:tail.find(self.codes.request_end)]<EOL>all_data.pop()<EOL>break<EOL><DEDENT><DEDENT><DEDENT>RuntimeGlobals.requests_stack.append("<STR_LIT>".join(all_data))<EOL>return True<EOL> | Reimplements the :meth:`SocketServer.BaseRequestHandler.handle` method.
:return: Method success.
:rtype: bool | f13130:c0:m0 |
def __server_shutdown(self): | return self.container.stop(terminate=True)<EOL> | Shutdowns the TCP Server. | f13130:c0:m1 |
def __init__(self, parent=None, name=None, *args, **kwargs): | LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>super(TCPServerUi, self).__init__(parent, name, *args, **kwargs)<EOL>self.deactivatable = True<EOL>self.__engine = None<EOL>self.__settings = None<EOL>self.__settings_section = None<EOL>self.__preferences_manager = None<EOL>self.__tcp_server = None<EOL>self.__address = foundations.common.get_host_address()<EOL>self.__port = <NUM_LIT><EOL> | Initializes the class.
:param parent: Object parent.
:type parent: QObject
:param name: Component name.
:type name: unicode
:param \*args: Arguments.
:type \*args: \*
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | f13130:c1:m0 |
@property<EOL><INDENT>def engine(self):<DEDENT> | return self.__engine<EOL> | Property for **self.__engine** attribute.
:return: self.__engine.
:rtype: QObject | f13130:c1:m1 |
@engine.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def engine(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__engine** attribute.
:param value: Attribute value.
:type value: QObject | f13130:c1:m2 |
@engine.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def engine(self):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Deleter for **self.__engine** attribute. | f13130:c1:m3 |
@property<EOL><INDENT>def settings(self):<DEDENT> | return self.__settings<EOL> | Property for **self.__settings** attribute.
:return: self.__settings.
:rtype: QSettings | f13130:c1:m4 |
@settings.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def settings(self, value):<DEDENT> | raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL> | Setter for **self.__settings** attribute.
:param value: Attribute value.
:type value: QSettings | f13130:c1:m5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.