signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def run(self):
self.__timer = QTimer()<EOL>self.__timer.moveToThread(self)<EOL>self.__timer.start(Constants.default_timer_cycle * self.__timer_cycle_multiplier)<EOL>self.__timer.timeout.connect(self.__watch_file_system, Qt.DirectConnection)<EOL>self.exec_()<EOL>
Reimplements the :meth:`QThread.run` method.
f13106:c0:m19
def __watch_file_system(self):
for path, data in self.__paths.items():<EOL><INDENT>stored_modified_time, is_file = data<EOL>try:<EOL><INDENT>if not foundations.common.path_exists(path):<EOL><INDENT>LOGGER.warning(<EOL>"<STR_LIT>".format(<EOL>self.__class__.__name__, path))<EOL>del (self.__paths[path])<EOL>if is_file:<EOL><INDENT>self.file_invalidated.emit(path)<EOL><DEDENT>else:<EOL><INDENT>self.directory_invalidated.emit(path)<EOL><DEDENT>continue<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(<EOL>self.__class__.__name__, path))<EOL>continue<EOL><DEDENT>try:<EOL><INDENT>modified_time = self.get_path_modified_time(path)<EOL><DEDENT>except OSError:<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(<EOL>self.__class__.__name__, path))<EOL>continue<EOL><DEDENT>if stored_modified_time != modified_time:<EOL><INDENT>self.__paths[path] = (modified_time, os.path.isfile(path))<EOL>LOGGER.debug("<STR_LIT>".format(self.__class__.__name__, path))<EOL>if is_file:<EOL><INDENT>self.file_changed.emit(path)<EOL><DEDENT>else:<EOL><INDENT>self.directory_changed.emit(path)<EOL><DEDENT><DEDENT><DEDENT>
Watches the file system for paths that have been changed or invalidated on disk.
f13106:c0:m20
def list_paths(self):
return sorted(self.__paths.keys())<EOL>
Returns the registered paths. :return: Registered paths. :rtype: list
f13106:c0:m21
def is_path_registered(self, path):
return path in self<EOL>
Returns if the given path is registered. :param path: Path name. :type path: unicode :return: Is path registered. :rtype: bool
f13106:c0:m22
@foundations.exceptions.handle_exceptions(foundations.exceptions.PathExistsError,<EOL>umbra.exceptions.PathRegistrationError)<EOL><INDENT>def register_path(self, path, modified_time=None):<DEDENT>
if not foundations.common.path_exists(path):<EOL><INDENT>raise foundations.exceptions.PathExistsError("<STR_LIT>".format(<EOL>self.__class__.__name__, path))<EOL><DEDENT>if path in self:<EOL><INDENT>raise umbra.exceptions.PathRegistrationError("<STR_LIT>".format(<EOL>self.__class__.__name__, path))<EOL><DEDENT>self.__paths[path] = (self.get_path_modified_time(<EOL>path) if modified_time is None else modified_time, os.path.isfile(path))<EOL>return True<EOL>
Registers given path. :param path: Path name. :type path: unicode :param modified_time: Custom modified time. :type modified_time: int or float :return: Method success. :rtype: bool
f13106:c0:m23
@foundations.exceptions.handle_exceptions(umbra.exceptions.PathExistsError)<EOL><INDENT>def unregister_path(self, path):<DEDENT>
if not path in self:<EOL><INDENT>raise umbra.exceptions.PathExistsError("<STR_LIT>".format(<EOL>self.__class__.__name__, path))<EOL><DEDENT>del (self.__paths[path])<EOL>return True<EOL>
Unregisters given path. :param path: Path name. :type path: unicode :return: Method success. :rtype: bool
f13106:c0:m24
@staticmethod<EOL><INDENT>def get_path_modified_time(path):<DEDENT>
return float(foundations.common.get_first_item(str(os.path.getmtime(path)).split("<STR_LIT:.>")))<EOL>
Returns given path modification time. :param path: Path. :type path: unicode :return: Modification time. :rtype: int
f13106:c0:m25
def __init__(self, **kwargs):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>foundations.data_structures.Structure.__init__(self, **kwargs)<EOL>
Initializes the class. :param \*\*kwargs: name, identity, shortcut. :type \*\*kwargs: dict
f13107:c0:m0
def __init__(self, parent=None):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QObject.__init__(self, parent)<EOL>self.__container = parent<EOL>self.__settings = self.__container.settings<EOL>self.__layouts = {}<EOL>self.__current_layout = None<EOL>self.__restore_geometry_on_layout_change = False<EOL>self.register_layout(UiConstants.startup_layout, Layout(name="<STR_LIT>",<EOL>identity=UiConstants.startup_layout,<EOL>shortcut=None))<EOL>
Initializes the class. :param parent: Object parent. :type parent: QObject
f13107:c1:m0
@property<EOL><INDENT>def container(self):<DEDENT>
return self.__container<EOL>
Property for **self.__container** attribute. :return: self.__container. :rtype: QObject
f13107:c1:m1
@container.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def container(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject
f13107:c1:m2
@container.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def container(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__container** attribute.
f13107:c1:m3
@property<EOL><INDENT>def settings(self):<DEDENT>
return self.__settings<EOL>
Property for **self.__settings** attribute. :return: self.__settings. :rtype: Preferences
f13107: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: Preferences
f13107:c1:m5
@settings.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def settings(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__settings** attribute.
f13107:c1:m6
@property<EOL><INDENT>def layouts(self):<DEDENT>
return self.__layouts<EOL>
Property for **self.__layouts** attribute. :return: self.__layouts. :rtype: dict
f13107:c1:m7
@layouts.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def layouts(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__layouts** attribute. :param value: Attribute value. :type value: dict
f13107:c1:m8
@layouts.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def layouts(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__layouts** attribute.
f13107:c1:m9
@property<EOL><INDENT>def current_layout(self):<DEDENT>
return self.__current_layout<EOL>
Property for **self.__current_layout** attribute. :return: self.__current_layout. :rtype: tuple or list
f13107:c1:m10
@current_layout.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def current_layout(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__current_layout** attribute. :param value: Attribute value. :type value: tuple or list
f13107:c1:m11
@current_layout.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def current_layout(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__current_layout** attribute.
f13107:c1:m12
@property<EOL><INDENT>def restore_geometry_on_layout_change(self):<DEDENT>
return self.__restore_geometry_on_layout_change<EOL>
Property for **self.__restore_geometry_on_layout_change** attribute. :return: self.__restore_geometry_on_layout_change. :rtype: bool
f13107:c1:m13
@restore_geometry_on_layout_change.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def restore_geometry_on_layout_change(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is bool, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__restore_geometry_on_layout_change = value<EOL>
Setter for **self.__restore_geometry_on_layout_change** attribute. :param value: Attribute value. :type value: bool
f13107:c1:m14
@restore_geometry_on_layout_change.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def restore_geometry_on_layout_change(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__,<EOL>"<STR_LIT>"))<EOL>
Deleter for **self.__restore_geometry_on_layout_change** attribute.
f13107:c1:m15
def __getitem__(self, layout):
return self.__layouts.__getitem__(layout)<EOL>
Reimplements the :meth:`object.__getitem__` method. :param layout: Layout name. :type layout: unicode :return: Layout. :rtype: Layout
f13107:c1:m16
def __setitem__(self, name, layout):
self.register_layout(name, layout)<EOL>
Reimplements the :meth:`object.__setitem__` method. :param name: Layout name. :type name: unicode :param layout: Layout. :type layout: Layout
f13107:c1:m17
def __iter__(self):
return self.__layouts.iteritems()<EOL>
Reimplements the :meth:`object.__iter__` method. :return: Layouts iterator. :rtype: object
f13107:c1:m18
def __contains__(self, layout):
return layout in self.__layouts<EOL>
Reimplements the :meth:`object.__contains__` method. :param layout: Layout name. :type layout: unicode :return: Layout existence. :rtype: bool
f13107:c1:m19
def __len__(self):
return len(self.__layouts)<EOL>
Reimplements the :meth:`object.__len__` method. :return: Layouts count. :rtype: int
f13107:c1:m20
def get(self, layout, default=None):
try:<EOL><INDENT>return self.__getitem__(layout)<EOL><DEDENT>except KeyError as error:<EOL><INDENT>return default<EOL><DEDENT>
Returns given layout value. :param layout: Layout name. :type layout: unicode :param default: Default value if layout is not found. :type default: object :return: Action. :rtype: QAction
f13107:c1:m21
def list_layouts(self):
return sorted(self.__layouts.keys())<EOL>
Returns the registered layouts. :return: Registered layouts. :rtype: list
f13107:c1:m22
def is_layout_registered(self, name):
return name in self<EOL>
Returns if the given layout name is registered. :param name: Layout name. :type name: unicode :return: Is layout registered. :rtype: bool
f13107:c1:m23
@foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutRegistrationError)<EOL><INDENT>def register_layout(self, name, layout):<DEDENT>
if name in self:<EOL><INDENT>raise umbra.exceptions.LayoutRegistrationError("<STR_LIT>".format(<EOL>self.__class__.__name__, name))<EOL><DEDENT>self.__layouts[name] = layout<EOL>return True<EOL>
Registers given layout. :param name: Layout name. :type name: unicode :param layout: Layout object. :type layout: Layout :return: Method success. :rtype: bool
f13107:c1:m24
@foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutRegistrationError)<EOL><INDENT>def unregister_layout(self, name):<DEDENT>
if not name in self:<EOL><INDENT>raise umbra.exceptions.LayoutRegistrationError("<STR_LIT>".format(<EOL>self.__class__.__name__, name))<EOL><DEDENT>del (self.__layouts[name])<EOL>return True<EOL>
Unregisters given layout. :param name: Layout name. :type name: unicode :param layout: Layout object. :type layout: Layout :return: Method success. :rtype: bool
f13107:c1:m25
@foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutExistError)<EOL><INDENT>def restore_layout(self, name, *args):<DEDENT>
layout = self.__layouts.get(name)<EOL>if not layout:<EOL><INDENT>raise umbra.exceptions.LayoutExistError("<STR_LIT>".format(<EOL>self.__class__.__name__, name))<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(name))<EOL>for component, profile in self.__container.components_manager:<EOL><INDENT>if profile.category == "<STR_LIT>" and component not in self.__container.visible_components:<EOL><INDENT>interface = self.__container.components_manager.get_interface(component)<EOL>interface and interface.hide()<EOL><DEDENT><DEDENT>self.__current_layout = name<EOL>self.__container.centralWidget().setVisible(<EOL>self.__settings.get_key("<STR_LIT>", "<STR_LIT>".format(name)).toBool())<EOL>self.__container.restoreState(<EOL>self.__settings.get_key("<STR_LIT>", "<STR_LIT>".format(name)).toByteArray())<EOL>self.__restore_geometry_on_layout_change andself.__container.restoreGeometry(<EOL>self.__settings.get_key("<STR_LIT>", "<STR_LIT>".format(name)).toByteArray())<EOL>self.layout_restored.emit(self.__current_layout)<EOL>return True<EOL>
Restores given layout. :param name: Layout name. :type name: unicode :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool
f13107:c1:m26
@foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutExistError)<EOL><INDENT>def store_layout(self, name, *args):<DEDENT>
layout = self.__layouts.get(name)<EOL>if not layout:<EOL><INDENT>raise umbra.exceptions.LayoutExistError("<STR_LIT>".format(<EOL>self.__class__.__name__, name))<EOL><DEDENT>LOGGER.debug("<STR_LIT>".format(name))<EOL>self.__current_layout = name<EOL>self.__settings.set_key("<STR_LIT>", "<STR_LIT>".format(name), self.__container.saveGeometry())<EOL>self.__settings.set_key("<STR_LIT>", "<STR_LIT>".format(name), self.__container.saveState())<EOL>self.__settings.set_key("<STR_LIT>", "<STR_LIT>".format(<EOL>name), self.__container.centralWidget().isVisible())<EOL>self.layout_stored.emit(self.__current_layout)<EOL>return True<EOL>
Stores given layout. :param name: Layout name. :type name: unicode :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool
f13107:c1:m27
def restore_startup_layout(self):
LOGGER.debug("<STR_LIT>")<EOL>if self.restore_layout(UiConstants.startup_layout):<EOL><INDENT>not self.__restore_geometry_on_layout_change and self.__container.restoreGeometry(<EOL>self.__settings.get_key("<STR_LIT>", "<STR_LIT>".format(UiConstants.startup_layout)).toByteArray())<EOL>return True<EOL><DEDENT>
Restores the startup layout. :return: Method success. :rtype: bool
f13107:c1:m28
def store_startup_layout(self):
LOGGER.debug("<STR_LIT>")<EOL>return self.store_layout(UiConstants.startup_layout)<EOL>
Stores the startup layout. :return: Method success. :rtype: bool
f13107:c1:m29
def __init__(self, **kwargs):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>foundations.data_structures.Structure.__init__(self, **kwargs)<EOL>
Initializes the class. :param \*\*kwargs: name, path, module, apply, uid. :type \*\*kwargs: dict
f13108:c0:m0
def __init__(self, history_file=None, paths=None, extension="<STR_LIT>"):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>self.__history_file = None<EOL>self.history_file = history_file<EOL>self.__paths = None<EOL>self.paths = paths<EOL>self.__extension = None<EOL>self.extension = extension<EOL>if foundations.common.path_exists(self.__history_file) is False:<EOL><INDENT>open(self.__history_file, "<STR_LIT:w>").close()<EOL><DEDENT>self.__patches = {}<EOL>
Initializes the class. :param history_file: Patches history file. :type history_file: unicode :param paths: Patches paths. :type paths: tuple or list :param extension: Patches extension. :type extension: unicode
f13108:c1:m0
@property<EOL><INDENT>def history_file(self):<DEDENT>
return self.__history_file<EOL>
Property for **self.__history_file** attribute. :return: self.__history_file. :rtype: unicode
f13108:c1:m1
@history_file.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def history_file(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__history_file = value<EOL>
Setter for **self.__history_file** attribute. :param value: Attribute value. :type value: unicode
f13108:c1:m2
@history_file.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def history_file(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__history_file** attribute.
f13108:c1:m3
@property<EOL><INDENT>def paths(self):<DEDENT>
return self.__paths<EOL>
Property for **self.__paths** attribute. :return: self.__paths. :rtype: tuple or list
f13108:c1:m4
@paths.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def paths(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) in (tuple, list), "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL>for element in value:<EOL><INDENT>assert type(element) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", element)<EOL>assert os.path.exists(element), "<STR_LIT>".format("<STR_LIT>",<EOL>element)<EOL><DEDENT><DEDENT>self.__paths = value<EOL>
Setter for **self.__paths** attribute. :param value: Attribute value. :type value: tuple or list
f13108:c1:m5
@paths.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def paths(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__paths** attribute.
f13108:c1:m6
@property<EOL><INDENT>def extension(self):<DEDENT>
return self.__extension<EOL>
Property for **self.__extension** attribute. :return: self.__extension. :rtype: unicode
f13108:c1:m7
@extension.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def extension(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__extension = value<EOL>
Setter for **self.__extension** attribute. :param value: Attribute value. :type value: unicode
f13108:c1:m8
@extension.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def extension(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__extension** attribute.
f13108:c1:m9
@property<EOL><INDENT>def patches(self):<DEDENT>
return self.__patches<EOL>
Property for **self.__patches** attribute. :return: self.__patches. :rtype: dict
f13108:c1:m10
@patches.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def patches(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__patches** attribute. :param value: Attribute value. :type value: dict
f13108:c1:m11
@patches.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def patches(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__patches** attribute.
f13108:c1:m12
def __getitem__(self, patch):
return self.__patches.__getitem__(patch)<EOL>
Reimplements the :meth:`object.__getitem__` method. :param patch: Patch name. :type patch: unicode :return: Patch. :rtype: Patch
f13108:c1:m13
def __setitem__(self, name, path):
self.register_patch(name, path)<EOL>
Reimplements the :meth:`object.__setitem__` method. :param name: Patch name. :type name: unicode :param path: Patch path. :type path: unicode
f13108:c1:m14
def __iter__(self):
return self.__patches.iteritems()<EOL>
Reimplements the :meth:`object.__iter__` method. :return: Patchs iterator. :rtype: object
f13108:c1:m15
def __contains__(self, patch):
return patch in self.__patches<EOL>
Reimplements the :meth:`object.__contains__` method. :param patch: Patch name. :type patch: unicode :return: Patch existence. :rtype: bool
f13108:c1:m16
def __len__(self):
return len(self.__patches)<EOL>
Reimplements the :meth:`object.__len__` method. :return: Patchs count. :rtype: int
f13108:c1:m17
def get(self, patch, default=None):
try:<EOL><INDENT>return self.__getitem__(patch)<EOL><DEDENT>except KeyError as error:<EOL><INDENT>return default<EOL><DEDENT>
Returns given patch value. :param patch: Patch name. :type patch: unicode :param default: Default value if patch is not found. :type default: object :return: Action. :rtype: QAction
f13108:c1:m18
def list_patches(self):
return sorted(self.__patches.keys())<EOL>
Returns the registered patches. :return: Patches list. :rtype: list
f13108:c1:m19
def is_patch_registered(self, patch):
return patch in self<EOL>
Returns if the given patch is registered. :param patch: Patch. :type patch: unicode :return: Is patch registered. :rtype: bool
f13108:c1:m20
@foundations.exceptions.handle_exceptions(umbra.exceptions.PatchInterfaceError)<EOL><INDENT>def register_patch(self, name, path):<DEDENT>
patch = foundations.strings.get_splitext_basename(path)<EOL>LOGGER.debug("<STR_LIT>".format(patch))<EOL>directory = os.path.dirname(path)<EOL>not directory in sys.path and sys.path.append(directory)<EOL>module = __import__(patch)<EOL>if hasattr(module, "<STR_LIT>") and hasattr(module, "<STR_LIT>"):<EOL><INDENT>self.__patches[name] = Patch(name=name,<EOL>path=path,<EOL>module=module,<EOL>apply=getattr(module, "<STR_LIT>"),<EOL>uid=getattr(module, "<STR_LIT>"))<EOL><DEDENT>else:<EOL><INDENT>raise umbra.exceptions.PatchInterfaceError(<EOL>"<STR_LIT>".format(self.__class__.__name__, patch))<EOL><DEDENT>return True<EOL>
Registers given patch. :param name: Patch name. :type name: unicode :param path: Patch path. :type path: unicode :return: Method success. :rtype: bool
f13108:c1:m21
@foundations.exceptions.handle_exceptions(umbra.exceptions.PatchRegistrationError)<EOL><INDENT>def register_patches(self):<DEDENT>
if not self.__paths:<EOL><INDENT>return False<EOL><DEDENT>unregistered_patches = []<EOL>for path in self.paths:<EOL><INDENT>for file in foundations.walkers.files_walker(path, ("<STR_LIT>".format(self.__extension),), ("<STR_LIT>",)):<EOL><INDENT>name = foundations.strings.get_splitext_basename(file)<EOL>if not self.register_patch(name, file):<EOL><INDENT>unregistered_patches.append(name)<EOL><DEDENT><DEDENT><DEDENT>if not unregistered_patches:<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>raise umbra.exceptions.PatchRegistrationError(<EOL>"<STR_LIT>".format(self.__class__.__name__,<EOL>"<STR_LIT:U+002CU+0020>".join(unregistered_patches)))<EOL><DEDENT>
Registers the patches. :return: Method success. :rtype: bool
f13108:c1:m22
@foundations.exceptions.handle_exceptions(umbra.exceptions.PatchApplyError)<EOL><INDENT>def apply_patch(self, patch):<DEDENT>
history_file = File(self.__history_file)<EOL>patches_history = history_file.cache() and [line.strip() for line in history_file.content] or []<EOL>if patch.uid not in patches_history:<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(patch.name))<EOL>if patch.apply():<EOL><INDENT>history_file.content = ["<STR_LIT>".format(patch.uid)]<EOL>history_file.append()<EOL><DEDENT>else:<EOL><INDENT>raise umbra.exceptions.PatchApplyError("<STR_LIT>".format(<EOL>self.__class__.__name__, patch.path))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>LOGGER.debug("<STR_LIT>".format(patch.name))<EOL><DEDENT>return True<EOL>
Applies given patch. :param patch: Patch. :type patch: Patch :return: Method success. :rtype: bool
f13108:c1:m23
def apply_patches(self):
success = True<EOL>for name, patch in sorted(self):<EOL><INDENT>success = self.apply_patch(patch)<EOL><DEDENT>return success<EOL>
Applies the patches. :return: Method success. :rtype: bool
f13108:c1:m24
def get_patch_from_uid(self, uid):
for name, patch in self:<EOL><INDENT>if patch.uid == uid:<EOL><INDENT>return patch<EOL><DEDENT><DEDENT>
Returns the patch with given uid. :param uid: Patch uid. :type uid: unicode :return: Patch. :rtype: Patch
f13108:c1:m25
def __init__(self, **kwargs):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>foundations.data_structures.Structure.__init__(self, **kwargs)<EOL>
Initializes the class. :param \*\*kwargs: message, time. :type \*\*kwargs: dict
f13109:c0:m0
def __init__(self, parent=None):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QObject.__init__(self, parent)<EOL>self.__container = parent<EOL>self.__notifications = []<EOL>self.__notifiers = []<EOL>self.__notifiers_stack_padding = <NUM_LIT:10><EOL>self.__maximum_notifiers = <NUM_LIT:5><EOL>
Initializes the class.
f13109:c1:m0
@property<EOL><INDENT>def container(self):<DEDENT>
return self.__container<EOL>
Property for **self.__container** attribute. :return: self.__container. :rtype: QObject
f13109:c1:m1
@container.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def container(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject
f13109:c1:m2
@container.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def container(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__container** attribute.
f13109:c1:m3
@property<EOL><INDENT>def notifications(self):<DEDENT>
return self.__notifications<EOL>
Property for **self.__notifications** attribute. :return: self.__notifications. :rtype: list
f13109:c1:m4
@notifications.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def notifications(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__notifications** attribute. :param value: Attribute value. :type value: list
f13109:c1:m5
@notifications.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def notifications(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__notifications** attribute.
f13109:c1:m6
@property<EOL><INDENT>def notifiers(self):<DEDENT>
return self.__notifiers<EOL>
Property for **self.__notifiers** attribute. :return: self.__notifiers. :rtype: list
f13109:c1:m7
@notifiers.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def notifiers(self, value):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Setter for **self.__notifiers** attribute. :param value: Attribute value. :type value: list
f13109:c1:m8
@notifiers.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def notifiers(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__notifiers** attribute.
f13109:c1:m9
@property<EOL><INDENT>def notifiers_stack_padding(self):<DEDENT>
return self.__notifiers_stack_padding<EOL>
Property for **self.__notifiers_stack_padding** attribute. :return: self.__notifiers_stack_padding. :rtype: int
f13109:c1:m10
@notifiers_stack_padding.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def notifiers_stack_padding(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is int, "<STR_LIT>".format("<STR_LIT>",<EOL>value)<EOL>assert value >= <NUM_LIT:0>, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__notifiers_stack_padding = value<EOL>
Setter for **self.__notifiers_stack_padding** attribute. :param value: Attribute value. :type value: int
f13109:c1:m11
@notifiers_stack_padding.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def notifiers_stack_padding(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__notifiers_stack_padding** attribute.
f13109:c1:m12
@property<EOL><INDENT>def maximum_notifiers(self):<DEDENT>
return self.__maximum_notifiers<EOL>
Property for **self.__maximum_notifiers** attribute. :return: self.__maximum_notifiers. :rtype: int
f13109:c1:m13
@maximum_notifiers.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def maximum_notifiers(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is int, "<STR_LIT>".format("<STR_LIT>",<EOL>value)<EOL>assert value > <NUM_LIT:0>, "<STR_LIT>".format("<STR_LIT>", value)<EOL><DEDENT>self.__maximum_notifiers = value<EOL>
Setter for **self.__maximum_notifiers** attribute. :param value: Attribute value. :type value: int
f13109:c1:m14
@maximum_notifiers.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def maximum_notifiers(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__maximum_notifiers** attribute.
f13109:c1:m15
def __iter__(self):
return iter(self.__notifications)<EOL>
Reimplements the :meth:`object.__iter__` method. :return: Notifications iterator. :rtype: object
f13109:c1:m16
def __len__(self):
return len(self.__notifications)<EOL>
Reimplements the :meth:`object.__len__` method. :return: Notifications count. :rtype: int
f13109:c1:m17
def __notifier__faded_out(self):
if self.sender() in self.__notifiers:<EOL><INDENT>self.__notifiers.pop(self.__notifiers.index(self.sender()))<EOL><DEDENT>
Defines the slot triggered by **Notification_QLabel** Widget when faded out.
f13109:c1:m18
def __offset_notifiers(self, offset):
overall_offset = offset<EOL>for notifier in self.__notifiers:<EOL><INDENT>notifier.vertical_offset = overall_offset<EOL>notifier.refresh_position()<EOL>overall_offset += offset<EOL><DEDENT>
Offsets existing notifiers. :param offset: Offset. :type offset: int
f13109:c1:m19
def list_notifications(self):
return [self.format_notification(notification) for notification in self]<EOL>
Returns the registered notifications. :return: Notifications list. :rtype: list
f13109:c1:m20
def is_notification_registered(self, notification):
return notification in self<EOL>
Returns if the given notification is registered. :param notification: Notification. :type notification: unicode :return: Is notification registered. :rtype: bool
f13109:c1:m21
def register_notification(self, notification):
LOGGER.debug("<STR_LIT>".format(notification))<EOL>self.__notifications.append(notification)<EOL>self.notification_registered.emit(notification)<EOL>return True<EOL>
Registers given notification. :param notification: Notification to register. :type notification: Notification :return: Method success. :rtype: bool
f13109:c1:m22
def format_notification(self, notification):
return "<STR_LIT>".format(time.ctime(notification.time), notification.message)<EOL>
Formats given notification. :param notification: Notification to format. :type notification: Notification :return: Method success. :rtype: bool
f13109:c1:m23
def notify(self, message, duration=<NUM_LIT>, notification_clicked_slot=None, message_level="<STR_LIT>", **kwargs):
for notifier in self.__notifiers[self.__maximum_notifiers - <NUM_LIT:1>:]:<EOL><INDENT>notifier.duration = <NUM_LIT><EOL>notifier.hide_message()<EOL><DEDENT>notification = Notification(message=message, time=time.time())<EOL>self.register_notification(notification)<EOL>notifier = Notification_QLabel(self.__container, **kwargs)<EOL>notifier.faded_out.connect(self.__notifier__faded_out)<EOL>self.__container.size_changed.connect(notifier.resizeEvent)<EOL>if notification_clicked_slot:<EOL><INDENT>notifier.notification_clicked.connect(notification_clicked_slot)<EOL><DEDENT>else:<EOL><INDENT>notifier.setAttribute(Qt.WA_TransparentForMouseEvents)<EOL><DEDENT>notifier.show_message(message, duration)<EOL>self.__offset_notifiers(-notifier.height() - self.__notifiers_stack_padding)<EOL>self.__notifiers.insert(<NUM_LIT:0>, notifier)<EOL>if message_level == "<STR_LIT>":<EOL><INDENT>LOGGER.info("<STR_LIT>".format(self.__class__.__name__, self.format_notification(notification)))<EOL><DEDENT>elif message_level == "<STR_LIT>":<EOL><INDENT>LOGGER.warning("<STR_LIT>".format(self.__class__.__name__, self.format_notification(notification)))<EOL><DEDENT>elif message_level == "<STR_LIT>":<EOL><INDENT>LOGGER.error("<STR_LIT>".format(self.__class__.__name__, self.format_notification(notification)))<EOL><DEDENT>return True<EOL>
Displays an Application notification. :param message: Notification message. :type message: unicode :param duration: Notification display duration. :type duration: int :param notification_clicked_slot: Notification clicked slot. :type notification_clicked_slot: object :param message_level: Message level ( "Information", "Warning", "Exception" ). :type message_level: unicode :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Method success. :rtype: bool
f13109:c1:m24
def warnify(self, message, duration=<NUM_LIT>, notification_clicked_slot=None, **kwargs):
return self.notify(message,<EOL>duration,<EOL>notification_clicked_slot,<EOL>message_level="<STR_LIT>",<EOL>color=QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT:64>),<EOL>background_color=QColor(<NUM_LIT:32>, <NUM_LIT:32>, <NUM_LIT:32>),<EOL>border_color=QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT:64>),<EOL>**kwargs)<EOL>
Displays an Application notification warning. :param message: Notification message. :type message: unicode :param duration: Notification display duration. :type duration: int :param notification_clicked_slot: Notification clicked slot. :type notification_clicked_slot: object :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Method success. :rtype: bool
f13109:c1:m25
def exceptify(self, message, duration=<NUM_LIT>, notification_clicked_slot=None, **kwargs):
return self.notify(message,<EOL>duration,<EOL>notification_clicked_slot,<EOL>message_level="<STR_LIT>",<EOL>color=QColor(<NUM_LIT>, <NUM_LIT:64>, <NUM_LIT:64>),<EOL>background_color=QColor(<NUM_LIT:32>, <NUM_LIT:32>, <NUM_LIT:32>),<EOL>border_color=QColor(<NUM_LIT>, <NUM_LIT:64>, <NUM_LIT:64>),<EOL>**kwargs)<EOL>
Displays an Application notification exception. :param message: Notification message. :type message: unicode :param duration: Notification display duration. :type duration: int :param notification_clicked_slot: Notification clicked slot. :type notification_clicked_slot: object :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Method success. :rtype: bool
f13109:c1:m26
def __init__(self, parent=None, namespace_splitter="<STR_LIT:|>", root_namespace="<STR_LIT>", default_namespace="<STR_LIT>"):
LOGGER.debug("<STR_LIT>".format(self.__class__.__name__))<EOL>QObject.__init__(self, parent)<EOL>self.__namespace_splitter = None<EOL>self.namespace_splitter = namespace_splitter<EOL>self.__root_namespace = None<EOL>self.root_namespace = root_namespace<EOL>self.__default_namespace = None<EOL>self.default_namespace = default_namespace<EOL>self.__categories = {}<EOL>self.__actions_signals_slots = {}<EOL>
Initializes the class. :param parent: Object parent. :type parent: QObject :param namespace_splitter: Namespace splitters character. :type namespace_splitter: unicode :param root_namespace: Root foundations.namespace. :type root_namespace: unicode :param default_namespace: Default namespace ( For actions with relative path ). :type default_namespace: unicode
f13110:c0:m0
@property<EOL><INDENT>def namespace_splitter(self):<DEDENT>
return self.__namespace_splitter<EOL>
Property for **self.__namespace_splitter** attribute. :return: self.__namespace_splitter. :rtype: unicode
f13110:c0:m1
@namespace_splitter.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def namespace_splitter(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL>assert len(value) == <NUM_LIT:1>, "<STR_LIT>".format("<STR_LIT>",<EOL>value)<EOL>assert not re.search(r"<STR_LIT>", value), "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__namespace_splitter = value<EOL>
Setter for **self.__namespace_splitter** attribute. :param value: Attribute value. :type value: unicode
f13110:c0:m2
@namespace_splitter.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def namespace_splitter(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__namespace_splitter** attribute.
f13110:c0:m3
@property<EOL><INDENT>def root_namespace(self):<DEDENT>
return self.__root_namespace<EOL>
Property for **self.__root_namespace** attribute. :return: self.__root_namespace. :rtype: unicode
f13110:c0:m4
@root_namespace.setter<EOL><INDENT>@foundations.exceptions.handle_exceptions(AssertionError)<EOL>def root_namespace(self, value):<DEDENT>
if value is not None:<EOL><INDENT>assert type(value) is unicode, "<STR_LIT>".format(<EOL>"<STR_LIT>", value)<EOL><DEDENT>self.__root_namespace = value<EOL>
Setter for **self.__root_namespace** attribute. :param value: Attribute value. :type value: unicode
f13110:c0:m5
@root_namespace.deleter<EOL><INDENT>@foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError)<EOL>def root_namespace(self):<DEDENT>
raise foundations.exceptions.ProgrammingError(<EOL>"<STR_LIT>".format(self.__class__.__name__, "<STR_LIT>"))<EOL>
Deleter for **self.__root_namespace** attribute.
f13110:c0:m6