id
int64
0
843k
repository_name
stringlengths
7
55
file_path
stringlengths
9
332
class_name
stringlengths
3
290
human_written_code
stringlengths
12
4.36M
class_skeleton
stringlengths
19
2.2M
total_program_units
int64
1
9.57k
total_doc_str
int64
0
4.2k
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
300
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
176
CountClassBase
float64
0
48
CountClassCoupled
float64
0
589
CountClassCoupledModified
float64
0
581
CountClassDerived
float64
0
5.37k
CountDeclInstanceMethod
float64
0
4.2k
CountDeclInstanceVariable
float64
0
299
CountDeclMethod
float64
0
4.2k
CountDeclMethodAll
float64
0
4.2k
CountLine
float64
1
115k
CountLineBlank
float64
0
9.01k
CountLineCode
float64
0
94.4k
CountLineCodeDecl
float64
0
46.1k
CountLineCodeExe
float64
0
91.3k
CountLineComment
float64
0
27k
CountStmt
float64
1
93.2k
CountStmtDecl
float64
0
46.1k
CountStmtExe
float64
0
90.2k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
6k
142,448
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentRegistrationError
class ComponentRegistrationError(AbstractComponentsManagerError): """ Defines Component registration exception. """ pass
class ComponentRegistrationError(AbstractComponentsManagerError): ''' Defines Component registration exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,449
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentProfileError
class ComponentProfileError(AbstractComponentsManagerError): """ Defines Component profile exception. """ pass
class ComponentProfileError(AbstractComponentsManagerError): ''' Defines Component profile exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,450
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentModuleError
class ComponentModuleError(AbstractComponentsManagerError): """ Defines Component associated module exception. """ pass
class ComponentModuleError(AbstractComponentsManagerError): ''' Defines Component associated module exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,451
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentInstantiationError
class ComponentInstantiationError(AbstractComponentsManagerError): """ Defines Component instantiation exception. """ pass
class ComponentInstantiationError(AbstractComponentsManagerError): ''' Defines Component instantiation exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,452
KelSolaar/Manager
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Manager/manager/tests/tests_manager/resources/components/core/tests_component_b/tests_component_b.py
manager.tests.tests_manager.resources.components.core.tests_component_b.tests_component_b.TestsComponentB
class TestsComponentB(Component): """ Defines the :mod:`tests.tests_manager.resources.components.core.tests_component_b.tests_component_b` Component Interface class. """ def __init__(self, name=None): """ Initializes the class. :param name: Component name. :type name: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) Component.__init__(self, name=name) # --- Setting class attributes. --- self.deactivatable = True self.__container = None @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) def activate(self, container): """ Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__container = container self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__container = None self.activated = False return True def initialize(self): """ Initializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = True return True def uninitialize(self): """ Uninitializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = False return True
class TestsComponentB(Component): ''' Defines the :mod:`tests.tests_manager.resources.components.core.tests_component_b.tests_component_b` Component Interface class. ''' def __init__(self, name=None): ''' Initializes the class. :param name: Component name. :type name: unicode ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass def activate(self, container): ''' Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize(self): ''' Initializes the Component. :return: Method success. :rtype: bool ''' pass def uninitialize(self): ''' Uninitializes the Component. :return: Method success. :rtype: bool ''' pass
14
9
12
3
4
5
1
1.22
1
0
0
0
8
4
8
25
114
32
37
16
23
45
30
13
21
1
2
0
8
142,453
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentExistsError
class ComponentExistsError(AbstractComponentsManagerError): """ Defines non existing Component exception. """ pass
class ComponentExistsError(AbstractComponentsManagerError): ''' Defines non existing Component exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,454
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentDeactivationError
class ComponentDeactivationError(AbstractComponentsManagerError): """ Defines Component deactivation exception. """ pass
class ComponentDeactivationError(AbstractComponentsManagerError): ''' Defines Component deactivation exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,455
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentActivationError
class ComponentActivationError(AbstractComponentsManagerError): """ Defines Component activation exception. """ pass
class ComponentActivationError(AbstractComponentsManagerError): ''' Defines Component activation exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,456
KelSolaar/Manager
KelSolaar_Manager/manager/components_manager.py
manager.components_manager.Components
class Components(foundations.data_structures.Structure): """ Defines a storage object for :class:`Manager` class Components. """ def __init__(self, **kwargs): """ Initializes the class. :param \*\*kwargs: Arguments. :type \*\*kwargs: dict """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) foundations.data_structures.Structure.__init__(self, **kwargs)
class Components(foundations.data_structures.Structure): ''' Defines a storage object for :class:`Manager` class Components. ''' def __init__(self, **kwargs): ''' Initializes the class. :param \*\*kwargs: Arguments. :type \*\*kwargs: dict ''' pass
2
2
11
3
3
5
1
2
1
0
0
0
1
0
1
1
16
4
4
2
2
8
4
2
2
1
1
0
1
142,457
KelSolaar/Manager
KelSolaar_Manager/manager/tests/tests_manager/tests_exceptions.py
manager.tests.tests_manager.tests_exceptions.TestExceptions
class TestExceptions(unittest.TestCase): """ Defines :mod:`manager.exceptions` module exceptions classes units tests methods. """ def test_required_attributes(self): """ Tests presence of required attributes. """ required_attributes = ("value",) for exception in EXCEPTIONS: exception_instance = exception(None) for attribute in required_attributes: self.assertIn(attribute, dir(exception_instance)) def test__str__(self): """ Tests exceptions classes **__str__** method. """ for exception in EXCEPTIONS: exception_instance = exception("{0} Exception raised!".format(exception.__class__)) self.assertIsInstance(exception_instance.__str__(), str) exception_instance = exception([exception.__class__, "Exception raised!"]) self.assertIsInstance(exception_instance.__str__(), str) exception_instance = exception(0) self.assertIsInstance(exception_instance.__str__(), str)
class TestExceptions(unittest.TestCase): ''' Defines :mod:`manager.exceptions` module exceptions classes units tests methods. ''' def test_required_attributes(self): ''' Tests presence of required attributes. ''' pass def test__str__(self): ''' Tests exceptions classes **__str__** method. ''' pass
3
3
11
1
7
3
3
0.6
1
1
0
0
2
0
2
74
28
4
15
9
12
9
15
9
12
3
2
2
5
142,458
KelSolaar/Manager
KelSolaar_Manager/manager/tests/tests_manager/tests_components_manager.py
manager.tests.tests_manager.tests_components_manager.TestProfile
class TestProfile(unittest.TestCase): """ Defines :class:`manager.components_manager.Profile` class units tests methods. """ def test_required_attributes(self): """ Tests presence of required attributes. """ required_attributes = ("name", "file", "directory", "attribute", "require", "module", "interface", "category", "title", "package", "version", "author", "email", "url", "description") for attribute in required_attributes: self.assertIn(attribute, dir(Profile)) def test_required_methods(self): """ Tests presence of required methods. """ required_methods = ("initializeProfile",) for method in required_methods: self.assertIn(method, dir(Profile)) def test_initialize_profile(self): """ Tests :meth:`manager.components_manager.Profile.initializeProfile` method. """ profile = Profile(file=STANDARD_PROFILE_CONTENT["file"]) self.assertTrue(profile.initializeProfile()) for attribute, value in STANDARD_PROFILE_CONTENT.iteritems(): self.assertIsInstance(getattr(profile, attribute), type(value)) self.assertEqual(getattr(profile, attribute), value)
class TestProfile(unittest.TestCase): ''' Defines :class:`manager.components_manager.Profile` class units tests methods. ''' def test_required_attributes(self): ''' Tests presence of required attributes. ''' pass def test_required_methods(self): ''' Tests presence of required methods. ''' pass def test_initialize_profile(self): ''' Tests :meth:`manager.components_manager.Profile.initializeProfile` method. ''' pass
4
4
14
2
9
3
2
0.41
1
2
1
0
3
0
3
75
49
8
29
10
25
12
15
10
11
2
2
1
6
142,459
KelSolaar/Manager
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Manager/manager/components_manager.py
manager.components_manager.Profile
class Profile(object): """ Stores :class:`Manager` class Components informations and objects. """ def __init__(self, name=None, file=None): """ Initializes the class. :param name: Name of the Component. :type name: unicode :param file: File of the Component. :type file: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) # --- Setting class attributes. --- self.__name = None self.name = name self.__file = None self.file = file self.__directory = None self.__attribute = None self.__require = None self.__module = None self.__interface = None self.__category = None self.__title = None self.__package = None self.__version = None self.__author = None self.__email = None self.__url = None self.__description = None @property def name(self): """ Property for **self.__name** attribute. :return: self.__name. :rtype: unicode """ return self.__name @name.setter @foundations.exceptions.handle_exceptions(AssertionError) def name(self, value): """ Setter for **self.__name** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "name", value) self.__name = value @name.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def name(self): """ Deleter for **self.__name** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "name")) @property def file(self): """ Property for **self.__file** attribute. :return: self.__file. :rtype: unicode """ return self.__file @file.setter @foundations.exceptions.handle_exceptions(AssertionError) def file(self, value): """ Setter for **self.__file** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "file", value) self.__file = value @file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file(self): """ Deleter for **self.__file** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "file")) @property def directory(self): """ Property for **self.__directory** attribute. :return: self.__directory. :rtype: unicode """ return self.__directory @directory.setter @foundations.exceptions.handle_exceptions(AssertionError) def directory(self, value): """ Setter for **self.__directory** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "directory", value) assert os.path.exists( value), "'{0}' attribute: '{1}' directory doesn't exists!".format("directory", value) self.__directory = value @directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def directory(self): """ Deleter for **self.__directory** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "directory")) @property def attribute(self): """ Property for **self.__attribute** attribute. :return: self.__attribute. :rtype: unicode """ return self.__attribute @attribute.setter @foundations.exceptions.handle_exceptions(AssertionError) def attribute(self, value): """ Setter for **self.__attribute** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "attribute", value) self.__attribute = value @attribute.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def attribute(self): """ Deleter for **self.__attribute** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "attribute")) @property def require(self): """ Property for **self.__require** attribute. :return: self.__require. :rtype: tuple or list """ return self.__require @require.setter @foundations.exceptions.handle_exceptions(AssertionError) def require(self, value): """ Setter for **self.__require** attribute. :param value: Attribute value. :type value: tuple or list """ if value is not None: assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format( "require", value) self.__require = value @require.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def require(self): """ Deleter for **self.__require** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "require")) @property def module(self): """ Property for **self.__module** attribute. :return: self.__module. :rtype: ModuleType """ return self.__module @module.setter @foundations.exceptions.handle_exceptions(AssertionError) def module(self, value): """ Setter for **self.__module** attribute. :param value: Attribute value. :type value: ModuleType """ if value is not None: assert type(value) is type( sys), "'{0}' attribute: '{1}' type is not 'module'!".format("module", value) self.__module = value @module.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def module(self): """ Deleter for **self.__module** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "module")) @property def interface(self): """ Property for **self.__interface** attribute. :return: self.__interface. :rtype: object """ return self.__interface @interface.setter def interface(self, value): """ Setter for **self.__interface** attribute. :param value: Attribute value. :type value: object """ self.__interface = value @interface.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def interface(self): """ Deleter for **self.__interface** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "interface")) @property def category(self): """ Property for **self.__category** attribute. :return: self.__category. :rtype: unicode """ return self.__category @category.setter @foundations.exceptions.handle_exceptions(AssertionError) def category(self, value): """ Setter for **self.__category** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "category", value) self.__category = value @category.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def category(self): """ Deleter for **self.__category** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "category")) @property def title(self): """ Property for **self.__title** attribute. :return: self.__title. :rtype: unicode """ return self.__title @title.setter @foundations.exceptions.handle_exceptions(AssertionError) def title(self, value): """ Setter for **self.__title** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "title", value) self.__title = value @title.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def title(self): """ Deleter for **self.__title** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "title")) @property def package(self): """ Property for **self.__package** attribute. :return: self.__package. :rtype: unicode """ return self.__package @package.setter @foundations.exceptions.handle_exceptions(AssertionError) def package(self, value): """ Setter for **self.__package** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "package", value) self.__package = value @package.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def package(self): """ Deleter for **self.__package** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "package")) @property def version(self): """ Property for **self.__version** attribute. :return: self.__version. :rtype: unicode """ return self.__version @version.setter @foundations.exceptions.handle_exceptions(AssertionError) def version(self, value): """ Setter for **self.__version** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "version", value) self.__version = value @version.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def version(self): """ Deleter for **self.__version** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "version")) @property def author(self): """ Property for **self.__author** attribute. :return: self.__author. :rtype: unicode """ return self.__author @author.setter @foundations.exceptions.handle_exceptions(AssertionError) def author(self, value): """ Setter for **self.__author** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "author", value) self.__author = value @author.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def author(self): """ Deleter for **self.__author** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "author")) @property def email(self): """ Property for **self.__email** attribute. :return: self.__email. :rtype: unicode """ return self.__email @email.setter @foundations.exceptions.handle_exceptions(AssertionError) def email(self, value): """ Setter for **self.__email** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "email", value) self.__email = value @email.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def email(self): """ Deleter for **self.__email** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "email")) @property def url(self): """ Property for **self.__url** attribute. :return: self.__url. :rtype: unicode """ return self.__url @url.setter @foundations.exceptions.handle_exceptions(AssertionError) def url(self, value): """ Setter for **self.__url** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "url", value) self.__url = value @url.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def url(self): """ Deleter for **self.__url** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "url")) @property def description(self): """ Property for **self.__description** attribute. :return: self.__description. :rtype: unicode """ return self.__description @description.setter @foundations.exceptions.handle_exceptions(AssertionError) def description(self, value): """ Setter for **self.__description** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "description", value) self.__description = value @description.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def description(self): """ Deleter for **self.__description** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "description")) @foundations.exceptions.handle_exceptions(foundations.exceptions.FileStructureParsingError) def initializeProfile(self): """ Initializes the Component Profile. :return: Method success. :rtype: bool """ LOGGER.debug("> Building '{0}' profile.".format(self.__file)) sections_file_parser = SectionsFileParser(self.__file) sections_file_parser.parse() if sections_file_parser.sections: def fileStructureParsingError(attribute): return foundations.exceptions.FileStructureParsingError( "{0} | No '{1}' attribute found, '{2}' file structure seems invalid!".format( self.__class__.__name__, attribute, self.__file)) self.__directory = os.path.dirname(self.__file) self.__name = sections_file_parser.get_value( "Name", "Component", default=None) if self.__name is None: raise fileStructureParsingError("Name") self.__title = sections_file_parser.get_value( "Title", "Component", default=None) if self.__title is None: self.__title = self.__name self.__package = sections_file_parser.get_value( "Module", "Component", default=None) if self.__package is None: raise fileStructureParsingError("Module") self.__attribute = sections_file_parser.get_value( "Object", "Component", default=None) if self.__attribute is None: raise fileStructureParsingError("Object") self.__require = sections_file_parser.get_value( "Require", "Component", default=None) self.__require = list() if self.__require is None else self.__require.split("|") self.__version = sections_file_parser.get_value( "Version", "Component", default=None) if self.__version is None: raise fileStructureParsingError("Version") self.__author = sections_file_parser.get_value( "Author", "Informations", default=None) self.__email = sections_file_parser.get_value( "Email", "Informations", default=None) self.__url = sections_file_parser.get_value( "Url", "Informations", default=None) self.__description = sections_file_parser.get_value( "Description", "Informations", default=None) return True else: raise foundations.exceptions.FileStructureParsingError( "{0} | No sections found, '{1}' file structure seems invalid!".format(self.__class__.__name__, self.__file))
class Profile(object): ''' Stores :class:`Manager` class Components informations and objects. ''' def __init__(self, name=None, file=None): ''' Initializes the class. :param name: Name of the Component. :type name: unicode :param file: File of the Component. :type file: unicode ''' pass @property def name(self): ''' Property for **self.__name** attribute. :return: self.__name. :rtype: unicode ''' pass @name.setter @foundations.exceptions.handle_exceptions(AssertionError) def name(self): ''' Setter for **self.__name** attribute. :param value: Attribute value. :type value: unicode ''' pass @name.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def name(self): ''' Deleter for **self.__name** attribute. ''' pass @property def file(self): ''' Property for **self.__file** attribute. :return: self.__file. :rtype: unicode ''' pass @file.setter @foundations.exceptions.handle_exceptions(AssertionError) def file(self): ''' Setter for **self.__file** attribute. :param value: Attribute value. :type value: unicode ''' pass @file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file(self): ''' Deleter for **self.__file** attribute. ''' pass @property def directory(self): ''' Property for **self.__directory** attribute. :return: self.__directory. :rtype: unicode ''' pass @directory.setter @foundations.exceptions.handle_exceptions(AssertionError) def directory(self): ''' Setter for **self.__directory** attribute. :param value: Attribute value. :type value: unicode ''' pass @directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def directory(self): ''' Deleter for **self.__directory** attribute. ''' pass @property def attribute(self): ''' Property for **self.__attribute** attribute. :return: self.__attribute. :rtype: unicode ''' pass @attribute.setter @foundations.exceptions.handle_exceptions(AssertionError) def attribute(self): ''' Setter for **self.__attribute** attribute. :param value: Attribute value. :type value: unicode ''' pass @attribute.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def attribute(self): ''' Deleter for **self.__attribute** attribute. ''' pass @property def require(self): ''' Property for **self.__require** attribute. :return: self.__require. :rtype: tuple or list ''' pass @require.setter @foundations.exceptions.handle_exceptions(AssertionError) def require(self): ''' Setter for **self.__require** attribute. :param value: Attribute value. :type value: tuple or list ''' pass @require.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def require(self): ''' Deleter for **self.__require** attribute. ''' pass @property def module(self): ''' Property for **self.__module** attribute. :return: self.__module. :rtype: ModuleType ''' pass @module.setter @foundations.exceptions.handle_exceptions(AssertionError) def module(self): ''' Setter for **self.__module** attribute. :param value: Attribute value. :type value: ModuleType ''' pass @module.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def module(self): ''' Deleter for **self.__module** attribute. ''' pass @property def interface(self): ''' Property for **self.__interface** attribute. :return: self.__interface. :rtype: object ''' pass @interface.setter def interface(self): ''' Setter for **self.__interface** attribute. :param value: Attribute value. :type value: object ''' pass @interface.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def interface(self): ''' Deleter for **self.__interface** attribute. ''' pass @property def category(self): ''' Property for **self.__category** attribute. :return: self.__category. :rtype: unicode ''' pass @category.setter @foundations.exceptions.handle_exceptions(AssertionError) def category(self): ''' Setter for **self.__category** attribute. :param value: Attribute value. :type value: unicode ''' pass @category.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def category(self): ''' Deleter for **self.__category** attribute. ''' pass @property def title(self): ''' Property for **self.__title** attribute. :return: self.__title. :rtype: unicode ''' pass @title.setter @foundations.exceptions.handle_exceptions(AssertionError) def title(self): ''' Setter for **self.__title** attribute. :param value: Attribute value. :type value: unicode ''' pass @title.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def title(self): ''' Deleter for **self.__title** attribute. ''' pass @property def package(self): ''' Property for **self.__package** attribute. :return: self.__package. :rtype: unicode ''' pass @package.setter @foundations.exceptions.handle_exceptions(AssertionError) def package(self): ''' Setter for **self.__package** attribute. :param value: Attribute value. :type value: unicode ''' pass @package.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def package(self): ''' Deleter for **self.__package** attribute. ''' pass @property def version(self): ''' Property for **self.__version** attribute. :return: self.__version. :rtype: unicode ''' pass @version.setter @foundations.exceptions.handle_exceptions(AssertionError) def version(self): ''' Setter for **self.__version** attribute. :param value: Attribute value. :type value: unicode ''' pass @version.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def version(self): ''' Deleter for **self.__version** attribute. ''' pass @property def author(self): ''' Property for **self.__author** attribute. :return: self.__author. :rtype: unicode ''' pass @author.setter @foundations.exceptions.handle_exceptions(AssertionError) def author(self): ''' Setter for **self.__author** attribute. :param value: Attribute value. :type value: unicode ''' pass @author.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def author(self): ''' Deleter for **self.__author** attribute. ''' pass @property def email(self): ''' Property for **self.__email** attribute. :return: self.__email. :rtype: unicode ''' pass @email.setter @foundations.exceptions.handle_exceptions(AssertionError) def email(self): ''' Setter for **self.__email** attribute. :param value: Attribute value. :type value: unicode ''' pass @email.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def email(self): ''' Deleter for **self.__email** attribute. ''' pass @property def url(self): ''' Property for **self.__url** attribute. :return: self.__url. :rtype: unicode ''' pass @url.setter @foundations.exceptions.handle_exceptions(AssertionError) def url(self): ''' Setter for **self.__url** attribute. :param value: Attribute value. :type value: unicode ''' pass @url.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def url(self): ''' Deleter for **self.__url** attribute. ''' pass @property def description(self): ''' Property for **self.__description** attribute. :return: self.__description. :rtype: unicode ''' pass @description.setter @foundations.exceptions.handle_exceptions(AssertionError) def description(self): ''' Setter for **self.__description** attribute. :param value: Attribute value. :type value: unicode ''' pass @description.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def description(self): ''' Deleter for **self.__description** attribute. ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.FileStructureParsingError) def initializeProfile(self): ''' Initializes the Component Profile. :return: Method success. :rtype: bool ''' pass def fileStructureParsingError(attribute): pass
124
48
11
2
4
4
1
0.76
1
3
0
0
47
15
47
47
629
142
276
111
153
211
169
65
121
8
1
2
68
142,460
KelSolaar/Manager
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Manager/manager/tests/tests_manager/resources/components/addons/tests_component_C/tests_component_c.py
manager.tests.tests_manager.resources.components.addons.tests_component_C.tests_component_c.TestsComponentC
class TestsComponentC(Component): """ Defines the :mod:`tests.tests_manager.resources.components.addons.tests_component_c.tests_component_c` Component Interface class. """ def __init__(self, name=None): """ Initializes the class. :param name: Component name. :type name: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) Component.__init__(self, name=name) # --- Setting class attributes. --- self.deactivatable = True self.__container = None @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) def activate(self, container): """ Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__container = container self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__container = None self.activated = False return True def initialize(self): """ Initializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = True return True def uninitialize(self): """ Uninitializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = False return True
class TestsComponentC(Component): ''' Defines the :mod:`tests.tests_manager.resources.components.addons.tests_component_c.tests_component_c` Component Interface class. ''' def __init__(self, name=None): ''' Initializes the class. :param name: Component name. :type name: unicode ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass def activate(self, container): ''' Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize(self): ''' Initializes the Component. :return: Method success. :rtype: bool ''' pass def uninitialize(self): ''' Uninitializes the Component. :return: Method success. :rtype: bool ''' pass
14
9
12
3
4
5
1
1.22
1
0
0
0
8
4
8
25
114
32
37
16
23
45
30
13
21
1
2
0
8
142,461
KelSolaar/Manager
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Manager/manager/tests/tests_manager/resources/components/extras/addons/tests_component_d/tests_component_d.py
manager.tests.tests_manager.resources.components.extras.addons.tests_component_d.tests_component_d.TestsComponentD
class TestsComponentD(Component): """ Defines the :mod:`tests.tests_manager.resources.components.addons.tests_component_d.tests_component_d` Component Interface class. """ def __init__(self, name=None): """ Initializes the class. :param name: Component name. :type name: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) Component.__init__(self, name=name) # --- Setting class attributes. --- self.deactivatable = True self.__container = None @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) def activate(self, container): """ Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__container = container self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__container = None self.activated = False return True def initialize(self): """ Initializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = True return True def uninitialize(self): """ Uninitializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = False return True
class TestsComponentD(Component): ''' Defines the :mod:`tests.tests_manager.resources.components.addons.tests_component_d.tests_component_d` Component Interface class. ''' def __init__(self, name=None): ''' Initializes the class. :param name: Component name. :type name: unicode ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass def activate(self, container): ''' Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize(self): ''' Initializes the Component. :return: Method success. :rtype: bool ''' pass def uninitialize(self): ''' Uninitializes the Component. :return: Method success. :rtype: bool ''' pass
14
9
12
3
4
5
1
1.22
1
0
0
0
8
4
8
25
114
32
37
16
23
45
30
13
21
1
2
0
8
142,462
KelSolaar/Manager
KelSolaar_Manager/manager/exceptions.py
manager.exceptions.ComponentInterfaceError
class ComponentInterfaceError(AbstractComponentsManagerError): """ Defines Component Interface exception. """ pass
class ComponentInterfaceError(AbstractComponentsManagerError): ''' Defines Component Interface exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,463
KelSolaar/Manager
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Manager/manager/tests/tests_manager/resources/components/core/tests_component_a/tests_component_a.py
manager.tests.tests_manager.resources.components.core.tests_component_a.tests_component_a.TestsComponentA
class TestsComponentA(Component): """ Defines the :mod:`tests.tests_manager.resources.components.core.tests_component_a.tests_component_a` Component Interface class. """ def __init__(self, name=None): """ Initializes the class. :param name: Component name. :type name: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) Component.__init__(self, name=name) # --- Setting class attributes. --- self.deactivatable = True self.__container = None @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) def activate(self, container): """ Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__container = container self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__container = None self.activated = False return True def initialize(self): """ Initializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = True return True def uninitialize(self): """ Uninitializes the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component.".format( self.__class__.__name__)) self.initialized = False return True
class TestsComponentA(Component): ''' Defines the :mod:`tests.tests_manager.resources.components.core.tests_component_a.tests_component_a` Component Interface class. ''' def __init__(self, name=None): ''' Initializes the class. :param name: Component name. :type name: unicode ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass def activate(self, container): ''' Activates the Component. :param container: Container to attach the Component to. :type container: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize(self): ''' Initializes the Component. :return: Method success. :rtype: bool ''' pass def uninitialize(self): ''' Uninitializes the Component. :return: Method success. :rtype: bool ''' pass
14
9
12
3
4
5
1
1.22
1
0
0
0
8
4
8
25
114
32
37
16
23
45
30
13
21
1
2
0
8
142,464
KelSolaar/Oncilla
KelSolaar_Oncilla/oncilla/globals/constants.py
oncilla.globals.constants.Constants
class Constants(): """ Defines **Oncilla** package default constants. """ application_name = "Oncilla" """ :param application_name: Package Application name. :type application_name: unicode """ major_version = "0" """ :param major_version: Package major version. :type major_version: unicode """ minor_version = "1" """ :param minor_version: Package minor version. :type minor_version: unicode """ change_version = "0" """ :param change_version: Package change version. :type change_version: unicode """ version = ".".join((major_version, minor_version, change_version)) """ :param version: Package version. :type version: unicode """ logger = "Oncilla_Logger" """ :param logger: Package logger name. :type logger: unicode """ verbosity_level = 3 """ :param verbosity_level: Default logging verbosity level. :type verbosity_level: int """ verbosity_labels = ("Critical", "Error", "Warning", "Info", "Debug") """ :param verbosity_labels: Logging verbosity labels. :type verbosity_labels: tuple """ logging_default_formatter = "Default" """ :param logging_default_formatter: Default logging formatter name. :type logging_default_formatter: unicode """ logging_separators = "*" * 96 """ :param logging_separators: Logging separators. :type logging_separators: unicode """ default_codec = "utf-8" """ :param default_codec: Default codec. :type default_codec: unicode """ codec_error = "ignore" """ :param codec_error: Default codec error behavior. :type codec_error: unicode """
class Constants(): ''' Defines **Oncilla** package default constants. '''
1
1
0
0
0
0
0
3.92
0
0
0
0
0
0
0
0
67
3
13
13
12
51
13
13
12
0
0
0
0
142,465
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/active_QLabelsCollection.py
umbra.ui.widgets.active_QLabelsCollection.Active_QLabelsCollection
class Active_QLabelsCollection(QObject): """ Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass providing a group for :class:`umbra.ui.widgets.active_QLabel.Active_QLabel` class objects. """ # Custom signals definitions. active_label_clicked = pyqtSignal(Active_QLabel) """ This signal is emited by the :class:`Active_QLabelsCollection` class when one of its :class:`umbra.ui.widgets.active_QLabel.Active_QLabel` child has been clicked. :return: Current clicked active label. :rtype: Active_QLabel """ active_label_pressed = pyqtSignal(Active_QLabel) """ This signal is emited by the :class:`Active_QLabelsCollection` class when one of its :class:`umbra.ui.widgets.active_QLabel.Active_QLabel` child has been pressed. :return: Current clicked active label. :rtype: Active_QLabel """ active_label_released = pyqtSignal(Active_QLabel) """ This signal is emited by the :class:`Active_QLabelsCollection` class when one of its :class:`umbra.ui.widgets.active_QLabel.Active_QLabel` child has been released. :return: Current clicked active label. :rtype: Active_QLabel """ active_label_toggled = pyqtSignal(Active_QLabel) """ This signal is emited by the :class:`Active_QLabelsCollection` class when one of its :class:`umbra.ui.widgets.active_QLabel.Active_QLabel` child has been toggled. :return: Current checked active label. :rtype: Active_QLabel """ def __init__(self, parent=None): """ Initializes the class. :param parent: Widget parent. :type parent: QObject """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QObject.__init__(self, parent) # --- Setting class attributes. --- self.__container = parent self.__active_labels = [] @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def active_labels(self): """ Property for **self.__active_labels** attribute. :return: self.__active_labels. :rtype: list """ return self.__active_labels @active_labels.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def active_labels(self, value): """ Setter for **self.__active_labels** attribute. :param value: Attribute value. :type value: list """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "active_labels")) @active_labels.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def active_labels(self): """ Deleter for **self.__active_labels** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "active_labels")) def __active_label__toggled(self, active_label, state): """ Defines the slot triggered by an **Active_QLabel** Widget when toggled. :param active_label: Active label. :type active_label: Active_QLabel :param state: Active label checked state. :type state: bool """ LOGGER.debug("> Toggled 'Active_QLabel': '{0}'.".format(active_label)) self.__update_siblings_active_labels_states(active_label) def __update_siblings_active_labels_states(self, active_label): """ Updates given **Active_QLabel** Widget siblings states. :param active_label: Active label. :type active_label: Active_QLabel """ LOGGER.debug("> Clicked 'Active_QLabel': '{0}'.".format(active_label)) for item in self.__active_labels: if item is active_label: continue umbra.ui.common.signals_blocker(item, item.set_checked, False) @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def add_active_label(self, active_label): """ Adds given **Active_QLabel** Widget. :param active_label: Active label to add. :type active_label: Active_QLabel :return: Method success. :rtype: bool """ if not issubclass(active_label.__class__, Active_QLabel): raise foundations.exceptions.ProgrammingError("{0} | '{1}' must be a '{2}' subclass!".format( self.__class__.__name__, active_label, Active_QLabel.__name__)) if active_label in self.__active_labels: raise foundations.exceptions.ProgrammingError("{0} | '{1}' is already in the collection!".format( self.__class__.__name__, active_label)) active_label.checkable = True not self.__active_labels and active_label.set_checked( True) or active_label.set_checked(False) self.__active_labels.append(active_label) # Signals / Slots. active_label.toggled.connect(functools.partial( self.__active_label__toggled, active_label)) active_label.clicked.connect(functools.partial( self.active_label_clicked.emit, active_label)) active_label.pressed.connect(functools.partial( self.active_label_pressed.emit, active_label)) active_label.released.connect(functools.partial( self.active_label_released.emit, active_label)) active_label.toggled.connect(functools.partial( self.active_label_toggled.emit, active_label)) return True def remove_active_label(self, active_label): """ Removes given **Active_QLabel** Widget. :param active_label: Active label to remove. :type active_label: Active_QLabel :return: Method success. :rtype: bool """ if not active_label in self.__active_labels: raise foundations.exceptions.ProgrammingError("{0} | '{1}' is not in the collection!".format( self.__class__.__name__, active_label)) self.__active_labels.remove(active_label) return True def get_toggled_active_label(self): """ Returns the toggled **Active_QLabel** Widget. :return: Checked active label. :rtype: bool """ for active_label in self.__active_labels: if active_label.checked: return active_label def get_active_label_index(self, active_label): """ Returns given **Active_QLabel** Widget index. :param active_label: Active label to retrieve index. :type active_label: Active_QLabel :return: Active label index. :rtype: int """ return self.__active_labels.index(active_label) def get_active_label_from_index(self, index): """ Returns the **Active_QLabel** Widget from given index. :param index: Index. :type index: int :return: Active label. :rtype: Active_QLabel """ return self.__active_labels[index]
class Active_QLabelsCollection(QObject): ''' Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass providing a group for :class:`umbra.ui.widgets.active_QLabel.Active_QLabel` class objects. ''' def __init__(self, parent=None): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def active_labels(self): ''' Property for **self.__active_labels** attribute. :return: self.__active_labels. :rtype: list ''' pass @active_labels.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def active_labels(self): ''' Setter for **self.__active_labels** attribute. :param value: Attribute value. :type value: list ''' pass @active_labels.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def active_labels(self): ''' Deleter for **self.__active_labels** attribute. ''' pass def __active_label__toggled(self, active_label, state): ''' Defines the slot triggered by an **Active_QLabel** Widget when toggled. :param active_label: Active label. :type active_label: Active_QLabel :param state: Active label checked state. :type state: bool ''' pass def __update_siblings_active_labels_states(self, active_label): ''' Updates given **Active_QLabel** Widget siblings states. :param active_label: Active label. :type active_label: Active_QLabel ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def add_active_label(self, active_label): ''' Adds given **Active_QLabel** Widget. :param active_label: Active label to add. :type active_label: Active_QLabel :return: Method success. :rtype: bool ''' pass def remove_active_label(self, active_label): ''' Removes given **Active_QLabel** Widget. :param active_label: Active label to remove. :type active_label: Active_QLabel :return: Method success. :rtype: bool ''' pass def get_toggled_active_label(self): ''' Returns the toggled **Active_QLabel** Widget. :return: Checked active label. :rtype: bool ''' pass def get_active_label_index(self, active_label): ''' Returns given **Active_QLabel** Widget index. :param active_label: Active label to retrieve index. :type active_label: Active_QLabel :return: Active label index. :rtype: int ''' pass def get_active_label_from_index(self, index): ''' Returns the **Active_QLabel** Widget from given index. :param index: Index. :type index: int :return: Active label. :rtype: Active_QLabel ''' pass
26
15
13
3
4
6
2
1.41
1
2
1
0
14
2
14
14
243
60
76
30
50
107
58
23
43
3
1
2
21
142,466
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/highlighters.py
umbra.ui.highlighters.DefaultHighlighter
class DefaultHighlighter(AbstractHighlighter): """ Defines a :class:`AbstractHighlighter` subclass providing syntax highlighting for documents. """ def __init__(self, parent=None, rules=None, theme=None): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param rules: Rules. :type rules: tuple or list :param theme: Theme. :type theme: dict """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) AbstractHighlighter.__init__(self, parent) # --- Setting class attributes. --- self.rules = rules self.__theme = None self.theme = theme self.__set_formats() @property def theme(self): """ Property for **self.__theme** attribute. :return: self.__theme. :rtype: dict """ return self.__theme @theme.setter @foundations.exceptions.handle_exceptions(AssertionError) def theme(self, value): """ Setter for **self.__theme** attribute. :param value: Attribute value. :type value: dict """ if value is not None: assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format( "theme", value) self.__theme = value @theme.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def theme(self): """ Deleter for **self.__theme** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "theme")) def __set_formats(self): """ Sets the highlighting formats. """ self.formats = FormatsTree(self.__theme) def highlightBlock(self, block): """ Reimplements the :meth:`AbstractHighlighter.highlightBlock` method. :param block: Text block. :type block: QString """ self.highlight_text(block, 0, len(block)) self.setCurrentBlockState(0) state = 1 for rule in self.rules: if re.match("comment\.block\.[\w\.]*start", rule.name): format = self.formats.get_format( rule.name) or self.formats.get_format("default") if self.highlight_multiline_block(block, rule.pattern, foundations.common.get_first_item([item for item in self.rules if item.name == rule.name.replace( "start", "end")]).pattern, state, format): break state += 1 def highlight_multiline_block(self, block, start_pattern, end_pattern, state, format): """ Highlights given multiline text block. :param block: Text block. :type block: QString :param pattern: Start regex pattern. :type pattern: QRegExp :param pattern: End regex pattern. :type pattern: QRegExp :param format: Format. :type format: QTextCharFormat :param state: Block state. :type state: int :return: Current block matching state. :rtype: bool """ if self.previousBlockState() == state: start = 0 extend = 0 else: start = start_pattern.indexIn(block) extend = start_pattern.matchedLength() while start >= 0: end = end_pattern.indexIn(block, start + extend) if end >= extend: length = end - start + extend + end_pattern.matchedLength() self.setCurrentBlockState(0) else: self.setCurrentBlockState(state) length = block.length() - start + extend self.setFormat(start, length, format) start = start_pattern.indexIn(block, start + length) if self.currentBlockState() == state: return True else: return False
class DefaultHighlighter(AbstractHighlighter): ''' Defines a :class:`AbstractHighlighter` subclass providing syntax highlighting for documents. ''' def __init__(self, parent=None, rules=None, theme=None): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param rules: Rules. :type rules: tuple or list :param theme: Theme. :type theme: dict ''' pass @property def theme(self): ''' Property for **self.__theme** attribute. :return: self.__theme. :rtype: dict ''' pass @theme.setter @foundations.exceptions.handle_exceptions(AssertionError) def theme(self): ''' Setter for **self.__theme** attribute. :param value: Attribute value. :type value: dict ''' pass @theme.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def theme(self): ''' Deleter for **self.__theme** attribute. ''' pass def __set_formats(self): ''' Sets the highlighting formats. ''' pass def highlightBlock(self, block): ''' Reimplements the :meth:`AbstractHighlighter.highlightBlock` method. :param block: Text block. :type block: QString ''' pass def highlight_multiline_block(self, block, start_pattern, end_pattern, state, format): ''' Highlights given multiline text block. :param block: Text block. :type block: QString :param pattern: Start regex pattern. :type pattern: QRegExp :param pattern: End regex pattern. :type pattern: QRegExp :param format: Format. :type format: QTextCharFormat :param state: Block state. :type state: int :return: Current block matching state. :rtype: bool ''' pass
13
8
17
3
7
7
2
0.84
1
3
1
0
7
3
7
16
132
25
58
20
45
49
46
17
38
5
2
3
15
142,467
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/delegates.py
umbra.ui.delegates.RichText_QStyledItemDelegate
class RichText_QStyledItemDelegate(QStyledItemDelegate): """ Defines a `QStyledItemDelegate <http://doc.qt.nokia.com/qstyleditemdelegate.html>`_ subclass used as a rich text Delegate for Application Views. """ def __init__(self, parent=None, style=None, highlightColor=None, hoverColor=None, background_color=None, highlightBackgroundColor=None, hoverBackgroundColor=None): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param style: Style. :type style: Style """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QStyledItemDelegate.__init__(self, parent) # --- Setting class attributes. --- self.__indent = 5 self.__label = QLabel() self.__label.setIndent(self.__indent) self.__label.setTextFormat(Qt.RichText) self.__default_style = Style(default=""" QLabel, QLabel link { background-color: rgb(32, 32, 32); color: rgb(192, 192, 192); } """, hover=""" QLabel, QLabel link { background-color: rgb(64, 64, 64); color: rgb(192, 192, 192); } """, highlight=""" QLabel, QLabel link { background-color: rgb(128, 128, 128); color: rgb(224, 224, 224); } """) self.__style = self.__default_style self.style = style or self.__style @property def style(self): """ Property for **self.__style** attribute. :return: self.__style. :rtype: Style """ return self.__style @style.setter @foundations.exceptions.handle_exceptions(AssertionError) def style(self, value): """ Setter for **self.__style** attribute. :param value: Attribute value. :type value: Style """ if value is not None: assert type(value) is Style, "'{0}' attribute: '{1}' type is not 'Style'!".format( "style", value) style = Style() for item in (self.__default_style, value): style.update(item) value = style self.__style = value @style.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): """ Deleter for **self.__style** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "style")) def paint(self, painter, option, index): """ Reimplements the :meth:`QStyledItemDelegate.paint` method. """ if option.state & QStyle.State_MouseOver: styleSheet = self.__style.hover elif option.state & QStyle.State_Selected: styleSheet = self.__style.highlight else: styleSheet = self.__style.default self.__label.setStyleSheet(styleSheet) data = index.model().data(index, Qt.DisplayRole) self.__label.setText(umbra.ui.common.QVariant_to_string(data)) self.__label.setFixedSize(option.rect.size()) painter.save() painter.translate(option.rect.topLeft()) self.__label.render(painter) painter.restore() def sizeHint(self, option, index): """ Reimplements the :meth:`QStyledItemDelegate.sizeHint` method. """ document = QTextDocument() document.setDefaultFont(option.font) data = index.model().data(index) text = umbra.ui.common.QVariant_to_string(data) self.__label.setText(text) document.setHtml(text) return QSize(document.idealWidth() + self.__indent, option.fontMetrics.height())
class RichText_QStyledItemDelegate(QStyledItemDelegate): ''' Defines a `QStyledItemDelegate <http://doc.qt.nokia.com/qstyleditemdelegate.html>`_ subclass used as a rich text Delegate for Application Views. ''' def __init__(self, parent=None, style=None, highlightColor=None, hoverColor=None, background_color=None, highlightBackgroundColor=None, hoverBackgroundColor=None): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param style: Style. :type style: Style ''' pass @property def style(self): ''' Property for **self.__style** attribute. :return: self.__style. :rtype: Style ''' pass @style.setter @foundations.exceptions.handle_exceptions(AssertionError) def style(self): ''' Setter for **self.__style** attribute. :param value: Attribute value. :type value: Style ''' pass @style.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): ''' Deleter for **self.__style** attribute. ''' pass def paint(self, painter, option, index): ''' Reimplements the :meth:`QStyledItemDelegate.paint` method. ''' pass def sizeHint(self, option, index): ''' Reimplements the :meth:`QStyledItemDelegate.sizeHint` method. ''' pass
12
7
19
3
12
5
2
0.41
1
2
1
0
6
4
6
6
128
21
76
28
57
31
44
18
37
3
1
2
10
142,468
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/completers.py
umbra.ui.completers.DefaultCompleter
class DefaultCompleter(QCompleter): """ Defines a `QCompleter <http://doc.qt.nokia.com/qcompleter.html>`_ subclass used as a completion widget. """ __tokens = {} """ :param __tokens: Tokens cache. :type __tokens: dict """ def __init__(self, parent=None, language=None, tokens=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param language: Language name. :type language: unicode :param tokens: Completer tokens list. :type tokens: tuple or list """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) # --- Setting class attributes. --- self.__language = None self.language = language self.__set_cache(tokens) QCompleter.__init__(self, DefaultCompleter._DefaultCompleter__tokens[self.__language], parent) self.setCaseSensitivity(Qt.CaseSensitive) self.setCompletionMode(QCompleter.PopupCompletion) @property def language(self): """ Property for **self.__language** attribute. :return: self.__language. :rtype: unicode """ return self.__language @language.setter @foundations.exceptions.handle_exceptions(AssertionError) def language(self, value): """ Setter for **self.__language** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "language", value) self.__language = value @language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def language(self): """ Deleter for **self.__language** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "language")) def __set_cache(self, tokens): """ Sets the tokens cache. :param tokens: Completer tokens list. :type tokens: tuple or list """ if DefaultCompleter._DefaultCompleter__tokens.get(self.__language): return DefaultCompleter._DefaultCompleter__tokens[self.__language] = tokens def update_model(self, words): """ Updates the completer model. :param words: Words to update the completer with. :type words: tuple or list :return: Method success. :rtype: bool """ extended_words = DefaultCompleter._DefaultCompleter__tokens[self.__language][:] extended_words.extend((word for word in set(words) if word not in DefaultCompleter._DefaultCompleter__tokens[self.__language])) self.setModel(QStringListModel(extended_words)) return True
class DefaultCompleter(QCompleter): ''' Defines a `QCompleter <http://doc.qt.nokia.com/qcompleter.html>`_ subclass used as a completion widget. ''' def __init__(self, parent=None, language=None, tokens=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param language: Language name. :type language: unicode :param tokens: Completer tokens list. :type tokens: tuple or list ''' pass @property def language(self): ''' Property for **self.__language** attribute. :return: self.__language. :rtype: unicode ''' pass @language.setter @foundations.exceptions.handle_exceptions(AssertionError) def language(self): ''' Setter for **self.__language** attribute. :param value: Attribute value. :type value: unicode ''' pass @language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def language(self): ''' Deleter for **self.__language** attribute. ''' pass def __set_cache(self, tokens): ''' Sets the tokens cache. :param tokens: Completer tokens list. :type tokens: tuple or list ''' pass def update_model(self, words): ''' Updates the completer model. :param words: Words to update the completer with. :type words: tuple or list :return: Method success. :rtype: bool ''' pass
12
7
13
3
5
6
1
1.19
1
2
0
0
6
1
6
6
102
23
36
13
24
43
27
10
20
2
1
1
8
142,469
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/reporter.py
umbra.reporter.Reporter
class Reporter(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): """ Defines an exception reporting Widget. """ __instance = None """ :param __instance: Class instance. :type __instance: Reporter """ def __new__(cls, *args, **kwargs): """ Constructor of the class. :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Class instance. :rtype: Library """ if not cls._Reporter__instance: cls._Reporter__instance = super( Reporter, cls).__new__(cls, *args, **kwargs) return cls._Reporter__instance def __init__(self, parent=None, report=True, enabled=True, *args, **kwargs): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param report: Report to Crittercism. :type report: bool :param enabled: Is reporter enabled. :type enabled: bool :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ if hasattr(self, "_Reporter__initialized"): return LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(Reporter, self).__init__(parent, *args, **kwargs) # --- Setting class attributes. --- self.__initialized = True self.__report = None self.report = report self.__enabled = None self.enabled = enabled self.__jquery_javascript_path = umbra.ui.common.get_resource_path( os.path.join("javascripts", "jquery.js")) self.__crittercism_javascript_path = umbra.ui.common.get_resource_path( os.path.join("javascripts", "crittercism.js")) self.__reporter_javascript_path = umbra.ui.common.get_resource_path( os.path.join("javascripts", "reporter.js")) self.__jquery_javascript = foundations.io.File( self.__jquery_javascript_path).read() self.__crittercism_javascript = foundations.io.File( self.__crittercism_javascript_path).read() self.__reporter_javascript = foundations.io.File(self.__reporter_javascript_path).read().format( UiConstants.crittercism_id, Constants.version) self.__style = """* { margin: 0; padding: 0; } ::-webkit-scrollbar { height: 12px; width: 12px; } ::-webkit-scrollbar-track-piece { background-color: rgb(48, 48, 48); } ::-webkit-scrollbar-thumb:horizontal, ::-webkit-scrollbar-thumb:vertical { background-color: rgb(96, 96, 96); } ::-webkit-scrollbar-thumb:horizontal:hover, ::-webkit-scrollbar-thumb:vertical:hover { background-color: rgb(128, 128, 128); } ::-webkit-scrollbar-thumb:horizontal { width: 50px; } ::-webkit-scrollbar-thumb:vertical { height: 50px; } body { background-color: rgb(32, 32, 32); color: rgb(192, 192, 192); font-size: 12pt; margin: 16px; overflow-y: scroll; } A:link { color: rgb(160, 96, 64); text-decoration: none; } A:visited { text-decoration: none; color: rgb(160, 96, 64); } A:active { text-decoration: none; color: rgb(160, 96, 64); } A:hover { text-decoration: underline; color: rgb(160, 96, 64); } .floatRight { float: right; } .textAlignRight { text-align: right; } div { overflow:hidden; margin: auto; text-overflow: ellipsis; word-wrap: break-word; } div.header { background-color: rgb(210, 64, 32); color: rgb(32, 32, 32); padding: 24px; } div.traceback { background-color: rgb(210, 64, 32); color: rgb(32, 32, 32); font-size: 16px; padding: 16px; } div.content { padding: 16px; } div.stack { } div.location { background-color: rgb(48, 48, 48); font-size: 16px; padding: 8px; } div.context { background-color: rgb(48, 48, 48); color: rgb(160, 160, 160); font-family: "Courier New"; font-size: 14px; padding: 32px; } span.highlight { background-color: rgb(160, 96, 64); color: rgb(32, 32, 32); display: block; font-weight: bold; } div.exception { background-color: rgb(210, 64, 32); color: rgb(32, 32, 32); font-size: 16px; padding: 16px; } div.debug { padding: 16px; } div.frame { background-color: rgb(48, 48, 48); padding: 8px; } div.type { font-size: 16px; } div.locals { background-color: rgb(48, 48, 48); color: rgb(160, 160, 160); line-height: 150%; padding: 32px; }""" self.__html = None self.__onlineText = "An <b>unhandled</b> exception occured, \ this report has been sent to <b>HDRLabs</b> development team!" self.__offlineText = "An <b>unhandled</b> exception occured, \ mailing this report to <b>{0}</b> would help improving <b>{1}</b>!".format(__email__, Constants.application_name) self.__footerText = \ "The severity of this exception is not critical and <b>{0}</b> will resume!".format( Constants.application_name) self.__initialize_ui() @property def report(self): """ Property for **self.__report** attribute. :return: self.__report. :rtype: bool """ return self.__report @report.setter @foundations.exceptions.handle_exceptions(AssertionError) def report(self, value): """ Setter for **self.__report** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format( "report", value) self.__report = value @report.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def report(self): """ Deleter for **self.__report** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "report")) @property def enabled(self): """ Property for **self.__enabled** attribute. :return: self.__enabled. :rtype: bool """ return self.__enabled @enabled.setter @foundations.exceptions.handle_exceptions(AssertionError) def enabled(self, value): """ Setter for **self.__enabled** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format( "enabled", value) self.__enabled = value @enabled.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def enabled(self): """ Deleter for **self.__enabled** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "enabled")) def __call__(self, *args): """ Caller of the class. :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Class instance. :rtype: Library """ self.handle_exception(*args) def show(self): """ Reimplements the :meth:`QWidget.show` method. """ RuntimeGlobals.splashscreen and RuntimeGlobals.splashscreen.hide() super(Reporter, self).show() self.raise_() def __initialize_ui(self): """ Initializes the Widget ui. """ LOGGER.debug("> Initializing '{0}' Widget ui.".format( self.__class__.__name__)) self.__view = self.Reporter_webView self.setWindowTitle( "{0} - Reporter".format(Constants.application_name)) self.Footer_label.setText(self.__footerText) self.__initialize_context_ui() self.__set_html() # Signals / Slots. self.Copy_Report_pushButton.clicked.connect( self.__Copy_Report_pushButton__clicked) self.Disable_Reporter_pushButton.clicked.connect( self.__Disable_Reporter_pushButton__clicked) def __initialize_context_ui(self): """ Sets the context Widget ui. """ if foundations.common.is_internet_available(): text = self.__onlineText else: text = self.__offlineText self.Header_label.setText(text) def __Copy_Report_pushButton__clicked(self, checked): """ Defines the slot triggered by **Copy_Report_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ clipboard = QApplication.clipboard() clipboard.setText(self.__view.page().mainFrame().toPlainText()) def __Disable_Reporter_pushButton__clicked(self, checked): """ Defines the slot triggered by **Disable_Reporter_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ uninstall_exception_reporter() self.__enabled = False def __get_html(self, body=None): """ Returns the html content with given body tag content. :param body: Body tag content. :type body: unicode :return: Html. :rtype: unicode """ output = [] output.append("<html>") output.append("<head>") for javascript in (self.__jquery_javascript, self.__crittercism_javascript, self.__reporter_javascript): output.append("<script type=\"text/javascript\">") output.append(javascript) output.append("</script>") output.append("<style type=\"text/css\">") output.append(self.__style) output.append("</style>") output.append("</head>") if body is not None: output.append(body) else: output.append("<body>") output.append("<div id=\"report\">") output.append("</div>") output.append("</body>") output.append("</html>") return "\n".join(output) def __set_html(self, html=None): """ Sets the html content in the View using given body. :param html: Html content. :type html: unicode """ self.__html = self.__get_html(html) self.__view.setHtml(self.__html) def __update_html(self, html): """ Updates the View with given html content. :param html: Html content. :type html: unicode """ if platform.system() in ("Windows", "Microsoft"): html = re.sub(r"((?:[a-zA-Z]\:|\\\\[\w\.]+\\[\w.$]+)\\(?:[\w]+\\)*\w([\w.])+)", lambda x: foundations.strings.to_forward_slashes( x.group(1)), html) html = foundations.strings.replace( html, OrderedDict([('"', '\\"'), ("\n", "")])) self.__evaluate_javascript( "$(\"#report\").html(\"{0}\");".format(html)) def __evaluate_javascript(self, javascript): """ Evaluates given javascript content in the View. :param javascript: Javascript. :type javascript: unicode """ self.__view.page().mainFrame().evaluateJavaScript(javascript) def handle_exception(self, *args): """ Handles given exception. :param \*args: Arguments. :type \*args: \* """ if not self.__enabled: return cls, instance, trcback = foundations.exceptions.extract_exception( *args) LOGGER.info("{0} | Handling '{1}' exception!".format( self.__class__.__name__, foundations.strings.to_string(cls))) self.__initialize_context_ui() self.__update_html(self.format_html_exception(cls, instance, trcback)) self.show() self.__report and self.report_exception_to_crittercism( cls, instance, trcback) foundations.exceptions.base_exception_handler(cls, instance, trcback) self.exec_() @staticmethod def format_html_exception(*args): """ Formats given exception as an html text. :param \*args: Arguments. :type \*args: \* :return: Exception html text. :rtype: unicode """ def escape(x): return foundations.strings.replace(x, OrderedDict([("&", "&amp;"), ("<", "&lt;"), (">", "&gt;")])) def format(x): return foundations.strings.replace(x.expandtabs(8), OrderedDict( [("\n\n", "\n \n"), ("\n\n", "\n \n"), (" ", "&nbsp;"), ("\n", "<br/>\n")])) verbose = 10 cls, instance, trcback = args stack = foundations.exceptions.extract_stack( foundations.exceptions.get_inner_most_frame(trcback), verbose) python = "Python {0}: {1}".format( sys.version.split()[0], sys.executable) date = time.ctime(time.time()) html = [] html.append( "<div class=\"header\"><span class=\"floatRight textAlignRight\"><h4>{0}<br/>{1}</h4></span><h2>{2}</h2></div>".format( python, date, escape(foundations.strings.to_string(cls)))) html.append("<div class=\"traceback\">") for line in foundations.exceptions.format_exception(cls, instance, trcback): html.append("{0}<br/>".format(format(escape(line)))) html.append("</div>") html.append("<div class=\"content\">") html.append("<p>An unhandled exception occured in <b>{0} {1}</b>! \ Sequence of calls leading up to the exception, in their occurring order:</p>".format( Constants.application_name, Constants.version)) html.append("<br/>") html.append("<div class=\"stack\">") for frame, file_name, line_number, name, context, index in stack: location = "<b>{0}{1}</b>".format(escape(name) if name != "<module>" else "", inspect.formatargvalues(*inspect.getargvalues(frame))) html.append( "<div class=\"location\">File <a href=file://{0}>\"{0}\"</a>, line <b>{1}</b>, in {2}</div><br>".format( file_name, line_number, location)) html.append("<div class=\"context\">") for i, line in enumerate(context): if i == index: html.append("<span class=\"highlight\">{0}&nbsp;{1}</span>".format( line_number - index + i, format(line))) else: html.append("{0}&nbsp;{1}".format( line_number - index + i, format(line))) html.append("</div>") html.append("<br/>") html.append("</div>") html.append("</div>") html.append("<div class=\"exception\">") for line in traceback.format_exception_only(cls, instance): html.append("<b>{0}</b>".format(format(line))) html.append("</div>") html.append("<div class=\"debug\">") html.append("<p>Frames locals by stack ordering, innermost last:</p>") for frame, locals in foundations.exceptions.extract_locals(trcback): name, file_name, line_number = frame html.append( "<div class=\"frame\">Frame \"{0}\" in <a href=file://{1}>\"{1}\"</a> file, line <b>{2}</b>:</div>".format( escape(name), file_name, line_number)) html.append("<br/>") html.append("<div class=\"locals\">") arguments, nameless_args, keyword_args, locals = locals has_arguments, has_locals = any( (arguments, nameless_args, keyword_args)), any(locals) has_arguments and html.append( "<div class=\"cls\"><b>{0}</b></div><ul>".format("Arguments:")) for key, value in arguments.iteritems(): html.append( "<li><b>{0}</b> = {1}</li>".format(key, escape(value))) for value in nameless_args: html.append("<li><b>{0}</b></li>".format(escape(value))) for key, value in sorted(keyword_args.iteritems()): html.append( "<li><b>{0}</b> = {1}</li>".format(key, escape(value))) has_arguments and html.append("</ul>") has_locals and html.append( "<div class=\"cls\"><b>{0}</b></div><ul>".format("Locals:")) for key, value in sorted(locals.iteritems()): html.append( "<li><b>{0}</b> = {1}</li>".format(key, escape(value))) has_locals and html.append("</ul>") html.append("</div>") html.append("<br/>") html.append("</div>") return "".join(html) @staticmethod def formatTextException(*args): """ Formats given exception as a text. :param \*args: Arguments. :type \*args: \* :return: Exception text. :rtype: unicode """ def format(x): return re.sub( r"^(\s+)", lambda y: "{0} ".format("." * len(y.group(0))), x.rstrip().expandtabs(4)) verbose = 10 cls, instance, trcback = args stack = foundations.exceptions.extract_stack( foundations.exceptions.get_inner_most_frame(trcback), verbose) text = [] text.append(foundations.strings.to_string(cls)) text.append("") for line in foundations.exceptions.format_exception(cls, instance, trcback): text.append(format("{0}".format(format(line)))) text.append("") text.append("An unhandled exception occured in {0} {1}!".format(Constants.application_name, Constants.version)) text.append( "Sequence of calls leading up to the exception, in their occurring order:") text.append("") for frame, file_name, line_number, name, context, index in stack: location = "{0}{1}".format(name if name != "<module>" else "", inspect.formatargvalues(*inspect.getargvalues(frame))) text.append("File \"{0}\", line {1}, in {2}".format( file_name, line_number, location)) for i, line in enumerate(context): if i == index: text.append(format("\t{0} {1} <===".format( line_number - index + i, format(format(line))))) else: text.append(format("\t{0} {1}".format( line_number - index + i, format(format(line))))) text.append("") for line in traceback.format_exception_only(cls, instance): text.append("{0}".format(format(line))) text.append("") text.append("Frames locals by stack ordering, innermost last:") text.append("") for frame, locals in foundations.exceptions.extract_locals(trcback): name, file_name, line_number = frame text.append("Frame \"{0}\" in \"{1}\" file, line {2}:".format( name, file_name, line_number)) arguments, nameless_args, keyword_args, locals = locals has_arguments, has_locals = any( (arguments, nameless_args, keyword_args)), any(locals) has_arguments and text.append(format("\tArguments:")) for key, value in arguments.iteritems(): text.append(format("\t\t{0} = {1}".format(key, value))) for value in nameless_args: text.append(format("\t\t{0}".format(value))) for key, value in sorted(keyword_args.iteritems()): text.append(format("\\tt{0} = {1}".format(key, value))) has_locals and text.append(format("\tLocals:")) for key, value in sorted(locals.iteritems()): text.append(format("\t\t{0} = {1}".format(key, value))) text.append("") return text def report_exception_to_crittercism(self, *args): """ Reports given exception to Crittercism. :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool """ if foundations.common.is_internet_available(): cls, instance, trcback = args title = re.escape("".join( map(lambda x: x.strip(), traceback.format_exception_only(cls, instance)))) file = trcback.tb_frame.f_code.co_filename line_number = trcback.tb_lineno stack = repr( map(str, self.formatTextException(cls, instance, trcback))) javascript = "Crittercism.logExternalException(\"{0}\", \"{1}\", {2}, {3});".format( title, file, line_number, stack) self.__evaluate_javascript(javascript) LOGGER.info("{0} | Exception report sent to Crittercism!".format( self.__class__.__name__)) return True else: LOGGER.warning("!> {0} | Failed sending exception report to Crittercism!".format( self.__class__.__name__)) return False
class Reporter(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): ''' Defines an exception reporting Widget. ''' def __new__(cls, *args, **kwargs): ''' Constructor of the class. :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Class instance. :rtype: Library ''' pass def __init__(self, parent=None, report=True, enabled=True, *args, **kwargs): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param report: Report to Crittercism. :type report: bool :param enabled: Is reporter enabled. :type enabled: bool :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def report(self): ''' Property for **self.__report** attribute. :return: self.__report. :rtype: bool ''' pass @report.setter @foundations.exceptions.handle_exceptions(AssertionError) def report(self): ''' Setter for **self.__report** attribute. :param value: Attribute value. :type value: bool ''' pass @report.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def report(self): ''' Deleter for **self.__report** attribute. ''' pass @property def enabled(self): ''' Property for **self.__enabled** attribute. :return: self.__enabled. :rtype: bool ''' pass @enabled.setter @foundations.exceptions.handle_exceptions(AssertionError) def enabled(self): ''' Setter for **self.__enabled** attribute. :param value: Attribute value. :type value: bool ''' pass @enabled.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def enabled(self): ''' Deleter for **self.__enabled** attribute. ''' pass def __call__(self, *args): ''' Caller of the class. :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Class instance. :rtype: Library ''' pass def show(self): ''' Reimplements the :meth:`QWidget.show` method. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __initialize_context_ui(self): ''' Sets the context Widget ui. ''' pass def __Copy_Report_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Copy_Report_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __Disable_Reporter_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Disable_Reporter_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __get_html(self, body=None): ''' Returns the html content with given body tag content. :param body: Body tag content. :type body: unicode :return: Html. :rtype: unicode ''' pass def __set_html(self, html=None): ''' Sets the html content in the View using given body. :param html: Html content. :type html: unicode ''' pass def __update_html(self, html): ''' Updates the View with given html content. :param html: Html content. :type html: unicode ''' pass def __evaluate_javascript(self, javascript): ''' Evaluates given javascript content in the View. :param javascript: Javascript. :type javascript: unicode ''' pass def handle_exception(self, *args): ''' Handles given exception. :param \*args: Arguments. :type \*args: \* ''' pass @staticmethod def format_html_exception(*args): ''' Formats given exception as an html text. :param \*args: Arguments. :type \*args: \* :return: Exception html text. :rtype: unicode ''' pass def escape(x): pass def format_html_exception(*args): pass @staticmethod def formatTextException(*args): ''' Formats given exception as a text. :param \*args: Arguments. :type \*args: \* :return: Exception text. :rtype: unicode ''' pass def format_html_exception(*args): pass def report_exception_to_crittercism(self, *args): ''' Reports given exception to Crittercism. :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool ''' pass
38
23
27
5
17
6
2
0.35
1
9
3
0
20
15
22
22
645
125
387
85
352
134
227
77
204
12
1
3
54
142,470
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/processing.py
umbra.processing.Processing
class Processing(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): """ Defines the Application processing status bar widget. """ def __init__(self, parent, *args, **kwargs): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(Processing, self).__init__(parent, *args, **kwargs) # --- Setting class attributes. --- self.__container = parent Processing.__initialize_ui(self) @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) def __initialize_ui(self): """ Initializes the Widget ui. """ pass
class Processing(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): ''' Defines the Application processing status bar widget. ''' def __init__(self, parent, *args, **kwargs): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass
11
6
10
2
3
5
1
1.38
1
1
0
0
5
1
5
5
66
16
21
10
10
29
14
7
8
1
1
0
5
142,471
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/preferences.py
umbra.preferences.Preferences
class Preferences(object): """ | Defines methods to manipulate Application preferences / settings. | Those are stored and retrieved using a `QSettings <http://doc.qt.nokia.com/qsettings.html>`_ class. """ def __init__(self, file=None): """ Initializes the class. :param file: Current preferences file path. :type file: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) # --- Setting class attributes. --- self.__file = None self.file = file self.__settings = QSettings( self.__file, QSettings.IniFormat) if self.__file is not None else QSettings() self.__default_settings = None self.__default_layouts_settings = None # --- Initializing preferences. --- self.__get_default_settings() self.__get_default_layouts_settings() @property def file(self): """ Property for **self.__file** attribute. :return: self.__file. :rtype: unicode """ return self.__file @file.setter @foundations.exceptions.handle_exceptions(AssertionError) def file(self, value): """ Setter for **self.__file** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "file", value) self.__file = value @file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file(self): """ Deleter for **self.__file** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "file")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def default_settings(self): """ Property for **self.__default_settings** attribute. :return: self.__default_settings. :rtype: QSettings """ return self.__default_settings @default_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_settings(self, value): """ Setter for **self.__default_settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_settings")) @default_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_settings(self): """ Deleter for **self.__default_settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_settings")) @property def default_layouts_settings(self): """ Property for **self.__default_layouts_settings** attribute. :return: self.__default_layouts_settings. :rtype: QSettings """ return self.__default_layouts_settings @default_layouts_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_layouts_settings(self, value): """ Setter for **self.__default_layouts_settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_layouts_settings")) @default_layouts_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_layouts_settings(self): """ Deleter for **self.__default_layouts_settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_layouts_settings")) def set_key(self, section, key, value): """ Stores given key in settings file. :param section: Current section to save the key into. :type section: unicode :param key: Current key to save. :type key: unicode :param value: Current key value to save. :type value: object """ LOGGER.debug("> Saving '{0}' in '{1}' section with value: '{2}' in settings file.".format( key, section, foundations.strings.to_string(value))) self.__settings.beginGroup(section) self.__settings.setValue(key, QVariant(value)) self.__settings.endGroup() def get_key(self, section, key): """ Gets key value from settings file. :param section: Current section to retrieve key from. :type section: unicode :param key: Current key to retrieve. :type key: unicode :return: Current key value. :rtype: object """ LOGGER.debug( "> Retrieving '{0}' in '{1}' section.".format(key, section)) self.__settings.beginGroup(section) value = self.__settings.value(key) LOGGER.debug("> Key value: '{0}'.".format(value)) self.__settings.endGroup() return value def key_exists(self, section, key): """ Checks if given key exists. :param section: Current section to check key in. :type section: unicode :param key: Current key to check. :type key: unicode :return: Key existence. :rtype: bool """ LOGGER.debug( "> Checking '{0}' key existence in '{1}' section.".format(key, section)) self.__settings.beginGroup(section) exists = self.__settings.contains(key) self.__settings.endGroup() return exists def __get_default_settings(self): """ Gets the default settings. """ LOGGER.debug("> Accessing '{0}' default settings file!".format( UiConstants.settings_file)) self.__default_settings = QSettings( umbra.ui.common.get_resource_path(UiConstants.settings_file), QSettings.IniFormat) def __get_default_layouts_settings(self): """ Gets the default layouts settings. """ LOGGER.debug("> Accessing '{0}' default layouts settings file!".format( UiConstants.layouts_file)) self.__default_layouts_settings = QSettings(umbra.ui.common.get_resource_path(UiConstants.layouts_file), QSettings.IniFormat) def set_default_preferences(self): """ Defines the default settings file content. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing default settings!") for key in self.__default_settings.allKeys(): self.__settings.setValue(key, self.__default_settings.value(key)) self.set_default_layouts() return True def set_default_layouts(self, ignored_layouts=None): """ Sets the default layouts in the preferences file. :param ignored_layouts: Ignored layouts. :type ignored_layouts: tuple or list :return: Method success. :rtype: bool """ for key in self.__default_layouts_settings.allKeys(): if ignored_layouts: if tuple((layout for layout in ignored_layouts if layout in key)): continue self.__settings.setValue( key, self.__default_layouts_settings.value(key)) return True
class Preferences(object): ''' | Defines methods to manipulate Application preferences / settings. | Those are stored and retrieved using a `QSettings <http://doc.qt.nokia.com/qsettings.html>`_ class. ''' def __init__(self, file=None): ''' Initializes the class. :param file: Current preferences file path. :type file: unicode ''' pass @property def file(self): ''' Property for **self.__file** attribute. :return: self.__file. :rtype: unicode ''' pass @file.setter @foundations.exceptions.handle_exceptions(AssertionError) def file(self): ''' Setter for **self.__file** attribute. :param value: Attribute value. :type value: unicode ''' pass @file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file(self): ''' Deleter for **self.__file** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def default_settings(self): ''' Property for **self.__default_settings** attribute. :return: self.__default_settings. :rtype: QSettings ''' pass @default_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_settings(self): ''' Setter for **self.__default_settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @default_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_settings(self): ''' Deleter for **self.__default_settings** attribute. ''' pass @property def default_layouts_settings(self): ''' Property for **self.__default_layouts_settings** attribute. :return: self.__default_layouts_settings. :rtype: QSettings ''' pass @default_layouts_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_layouts_settings(self): ''' Setter for **self.__default_layouts_settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @default_layouts_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_layouts_settings(self): ''' Deleter for **self.__default_layouts_settings** attribute. ''' pass def set_key(self, section, key, value): ''' Stores given key in settings file. :param section: Current section to save the key into. :type section: unicode :param key: Current key to save. :type key: unicode :param value: Current key value to save. :type value: object ''' pass def get_key(self, section, key): ''' Gets key value from settings file. :param section: Current section to retrieve key from. :type section: unicode :param key: Current key to retrieve. :type key: unicode :return: Current key value. :rtype: object ''' pass def key_exists(self, section, key): ''' Checks if given key exists. :param section: Current section to check key in. :type section: unicode :param key: Current key to check. :type key: unicode :return: Key existence. :rtype: bool ''' pass def __get_default_settings(self): ''' Gets the default settings. ''' pass def __get_default_layouts_settings(self): ''' Gets the default layouts settings. ''' pass def set_default_preferences(self): ''' Defines the default settings file content. :return: Method success. :rtype: bool ''' pass def set_default_layouts(self, ignored_layouts=None): ''' Sets the default layouts in the preferences file. :param ignored_layouts: Ignored layouts. :type ignored_layouts: tuple or list :return: Method success. :rtype: bool ''' pass
41
21
12
2
4
5
1
1.04
1
3
1
0
20
4
20
20
276
64
104
41
63
108
73
29
52
4
1
3
26
142,472
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/managers/patches_manager.py
umbra.managers.patches_manager.PatchesManager
class PatchesManager(object): """ Defines the Application patches manager. """ def __init__(self, history_file=None, paths=None, extension="py"): """ 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 """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) # --- Setting class attributes. --- self.__history_file = None self.history_file = history_file self.__paths = None self.paths = paths self.__extension = None self.extension = extension if foundations.common.path_exists(self.__history_file) is False: open(self.__history_file, "w").close() self.__patches = {} @property def history_file(self): """ Property for **self.__history_file** attribute. :return: self.__history_file. :rtype: unicode """ return self.__history_file @history_file.setter @foundations.exceptions.handle_exceptions(AssertionError) def history_file(self, value): """ Setter for **self.__history_file** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "history_file", value) self.__history_file = value @history_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def history_file(self): """ Deleter for **self.__history_file** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "history_file")) @property def paths(self): """ Property for **self.__paths** attribute. :return: self.__paths. :rtype: tuple or list """ return self.__paths @paths.setter @foundations.exceptions.handle_exceptions(AssertionError) def paths(self, value): """ Setter for **self.__paths** attribute. :param value: Attribute value. :type value: tuple or list """ if value is not None: assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format( "paths", value) for element in value: assert type(element) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "paths", element) assert os.path.exists(element), "'{0}' attribute: '{1}' directory doesn't exists!".format("paths", element) self.__paths = value @paths.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def paths(self): """ Deleter for **self.__paths** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "paths")) @property def extension(self): """ Property for **self.__extension** attribute. :return: self.__extension. :rtype: unicode """ return self.__extension @extension.setter @foundations.exceptions.handle_exceptions(AssertionError) def extension(self, value): """ Setter for **self.__extension** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "extension", value) self.__extension = value @extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def extension(self): """ Deleter for **self.__extension** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "extension")) @property def patches(self): """ Property for **self.__patches** attribute. :return: self.__patches. :rtype: dict """ return self.__patches @patches.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def patches(self, value): """ Setter for **self.__patches** attribute. :param value: Attribute value. :type value: dict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "patches")) @patches.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def patches(self): """ Deleter for **self.__patches** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "patches")) def __getitem__(self, patch): """ Reimplements the :meth:`object.__getitem__` method. :param patch: Patch name. :type patch: unicode :return: Patch. :rtype: Patch """ return self.__patches.__getitem__(patch) def __setitem__(self, name, path): """ Reimplements the :meth:`object.__setitem__` method. :param name: Patch name. :type name: unicode :param path: Patch path. :type path: unicode """ self.register_patch(name, path) def __iter__(self): """ Reimplements the :meth:`object.__iter__` method. :return: Patchs iterator. :rtype: object """ return self.__patches.iteritems() def __contains__(self, patch): """ Reimplements the :meth:`object.__contains__` method. :param patch: Patch name. :type patch: unicode :return: Patch existence. :rtype: bool """ return patch in self.__patches def __len__(self): """ Reimplements the :meth:`object.__len__` method. :return: Patchs count. :rtype: int """ return len(self.__patches) def get(self, patch, default=None): """ 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 """ try: return self.__getitem__(patch) except KeyError as error: return default def list_patches(self): """ Returns the registered patches. :return: Patches list. :rtype: list """ return sorted(self.__patches.keys()) def is_patch_registered(self, patch): """ Returns if the given patch is registered. :param patch: Patch. :type patch: unicode :return: Is patch registered. :rtype: bool """ return patch in self @foundations.exceptions.handle_exceptions(umbra.exceptions.PatchInterfaceError) def register_patch(self, name, path): """ Registers given patch. :param name: Patch name. :type name: unicode :param path: Patch path. :type path: unicode :return: Method success. :rtype: bool """ patch = foundations.strings.get_splitext_basename(path) LOGGER.debug("> Current patch: '{0}'.".format(patch)) directory = os.path.dirname(path) not directory in sys.path and sys.path.append(directory) module = __import__(patch) if hasattr(module, "apply") and hasattr(module, "UID"): self.__patches[name] = Patch(name=name, path=path, module=module, apply=getattr(module, "apply"), uid=getattr(module, "UID")) else: raise umbra.exceptions.PatchInterfaceError( "{0} | '{1}' is not a valid patch and has been rejected!".format(self.__class__.__name__, patch)) return True @foundations.exceptions.handle_exceptions(umbra.exceptions.PatchRegistrationError) def register_patches(self): """ Registers the patches. :return: Method success. :rtype: bool """ if not self.__paths: return False unregistered_patches = [] for path in self.paths: for file in foundations.walkers.files_walker(path, ("\.{0}$".format(self.__extension),), ("\._",)): name = foundations.strings.get_splitext_basename(file) if not self.register_patch(name, file): unregistered_patches.append(name) if not unregistered_patches: return True else: raise umbra.exceptions.PatchRegistrationError( "{0} | '{1}' patches failed to register!".format(self.__class__.__name__, ", ".join(unregistered_patches))) @foundations.exceptions.handle_exceptions(umbra.exceptions.PatchApplyError) def apply_patch(self, patch): """ Applies given patch. :param patch: Patch. :type patch: Patch :return: Method success. :rtype: bool """ history_file = File(self.__history_file) patches_history = history_file.cache( ) and [line.strip() for line in history_file.content] or [] if patch.uid not in patches_history: LOGGER.debug("> Applying '{0}' patch!".format(patch.name)) if patch.apply(): history_file.content = ["{0}\n".format(patch.uid)] history_file.append() else: raise umbra.exceptions.PatchApplyError("{0} | '{1}' patch failed to apply!".format( self.__class__.__name__, patch.path)) else: LOGGER.debug( "> '{0}' patch is already applied!".format(patch.name)) return True def apply_patches(self): """ Applies the patches. :return: Method success. :rtype: bool """ success = True for name, patch in sorted(self): success = self.apply_patch(patch) return success def get_patch_from_uid(self, uid): """ Returns the patch with given uid. :param uid: Patch uid. :type uid: unicode :return: Patch. :rtype: Patch """ for name, patch in self: if patch.uid == uid: return patch
class PatchesManager(object): ''' Defines the Application patches manager. ''' def __init__(self, history_file=None, paths=None, extension="py"): ''' 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 ''' pass @property def history_file(self): ''' Property for **self.__history_file** attribute. :return: self.__history_file. :rtype: unicode ''' pass @history_file.setter @foundations.exceptions.handle_exceptions(AssertionError) def history_file(self): ''' Setter for **self.__history_file** attribute. :param value: Attribute value. :type value: unicode ''' pass @history_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def history_file(self): ''' Deleter for **self.__history_file** attribute. ''' pass @property def paths(self): ''' Property for **self.__paths** attribute. :return: self.__paths. :rtype: tuple or list ''' pass @paths.setter @foundations.exceptions.handle_exceptions(AssertionError) def paths(self): ''' Setter for **self.__paths** attribute. :param value: Attribute value. :type value: tuple or list ''' pass @paths.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def paths(self): ''' Deleter for **self.__paths** attribute. ''' pass @property def extension(self): ''' Property for **self.__extension** attribute. :return: self.__extension. :rtype: unicode ''' pass @extension.setter @foundations.exceptions.handle_exceptions(AssertionError) def extension(self): ''' Setter for **self.__extension** attribute. :param value: Attribute value. :type value: unicode ''' pass @extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def extension(self): ''' Deleter for **self.__extension** attribute. ''' pass @property def patches(self): ''' Property for **self.__patches** attribute. :return: self.__patches. :rtype: dict ''' pass @patches.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def patches(self): ''' Setter for **self.__patches** attribute. :param value: Attribute value. :type value: dict ''' pass @patches.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def patches(self): ''' Deleter for **self.__patches** attribute. ''' pass def __getitem__(self, patch): ''' Reimplements the :meth:`object.__getitem__` method. :param patch: Patch name. :type patch: unicode :return: Patch. :rtype: Patch ''' pass def __setitem__(self, name, path): ''' Reimplements the :meth:`object.__setitem__` method. :param name: Patch name. :type name: unicode :param path: Patch path. :type path: unicode ''' pass def __iter__(self): ''' Reimplements the :meth:`object.__iter__` method. :return: Patchs iterator. :rtype: object ''' pass def __contains__(self, patch): ''' Reimplements the :meth:`object.__contains__` method. :param patch: Patch name. :type patch: unicode :return: Patch existence. :rtype: bool ''' pass def __len__(self): ''' Reimplements the :meth:`object.__len__` method. :return: Patchs count. :rtype: int ''' pass def get(self, patch, default=None): ''' 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 ''' pass def list_patches(self): ''' Returns the registered patches. :return: Patches list. :rtype: list ''' pass def is_patch_registered(self, patch): ''' Returns if the given patch is registered. :param patch: Patch. :type patch: unicode :return: Is patch registered. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.PatchInterfaceError) def register_patch(self, name, path): ''' Registers given patch. :param name: Patch name. :type name: unicode :param path: Patch path. :type path: unicode :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.PatchRegistrationError) def register_patches(self): ''' Registers the patches. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.PatchApplyError) def apply_patch(self, patch): ''' Applies given patch. :param patch: Patch. :type patch: Patch :return: Method success. :rtype: bool ''' pass def apply_patches(self): ''' Applies the patches. :return: Method success. :rtype: bool ''' pass def get_patch_from_uid(self, uid): ''' Returns the patch with given uid. :param uid: Patch uid. :type uid: unicode :return: Patch. :rtype: Patch ''' pass
50
27
13
2
5
6
2
0.99
1
8
4
0
26
4
26
26
383
82
151
60
101
150
106
44
79
6
1
3
43
142,473
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/managers/notifications_manager.py
umbra.managers.notifications_manager.NotificationsManager
class NotificationsManager(QObject): """ Defines the Application notifications manager. """ # Custom signals definitions. notification_registered = pyqtSignal(Notification) """ This signal is emited by the :class:`NotificationsManager` class when a notification is registered. :return: Current registered notification. :rtype: Notification """ def __init__(self, parent=None): """ Initializes the class. """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QObject.__init__(self, parent) # --- Setting class attributes. --- self.__container = parent self.__notifications = [] self.__notifiers = [] self.__notifiers_stack_padding = 10 self.__maximum_notifiers = 5 @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def notifications(self): """ Property for **self.__notifications** attribute. :return: self.__notifications. :rtype: list """ return self.__notifications @notifications.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifications(self, value): """ Setter for **self.__notifications** attribute. :param value: Attribute value. :type value: list """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "notifications")) @notifications.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifications(self): """ Deleter for **self.__notifications** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "notifications")) @property def notifiers(self): """ Property for **self.__notifiers** attribute. :return: self.__notifiers. :rtype: list """ return self.__notifiers @notifiers.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifiers(self, value): """ Setter for **self.__notifiers** attribute. :param value: Attribute value. :type value: list """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "notifiers")) @notifiers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifiers(self): """ Deleter for **self.__notifiers** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "notifiers")) @property def notifiers_stack_padding(self): """ Property for **self.__notifiers_stack_padding** attribute. :return: self.__notifiers_stack_padding. :rtype: int """ return self.__notifiers_stack_padding @notifiers_stack_padding.setter @foundations.exceptions.handle_exceptions(AssertionError) def notifiers_stack_padding(self, value): """ Setter for **self.__notifiers_stack_padding** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format("notifiers_stack_padding", value) assert value >= 0, "'{0}' attribute: '{1}' need to be positive!".format( "notifiers_stack_padding", value) self.__notifiers_stack_padding = value @notifiers_stack_padding.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifiers_stack_padding(self): """ Deleter for **self.__notifiers_stack_padding** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "notifiers_stack_padding")) @property def maximum_notifiers(self): """ Property for **self.__maximum_notifiers** attribute. :return: self.__maximum_notifiers. :rtype: int """ return self.__maximum_notifiers @maximum_notifiers.setter @foundations.exceptions.handle_exceptions(AssertionError) def maximum_notifiers(self, value): """ Setter for **self.__maximum_notifiers** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format("maximum_notifiers", value) assert value > 0, "'{0}' attribute: '{1}' need to be exactly positive!".format( "maximum_notifiers", value) self.__maximum_notifiers = value @maximum_notifiers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_notifiers(self): """ Deleter for **self.__maximum_notifiers** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "maximum_notifiers")) def __iter__(self): """ Reimplements the :meth:`object.__iter__` method. :return: Notifications iterator. :rtype: object """ return iter(self.__notifications) def __len__(self): """ Reimplements the :meth:`object.__len__` method. :return: Notifications count. :rtype: int """ return len(self.__notifications) def __notifier__faded_out(self): """ Defines the slot triggered by **Notification_QLabel** Widget when faded out. """ if self.sender() in self.__notifiers: self.__notifiers.pop(self.__notifiers.index(self.sender())) def __offset_notifiers(self, offset): """ Offsets existing notifiers. :param offset: Offset. :type offset: int """ overall_offset = offset for notifier in self.__notifiers: notifier.vertical_offset = overall_offset notifier.refresh_position() overall_offset += offset def list_notifications(self): """ Returns the registered notifications. :return: Notifications list. :rtype: list """ return [self.format_notification(notification) for notification in self] def is_notification_registered(self, notification): """ Returns if the given notification is registered. :param notification: Notification. :type notification: unicode :return: Is notification registered. :rtype: bool """ return notification in self def register_notification(self, notification): """ Registers given notification. :param notification: Notification to register. :type notification: Notification :return: Method success. :rtype: bool """ LOGGER.debug("> Registering notification: '{0}'.".format(notification)) self.__notifications.append(notification) self.notification_registered.emit(notification) return True def format_notification(self, notification): """ Formats given notification. :param notification: Notification to format. :type notification: Notification :return: Method success. :rtype: bool """ return "{0} | '{1}'".format(time.ctime(notification.time), notification.message) def notify(self, message, duration=3000, notification_clicked_slot=None, message_level="Information", **kwargs): """ 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 """ for notifier in self.__notifiers[self.__maximum_notifiers - 1:]: notifier.duration = 150 notifier.hide_message() notification = Notification(message=message, time=time.time()) self.register_notification(notification) notifier = Notification_QLabel(self.__container, **kwargs) # Signals / Slots. notifier.faded_out.connect(self.__notifier__faded_out) self.__container.size_changed.connect(notifier.resizeEvent) if notification_clicked_slot: notifier.notification_clicked.connect(notification_clicked_slot) else: notifier.setAttribute(Qt.WA_TransparentForMouseEvents) notifier.show_message(message, duration) self.__offset_notifiers(-notifier.height() - self.__notifiers_stack_padding) self.__notifiers.insert(0, notifier) if message_level == "Information": LOGGER.info("{0} | '{1}'.".format( self.__class__.__name__, self.format_notification(notification))) elif message_level == "Warning": LOGGER.warning("!> {0} | '{1}'.".format( self.__class__.__name__, self.format_notification(notification))) elif message_level == "Exception": LOGGER.error("!> {0} | '{1}'.".format( self.__class__.__name__, self.format_notification(notification))) return True def warnify(self, message, duration=3000, notification_clicked_slot=None, **kwargs): """ 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 """ return self.notify(message, duration, notification_clicked_slot, message_level="Warning", color=QColor(220, 128, 64), background_color=QColor(32, 32, 32), border_color=QColor(220, 128, 64), **kwargs) def exceptify(self, message, duration=3000, notification_clicked_slot=None, **kwargs): """ 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 """ return self.notify(message, duration, notification_clicked_slot, message_level="Exception", color=QColor(220, 64, 64), background_color=QColor(32, 32, 32), border_color=QColor(220, 64, 64), **kwargs)
class NotificationsManager(QObject): ''' Defines the Application notifications manager. ''' def __init__(self, parent=None): ''' Initializes the class. ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def notifications(self): ''' Property for **self.__notifications** attribute. :return: self.__notifications. :rtype: list ''' pass @notifications.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifications(self): ''' Setter for **self.__notifications** attribute. :param value: Attribute value. :type value: list ''' pass @notifications.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifications(self): ''' Deleter for **self.__notifications** attribute. ''' pass @property def notifiers(self): ''' Property for **self.__notifiers** attribute. :return: self.__notifiers. :rtype: list ''' pass @notifiers.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifiers(self): ''' Setter for **self.__notifiers** attribute. :param value: Attribute value. :type value: list ''' pass @notifiers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifiers(self): ''' Deleter for **self.__notifiers** attribute. ''' pass @property def notifiers_stack_padding(self): ''' Property for **self.__notifiers_stack_padding** attribute. :return: self.__notifiers_stack_padding. :rtype: int ''' pass @notifiers_stack_padding.setter @foundations.exceptions.handle_exceptions(AssertionError) def notifiers_stack_padding(self): ''' Setter for **self.__notifiers_stack_padding** attribute. :param value: Attribute value. :type value: int ''' pass @notifiers_stack_padding.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def notifiers_stack_padding(self): ''' Deleter for **self.__notifiers_stack_padding** attribute. ''' pass @property def maximum_notifiers(self): ''' Property for **self.__maximum_notifiers** attribute. :return: self.__maximum_notifiers. :rtype: int ''' pass @maximum_notifiers.setter @foundations.exceptions.handle_exceptions(AssertionError) def maximum_notifiers(self): ''' Setter for **self.__maximum_notifiers** attribute. :param value: Attribute value. :type value: int ''' pass @maximum_notifiers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_notifiers(self): ''' Deleter for **self.__maximum_notifiers** attribute. ''' pass def __iter__(self): ''' Reimplements the :meth:`object.__iter__` method. :return: Notifications iterator. :rtype: object ''' pass def __len__(self): ''' Reimplements the :meth:`object.__len__` method. :return: Notifications count. :rtype: int ''' pass def __notifier__faded_out(self): ''' Defines the slot triggered by **Notification_QLabel** Widget when faded out. ''' pass def __offset_notifiers(self, offset): ''' Offsets existing notifiers. :param offset: Offset. :type offset: int ''' pass def list_notifications(self): ''' Returns the registered notifications. :return: Notifications list. :rtype: list ''' pass def is_notification_registered(self, notification): ''' Returns if the given notification is registered. :param notification: Notification. :type notification: unicode :return: Is notification registered. :rtype: bool ''' pass def register_notification(self, notification): ''' Registers given notification. :param notification: Notification to register. :type notification: Notification :return: Method success. :rtype: bool ''' pass def format_notification(self, notification): ''' Formats given notification. :param notification: Notification to format. :type notification: Notification :return: Method success. :rtype: bool ''' pass def notify(self, message, duration=3000, notification_clicked_slot=None, message_level="Information", **kwargs): ''' 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 ''' pass def warnify(self, message, duration=3000, notification_clicked_slot=None, **kwargs): ''' 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 ''' pass def exceptify(self, message, duration=3000, notification_clicked_slot=None, **kwargs): ''' 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 ''' pass
53
28
12
2
4
6
1
1.12
1
4
2
0
27
5
27
27
399
89
146
53
93
164
94
38
66
6
1
1
36
142,474
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/managers/layouts_manager.py
umbra.managers.layouts_manager.LayoutsManager
class LayoutsManager(QObject): """ Defines the Application layouts manager. """ layout_restored = pyqtSignal(unicode) """ This signal is emited by the :class:`LayoutsManager` class when the current layout has been restored. :return: Current layout. :rtype: unicode """ layout_stored = pyqtSignal(unicode) """ This signal is emited by the :class:`LayoutsManager` class when the current layout has been stored. :return: Current layout. :rtype: unicode """ def __init__(self, parent=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QObject.__init__(self, parent) # --- Setting class attributes. --- self.__container = parent self.__settings = self.__container.settings self.__layouts = {} self.__current_layout = None self.__restore_geometry_on_layout_change = False self.register_layout(UiConstants.startup_layout, Layout(name="Startup", identity=UiConstants.startup_layout, shortcut=None)) @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: Preferences """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: Preferences """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def layouts(self): """ Property for **self.__layouts** attribute. :return: self.__layouts. :rtype: dict """ return self.__layouts @layouts.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts(self, value): """ Setter for **self.__layouts** attribute. :param value: Attribute value. :type value: dict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "layouts")) @layouts.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts(self): """ Deleter for **self.__layouts** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "layouts")) @property def current_layout(self): """ Property for **self.__current_layout** attribute. :return: self.__current_layout. :rtype: tuple or list """ return self.__current_layout @current_layout.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def current_layout(self, value): """ Setter for **self.__current_layout** attribute. :param value: Attribute value. :type value: tuple or list """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "current_layout")) @current_layout.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def current_layout(self): """ Deleter for **self.__current_layout** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "current_layout")) @property def restore_geometry_on_layout_change(self): """ Property for **self.__restore_geometry_on_layout_change** attribute. :return: self.__restore_geometry_on_layout_change. :rtype: bool """ return self.__restore_geometry_on_layout_change @restore_geometry_on_layout_change.setter @foundations.exceptions.handle_exceptions(AssertionError) def restore_geometry_on_layout_change(self, value): """ Setter for **self.__restore_geometry_on_layout_change** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format( "restore_geometry_on_layout_change", value) self.__restore_geometry_on_layout_change = value @restore_geometry_on_layout_change.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def restore_geometry_on_layout_change(self): """ Deleter for **self.__restore_geometry_on_layout_change** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "restore_geometry_on_layout_change")) def __getitem__(self, layout): """ Reimplements the :meth:`object.__getitem__` method. :param layout: Layout name. :type layout: unicode :return: Layout. :rtype: Layout """ return self.__layouts.__getitem__(layout) def __setitem__(self, name, layout): """ Reimplements the :meth:`object.__setitem__` method. :param name: Layout name. :type name: unicode :param layout: Layout. :type layout: Layout """ self.register_layout(name, layout) def __iter__(self): """ Reimplements the :meth:`object.__iter__` method. :return: Layouts iterator. :rtype: object """ return self.__layouts.iteritems() def __contains__(self, layout): """ Reimplements the :meth:`object.__contains__` method. :param layout: Layout name. :type layout: unicode :return: Layout existence. :rtype: bool """ return layout in self.__layouts def __len__(self): """ Reimplements the :meth:`object.__len__` method. :return: Layouts count. :rtype: int """ return len(self.__layouts) def get(self, layout, default=None): """ 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 """ try: return self.__getitem__(layout) except KeyError as error: return default def list_layouts(self): """ Returns the registered layouts. :return: Registered layouts. :rtype: list """ return sorted(self.__layouts.keys()) def is_layout_registered(self, name): """ Returns if the given layout name is registered. :param name: Layout name. :type name: unicode :return: Is layout registered. :rtype: bool """ return name in self @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutRegistrationError) def register_layout(self, name, layout): """ Registers given layout. :param name: Layout name. :type name: unicode :param layout: Layout object. :type layout: Layout :return: Method success. :rtype: bool """ if name in self: raise umbra.exceptions.LayoutRegistrationError("{0} | '{1}' layout is already registered!".format( self.__class__.__name__, name)) self.__layouts[name] = layout return True @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutRegistrationError) def unregister_layout(self, name): """ Unregisters given layout. :param name: Layout name. :type name: unicode :param layout: Layout object. :type layout: Layout :return: Method success. :rtype: bool """ if not name in self: raise umbra.exceptions.LayoutRegistrationError("{0} | '{1}' layout is not registered!".format( self.__class__.__name__, name)) del (self.__layouts[name]) return True @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutExistError) def restore_layout(self, name, *args): """ Restores given layout. :param name: Layout name. :type name: unicode :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool """ layout = self.__layouts.get(name) if not layout: raise umbra.exceptions.LayoutExistError("{0} | '{1}' layout isn't registered!".format( self.__class__.__name__, name)) LOGGER.debug("> Restoring layout '{0}'.".format(name)) for component, profile in self.__container.components_manager: if profile.category == "QWidget" and component not in self.__container.visible_components: interface = self.__container.components_manager.get_interface( component) interface and interface.hide() self.__current_layout = name self.__container.centralWidget().setVisible( self.__settings.get_key("Layouts", "{0}_central_widget".format(name)).toBool()) self.__container.restoreState( self.__settings.get_key("Layouts", "{0}_window_state".format(name)).toByteArray()) self.__restore_geometry_on_layout_change and \ self.__container.restoreGeometry( self.__settings.get_key("Layouts", "{0}_geometry".format(name)).toByteArray()) self.layout_restored.emit(self.__current_layout) return True @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutExistError) def store_layout(self, name, *args): """ Stores given layout. :param name: Layout name. :type name: unicode :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool """ layout = self.__layouts.get(name) if not layout: raise umbra.exceptions.LayoutExistError("{0} | '{1}' layout isn't registered!".format( self.__class__.__name__, name)) LOGGER.debug("> Storing layout '{0}'.".format(name)) self.__current_layout = name self.__settings.set_key("Layouts", "{0}_geometry".format( name), self.__container.saveGeometry()) self.__settings.set_key("Layouts", "{0}_window_state".format( name), self.__container.saveState()) self.__settings.set_key("Layouts", "{0}_central_widget".format( name), self.__container.centralWidget().isVisible()) self.layout_stored.emit(self.__current_layout) return True def restore_startup_layout(self): """ Restores the startup layout. :return: Method success. :rtype: bool """ LOGGER.debug("> Restoring startup layout.") if self.restore_layout(UiConstants.startup_layout): not self.__restore_geometry_on_layout_change and self.__container.restoreGeometry( self.__settings.get_key("Layouts", "{0}_geometry".format(UiConstants.startup_layout)).toByteArray()) return True def store_startup_layout(self): """ Stores the startup layout. :return: Method success. :rtype: bool """ LOGGER.debug("> Storing startup layout.") return self.store_layout(UiConstants.startup_layout)
class LayoutsManager(QObject): ''' Defines the Application layouts manager. ''' def __init__(self, parent=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: Preferences ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: Preferences ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def layouts(self): ''' Property for **self.__layouts** attribute. :return: self.__layouts. :rtype: dict ''' pass @layouts.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts(self): ''' Setter for **self.__layouts** attribute. :param value: Attribute value. :type value: dict ''' pass @layouts.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts(self): ''' Deleter for **self.__layouts** attribute. ''' pass @property def current_layout(self): ''' Property for **self.__current_layout** attribute. :return: self.__current_layout. :rtype: tuple or list ''' pass @current_layout.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def current_layout(self): ''' Setter for **self.__current_layout** attribute. :param value: Attribute value. :type value: tuple or list ''' pass @current_layout.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def current_layout(self): ''' Deleter for **self.__current_layout** attribute. ''' pass @property def restore_geometry_on_layout_change(self): ''' Property for **self.__restore_geometry_on_layout_change** attribute. :return: self.__restore_geometry_on_layout_change. :rtype: bool ''' pass @restore_geometry_on_layout_change.setter @foundations.exceptions.handle_exceptions(AssertionError) def restore_geometry_on_layout_change(self): ''' Setter for **self.__restore_geometry_on_layout_change** attribute. :param value: Attribute value. :type value: bool ''' pass @restore_geometry_on_layout_change.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def restore_geometry_on_layout_change(self): ''' Deleter for **self.__restore_geometry_on_layout_change** attribute. ''' pass def __getitem__(self, layout): ''' Reimplements the :meth:`object.__getitem__` method. :param layout: Layout name. :type layout: unicode :return: Layout. :rtype: Layout ''' pass def __setitem__(self, name, layout): ''' Reimplements the :meth:`object.__setitem__` method. :param name: Layout name. :type name: unicode :param layout: Layout. :type layout: Layout ''' pass def __iter__(self): ''' Reimplements the :meth:`object.__iter__` method. :return: Layouts iterator. :rtype: object ''' pass def __contains__(self, layout): ''' Reimplements the :meth:`object.__contains__` method. :param layout: Layout name. :type layout: unicode :return: Layout existence. :rtype: bool ''' pass def __len__(self): ''' Reimplements the :meth:`object.__len__` method. :return: Layouts count. :rtype: int ''' pass def get(self, layout, default=None): ''' 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 ''' pass def list_layouts(self): ''' Returns the registered layouts. :return: Registered layouts. :rtype: list ''' pass def is_layout_registered(self, name): ''' Returns if the given layout name is registered. :param name: Layout name. :type name: unicode :return: Is layout registered. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutRegistrationError) def register_layout(self, name, layout): ''' Registers given layout. :param name: Layout name. :type name: unicode :param layout: Layout object. :type layout: Layout :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutRegistrationError) def unregister_layout(self, name): ''' Unregisters given layout. :param name: Layout name. :type name: unicode :param layout: Layout object. :type layout: Layout :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutExistError) def restore_layout(self, name, *args): ''' Restores given layout. :param name: Layout name. :type name: unicode :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.LayoutExistError) def store_layout(self, name, *args): ''' Stores given layout. :param name: Layout name. :type name: unicode :param \*args: Arguments. :type \*args: \* :return: Method success. :rtype: bool ''' pass def restore_startup_layout(self): ''' Restores the startup layout. :return: Method success. :rtype: bool ''' pass def store_startup_layout(self): ''' Stores the startup layout. :return: Method success. :rtype: bool ''' pass
60
31
12
2
4
6
1
1.14
1
7
4
0
30
5
30
30
444
103
159
62
99
182
107
42
76
4
1
2
39
142,475
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/managers/file_system_events_manager.py
umbra.managers.file_system_events_manager.FileSystemEventsManager
class FileSystemEventsManager(QThread): """ Defines the file system events manager. """ # Custom signals definitions. file_changed = pyqtSignal(unicode) """ This signal is emited by the :class:`FileSystemEventsManager` class when a file is changed. :return: Current changed file. :rtype: unicode """ file_invalidated = pyqtSignal(unicode) """ This signal is emited by the :class:`FileSystemEventsManager` class when a file is invalidated. :return: Current invalidated file. :rtype: unicode """ directory_changed = pyqtSignal(unicode) """ This signal is emited by the :class:`FileSystemEventsManager` class when a directory is changed. :return: Current changed directory. :rtype: unicode """ directory_invalidated = pyqtSignal(unicode) """ This signal is emited by the :class:`FileSystemEventsManager` class when a directory is invalidated. :return: Current invalidated directory. :rtype: unicode """ def __init__(self, parent=None): """ Initializes the class. """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QThread.__init__(self, parent) # --- Setting class attributes. --- self.__container = parent self.__paths = {} self.__timer = None self.__timer_cycle_multiplier = 5 @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def paths(self): """ Property for **self.__paths** attribute. :return: self.__paths. :rtype: dict """ return self.__paths @paths.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def paths(self, value): """ Setter for **self.__paths** attribute. :param value: Attribute value. :type value: dict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "paths")) @paths.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def paths(self): """ Deleter for **self.__paths** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "paths")) @property def timer(self): """ Property for **self.__timer** attribute. :return: self.__timer. :rtype: QTimer """ return self.__timer @timer.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer(self, value): """ Setter for **self.__timer** attribute. :param value: Attribute value. :type value: QTimer """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "timer")) @timer.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer(self): """ Deleter for **self.__timer** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "timer")) @property def timer_cycle_multiplier(self): """ Property for **self.__timer_cycle_multiplier** attribute. :return: self.__timer_cycle_multiplier. :rtype: float """ return self.__timer_cycle_multiplier @timer_cycle_multiplier.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer_cycle_multiplier(self, value): """ Setter for **self.__timer_cycle_multiplier** attribute. :param value: Attribute value. :type value: float """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "timer_cycle_multiplier")) @timer_cycle_multiplier.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer_cycle_multiplier(self): """ Deleter for **self.__timer_cycle_multiplier** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "timer_cycle_multiplier")) def __getitem__(self, path): """ Reimplements the :meth:`object.__getitem__` method. :param path: Path name. :type path: unicode :return: Path. :rtype: Path """ return self.__paths.__getitem__(path) def __setitem__(self, path, modified_time): """ Reimplements the :meth:`object.__setitem__` method. :param path: Path. :type path: unicode :param modified_time: Modified time. :type modified_time: int or float """ self.register_path(path, modified_time) def __iter__(self): """ Reimplements the :meth:`object.__iter__` method. :return: Paths iterator. :rtype: object """ return self.__paths.iteritems() def __contains__(self, path): """ Reimplements the :meth:`object.__contains__` method. :param path: Path name. :type path: unicode :return: Path existence. :rtype: bool """ return path in self.__paths def __len__(self): """ Reimplements the :meth:`object.__len__` method. :return: Paths count. :rtype: int """ return len(self.__paths) def get(self, path, default=None): """ Returns given path value. :param path: Path name. :type path: unicode :param default: Default value if path is not found. :type default: object :return: Action. :rtype: QAction """ try: return self.__getitem__(path) except KeyError as error: return default def run(self): """ Reimplements the :meth:`QThread.run` method. """ self.__timer = QTimer() self.__timer.moveToThread(self) self.__timer.start(Constants.default_timer_cycle * self.__timer_cycle_multiplier) self.__timer.timeout.connect( self.__watch_file_system, Qt.DirectConnection) self.exec_() def __watch_file_system(self): """ Watches the file system for paths that have been changed or invalidated on disk. """ for path, data in self.__paths.items(): stored_modified_time, is_file = data try: if not foundations.common.path_exists(path): LOGGER.warning( "!> {0} | '{1}' path has been invalidated and will be unregistered!".format( self.__class__.__name__, path)) del (self.__paths[path]) if is_file: self.file_invalidated.emit(path) else: self.directory_invalidated.emit(path) continue except KeyError: LOGGER.debug("> {0} | '{1}' path has been unregistered while iterating!".format( self.__class__.__name__, path)) continue try: modified_time = self.get_path_modified_time(path) except OSError: LOGGER.debug("> {0} | '{1}' path has been invalidated while iterating!".format( self.__class__.__name__, path)) continue if stored_modified_time != modified_time: self.__paths[path] = (modified_time, os.path.isfile(path)) LOGGER.debug("> {0} | '{1}' path has been changed!".format( self.__class__.__name__, path)) if is_file: self.file_changed.emit(path) else: self.directory_changed.emit(path) def list_paths(self): """ Returns the registered paths. :return: Registered paths. :rtype: list """ return sorted(self.__paths.keys()) def is_path_registered(self, path): """ Returns if the given path is registered. :param path: Path name. :type path: unicode :return: Is path registered. :rtype: bool """ return path in self @foundations.exceptions.handle_exceptions(foundations.exceptions.PathExistsError, umbra.exceptions.PathRegistrationError) def register_path(self, path, modified_time=None): """ 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 """ if not foundations.common.path_exists(path): raise foundations.exceptions.PathExistsError("{0} | '{1}' path doesn't exists!".format( self.__class__.__name__, path)) if path in self: raise umbra.exceptions.PathRegistrationError("{0} | '{1}' path is already registered!".format( self.__class__.__name__, path)) self.__paths[path] = (self.get_path_modified_time( path) if modified_time is None else modified_time, os.path.isfile(path)) return True @foundations.exceptions.handle_exceptions(umbra.exceptions.PathExistsError) def unregister_path(self, path): """ Unregisters given path. :param path: Path name. :type path: unicode :return: Method success. :rtype: bool """ if not path in self: raise umbra.exceptions.PathExistsError("{0} | '{1}' path isn't registered!".format( self.__class__.__name__, path)) del (self.__paths[path]) return True @staticmethod def get_path_modified_time(path): """ Returns given path modification time. :param path: Path. :type path: unicode :return: Modification time. :rtype: int """ return float(foundations.common.get_first_item(str(os.path.getmtime(path)).split(".")))
class FileSystemEventsManager(QThread): ''' Defines the file system events manager. ''' def __init__(self, parent=None): ''' Initializes the class. ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def paths(self): ''' Property for **self.__paths** attribute. :return: self.__paths. :rtype: dict ''' pass @paths.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def paths(self): ''' Setter for **self.__paths** attribute. :param value: Attribute value. :type value: dict ''' pass @paths.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def paths(self): ''' Deleter for **self.__paths** attribute. ''' pass @property def timer(self): ''' Property for **self.__timer** attribute. :return: self.__timer. :rtype: QTimer ''' pass @timer.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer(self): ''' Setter for **self.__timer** attribute. :param value: Attribute value. :type value: QTimer ''' pass @timer.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer(self): ''' Deleter for **self.__timer** attribute. ''' pass @property def timer_cycle_multiplier(self): ''' Property for **self.__timer_cycle_multiplier** attribute. :return: self.__timer_cycle_multiplier. :rtype: float ''' pass @timer_cycle_multiplier.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer_cycle_multiplier(self): ''' Setter for **self.__timer_cycle_multiplier** attribute. :param value: Attribute value. :type value: float ''' pass @timer_cycle_multiplier.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def timer_cycle_multiplier(self): ''' Deleter for **self.__timer_cycle_multiplier** attribute. ''' pass def __getitem__(self, path): ''' Reimplements the :meth:`object.__getitem__` method. :param path: Path name. :type path: unicode :return: Path. :rtype: Path ''' pass def __setitem__(self, path, modified_time): ''' Reimplements the :meth:`object.__setitem__` method. :param path: Path. :type path: unicode :param modified_time: Modified time. :type modified_time: int or float ''' pass def __iter__(self): ''' Reimplements the :meth:`object.__iter__` method. :return: Paths iterator. :rtype: object ''' pass def __contains__(self, path): ''' Reimplements the :meth:`object.__contains__` method. :param path: Path name. :type path: unicode :return: Path existence. :rtype: bool ''' pass def __len__(self): ''' Reimplements the :meth:`object.__len__` method. :return: Paths count. :rtype: int ''' pass def get(self, path, default=None): ''' Returns given path value. :param path: Path name. :type path: unicode :param default: Default value if path is not found. :type default: object :return: Action. :rtype: QAction ''' pass def run(self): ''' Reimplements the :meth:`QThread.run` method. ''' pass def __watch_file_system(self): ''' Watches the file system for paths that have been changed or invalidated on disk. ''' pass def list_paths(self): ''' Returns the registered paths. :return: Registered paths. :rtype: list ''' pass def is_path_registered(self, path): ''' Returns if the given path is registered. :param path: Path name. :type path: unicode :return: Is path registered. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.PathExistsError, umbra.exceptions.PathRegistrationError) def register_path(self, path, modified_time=None): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.PathExistsError) def unregister_path(self, path): ''' Unregisters given path. :param path: Path name. :type path: unicode :return: Method success. :rtype: bool ''' pass @staticmethod def get_path_modified_time(path): ''' Returns given path modification time. :param path: Path. :type path: unicode :return: Modification time. :rtype: int ''' pass
50
27
12
2
4
5
1
1.13
1
7
3
0
25
4
26
26
393
90
142
55
91
161
100
38
73
8
1
4
38
142,476
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/managers/actions_manager.py
umbra.managers.actions_manager.ActionsManager
class ActionsManager(QObject): """ Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass providing an actions manager. """ def __init__(self, parent=None, namespace_splitter="|", root_namespace="Actions", default_namespace="Others"): """ 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 """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QObject.__init__(self, parent) # --- Setting class attributes. --- self.__namespace_splitter = None self.namespace_splitter = namespace_splitter self.__root_namespace = None self.root_namespace = root_namespace self.__default_namespace = None self.default_namespace = default_namespace self.__categories = {} self.__actions_signals_slots = {} @property def namespace_splitter(self): """ Property for **self.__namespace_splitter** attribute. :return: self.__namespace_splitter. :rtype: unicode """ return self.__namespace_splitter @namespace_splitter.setter @foundations.exceptions.handle_exceptions(AssertionError) def namespace_splitter(self, value): """ Setter for **self.__namespace_splitter** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "namespace_splitter", value) assert len(value) == 1, "'{0}' attribute: '{1}' has multiples characters!".format("namespace_splitter", value) assert not re.search(r"\w", value), "'{0}' attribute: '{1}' is an alphanumeric character!".format( "namespace_splitter", value) self.__namespace_splitter = value @namespace_splitter.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def namespace_splitter(self): """ Deleter for **self.__namespace_splitter** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "namespace_splitter")) @property def root_namespace(self): """ Property for **self.__root_namespace** attribute. :return: self.__root_namespace. :rtype: unicode """ return self.__root_namespace @root_namespace.setter @foundations.exceptions.handle_exceptions(AssertionError) def root_namespace(self, value): """ Setter for **self.__root_namespace** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "root_namespace", value) self.__root_namespace = value @root_namespace.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def root_namespace(self): """ Deleter for **self.__root_namespace** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "root_namespace")) @property def default_namespace(self): """ Property for **self.__default_namespace** attribute. :return: self.__default_namespace. :rtype: unicode """ return self.__default_namespace @default_namespace.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_namespace(self, value): """ Setter for **self.__default_namespace** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "default_namespace", value) self.__default_namespace = value @default_namespace.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_namespace(self): """ Deleter for **self.__default_namespace** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_namespace")) @property def categories(self): """ Property for **self.__categories** attribute. :return: self.__categories. :rtype: dict """ return self.__categories @categories.setter @foundations.exceptions.handle_exceptions(AssertionError) def categories(self, value): """ Setter for **self.__categories** attribute. :param value: Attribute value. :type value: dict """ if value is not None: assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format( "categories", value) for key, element in value.iteritems(): assert type(key) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format( "categories", key) assert type(element) is list, "'{0}' attribute: '{1}' type is not 'list'!".format( "categories", element) self.__categories = value @categories.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def categories(self): """ Deleter for **self.__categories** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "categories")) def __getitem__(self, action): """ Reimplements the :meth:`object.__getitem__` method. :param action: Action name. :type action: unicode :return: Action. :rtype: QAction """ action = self.__normalize_name(action) for path, name, object in foundations.walkers.dictionaries_walker(self.__categories): if action == foundations.namespace.set_namespace(self.__namespace_splitter.join(path), name): LOGGER.debug( "> Retrieved object for '{0}' action name!".format(action)) return object raise umbra.exceptions.ActionExistsError( "{0} | '{1}' action isn't registered!".format(self.__class__.__name__, action)) def __setitem__(self, action, kwargs): """ Reimplements the :meth:`object.__setitem__` method. :param action: Action. :type action: unicode :param kwargs: kwargs. :type kwargs: dict """ self.register_action(action, **kwargs) def __iter__(self): """ Reimplements the :meth:`object.__iter__` method. :return: Actions iterator. :rtype: object """ return foundations.walkers.dictionaries_walker(self.__categories) def __contains__(self, action): """ Reimplements the :meth:`object.__contains__` method. :param action: Action name. :type action: unicode :return: Action existence. :rtype: bool """ for path, name, object in self: if foundations.namespace.set_namespace(self.__namespace_splitter.join(path), name) == action: return True return False def __len__(self): """ Reimplements the :meth:`object.__len__` method. :return: Actions count. :rtype: int """ return len([action for action in self]) def __normalize_name(self, name): """ Normalizes given action name. :param name: Action name. :type name: unicode :return: Normalized name. :rtype: bool """ if not name.startswith(self.__root_namespace): name = foundations.namespace.set_namespace(self.__root_namespace, foundations.namespace.set_namespace(self.__default_namespace, name)) LOGGER.debug("> Normalized name: '{0}'.".format(name)) return name else: LOGGER.debug("> Name '{0}' is already normalized!".format(name)) return name def __get_category(self, category, name, vivify=False): """ Gets recusively requested category, alternately if **vivify** argument is set, the category will be created. :param category: Base category. :type category: dict :param name: Category to retrieve or vivify. :type name: unicode :param vivify: Vivify missing parents in the chain to the requested category. :type vivify: bool :return: Requested category. :rtype: dict """ namespace = foundations.namespace.get_namespace(name, root_only=True) name = foundations.namespace.remove_namespace(name, root_only=True) if namespace: if vivify and namespace not in category: category[namespace] = {} return self.__get_category(category[namespace], name, vivify) else: if vivify and name not in category: category[name] = {} return category[name] def get(self, action, default=None): """ Returns given action value. :param action: Action name. :type action: unicode :param default: Default value if action is not found. :type default: object :return: Action. :rtype: QAction """ try: return self.__getitem__(action) except KeyError as error: return default def list_actions(self): """ Returns the registered actions. :return: Actions list. :rtype: list """ actions = [] for path, actionName, action in self: actions.append(self.__namespace_splitter.join( itertools.chain(path, (actionName,)))) return sorted(actions) @foundations.exceptions.handle_exceptions(umbra.exceptions.CategoryExistsError) def get_category(self, name, vivify=False): """ Returns requested category. :param name: Category to retrieve. :type name: unicode :param vivify: Vivify missing parents in the chain to the requested category. :type vivify: bool :return: Category. :rtype: dict """ category = self.__get_category(self.__categories, name, vivify) if isinstance(category, dict): LOGGER.debug("> Category '{0}': '{1}'.".format(name, category)) return category else: raise umbra.exceptions.CategoryExistsError("{0} | '{1}' category doesn't exists!".format (self.__class__.__name__, name)) def add_to_category(self, category, name, action): """ Adds given action to given category. :param category: Category to store the action. :type category: unicode :param name: Action name. :type name: unicode :param action: Action object. :type action: QAction :return: Method success. :rtype: bool """ category = self.get_category(category, vivify=True) if not isinstance(category, dict): return False category[name] = action LOGGER.debug( "> Added '{0}' action to '{1}' category!".format(category, name)) return True def remove_from_category(self, category, name): """ Removes given action from given category. :param category: Category to remove the action from. :type category: unicode :param name: Action name. :type name: unicode :return: Method success. :rtype: bool """ category = self.get_category(category) if not isinstance(category, dict): return False del (category[name]) LOGGER.debug( "> Removed '{0}' action from '{1}' category!".format(category, name)) return True @foundations.exceptions.handle_exceptions(umbra.exceptions.ActionExistsError) def get_action(self, action): """ Returns requested action. :param action: Action name. :type action: unicode :return: Action. :rtype: QAction """ return self[action] def is_action_registered(self, name): """ Returns if the given action name is registered. :param name: Action name. :type name: unicode :return: Is action registered. :rtype: bool """ return name in self def register_action(self, name, **kwargs): """ Registers given action name, optional arguments like a parent, icon, slot etc ... can be given. :param name: Action to register. :type name: unicode :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Action. :rtype: QAction """ settings = foundations.data_structures.Structure(**{"parent": None, "text": None, "icon": None, "icon_text": None, "checkable": None, "checked": None, "status_tip": None, "whats_this": None, "tool_tip": None, "shortcut": None, "shortcut_context": None, "slot": None}) settings.update(kwargs) name = self.__normalize_name(name) category = foundations.namespace.get_namespace(name) name = foundations.namespace.remove_namespace(name) action = QAction(name, settings.parent or self) self.add_to_category(category, name, action) settings.text and action.setText(settings.text) settings.icon and action.setIcon(settings.icon) settings.icon_text and action.setIconText(settings.icon_text) settings.checkable and action.setCheckable(settings.checkable) settings.checked and action.set_checked(settings.checked) settings.status_tip and action.setStatusTip(settings.status_tip) settings.whats_this and action.setWhatsThis(settings.whats_this) settings.tool_tip and action.setToolTip(settings.tool_tip) settings.shortcut and action.setShortcut( QKeySequence(settings.shortcut)) settings.shortcut_context and action.setShortcutContext( settings.shortcut_context) if settings.slot: self.__actions_signals_slots[action] = settings.slot action.triggered.connect(settings.slot) return action def unregister_action(self, name): """ Unregisters given action name. :param name: Action to register. :type name: unicode :return: Method success. :rtype: bool """ name = self.__normalize_name(name) action = self.get_action(name) if not action: return False action.triggered.disconnect(self.__actions_signals_slots.pop(action)) category = foundations.namespace.get_namespace(name) name = foundations.namespace.remove_namespace(name) self.remove_from_category(category, name) return True def is_shortcut_in_use(self, shortcut): """ Returns if given action shortcut is in use. :param name: Action shortcut. :type name: unicode :return: Is shortcut in use. :rtype: bool """ for path, actionName, action in foundations.walkers.dictionaries_walker(self.__categories): if action.shortcut() == QKeySequence(shortcut): return True return False def get_shortcut(self, name): """ Returns given action shortcut. :param name: Action to retrieve the shortcut. :type name: unicode :return: Action shortcut. :rtype: unicode """ name = self.__normalize_name(name) action = self.get_action(name) if not action: return "" return action.shortcut().toString() def set_shortcut(self, name, shortcut): """ Sets given action shortcut. :param name: Action to set the shortcut. :type name: unicode :param shortcut: Shortcut to set. :type shortcut: unicode :return: Method success. :rtype: bool """ name = self.__normalize_name(name) action = self.get_action(name) if not action: return action.setShortcut(QKeySequence(shortcut)) return True
class ActionsManager(QObject): ''' Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass providing an actions manager. ''' def __init__(self, parent=None, namespace_splitter="|", root_namespace="Actions", default_namespace="Others"): ''' 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 ''' pass @property def namespace_splitter(self): ''' Property for **self.__namespace_splitter** attribute. :return: self.__namespace_splitter. :rtype: unicode ''' pass @namespace_splitter.setter @foundations.exceptions.handle_exceptions(AssertionError) def namespace_splitter(self): ''' Setter for **self.__namespace_splitter** attribute. :param value: Attribute value. :type value: unicode ''' pass @namespace_splitter.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def namespace_splitter(self): ''' Deleter for **self.__namespace_splitter** attribute. ''' pass @property def root_namespace(self): ''' Property for **self.__root_namespace** attribute. :return: self.__root_namespace. :rtype: unicode ''' pass @root_namespace.setter @foundations.exceptions.handle_exceptions(AssertionError) def root_namespace(self): ''' Setter for **self.__root_namespace** attribute. :param value: Attribute value. :type value: unicode ''' pass @root_namespace.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def root_namespace(self): ''' Deleter for **self.__root_namespace** attribute. ''' pass @property def default_namespace(self): ''' Property for **self.__default_namespace** attribute. :return: self.__default_namespace. :rtype: unicode ''' pass @default_namespace.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_namespace(self): ''' Setter for **self.__default_namespace** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_namespace.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_namespace(self): ''' Deleter for **self.__default_namespace** attribute. ''' pass @property def categories(self): ''' Property for **self.__categories** attribute. :return: self.__categories. :rtype: dict ''' pass @categories.setter @foundations.exceptions.handle_exceptions(AssertionError) def categories(self): ''' Setter for **self.__categories** attribute. :param value: Attribute value. :type value: dict ''' pass @categories.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def categories(self): ''' Deleter for **self.__categories** attribute. ''' pass def __getitem__(self, action): ''' Reimplements the :meth:`object.__getitem__` method. :param action: Action name. :type action: unicode :return: Action. :rtype: QAction ''' pass def __setitem__(self, action, kwargs): ''' Reimplements the :meth:`object.__setitem__` method. :param action: Action. :type action: unicode :param kwargs: kwargs. :type kwargs: dict ''' pass def __iter__(self): ''' Reimplements the :meth:`object.__iter__` method. :return: Actions iterator. :rtype: object ''' pass def __contains__(self, action): ''' Reimplements the :meth:`object.__contains__` method. :param action: Action name. :type action: unicode :return: Action existence. :rtype: bool ''' pass def __len__(self): ''' Reimplements the :meth:`object.__len__` method. :return: Actions count. :rtype: int ''' pass def __normalize_name(self, name): ''' Normalizes given action name. :param name: Action name. :type name: unicode :return: Normalized name. :rtype: bool ''' pass def __get_category(self, category, name, vivify=False): ''' Gets recusively requested category, alternately if **vivify** argument is set, the category will be created. :param category: Base category. :type category: dict :param name: Category to retrieve or vivify. :type name: unicode :param vivify: Vivify missing parents in the chain to the requested category. :type vivify: bool :return: Requested category. :rtype: dict ''' pass def get(self, action, default=None): ''' Returns given action value. :param action: Action name. :type action: unicode :param default: Default value if action is not found. :type default: object :return: Action. :rtype: QAction ''' pass def list_actions(self): ''' Returns the registered actions. :return: Actions list. :rtype: list ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.CategoryExistsError) def get_category(self, name, vivify=False): ''' Returns requested category. :param name: Category to retrieve. :type name: unicode :param vivify: Vivify missing parents in the chain to the requested category. :type vivify: bool :return: Category. :rtype: dict ''' pass def add_to_category(self, category, name, action): ''' Adds given action to given category. :param category: Category to store the action. :type category: unicode :param name: Action name. :type name: unicode :param action: Action object. :type action: QAction :return: Method success. :rtype: bool ''' pass def remove_from_category(self, category, name): ''' Removes given action from given category. :param category: Category to remove the action from. :type category: unicode :param name: Action name. :type name: unicode :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.ActionExistsError) def get_action(self, action): ''' Returns requested action. :param action: Action name. :type action: unicode :return: Action. :rtype: QAction ''' pass def is_action_registered(self, name): ''' Returns if the given action name is registered. :param name: Action name. :type name: unicode :return: Is action registered. :rtype: bool ''' pass def register_action(self, name, **kwargs): ''' Registers given action name, optional arguments like a parent, icon, slot etc ... can be given. :param name: Action to register. :type name: unicode :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Action. :rtype: QAction ''' pass def unregister_action(self, name): ''' Unregisters given action name. :param name: Action to register. :type name: unicode :return: Method success. :rtype: bool ''' pass def is_shortcut_in_use(self, shortcut): ''' Returns if given action shortcut is in use. :param name: Action shortcut. :type name: unicode :return: Is shortcut in use. :rtype: bool ''' pass def get_shortcut(self, name): ''' Returns given action shortcut. :param name: Action to retrieve the shortcut. :type name: unicode :return: Action shortcut. :rtype: unicode ''' pass def set_shortcut(self, name, shortcut): ''' Sets given action shortcut. :param name: Action to set the shortcut. :type name: unicode :param shortcut: Shortcut to set. :type shortcut: unicode :return: Method success. :rtype: bool ''' pass
55
33
15
2
6
7
2
0.98
1
7
2
0
32
5
32
32
536
105
218
68
163
213
168
53
135
4
1
2
56
142,477
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/workers.py
umbra.components.factory.script_editor.workers.Search_worker
class Search_worker(QThread): """ Defines a `QThread <http://doc.qt.nokia.com/qthread.html>`_ subclass used to search for a pattern in a directory files. """ # Custom signals definitions. searchFinished = pyqtSignal(list) """ This signal is emited by the :class:`Search_worker` class when the search is finished. :return: Search results. :rtype: list """ def __init__(self, parent, pattern=None, location=None, settings=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QThread.__init__(self, parent) # --- Setting class attributes. --- self.__container = parent self.__pattern = None self.pattern = pattern self.__location = None self.location = location self.__settings = None self.settings = settings self.__search_results = None self.__interrupt = False self.__lock = QMutex() @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def pattern(self): """ Property for **self.__pattern** attribute. :return: self.__pattern. :rtype: unicode """ return self.__pattern @pattern.setter @foundations.exceptions.handle_exceptions(AssertionError) def pattern(self, value): """ Setter for **self.__pattern** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) in (unicode, QString), \ "'{0}' attribute: '{1}' type is not 'unicode' or 'QString'!".format( "pattern", value) self.__pattern = value @pattern.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def pattern(self): """ Deleter for **self.__pattern** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "pattern")) @property def location(self): """ Property for **self.__location** attribute. :return: self.__location. :rtype: Location """ return self.__location @location.setter @foundations.exceptions.handle_exceptions(AssertionError) def location(self, value): """ Setter for **self.__location** attribute. :param value: Attribute value. :type value: Location """ if value is not None: assert type(value) is umbra.ui.common.Location, \ "'{0}' attribute: '{1}' type is not 'umbra.ui.common.Location'!".format( "location", value) self.__location = value @location.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def location(self): """ Deleter for **self.__location** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "location")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: Location """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(AssertionError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: Location """ if value is not None: assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format( "settings", value) self.__settings = foundations.data_structures.Structure(**{"case_sensitive": False, "whole_word": False, "regular_expressions": False}) self.__settings.update(value) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def search_results(self): """ Property for **self.__search_results** attribute. :return: self.__search_results. :rtype: list """ return self.__search_results @search_results.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_results(self, value): """ Setter for **self.__search_results** attribute. :param value: Attribute value. :type value: list """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_results")) @search_results.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_results(self): """ Deleter for **self.__search_results** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_results")) def run(self): """ Reimplements the :meth:`QThread.run` method. """ self.__search() def quit(self): """ Reimplements the :meth:`QThread.quit` method. """ self.__interrupt = True QThread.quit(self) def __search(self): """ Performs the search. """ self.__search_results = [] editorsFiles = self.__container.default_target in self.__location.targets and \ [editor.file for editor in self.__container.script_editor.list_editors()] or [ ] self.__search_editors_files(editorsFiles) self.__search_files(self.__location.files) for directory in self.__location.directories: if self.__interrupt: return files_walker = foundations.walkers.files_walker(directory, self.__location.filters_in, list(itertools.chain(self.__location.filters_out, self.__location.files, editorsFiles))) self.__search_files(files_walker) not self.__interrupt and self.searchFinished.emit( self.__search_results) def __search_editors_files(self, files): """ Searches in :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` class editors files. :param files: Editor files. :type files: list """ for file in files: if self.__interrupt: return if foundations.io.is_readable(file): if foundations.io.is_binary_file(file): continue LOGGER.info("{0} | Searching '{1}' file!".format( self.__class__.__name__, file)) editor = self.__container.script_editor.get_editor(file) if not editor: continue self.__lock.lock() occurrences = self.__search_document( editor.document(), self.__pattern, self.__settings) self.__lock.unlock() occurrences and self.__search_results.append(SearchResult(file=file, pattern=self.__pattern, settings=self.__settings, occurrences=occurrences)) def __search_files(self, files): """ Searches in given files. :param files: Files. :type files: list """ for file in files: if self.__interrupt: return if not foundations.common.path_exists(file): continue if foundations.io.is_readable(file): if foundations.io.is_binary_file(file): continue LOGGER.info("{0} | Searching '{1}' file!".format( self.__class__.__name__, file)) cache_data = self.__container.files_cache.get_content(file) if not cache_data: reader = foundations.io.File(file) content = reader.read() if content is None: LOGGER.warning( "!> Error occured while reading '{0}' file proceeding to next one!".format(file)) continue self.__container.files_cache.add_content( **{file: CacheData(content=content, document=None)}) else: content = cache_data.content occurrences = self.__search_document(QTextDocument( QString(content)), self.__pattern, self.__settings) occurrences and self.__search_results.append(SearchResult(file=file, pattern=self.__pattern, settings=self.__settings, occurrences=occurrences)) def __search_document(self, document, pattern, settings): """ Searches for given pattern occurrences in given document using given settings. :param document: Document. :type document: QTextDocument :param pattern: Pattern. :type pattern: unicode :param settings: Search settings. :type settings: Structure :return: Matched occurrences. :rtype: list """ pattern = settings.regular_expressions and QRegExp(pattern) or pattern flags = QTextDocument.FindFlags() if settings.case_sensitive: flags = flags | QTextDocument.FindCaseSensitively if settings.whole_word: flags = flags | QTextDocument.FindWholeWords occurrences = [] block = document.findBlock(0) cursor = document.find(pattern, block.position(), flags) while block.isValid() and cursor.position() != -1: if self.__interrupt: return block_cursor = QTextCursor(cursor) block_cursor.movePosition( QTextCursor.StartOfLine, QTextCursor.MoveAnchor) block_cursor.movePosition( QTextCursor.EndOfLine, QTextCursor.KeepAnchor) length = cursor.selectionEnd() - cursor.selectionStart() occurrences.append(Occurence(line=cursor.blockNumber(), column=cursor.columnNumber() - length, length=length, position=cursor.position() - length, text=block_cursor.selectedText())) cursor = document.find(pattern, cursor.position(), flags) block = block.next() return occurrences
class Search_worker(QThread): ''' Defines a `QThread <http://doc.qt.nokia.com/qthread.html>`_ subclass used to search for a pattern in a directory files. ''' def __init__(self, parent, pattern=None, location=None, settings=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def pattern(self): ''' Property for **self.__pattern** attribute. :return: self.__pattern. :rtype: unicode ''' pass @pattern.setter @foundations.exceptions.handle_exceptions(AssertionError) def pattern(self): ''' Setter for **self.__pattern** attribute. :param value: Attribute value. :type value: unicode ''' pass @pattern.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def pattern(self): ''' Deleter for **self.__pattern** attribute. ''' pass @property def location(self): ''' Property for **self.__location** attribute. :return: self.__location. :rtype: Location ''' pass @location.setter @foundations.exceptions.handle_exceptions(AssertionError) def location(self): ''' Setter for **self.__location** attribute. :param value: Attribute value. :type value: Location ''' pass @location.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def location(self): ''' Deleter for **self.__location** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: Location ''' pass @settings.setter @foundations.exceptions.handle_exceptions(AssertionError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: Location ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def search_results(self): ''' Property for **self.__search_results** attribute. :return: self.__search_results. :rtype: list ''' pass @search_results.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_results(self): ''' Setter for **self.__search_results** attribute. :param value: Attribute value. :type value: list ''' pass @search_results.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_results(self): ''' Deleter for **self.__search_results** attribute. ''' pass def run(self): ''' Reimplements the :meth:`QThread.run` method. ''' pass def quit(self): ''' Reimplements the :meth:`QThread.quit` method. ''' pass def __search(self): ''' Performs the search. ''' pass def __search_editors_files(self, files): ''' Searches in :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` class editors files. :param files: Editor files. :type files: list ''' pass def __search_files(self, files): ''' Searches in given files. :param files: Files. :type files: list ''' pass def __search_document(self, document, pattern, settings): ''' Searches for given pattern occurrences in given document using given settings. :param document: Document. :type document: QTextDocument :param pattern: Pattern. :type pattern: unicode :param settings: Search settings. :type settings: Structure :return: Matched occurrences. :rtype: list ''' pass
48
23
14
3
7
5
2
0.63
1
8
4
0
22
7
22
22
368
80
177
63
129
111
125
48
102
8
1
3
43
142,478
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/views.py
umbra.components.factory.script_editor.views.SearchResults_QTreeView
class SearchResults_QTreeView(umbra.ui.views.Abstract_QTreeView): """ Defines the view for Database Ibl Sets columns. """ def __init__(self, parent, model=None, read_only=False, message=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.views.Abstract_QTreeView.__init__( self, parent, read_only, message) # --- Setting class attributes. --- self.setModel(model) self.__tree_view_indentation = 15 SearchResults_QTreeView.__initialize_ui(self) @property def tree_view_indentation(self): """ Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int """ return self.__tree_view_indentation @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self, value): """ Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "tree_view_indentation")) @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): """ Deleter for **self.__tree_view_indentation** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tree_view_indentation")) def __initialize_ui(self): """ Initializes the Widget ui. """ self.setAutoScroll(True) self.setSelectionMode(QAbstractItemView.ExtendedSelection) self.setIndentation(self.__tree_view_indentation) self.setDragDropMode(QAbstractItemView.DragOnly) self.setHeaderHidden(True) self.__set_default_ui_state() # Signals / Slots. self.model().modelReset.connect(self.__set_default_ui_state) def __set_default_ui_state(self, *args): """ Sets the Widget default ui state. :param \*args: Arguments. :type \*args: \* """ LOGGER.debug("> Setting default View state!") if not self.model(): return self.expandAll() for column in range(len(self.model().horizontal_headers)): self.resizeColumnToContents(column)
class SearchResults_QTreeView(umbra.ui.views.Abstract_QTreeView): ''' Defines the view for Database Ibl Sets columns. ''' def __init__(self, parent, model=None, read_only=False, message=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode ''' pass @property def tree_view_indentation(self): ''' Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int ''' pass @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int ''' pass @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Deleter for **self.__tree_view_indentation** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __set_default_ui_state(self, *args): ''' Sets the Widget default ui state. :param \*args: Arguments. :type \*args: \* ''' pass
12
7
13
3
5
5
1
1
1
1
0
0
6
1
6
25
95
25
35
12
23
35
28
9
21
3
4
1
8
142,479
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/views.py
umbra.components.factory.script_editor.views.ScriptEditor_QTabWidget
class ScriptEditor_QTabWidget(QTabWidget): """ | Defines a `QTabWidget <http://doc.qt.nokia.com/qtabwidget.html>`_ subclass used to display :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` editors. | It provides support for drag'n'drop by reimplementing relevant methods. """ # Custom signals definitions. content_dropped = pyqtSignal(QEvent) """ This signal is emited by the :class:`ScriptEditor_QTabWidget` class when it receives dropped content. :return: Event. :rtype: QEvent """ def __init__(self, parent): """ Initializes the class. :param parent: Parent object. :type parent: QObject """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QTabWidget.__init__(self, parent) self.setAcceptDrops(True) # --- Setting class attributes. --- self.__container = parent @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) def dragEnterEvent(self, event): """ Reimplements the :meth:`QTabWidget.dragEnterEvent` method. :param event: QEvent. :type event: QEvent """ LOGGER.debug("> '{0}' widget drag enter event accepted!".format( self.__class__.__name__)) event.accept() def dragMoveEvent(self, event): """ Reimplements the :meth:`QTabWidget.dragMoveEvent` method. :param event: QEvent. :type event: QEvent """ LOGGER.debug("> '{0}' widget drag move event accepted!".format( self.__class__.__name__)) event.accept() def dropEvent(self, event): """ Reimplements the :meth:`QTabWidget.dropEvent` method. :param event: QEvent. :type event: QEvent """ LOGGER.debug("> '{0}' widget drop event accepted!".format( self.__class__.__name__)) self.content_dropped.emit(event)
class ScriptEditor_QTabWidget(QTabWidget): ''' | Defines a `QTabWidget <http://doc.qt.nokia.com/qtabwidget.html>`_ subclass used to display :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` editors. | It provides support for drag'n'drop by reimplementing relevant methods. ''' def __init__(self, parent): ''' Initializes the class. :param parent: Parent object. :type parent: QObject ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass def dragEnterEvent(self, event): ''' Reimplements the :meth:`QTabWidget.dragEnterEvent` method. :param event: QEvent. :type event: QEvent ''' pass def dragMoveEvent(self, event): ''' Reimplements the :meth:`QTabWidget.dragMoveEvent` method. :param event: QEvent. :type event: QEvent ''' pass def dropEvent(self, event): ''' Reimplements the :meth:`QTabWidget.dropEvent` method. :param event: QEvent. :type event: QEvent ''' pass
13
8
10
2
3
5
1
1.55
1
0
0
0
7
1
7
7
99
25
29
13
16
45
22
10
14
1
1
0
7
142,480
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/search_in_files.py
umbra.components.factory.script_editor.search_in_files.SearchInFiles
class SearchInFiles(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): """ Defines search and replace in files dialog used by the **ScriptEditor** Component. """ def __init__(self, parent, *args, **kwargs): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(SearchInFiles, self).__init__(parent, *args, **kwargs) # --- Setting class attributes. --- self.__container = self.__script_editor = parent self.__files_cache = foundations.cache.Cache() self.__search_patterns_model = None self.__replace_with_patterns_model = None self.__model = None self.__view = None self.__delegate = None self.__locations = OrderedDict([("Add Directory ...", "directory"), ("Add File ...", "file"), ("Add Opened Files", "editors"), ("Add Include Filter", "include_filter"), ("Add Exclude Filter", "exclude_filter")]) self.__locations_menu = None self.__default_filter_in = "*.txt" self.__filters_in_format = "{0}" self.__default_filter_out = "*.txt" self.__filters_out_format = "!{0}" self.__default_target = "Opened Files" self.__targets_format = "<{0}>" self.__default_line_number_width = 6 self.__default_line_color = QColor(144, 144, 144) self.__ignore_hidden_files = True self.__search_worker_thread = None SearchInFiles.__initialize_ui(self) @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def script_editor(self): """ Property for **self.__script_editor** attribute. :return: self.__script_editor. :rtype: QWidget """ return self.__script_editor @script_editor.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self, value): """ Setter for **self.__script_editor** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "script_editor")) @script_editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): """ Deleter for **self.__script_editor** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "script_editor")) @property def files_cache(self): """ Property for **self.__files_cache** attribute. :return: self.__files_cache. :rtype: Cache """ return self.__files_cache @files_cache.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def files_cache(self, value): """ Setter for **self.__files_cache** attribute. :param value: Attribute value. :type value: Cache """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "files_cache")) @files_cache.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def files_cache(self): """ Deleter for **self.__files_cache** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "files_cache")) @property def search_patterns_model(self): """ Property for **self.__search_patterns_model** attribute. :return: self.__search_patterns_model. :rtype: PatternsModel """ return self.__search_patterns_model @search_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self, value): """ Setter for **self.__search_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_patterns_model")) @search_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self): """ Deleter for **self.__search_patterns_model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_patterns_model")) @property def replace_with_patterns_model(self): """ Property for **self.__replace_with_patterns_model** attribute. :return: self.__replace_with_patterns_model. :rtype: PatternsModel """ return self.__replace_with_patterns_model @replace_with_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self, value): """ Setter for **self.__replace_with_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "replace_with_patterns_model")) @replace_with_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self): """ Deleter for **self.__replace_with_patterns_model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "replace_with_patterns_model")) @property def model(self): """ Property for **self.__model** attribute. :return: self.__model. :rtype: SearchResultsModel """ return self.__model @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self, value): """ Setter for **self.__model** attribute. :param value: Attribute value. :type value: SearchResultsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "model")) @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): """ Deleter for **self.__model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "model")) @property def view(self): """ Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget """ return self.__view @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self, value): """ Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "view")) @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): """ Deleter for **self.__view** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "view")) @property def delegate(self): """ Property for **self.__delegate** attribute. :return: self.__delegate. :rtype: QItemDelegate """ return self.__delegate @delegate.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self, value): """ Setter for **self.__delegate** attribute. :param value: Attribute value. :type value: QItemDelegate """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "delegate")) @delegate.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self): """ Deleter for **self.__delegate** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "delegate")) @property def locations(self): """ Property for **self.__locations** attribute. :return: self.__locations. :rtype: OrderedDict """ return self.__locations @locations.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations(self, value): """ Setter for **self.__locations** attribute. :param value: Attribute value. :type value: OrderedDict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "locations")) @locations.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations(self): """ Deleter for **self.__locations** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "locations")) @property def locations_menu(self): """ Property for **self.__locations_menu** attribute. :return: self.__locations_menu. :rtype: QMenu """ return self.__locations_menu @locations_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations_menu(self, value): """ Setter for **self.__locations_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "locations_menu")) @locations_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations_menu(self): """ Deleter for **self.__locations_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "locations_menu")) @property def default_filter_in(self): """ Property for **self.__default_filter_in** attribute. :return: self.__default_filter_in. :rtype: unicode """ return self.__default_filter_in @default_filter_in.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_filter_in(self, value): """ Setter for **self.__default_filter_in** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "default_filter_in", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "default_filter_in", value) self.__default_filter_in = value @default_filter_in.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_filter_in(self): """ Deleter for **self.__default_filter_in** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_filter_in")) @property def filters_in_format(self): """ Property for **self.__filters_in_format** attribute. :return: self.__filters_in_format. :rtype: unicode """ return self.__filters_in_format @filters_in_format.setter @foundations.exceptions.handle_exceptions(AssertionError) def filters_in_format(self, value): """ Setter for **self.__filters_in_format** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "filters_in_format", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "filters_in_format", value) self.__filters_in_format = value @filters_in_format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def filters_in_format(self): """ Deleter for **self.__filters_in_format** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "filters_in_format")) @property def default_filter_out(self): """ Property for **self.__default_filter_out** attribute. :return: self.__default_filter_out. :rtype: unicode """ return self.__default_filter_out @default_filter_out.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_filter_out(self, value): """ Setter for **self.__default_filter_out** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "default_filter_out", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "default_filter_out", value) self.__default_filter_out = value @default_filter_out.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_filter_out(self): """ Deleter for **self.__default_filter_out** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_filter_out")) @property def filters_out_format(self): """ Property for **self.__filters_out_format** attribute. :return: self.__filters_out_format. :rtype: unicode """ return self.__filters_out_format @filters_out_format.setter @foundations.exceptions.handle_exceptions(AssertionError) def filters_out_format(self, value): """ Setter for **self.__filters_out_format** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "filters_out_format", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "filters_out_format", value) self.__filters_out_format = value @filters_out_format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def filters_out_format(self): """ Deleter for **self.__filters_out_format** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "filters_out_format")) @property def default_target(self): """ Property for **self.__default_target** attribute. :return: self.__default_target. :rtype: unicode """ return self.__default_target @default_target.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_target(self, value): """ Setter for **self.__default_target** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "default_target", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "default_target", value) self.__default_target = value @default_target.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_target(self): """ Deleter for **self.__default_target** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_target")) @property def targets_format(self): """ Property for **self.__targets_format** attribute. :return: self.__targets_format. :rtype: unicode """ return self.__targets_format @targets_format.setter @foundations.exceptions.handle_exceptions(AssertionError) def targets_format(self, value): """ Setter for **self.__targets_format** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "targets_format", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "targets_format", value) self.__targets_format = value @targets_format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def targets_format(self): """ Deleter for **self.__targets_format** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "targets_format")) @property def default_line_number_width(self): """ Property for **self.__default_line_number_width** attribute. :return: self.__default_line_number_width. :rtype: int """ return self.__default_line_number_width @default_line_number_width.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_line_number_width(self, value): """ Setter for **self.__default_line_number_width** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "default_line_number_width", value) assert value > 0, "'{0}' attribute: '{1}' need to be exactly positive!".format( "default_line_number_width", value) self.__default_line_number_width = value @default_line_number_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_line_number_width(self): """ Deleter for **self.__default_line_number_width** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_line_number_width")) @property def default_line_color(self): """ Property for **self.__default_line_color** attribute. :return: self.__default_line_color. :rtype: QColor """ return self.__default_line_color @default_line_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_line_color(self, value): """ Setter for **self.__default_line_color** attribute. :param value: Attribute value. :type value: QColor """ if value is not None: assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format( "default_line_color", value) self.__default_line_color = value @default_line_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_line_color(self): """ Deleter for **self.__default_line_color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_line_color")) @property def ignore_hidden_files(self): """ Property for **self.__ignore_hidden_files** attribute. :return: self.__ignore_hidden_files. :rtype: bool """ return self.__ignore_hidden_files @ignore_hidden_files.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ignore_hidden_files(self, value): """ Setter for **self.__ignore_hidden_files** attribute. :param value: Attribute value. :type value: bool """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "ignore_hidden_files")) @ignore_hidden_files.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ignore_hidden_files(self): """ Deleter for **self.__ignore_hidden_files** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ignore_hidden_files")) @property def search_worker_thread(self): """ Property for **self.__search_worker_thread** attribute. :return: self.__search_worker_thread. :rtype: QThread """ return self.__search_worker_thread @search_worker_thread.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_worker_thread(self, value): """ Setter for **self.__search_worker_thread** attribute. :param value: Attribute value. :type value: QThread """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_worker_thread")) @search_worker_thread.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_worker_thread(self): """ Deleter for **self.__search_worker_thread** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_worker_thread")) def show(self): """ Reimplements the :meth:`QWidget.show` method. """ selected_text = self.__container.get_current_editor().get_selected_text() selected_text and SearchAndReplace.insert_pattern( selected_text, self.__search_patterns_model) self.Search_comboBox.line_edit().selectAll() self.Search_comboBox.setFocus() super(SearchInFiles, self).show() self.raise_() def closeEvent(self, event): """ Reimplements the :meth:`QWidget.closeEvent` method. :param event: QEvent. :type event: QEvent """ self.__interrupt_search() super(SearchInFiles, self).closeEvent(event) def __initialize_ui(self): """ Initializes the Widget ui. """ umbra.ui.common.set_window_default_icon(self) self.__model = SearchResultsModel(self) self.__delegate = RichText_QStyledItemDelegate(self) self.Search_Results_treeView.setParent(None) self.Search_Results_treeView = SearchResults_QTreeView(self, self.__model, message="No Search Result to view!") self.Search_Results_treeView.setItemDelegate(self.__delegate) self.Search_Results_treeView.setObjectName("Search_Results_treeView") self.Search_Results_frame_gridLayout.addWidget( self.Search_Results_treeView, 0, 0) self.__view = self.Search_Results_treeView self.__view.setContextMenuPolicy(Qt.ActionsContextMenu) self.__view_add_actions() self.__search_patterns_model = self.__container.search_and_replace.search_patterns_model self.Search_comboBox.setModel( self.__container.search_and_replace.search_patterns_model) self.Search_comboBox.setInsertPolicy(QComboBox.InsertAtTop) self.Search_comboBox.completer().setCaseSensitivity(Qt.CaseSensitive) self.__replace_with_patterns_model = self.__container.search_and_replace.replace_with_patterns_model self.Replace_With_comboBox.setModel( self.__container.search_and_replace.replace_with_patterns_model) self.Replace_With_comboBox.setInsertPolicy(QComboBox.InsertAtTop) self.Replace_With_comboBox.completer().setCaseSensitivity(Qt.CaseSensitive) self.Where_lineEdit.setParent(None) self.Where_lineEdit = Search_QLineEdit(self) self.Where_lineEdit.setObjectName("Where_lineEdit") self.Where_frame_gridLayout.addWidget(self.Where_lineEdit, 0, 0) self.__locations_menu = QMenu() for title, location in self.__locations.iteritems(): self.__locations_menu.addAction(self.__container.engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|Search In Files|{0}".format( title), text="{0}".format(title), slot=functools.partial(self.__add_location, location))) self.Where_lineEdit.search_active_label.set_menu(self.__locations_menu) self.Where_lineEdit.setPlaceholderText( "Use the magnifier to add locations!") self.installEventFilter(ValidationFilter(self)) # Signals / Slots. self.__view.selectionModel().selectionChanged.connect( self.__view_selectionModel__selectionChanged) self.__view.doubleClicked.connect(self.__view__doubleClicked) self.__search_patterns_model.pattern_inserted.connect(functools.partial( self.__patterns_model__pattern_inserted, self.Search_comboBox)) self.__replace_with_patterns_model.pattern_inserted.connect(functools.partial( self.__patterns_model__pattern_inserted, self.Replace_With_comboBox)) self.Search_pushButton.clicked.connect( self.__Search_pushButton__clicked) self.Close_pushButton.clicked.connect(self.__Close_pushButton__clicked) def __view_add_actions(self): """ Sets the View actions. """ self.__view.addAction(self.__container.engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|Search In Files|Replace All", slot=self.__view_replace_all_action__triggered)) self.__view.addAction(self.__container.engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|Search In Files|Replace Selected", slot=self.__view_replace_selected_action__triggered)) separator_action = QAction(self.__view) separator_action.setSeparator(True) self.__view.addAction(separator_action) self.__view.addAction(self.__container.engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|Search In Files|Save All", slot=self.__view_save_all_action__triggered)) self.__view.addAction(self.__container.engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|Search In Files|Save Selected", slot=self.__view_save_selected_action__triggered)) def __view_replace_all_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Replace All'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ all_nodes = filter(lambda x: x.family in ( "SearchFile", "SearchOccurence"), self.__model.root_node.children) if all_nodes: return self.replace(all_nodes) def __view_replace_selected_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Replace Selected'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ selected_nodes = filter( lambda x: x.family in ("SearchFile", "SearchOccurence"), self.__view.get_selected_nodes()) if selected_nodes: return self.replace(filter(lambda x: x.parent not in selected_nodes, selected_nodes)) def __view_save_all_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Save All'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ all_nodes = filter(lambda x: x.family is "ReplaceResult", self.__model.root_node.children) if all_nodes: return self.save_files(all_nodes) def __view_save_selected_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Save Selected'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ selected_nodes = filter( lambda x: x.family is "ReplaceResult", self.__view.get_selected_nodes()) if selected_nodes: return self.save_files(selected_nodes) def __patterns_model__pattern_inserted(self, combo_box, index): """ Defines the slot triggered by a pattern when inserted into a patterns Model. :param combo_box: Pattern Model attached combo_box. :type combo_box: QComboBox :param index: Inserted pattern index. :type index: QModelIndex """ combo_box.setCurrentIndex(index.row()) def __Search_pushButton__clicked(self, checked): """ Defines the slot triggered by **Search_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.search() def __Close_pushButton__clicked(self, checked): """ Defines the slot triggered by **Close_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.close() def __view__doubleClicked(self, index): """ Defines the slot triggered by a View when double clicked. :param index: Clicked item index. :type index: QModelIndex """ node = self.__model.get_node(index) if node.family == "SearchOccurence": file = node.parent.file occurence = node elif node.family in ("SearchFile", "ReplaceResult"): file = node.file occurence = None self.__highlight_occurence(file, occurence) def __view_selectionModel__selectionChanged(self, selected_items, deselected_items): """ Defines the slot triggered by the View **selectionModel** when selection changed. :param selected_items: Selected items. :type selected_items: QItemSelection :param deselected_items: Deselected items. :type deselected_items: QItemSelection """ indexes = selected_items.indexes() if not indexes: return node = self.__model.get_node(indexes.pop()) if node.family == "SearchOccurence": file = node.parent.file occurence = node elif node.family in ("SearchFile", "ReplaceResult"): file = node.file occurence = None if self.__container.get_editor(file): self.__highlight_occurence(file, occurence) def __search_worker_thread__searchFinished(self, search_results): """ Defines the slot triggered by :attr:`SearchInFiles.grepWorkerThread` attribute worker thread when the search is finished. :param search_results: Search results. :type search_results: list """ self.set_search_results(search_results) self.__container.engine.stop_processing() metrics = self.__model.get_metrics() self.__container.engine.notifications_manager.notify( "{0} | '{1}' pattern occurence(s) found in '{2}' files!".format(self.__class__.__name__, metrics["SearchOccurence"], metrics["SearchFile"])) def __add_location(self, type, *args): """ Defines the slot triggered by **Where_lineEdit** Widget when a context menu entry is clicked. :param type: Location type. :type type: unicode :param \*args: Arguments. :type \*args: \* """ if type == "directory": location = umbra.ui.common.store_last_browsed_path((QFileDialog.getExistingDirectory(self, "Add Directory:", RuntimeGlobals.last_browsed_path))) elif type == "file": location = umbra.ui.common.store_last_browsed_path((QFileDialog.getOpenFileName(self, "Add File:", RuntimeGlobals.last_browsed_path, "All Files (*)"))) elif type == "editors": location = self.__targets_format.format(self.__default_target) elif type == "include_filter": location = self.__filters_in_format.format( self.__default_filter_in) elif type == "exclude_filter": location = self.__filters_out_format.format( self.__default_filter_out) location and self.Where_lineEdit.setText(", ".join(filter(bool, (foundations.strings.to_string( self.Where_lineEdit.text()), location)))) def __format_occurence(self, occurence): """ Formats the given occurence and returns the matching rich html text. :param occurence: Occurence to format. :type occurence: Occurence :return: Rich text. :rtype: unicode """ color = "rgb({0}, {1}, {2})" span_format = "<span style=\"color: {0};\">{{0}}</span>".format(color.format(self.__default_line_color.red(), self.__default_line_color.green(), self.__default_line_color.blue())) line = foundations.strings.to_string(occurence.text) start = span_format.format(line[:occurence.column]) pattern = "<b>{0}</b>".format( line[occurence.column:occurence.column + occurence.length]) end = span_format.format(line[occurence.column + occurence.length:]) return "".join((start, pattern, end)) def __format_replace_metrics(self, file, metrics): """ Formats the given replace metrics and returns the matching rich html text. :param file: File. :type file: unicode :param metrics: Replace metrics to format. :type metrics: unicode :return: Rich text. :rtype: unicode """ color = "rgb({0}, {1}, {2})" span_format = "<span style=\"color: {0};\">{{0}}</span>".format(color.format(self.__default_line_color.red(), self.__default_line_color.green(), self.__default_line_color.blue())) dir_name, base_name = (os.path.dirname(file), os.path.basename(file)) return "".join((span_format.format("'"), span_format.format(dir_name), span_format.format(os.path.sep), base_name, span_format.format("' file: '"), foundations.strings.to_string(metrics), span_format.format("' occurence(s) replaced!"))) def __highlight_occurence(self, file, occurence): """ Highlights given file occurence. :param file: File containing the occurence. :type file: unicode :param occurence: Occurence to highlight. :type occurence: Occurence or SearchOccurenceNode """ if not self.__container.get_editor(file): cache_data = self.__files_cache.get_content(file) if cache_data: document = cache_data.document or self.__get_document( cache_data.content) self.__container.load_document(document, file) self.__uncache(file) else: self.__container.load_file(file) else: self.__container.set_current_editor(file) if not occurence: return cursor = self.__container.get_current_editor().textCursor() cursor.setPosition(occurence.position, QTextCursor.MoveAnchor) cursor.setPosition(occurence.position + occurence.length, QTextCursor.KeepAnchor) self.__container.get_current_editor().setTextCursor(cursor) def __get_document(self, content): """ Returns a `QTextDocument <http://doc.qt.nokia.com/qtextdocument.html>`_ class instance with given content. :return: Document. :rtype: QTextDocument """ document = QTextDocument(QString(content)) document.clearUndoRedoStacks() document.setModified(False) return document def __replace_within_document(self, document, occurrences, replacement_pattern): """ Replaces given pattern occurrences in given document using given settings. :param document: Document. :type document: QTextDocument :param replacement_pattern: Replacement pattern. :type replacement_pattern: unicode :return: Replaced occurrences count. :rtype: int """ cursor = QTextCursor(document) cursor.beginEditBlock() offset = count = 0 for occurence in sorted(occurrences, key=lambda x: x.position): cursor.setPosition(offset + occurence.position, QTextCursor.MoveAnchor) cursor.setPosition(offset + occurence.position + occurence.length, QTextCursor.KeepAnchor) cursor.insertText(replacement_pattern) offset += len(replacement_pattern) - occurence.length count += 1 cursor.endEditBlock() return count def __get_settings(self): """ Returns the current search and replace settings. :return: Settings. :rtype: dict """ return {"case_sensitive": self.Case_Sensitive_checkBox.isChecked(), "whole_word": self.Whole_Word_checkBox.isChecked(), "regular_expressions": self.Regular_Expressions_checkBox.isChecked()} def __interrupt_search(self): """ Interrupt the current search. """ if self.__search_worker_thread: self.__search_worker_thread.quit() self.__search_worker_thread.wait() self.__container.engine.stop_processing(warning=False) def __cache(self, file, content, document): """ Caches given file. :param file: File to cache. :type file: unicode :param content: File content. :type content: list :param document: File document. :type document: QTextDocument """ self.__files_cache.add_content( **{file: CacheData(content=content, document=document)}) def __uncache(self, file): """ Uncaches given file. :param file: File to uncache. :type file: unicode """ if file in self.__files_cache: self.__files_cache.remove_content(file) def set_search_results(self, search_results): """ Sets the Model Nodes using given search results. :param search_results: Search results. :type search_results: list :return: Method success. :rtype: bool """ root_node = umbra.ui.nodes.DefaultNode(name="InvisibleRootNode") for search_result in search_results: search_file_node = SearchFileNode(name=search_result.file, parent=root_node) search_file_node.update(search_result) width = \ max(self.__default_line_number_width, max([len(foundations.strings.to_string(occurence.line)) for occurence in search_result.occurrences])) for occurence in search_result.occurrences: formatter = "{{0:>{0}}}".format(width) name = "{0}:{1}".format(formatter.format(occurence.line + 1).replace(" ", "&nbsp;"), self.__format_occurence(occurence)) search_occurence_node = SearchOccurenceNode(name=name, parent=search_file_node) search_occurence_node.update(occurence) self.__model.initialize_model(root_node) return True def set_replace_results(self, replace_results): """ Sets the Model Nodes using given replace results. :param replace_results: Replace results. :type replace_results: list :return: Method success. :rtype: bool """ root_node = umbra.ui.nodes.DefaultNode(name="InvisibleRootNode") for file, metrics in sorted(replace_results.iteritems()): replace_result_node = ReplaceResultNode(name=self.__format_replace_metrics(file, metrics), parent=root_node, file=file) self.__model.initialize_model(root_node) return True def search(self): """ Searchs user defined locations for search pattern. :return: Method success. :rtype: bool """ self.__interrupt_search() search_pattern = self.Search_comboBox.currentText() replacement_pattern = self.Replace_With_comboBox.currentText() if not search_pattern: return False SearchAndReplace.insert_pattern( search_pattern, self.__search_patterns_model) SearchAndReplace.insert_pattern( replacement_pattern, self.__replace_with_patterns_model) location = umbra.ui.common.parse_location( foundations.strings.to_string(self.Where_lineEdit.text()) or self.__targets_format.format(self.__default_target)) self.__ignore_hidden_files and location.filters_out.append("\\\.|/\.") settings = self.__get_settings() self.__search_worker_thread = Search_worker( self, search_pattern, location, settings) # Signals / Slots. self.__search_worker_thread.searchFinished.connect( self.__search_worker_thread__searchFinished) self.__container.engine.worker_threads.append( self.__search_worker_thread) self.__container.engine.start_processing("Searching In Files ...") self.__search_worker_thread.start() return True def replace(self, nodes): """ Replaces user defined files search pattern occurrences with replacement pattern using given nodes. :param nodes: Nodes. :type nodes: list :return: Method success. :rtype: bool """ files = {} for node in nodes: if node.family == "SearchFile": files[node.file] = node.children elif node.family == "SearchOccurence": file = node.parent.file if not file in files: files[file] = [] files[file].append(node) replacement_pattern = self.Replace_With_comboBox.currentText() SearchAndReplace.insert_pattern( replacement_pattern, self.__replace_with_patterns_model) replace_results = {} for file, occurrences in files.iteritems(): editor = self.__container.get_editor(file) if editor: document = editor.document() else: cache_data = self.__files_cache.get_content(file) if cache_data is None: LOGGER.warning( "!> {0} | '{1}' file doesn't exists in files cache!".format(self.__class__.__name__, file)) continue content = self.__files_cache.get_content(file).content document = self.__get_document(content) self.__cache(file, content, document) replace_results[file] = self.__replace_within_document( document, occurrences, replacement_pattern) self.set_replace_results(replace_results) self.__container.engine.notifications_manager.notify( "{0} | '{1}' pattern occurence(s) replaced in '{2}' files!".format(self.__class__.__name__, sum(replace_results.values( )), len(replace_results.keys()))) def save_files(self, nodes): """ Saves user defined files using give nodes. :param nodes: Nodes. :type nodes: list :return: Method success. :rtype: bool """ metrics = {"Opened": 0, "Cached": 0} for node in nodes: file = node.file if self.__container.get_editor(file): if self.__container.save_file(file): metrics["Opened"] += 1 self.__uncache(file) else: cache_data = self.__files_cache.get_content(file) if cache_data is None: LOGGER.warning( "!> {0} | '{1}' file doesn't exists in files cache!".format(self.__class__.__name__, file)) continue if cache_data.document: file_handle = File(file) file_handle.content = [ cache_data.document.toPlainText().toUtf8()] if file_handle.write(): metrics["Cached"] += 1 self.__uncache(file) else: LOGGER.warning( "!> {0} | '{1}' file document doesn't exists in files cache!".format(self.__class__.__name__, file)) self.__container.engine.notifications_manager.notify( "{0} | '{1}' opened file(s) and '{2}' cached file(s) saved!".format(self.__class__.__name__, metrics["Opened"], metrics["Cached"]))
class SearchInFiles(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): ''' Defines search and replace in files dialog used by the **ScriptEditor** Component. ''' def __init__(self, parent, *args, **kwargs): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def script_editor(self): ''' Property for **self.__script_editor** attribute. :return: self.__script_editor. :rtype: QWidget ''' pass @script_editor.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): ''' Setter for **self.__script_editor** attribute. :param value: Attribute value. :type value: QWidget ''' pass @script_editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): ''' Deleter for **self.__script_editor** attribute. ''' pass @property def files_cache(self): ''' Property for **self.__files_cache** attribute. :return: self.__files_cache. :rtype: Cache ''' pass @files_cache.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def files_cache(self): ''' Setter for **self.__files_cache** attribute. :param value: Attribute value. :type value: Cache ''' pass @files_cache.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def files_cache(self): ''' Deleter for **self.__files_cache** attribute. ''' pass @property def search_patterns_model(self): ''' Property for **self.__search_patterns_model** attribute. :return: self.__search_patterns_model. :rtype: PatternsModel ''' pass @search_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self): ''' Setter for **self.__search_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel ''' pass @search_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self): ''' Deleter for **self.__search_patterns_model** attribute. ''' pass @property def replace_with_patterns_model(self): ''' Property for **self.__replace_with_patterns_model** attribute. :return: self.__replace_with_patterns_model. :rtype: PatternsModel ''' pass @replace_with_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self): ''' Setter for **self.__replace_with_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel ''' pass @replace_with_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self): ''' Deleter for **self.__replace_with_patterns_model** attribute. ''' pass @property def model(self): ''' Property for **self.__model** attribute. :return: self.__model. :rtype: SearchResultsModel ''' pass @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Setter for **self.__model** attribute. :param value: Attribute value. :type value: SearchResultsModel ''' pass @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Deleter for **self.__model** attribute. ''' pass @property def view(self): ''' Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget ''' pass @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget ''' pass @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Deleter for **self.__view** attribute. ''' pass @property def delegate(self): ''' Property for **self.__delegate** attribute. :return: self.__delegate. :rtype: QItemDelegate ''' pass @delegate.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self): ''' Setter for **self.__delegate** attribute. :param value: Attribute value. :type value: QItemDelegate ''' pass @delegate.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self): ''' Deleter for **self.__delegate** attribute. ''' pass @property def locations(self): ''' Property for **self.__locations** attribute. :return: self.__locations. :rtype: OrderedDict ''' pass @locations.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations(self): ''' Setter for **self.__locations** attribute. :param value: Attribute value. :type value: OrderedDict ''' pass @locations.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations(self): ''' Deleter for **self.__locations** attribute. ''' pass @property def locations_menu(self): ''' Property for **self.__locations_menu** attribute. :return: self.__locations_menu. :rtype: QMenu ''' pass @locations_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations_menu(self): ''' Setter for **self.__locations_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @locations_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def locations_menu(self): ''' Deleter for **self.__locations_menu** attribute. ''' pass @property def default_filter_in(self): ''' Property for **self.__default_filter_in** attribute. :return: self.__default_filter_in. :rtype: unicode ''' pass @default_filter_in.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_filter_in(self): ''' Setter for **self.__default_filter_in** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_filter_in.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_filter_in(self): ''' Deleter for **self.__default_filter_in** attribute. ''' pass @property def filters_in_format(self): ''' Property for **self.__filters_in_format** attribute. :return: self.__filters_in_format. :rtype: unicode ''' pass @filters_in_format.setter @foundations.exceptions.handle_exceptions(AssertionError) def filters_in_format(self): ''' Setter for **self.__filters_in_format** attribute. :param value: Attribute value. :type value: unicode ''' pass @filters_in_format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def filters_in_format(self): ''' Deleter for **self.__filters_in_format** attribute. ''' pass @property def default_filter_out(self): ''' Property for **self.__default_filter_out** attribute. :return: self.__default_filter_out. :rtype: unicode ''' pass @default_filter_out.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_filter_out(self): ''' Setter for **self.__default_filter_out** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_filter_out.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_filter_out(self): ''' Deleter for **self.__default_filter_out** attribute. ''' pass @property def filters_out_format(self): ''' Property for **self.__filters_out_format** attribute. :return: self.__filters_out_format. :rtype: unicode ''' pass @filters_out_format.setter @foundations.exceptions.handle_exceptions(AssertionError) def filters_out_format(self): ''' Setter for **self.__filters_out_format** attribute. :param value: Attribute value. :type value: unicode ''' pass @filters_out_format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def filters_out_format(self): ''' Deleter for **self.__filters_out_format** attribute. ''' pass @property def default_target(self): ''' Property for **self.__default_target** attribute. :return: self.__default_target. :rtype: unicode ''' pass @default_target.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_target(self): ''' Setter for **self.__default_target** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_target.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_target(self): ''' Deleter for **self.__default_target** attribute. ''' pass @property def targets_format(self): ''' Property for **self.__targets_format** attribute. :return: self.__targets_format. :rtype: unicode ''' pass @targets_format.setter @foundations.exceptions.handle_exceptions(AssertionError) def targets_format(self): ''' Setter for **self.__targets_format** attribute. :param value: Attribute value. :type value: unicode ''' pass @targets_format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def targets_format(self): ''' Deleter for **self.__targets_format** attribute. ''' pass @property def default_line_number_width(self): ''' Property for **self.__default_line_number_width** attribute. :return: self.__default_line_number_width. :rtype: int ''' pass @default_line_number_width.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_line_number_width(self): ''' Setter for **self.__default_line_number_width** attribute. :param value: Attribute value. :type value: int ''' pass @default_line_number_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_line_number_width(self): ''' Deleter for **self.__default_line_number_width** attribute. ''' pass @property def default_line_color(self): ''' Property for **self.__default_line_color** attribute. :return: self.__default_line_color. :rtype: QColor ''' pass @default_line_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_line_color(self): ''' Setter for **self.__default_line_color** attribute. :param value: Attribute value. :type value: QColor ''' pass @default_line_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_line_color(self): ''' Deleter for **self.__default_line_color** attribute. ''' pass @property def ignore_hidden_files(self): ''' Property for **self.__ignore_hidden_files** attribute. :return: self.__ignore_hidden_files. :rtype: bool ''' pass @ignore_hidden_files.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ignore_hidden_files(self): ''' Setter for **self.__ignore_hidden_files** attribute. :param value: Attribute value. :type value: bool ''' pass @ignore_hidden_files.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ignore_hidden_files(self): ''' Deleter for **self.__ignore_hidden_files** attribute. ''' pass @property def search_worker_thread(self): ''' Property for **self.__search_worker_thread** attribute. :return: self.__search_worker_thread. :rtype: QThread ''' pass @search_worker_thread.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_worker_thread(self): ''' Setter for **self.__search_worker_thread** attribute. :param value: Attribute value. :type value: QThread ''' pass @search_worker_thread.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_worker_thread(self): ''' Deleter for **self.__search_worker_thread** attribute. ''' pass def show(self): ''' Reimplements the :meth:`QWidget.show` method. ''' pass def closeEvent(self, event): ''' Reimplements the :meth:`QWidget.closeEvent` method. :param event: QEvent. :type event: QEvent ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __view_add_actions(self): ''' Sets the View actions. ''' pass def __view_replace_all_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Replace All'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_replace_selected_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Replace Selected'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_save_all_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Save All'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_save_selected_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Search In Files|Save Selected'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __patterns_model__pattern_inserted(self, combo_box, index): ''' Defines the slot triggered by a pattern when inserted into a patterns Model. :param combo_box: Pattern Model attached combo_box. :type combo_box: QComboBox :param index: Inserted pattern index. :type index: QModelIndex ''' pass def __Search_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Search_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __Close_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Close_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __view__doubleClicked(self, index): ''' Defines the slot triggered by a View when double clicked. :param index: Clicked item index. :type index: QModelIndex ''' pass def __view_selectionModel__selectionChanged(self, selected_items, deselected_items): ''' Defines the slot triggered by the View **selectionModel** when selection changed. :param selected_items: Selected items. :type selected_items: QItemSelection :param deselected_items: Deselected items. :type deselected_items: QItemSelection ''' pass def __search_worker_thread__searchFinished(self, search_results): ''' Defines the slot triggered by :attr:`SearchInFiles.grepWorkerThread` attribute worker thread when the search is finished. :param search_results: Search results. :type search_results: list ''' pass def __add_location(self, type, *args): ''' Defines the slot triggered by **Where_lineEdit** Widget when a context menu entry is clicked. :param type: Location type. :type type: unicode :param \*args: Arguments. :type \*args: \* ''' pass def __format_occurence(self, occurence): ''' Formats the given occurence and returns the matching rich html text. :param occurence: Occurence to format. :type occurence: Occurence :return: Rich text. :rtype: unicode ''' pass def __format_replace_metrics(self, file, metrics): ''' Formats the given replace metrics and returns the matching rich html text. :param file: File. :type file: unicode :param metrics: Replace metrics to format. :type metrics: unicode :return: Rich text. :rtype: unicode ''' pass def __highlight_occurence(self, file, occurence): ''' Highlights given file occurence. :param file: File containing the occurence. :type file: unicode :param occurence: Occurence to highlight. :type occurence: Occurence or SearchOccurenceNode ''' pass def __get_document(self, content): ''' Returns a `QTextDocument <http://doc.qt.nokia.com/qtextdocument.html>`_ class instance with given content. :return: Document. :rtype: QTextDocument ''' pass def __replace_within_document(self, document, occurrences, replacement_pattern): ''' Replaces given pattern occurrences in given document using given settings. :param document: Document. :type document: QTextDocument :param replacement_pattern: Replacement pattern. :type replacement_pattern: unicode :return: Replaced occurrences count. :rtype: int ''' pass def __get_settings(self): ''' Returns the current search and replace settings. :return: Settings. :rtype: dict ''' pass def __interrupt_search(self): ''' Interrupt the current search. ''' pass def __cache(self, file, content, document): ''' Caches given file. :param file: File to cache. :type file: unicode :param content: File content. :type content: list :param document: File document. :type document: QTextDocument ''' pass def __uncache(self, file): ''' Uncaches given file. :param file: File to uncache. :type file: unicode ''' pass def set_search_results(self, search_results): ''' Sets the Model Nodes using given search results. :param search_results: Search results. :type search_results: list :return: Method success. :rtype: bool ''' pass def set_replace_results(self, replace_results): ''' Sets the Model Nodes using given replace results. :param replace_results: Replace results. :type replace_results: list :return: Method success. :rtype: bool ''' pass def search_patterns_model(self): ''' Searchs user defined locations for search pattern. :return: Method success. :rtype: bool ''' pass def replace_with_patterns_model(self): ''' Replaces user defined files search pattern occurrences with replacement pattern using given nodes. :param nodes: Nodes. :type nodes: list :return: Method success. :rtype: bool ''' pass def save_files(self, nodes): ''' Saves user defined files using give nodes. :param nodes: Nodes. :type nodes: list :return: Method success. :rtype: bool ''' pass
191
91
13
2
6
5
2
0.71
1
19
13
0
90
22
90
90
1,372
287
633
233
442
452
415
173
324
8
1
4
137
142,481
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/search_and_replace.py
umbra.components.factory.script_editor.search_and_replace.SearchAndReplace
class SearchAndReplace(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): """ Defines the default search and replace dialog used by the **ScriptEditor** Component. """ def __init__(self, parent, *args, **kwargs): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(SearchAndReplace, self).__init__(parent, *args, **kwargs) # --- Setting class attributes. --- self.__container = parent self.__search_patterns_model = None self.__replace_with_patterns_model = None self.__maximum_stored_patterns = 15 SearchAndReplace.__initialize_ui(self) @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def search_patterns_model(self): """ Property for **self.__search_patterns_model** attribute. :return: self.__search_patterns_model. :rtype: PatternsModel """ return self.__search_patterns_model @search_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self, value): """ Setter for **self.__search_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_patterns_model")) @search_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self): """ Deleter for **self.__search_patterns_model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_patterns_model")) @property def replace_with_patterns_model(self): """ Property for **self.__replace_with_patterns_model** attribute. :return: self.__replace_with_patterns_model. :rtype: PatternsModel """ return self.__replace_with_patterns_model @replace_with_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self, value): """ Setter for **self.__replace_with_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "replace_with_patterns_model")) @replace_with_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self): """ Deleter for **self.__replace_with_patterns_model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "replace_with_patterns_model")) @property def maximum_stored_patterns(self): """ Property for **self.__maximum_stored_patterns** attribute. :return: self.__maximum_stored_patterns. :rtype: int """ return self.__maximum_stored_patterns @maximum_stored_patterns.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_stored_patterns(self, value): """ Setter for **self.__maximum_stored_patterns** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "maximum_stored_patterns")) @maximum_stored_patterns.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_stored_patterns(self): """ Deleter for **self.__maximum_stored_patterns** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "maximum_stored_patterns")) def show(self): """ Reimplements the :meth:`QWidget.show` method. """ selected_text = self.__container.get_current_editor().get_selected_text() selected_text and self.insert_pattern( selected_text, self.__search_patterns_model) self.Search_comboBox.line_edit().selectAll() self.Search_comboBox.setFocus() super(SearchAndReplace, self).show() self.raise_() def __initialize_ui(self): """ Initializes the Widget ui. """ umbra.ui.common.set_window_default_icon(self) for model, settings_key, combo_box in \ (("_SearchAndReplace__search_patterns_model", "recent_search_patterns", self.Search_comboBox), ("_SearchAndReplace__replace_with_patterns_model", "recent_replace_with_patterns", self.Replace_With_comboBox)): self.__dict__[model] = PatternsModel() patterns = foundations.common.ordered_uniqify([foundations.strings.to_string(pattern) for pattern in self.__container.settings.get_key( self.__container.settings_section, settings_key).toStringList()]) [PatternNode(parent=self.__dict__[model].root_node, name=pattern) for pattern in patterns[:self.__maximum_stored_patterns]] combo_box.setInsertPolicy(QComboBox.InsertAtTop) combo_box.setModel(self.__dict__[model]) combo_box.completer().setCaseSensitivity(Qt.CaseSensitive) # Signals / Slots. self.__dict__[model].pattern_inserted.connect( functools.partial(self.__patterns_model__pattern_inserted, settings_key, combo_box)) self.Wrap_Around_checkBox.setChecked(True) self.installEventFilter(ValidationFilter(self)) # Signals / Slots. self.Search_pushButton.clicked.connect( self.__Search_pushButton__clicked) self.Replace_pushButton.clicked.connect( self.__Replace_pushButton__clicked) self.Replace_All_pushButton.clicked.connect( self.__Replace_All_pushButton__clicked) self.Close_pushButton.clicked.connect(self.__Close_pushButton__clicked) def __patterns_model__pattern_inserted(self, settings_key, combo_box, index): """ Defines the slot triggered by a pattern when inserted into a patterns Model. :param settings_key: Pattern Model settings key. :type settings_key: unicode :param combo_box: Pattern Model attached combo_box. :type combo_box: QComboBox :param index: Inserted pattern index. :type index: QModelIndex """ patterns_model = self.sender() LOGGER.debug("> Storing '{0}' model patterns in '{1}' settings key.".format( patterns_model, settings_key)) self.__container.settings.set_key(self.__container.settings_section, settings_key, [pattern_node.name for pattern_node in patterns_model.root_node.children[:self.maximum_stored_patterns]]) combo_box.setCurrentIndex(index.row()) def __Search_pushButton__clicked(self, checked): """ Defines the slot triggered by **Search_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.search() def __Replace_pushButton__clicked(self, checked): """ Defines the slot triggered by **Replace_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.replace() def __Replace_All_pushButton__clicked(self, checked): """ Defines the slot triggered by **Replace_All_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.replace_all() def __Close_pushButton__clicked(self, checked): """ Defines the slot triggered by **Close_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.close() def __get_settings(self): """ Returns the current search and replace settings. :return: Settings. :rtype: dict """ return {"case_sensitive": self.Case_Sensitive_checkBox.isChecked(), "whole_word": self.Whole_Word_checkBox.isChecked(), "regular_expressions": self.Regular_Expressions_checkBox.isChecked(), "backward_search": self.Backward_Search_checkBox.isChecked(), "wrap_around": self.Wrap_Around_checkBox.isChecked()} @staticmethod def insert_pattern(pattern, model, index=0): """ Inserts given pattern into given Model. :param pattern: Pattern. :type pattern: unicode :param model: Model. :type model: PatternsModel :param index: Insertion indes. :type index: int :return: Method success. :rtype: bool """ if not pattern: return False pattern = pattern.replace( QChar(QChar.ParagraphSeparator), QString("\n")) pattern = foundations.common.get_first_item( foundations.strings.to_string(pattern).split("\n")) model.insert_pattern(foundations.strings.to_string(pattern), index) return True def search(self): """ Searchs current editor Widget for search pattern. :return: Method success. :rtype: bool """ editor = self.__container.get_current_editor() search_pattern = self.Search_comboBox.currentText() replacement_pattern = self.Replace_With_comboBox.currentText() if not editor or not search_pattern: return False self.insert_pattern(search_pattern, self.__search_patterns_model) self.insert_pattern(replacement_pattern, self.__replace_with_patterns_model) settings = self.__get_settings() LOGGER.debug("> 'Search' on '{0}' search pattern with '{1}' settings.".format( search_pattern, settings)) return editor.search(search_pattern, **settings) def replace(self): """ Replaces current editor Widget current search pattern occurence with replacement pattern. :return: Method success. :rtype: bool """ editor = self.__container.get_current_editor() search_pattern = self.Search_comboBox.currentText() replacement_pattern = self.Replace_With_comboBox.currentText() if not editor or not search_pattern: return False self.insert_pattern(search_pattern, self.__search_patterns_model) self.insert_pattern(replacement_pattern, self.__replace_with_patterns_model) settings = self.__get_settings() LOGGER.debug("> 'Replace' on search '{0}' pattern, '{1}' replacement pattern with '{2}' settings.".format( search_pattern, replacement_pattern, settings)) return editor.replace(search_pattern, replacement_pattern, **settings) def replace_all(self): """ Replaces current editor Widget search pattern occurrences with replacement pattern. :return: Method success. :rtype: bool """ editor = self.__container.get_current_editor() search_pattern = self.Search_comboBox.currentText() replacement_pattern = self.Replace_With_comboBox.currentText() if not editor or not search_pattern: return False self.insert_pattern(search_pattern, self.__search_patterns_model) self.insert_pattern(replacement_pattern, self.__replace_with_patterns_model) settings = self.__get_settings() settings.update({"backward_search": False, "wrap_around": False}) LOGGER.debug("> 'Replace All' on search '{0}' pattern, '{1}' replacement pattern with '{2}' settings.".format( search_pattern, replacement_pattern, settings)) return editor.replace_all(search_pattern, replacement_pattern, **settings)
class SearchAndReplace(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): ''' Defines the default search and replace dialog used by the **ScriptEditor** Component. ''' def __init__(self, parent, *args, **kwargs): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def search_patterns_model(self): ''' Property for **self.__search_patterns_model** attribute. :return: self.__search_patterns_model. :rtype: PatternsModel ''' pass @search_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self): ''' Setter for **self.__search_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel ''' pass @search_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_patterns_model(self): ''' Deleter for **self.__search_patterns_model** attribute. ''' pass @property def replace_with_patterns_model(self): ''' Property for **self.__replace_with_patterns_model** attribute. :return: self.__replace_with_patterns_model. :rtype: PatternsModel ''' pass @replace_with_patterns_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self): ''' Setter for **self.__replace_with_patterns_model** attribute. :param value: Attribute value. :type value: PatternsModel ''' pass @replace_with_patterns_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def replace_with_patterns_model(self): ''' Deleter for **self.__replace_with_patterns_model** attribute. ''' pass @property def maximum_stored_patterns(self): ''' Property for **self.__maximum_stored_patterns** attribute. :return: self.__maximum_stored_patterns. :rtype: int ''' pass @maximum_stored_patterns.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_stored_patterns(self): ''' Setter for **self.__maximum_stored_patterns** attribute. :param value: Attribute value. :type value: int ''' pass @maximum_stored_patterns.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_stored_patterns(self): ''' Deleter for **self.__maximum_stored_patterns** attribute. ''' pass def show(self): ''' Reimplements the :meth:`QWidget.show` method. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __patterns_model__pattern_inserted(self, settings_key, combo_box, index): ''' Defines the slot triggered by a pattern when inserted into a patterns Model. :param settings_key: Pattern Model settings key. :type settings_key: unicode :param combo_box: Pattern Model attached combo_box. :type combo_box: QComboBox :param index: Inserted pattern index. :type index: QModelIndex ''' pass def __Search_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Search_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __Replace_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Replace_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __Replace_All_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Replace_All_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __Close_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Close_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __get_settings(self): ''' Returns the current search and replace settings. :return: Settings. :rtype: dict ''' pass @staticmethod def insert_pattern(pattern, model, index=0): ''' Inserts given pattern into given Model. :param pattern: Pattern. :type pattern: unicode :param model: Model. :type model: PatternsModel :param index: Insertion indes. :type index: int :return: Method success. :rtype: bool ''' pass def search_patterns_model(self): ''' Searchs current editor Widget for search pattern. :return: Method success. :rtype: bool ''' pass def replace_with_patterns_model(self): ''' Replaces current editor Widget current search pattern occurence with replacement pattern. :return: Method success. :rtype: bool ''' pass def replace_all(self): ''' Replaces current editor Widget search pattern occurrences with replacement pattern. :return: Method success. :rtype: bool ''' pass
47
26
14
3
5
5
1
0.84
1
5
3
0
24
4
25
25
393
101
159
59
112
133
112
46
86
2
1
1
30
142,482
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/script_editor.py
umbra.components.factory.script_editor.script_editor.ScriptEditor
class ScriptEditor(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): """ Defines the :mod:`sibl_gui.components.addons.script_editor.script_editor` Component Interface class. """ # Custom signals definitions. ui_refresh = pyqtSignal() """ This signal is emited by the :class:`ScriptEditor` class when the Ui needs to be refreshed. """ recent_files_changed = pyqtSignal() """ This signal is emited by the :class:`ScriptEditor` class when the recent files list has changed. """ file_loaded = pyqtSignal(unicode) """ This signal is emited by the :class:`ScriptEditor` class when a file is loaded. :return: Loaded file. :rtype: unicode """ file_closed = pyqtSignal(unicode) """ This signal is emited by the :class:`ScriptEditor` class when a file is closed. :return: Closed file. :rtype: unicode """ def __init__(self, parent=None, name=None, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(ScriptEditor, self).__init__(parent, name, *args, **kwargs) # --- Setting class attributes. --- self.deactivatable = False self.__dock_area = 1 self.__engine = None self.__settings = None self.__settings_section = None self.__development_layout = UiConstants.development_layout self.__grammars_directory = "grammars" self.__extension = "grc" self.__model = None self.__languages_model = None self.__default_project = "default_project" self.__default_language = "Text" self.__default_script_language = "Python" self.__default_file_name = "Untitled" self.__default_file_extension = "py" self.__default_window_title = "Script Editor" self.__default_script_editor_directory = "script_editor" self.__default_session_directory = "session" self.__default_script_editor_file = "default_script.py" self.__factory_default_script_editor_file = "others/default_script.py" self.__script_editor_file = None self.__maximum_recent_files = 10 self.__recent_files_actions = None self.__search_and_replace = None self.__search_in_files = None self.__indent_width = 20 self.__default_fonts_settings = {"Windows": ("Consolas", 10), "Darwin": ("Monaco", 12), "Linux": ("Monospace", 10)} self.__console = None self.__memory_handler_stack_depth = None self.__menu_bar = None self.__file_menu = None self.__edit_menu = None self.__source_menu = None self.__navigate_menu = None self.__search_menu = None self.__command_menu = None self.__view_menu = None @property def dock_area(self): """ Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int """ return self.__dock_area @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self, value): """ Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "dock_area")) @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): """ Deleter for **self.__dock_area** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "dock_area")) @property def engine(self): """ Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject """ return self.__engine @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self, value): """ Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "engine")) @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): """ Deleter for **self.__engine** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "engine")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def settings_section(self): """ Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode """ return self.__settings_section @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self, value): """ Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings_section")) @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): """ Deleter for **self.__settings_section** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings_section")) @property def development_layout(self): """ Property for **self.__development_layout** attribute. :return: self.__development_layout. :rtype: unicode """ return self.__development_layout @development_layout.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def development_layout(self, value): """ Setter for **self.__development_layout** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "development_layout")) @development_layout.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def development_layout(self): """ Deleter for **self.__development_layout** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "development_layout")) @property def grammars_directory(self): """ Property for **self.__grammars_directory** attribute. :return: self.__grammars_directory. :rtype: unicode """ return self.__grammars_directory @grammars_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def grammars_directory(self, value): """ Setter for **self.__grammars_directory** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "grammars_directory")) @grammars_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def grammars_directory(self): """ Deleter for **self.__grammars_directory** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "grammars_directory")) @property def extension(self): """ Property for **self.__extension** attribute. :return: self.__extension. :rtype: unicode """ return self.__extension @extension.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def extension(self, value): """ Setter for **self.__extension** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "extension")) @extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def extension(self): """ Deleter for **self.__extension** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "extension")) @property def model(self): """ Property for **self.__model** attribute. :return: self.__model. :rtype: ProjectsModel """ return self.__model @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self, value): """ Setter for **self.__model** attribute. :param value: Attribute value. :type value: ProjectsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "model")) @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): """ Deleter for **self.__model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "model")) @property def languages_model(self): """ Property for **self.__languages_model** attribute. :return: self.__languages_model. :rtype: LanguagesModel """ return self.__languages_model @languages_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def languages_model(self, value): """ Setter for **self.__languages_model** attribute. :param value: Attribute value. :type value: LanguagesModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "languages_model")) @languages_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def languages_model(self): """ Deleter for **self.__languages_model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "languages_model")) @property def default_project(self): """ Property for **self.__default_project** attribute. :return: self.__default_project. :rtype: unicode """ return self.__default_project @default_project.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project(self, value): """ Setter for **self.__default_project** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_project")) @default_project.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project(self): """ Deleter for **self.__default_project** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_project")) @property def default_language(self): """ Property for **self.__default_language** attribute. :return: self.__default_language. :rtype: unicode """ return self.__default_language @default_language.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_language(self, value): """ Setter for **self.__default_language** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_language")) @default_language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_language(self): """ Deleter for **self.__default_language** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_language")) @property def default_script_language(self): """ Property for **self.__default_script_language** attribute. :return: self.__default_script_language. :rtype: unicode """ return self.__default_script_language @default_script_language.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_language(self, value): """ Setter for **self.__default_script_language** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_script_language")) @default_script_language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_language(self): """ Deleter for **self.__default_script_language** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_script_language")) @property def default_file_name(self): """ Property for **self.__default_file_name** attribute. :return: self.__default_file_name. :rtype: unicode """ return self.__default_file_name @default_file_name.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self, value): """ Setter for **self.__default_file_name** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_file_name")) @default_file_name.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self): """ Deleter for **self.__default_file_name** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_file_name")) @property def default_file_extension(self): """ Property for **self.__default_file_extension** attribute. :return: self.__default_file_extension. :rtype: unicode """ return self.__default_file_extension @default_file_extension.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self, value): """ Setter for **self.__default_file_extension** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_file_extension")) @default_file_extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self): """ Deleter for **self.__default_file_extension** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_file_extension")) @property def default_window_title(self): """ Property for **self.__default_window_title** attribute. :return: self.__default_window_title. :rtype: unicode """ return self.__default_window_title @default_window_title.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_window_title(self, value): """ Setter for **self.__default_window_title** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_window_title")) @default_window_title.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_window_title(self): """ Deleter for **self.__default_window_title** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_window_title")) @property def default_script_editor_directory(self): """ Property for **self.__default_script_editor_directory** attribute. :return: self.__default_script_editor_directory. :rtype: unicode """ return self.__default_script_editor_directory @default_script_editor_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_directory(self, value): """ Setter for **self.__default_script_editor_directory** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_script_editor_directory")) @default_script_editor_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_directory(self): """ Deleter for **self.__default_script_editor_directory** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_script_editor_directory")) @property def default_session_directory(self): """ Property for **self.__default_session_directory** attribute. :return: self.__default_session_directory. :rtype: unicode """ return self.__default_session_directory @default_session_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_session_directory(self, value): """ Setter for **self.__default_session_directory** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_session_directory")) @default_session_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_session_directory(self): """ Deleter for **self.__default_session_directory** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_session_directory")) @property def default_script_editor_file(self): """ Property for **self.__default_script_editor_file** attribute. :return: self.__default_script_editor_file. :rtype: unicode """ return self.__default_script_editor_file @default_script_editor_file.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_file(self, value): """ Setter for **self.__default_script_editor_file** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_script_editor_file")) @default_script_editor_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_file(self): """ Deleter for **self.__default_script_editor_file** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_script_editor_file")) @property def factory_default_script_editor_file(self): """ Property for **self.__factory_default_script_editor_file** attribute. :return: self.__factory_default_script_editor_file. :rtype: unicode """ return self.__factory_default_script_editor_file @factory_default_script_editor_file.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def factory_default_script_editor_file(self, value): """ Setter for **self.__factory_default_script_editor_file** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "factory_default_script_editor_file")) @factory_default_script_editor_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def factory_default_script_editor_file(self): """ Deleter for **self.__factory_default_script_editor_file** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "factory_default_script_editor_file")) @property def script_editor_file(self): """ Property for **self.__script_editor_file** attribute. :return: self.__script_editor_file. :rtype: unicode """ return self.__script_editor_file @script_editor_file.setter @foundations.exceptions.handle_exceptions(AssertionError) def script_editor_file(self, value): """ Setter for **self.__script_editor_file** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "script_editor_file", value) self.__script_editor_file = value @script_editor_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor_file(self): """ Deleter for **self.__script_editor_file** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "script_editor_file")) @property def maximum_recent_files(self): """ Property for **self.__maximum_recent_files** attribute. :return: self.__maximum_recent_files. :rtype: int """ return self.__maximum_recent_files @maximum_recent_files.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_recent_files(self, value): """ Setter for **self.__maximum_recent_files** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "maximum_recent_files")) @maximum_recent_files.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_recent_files(self): """ Deleter for **self.__maximum_recent_files** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "maximum_recent_files")) @property def recent_files_actions(self): """ Property for **self.__recent_files_actions** attribute. :return: self.__recent_files_actions. :rtype: list """ return self.__recent_files_actions @recent_files_actions.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def recent_files_actions(self, value): """ Setter for **self.__recent_files_actions** attribute. :param value: Attribute value. :type value: list """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "recent_files_actions")) @recent_files_actions.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def recent_files_actions(self): """ Deleter for **self.__recent_files_actions** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "recent_files_actions")) @property def search_and_replace(self): """ Property for **self.__search_and_replace** attribute. :return: self.__search_and_replace. :rtype: SearchAndReplace """ return self.__search_and_replace @search_and_replace.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_and_replace(self, value): """ Setter for **self.__search_and_replace** attribute. :param value: Attribute value. :type value: SearchAndReplace """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_and_replace")) @search_and_replace.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_and_replace(self): """ Deleter for **self.__search_and_replace** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_and_replace")) @property def search_in_files(self): """ Property for **self.__search_in_files** attribute. :return: self.__search_in_files. :rtype: SearchInFiles """ return self.__search_in_files @search_in_files.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_in_files(self, value): """ Setter for **self.__search_in_files** attribute. :param value: Attribute value. :type value: SearchInFiles """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_in_files")) @search_in_files.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_in_files(self): """ Deleter for **self.__search_in_files** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_in_files")) @property def indent_width(self): """ Property for **self.__indent_width** attribute. :return: self.__indent_width. :rtype: int """ return self.__indent_width @indent_width.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_width(self, value): """ Setter for **self.__indent_width** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "indent_width")) @indent_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_width(self): """ Deleter for **self.__indent_width** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "indent_width")) @property def default_fonts_settings(self): """ Property for **self.__default_fonts_settings** attribute. :return: self.__default_fonts_settings. :rtype: dict """ return self.__default_fonts_settings @default_fonts_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self, value): """ Setter for **self.__default_fonts_settings** attribute. :param value: Attribute value. :type value: dict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_fonts_settings")) @default_fonts_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self): """ Deleter for **self.__default_fonts_settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_fonts_settings")) @property def console(self): """ Property for **self.__console** attribute. :return: self.__console. :rtype: dict """ return self.__console @console.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def console(self, value): """ Setter for **self.__console** attribute. :param value: Attribute value. :type value: dict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "console")) @console.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def console(self): """ Deleter for **self.__console** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "console")) @property def memory_handler_stack_depth(self): """ Property for **self.__memory_handler_stack_depth** attribute. :return: self.__memory_handler_stack_depth. :rtype: int """ return self.__memory_handler_stack_depth @memory_handler_stack_depth.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def memory_handler_stack_depth(self, value): """ Setter for **self.__memory_handler_stack_depth** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "memory_handler_stack_depth")) @memory_handler_stack_depth.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def memory_handler_stack_depth(self): """ Deleter for **self.__memory_handler_stack_depth** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "memory_handler_stack_depth")) @property def menu_bar(self): """ Property for **self.__menu_bar** attribute. :return: self.__menu_bar. :rtype: QToolbar """ return self.__menu_bar @menu_bar.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu_bar(self, value): """ Setter for **self.__menu_bar** attribute. :param value: Attribute value. :type value: QToolbar """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "menu_bar")) @menu_bar.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu_bar(self): """ Deleter for **self.__menu_bar** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "menu_bar")) @property def file_menu(self): """ Property for **self.__file_menu** attribute. :return: self.__file_menu. :rtype: QMenu """ return self.__file_menu @file_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_menu(self, value): """ Setter for **self.__file_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "file_menu")) @file_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_menu(self): """ Deleter for **self.__file_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "file_menu")) @property def edit_menu(self): """ Property for **self.__edit_menu** attribute. :return: self.__edit_menu. :rtype: QMenu """ return self.__edit_menu @edit_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def edit_menu(self, value): """ Setter for **self.__edit_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "edit_menu")) @edit_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def edit_menu(self): """ Deleter for **self.__edit_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "edit_menu")) @property def source_menu(self): """ Property for **self.__source_menu** attribute. :return: self.__source_menu. :rtype: QMenu """ return self.__source_menu @source_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def source_menu(self, value): """ Setter for **self.__source_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "source_menu")) @source_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def source_menu(self): """ Deleter for **self.__source_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "source_menu")) @property def navigate_menu(self): """ Property for **self.__navigate_menu** attribute. :return: self.__navigate_menu. :rtype: QMenu """ return self.__navigate_menu @navigate_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def navigate_menu(self, value): """ Setter for **self.__navigate_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "navigate_menu")) @navigate_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def navigate_menu(self): """ Deleter for **self.__navigate_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "navigate_menu")) @property def search_menu(self): """ Property for **self.__search_menu** attribute. :return: self.__search_menu. :rtype: QMenu """ return self.__search_menu @search_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_menu(self, value): """ Setter for **self.__search_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_menu")) @search_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_menu(self): """ Deleter for **self.__search_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_menu")) @property def command_menu(self): """ Property for **self.__command_menu** attribute. :return: self.__command_menu. :rtype: QMenu """ return self.__command_menu @command_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def command_menu(self, value): """ Setter for **self.__command_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "command_menu")) @command_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def command_menu(self): """ Deleter for **self.__command_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "command_menu")) @property def view_menu(self): """ Property for **self.__view_menu** attribute. :return: self.__view_menu. :rtype: QMenu """ return self.__view_menu @view_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view_menu(self, value): """ Setter for **self.__view_menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "view_menu")) @view_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view_menu(self): """ Deleter for **self.__view_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "view_menu")) def activate(self, engine): """ Activates the Component. :param engine: Container to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__engine = engine self.__settings = self.__engine.settings self.__settings_section = self.name self.__default_script_editor_directory = os.path.join(self.__engine.user_application_data_directory, Constants.io_directory, self.__default_script_editor_directory) not foundations.common.path_exists(self.__default_script_editor_directory) and \ os.makedirs(self.__default_script_editor_directory) self.__default_session_directory = os.path.join( self.__default_script_editor_directory, self.__default_session_directory) not foundations.common.path_exists(self.__default_session_directory) and os.makedirs( self.__default_session_directory) self.__default_script_editor_file = os.path.join(self.__default_script_editor_directory, self.__default_script_editor_file) self.__console = code.InteractiveConsole(self.__engine.locals) self.activated = True return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component cannot be deactivated!".format(self.__class__.__name__, self.__name)) def initialize_ui(self): """ Initializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component ui.".format( self.__class__.__name__)) self.__model = ProjectsModel( self, default_project=self.__default_project) self.Script_Editor_tabWidget = ScriptEditor_QTabWidget(self.__engine) self.Script_Editor_tabWidget_frame_gridLayout.addWidget( self.Script_Editor_tabWidget, 0, 0) self.__Script_Editor_tabWidget_set_ui() self.__recent_files_actions = [] for i in range(self.__maximum_recent_files): self.__recent_files_actions.append(QAction(self.__menu_bar, visible=False, triggered=self.__load_recent_file__triggered)) self.__menu_bar = QMenuBar() self.__menu_bar.setNativeMenuBar(False) self.Menu_Bar_frame_gridLayout.addWidget(self.__menu_bar) # Qt 4.8.4: Needs to show the menu_bar, otherwise it doesn't appear. self.__menu_bar.show() self.__initialize_menu_bar() self.Script_Editor_Output_plainTextEdit.setParent(None) self.Script_Editor_Output_plainTextEdit = Basic_QPlainTextEdit(self) self.Script_Editor_Output_plainTextEdit_frame_gridLayout.addWidget( self.Script_Editor_Output_plainTextEdit, 0, 0) self.Script_Editor_Output_plainTextEdit.setObjectName( "Script_Editor_Output_plainTextEdit") self.__Script_Editor_Output_plainTextEdit_set_ui() self.__search_and_replace = SearchAndReplace(self, Qt.Window) self.__search_in_files = SearchInFiles(self, Qt.Window) self.__initialize_languages_model() self.Editor_Status_editorStatus = EditorStatus(self) self.__engine.statusBar.insertPermanentWidget( 0, self.Editor_Status_editorStatus) Editor.get_untitled_file_name = self.__get_untitled_file_name # Signals / Slots. self.__engine.timer.timeout.connect( self.__Script_Editor_Output_plainTextEdit_refresh_ui) self.__engine.content_dropped.connect(self.__engine__content_dropped) self.__engine.layouts_manager.layout_restored.connect( self.__engine_layouts_manager__layout_restored) self.__engine.file_system_events_manager.file_changed.connect( self.__engine_file_system_events_manager__file_changed) self.__engine.file_system_events_manager.file_invalidated.connect( self.__engine_file_system_events_manager__file_invalidated) self.__engine.file_system_events_manager.directory_changed.connect( self.__engine_file_system_events_manager__directory_changed) self.__engine.file_system_events_manager.directory_invalidated.connect( self.__engine_file_system_events_manager__directory_invalidated) self.Script_Editor_tabWidget.tabCloseRequested.connect( self.__Script_Editor_tabWidget__tabCloseRequested) self.Script_Editor_tabWidget.currentChanged.connect( self.__Script_Editor_tabWidget__currentChanged) self.Script_Editor_tabWidget.content_dropped.connect( self.__Script_Editor_tabWidget__content_dropped) self.Script_Editor_tabWidget.tabBar().tabMoved.connect( self.__Script_Editor_tabWidget_tabBar__tabMoved) self.visibilityChanged.connect(self.__script_editor__visibilityChanged) self.ui_refresh.connect( self.__Script_Editor_Output_plainTextEdit_refresh_ui) self.recent_files_changed.connect(self.__set_recent_files_actions) self.__model.file_registered.connect(self.__model__file_registered) self.__model.file_unregistered.connect(self.__model__file_unregistered) self.__model.directory_registered.connect( self.__model__directory_registered) self.__model.directory_unregistered.connect( self.__model__directory_unregistered) self.__model.project_registered.connect( self.__model__project_registered) self.__model.project_unregistered.connect( self.__model__project_unregistered) self.__model.editor_registered.connect(self.__model__editor_registered) self.__model.editor_unregistered.connect( self.__model__editor_unregistered) self.initialized_ui = True return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def uninitialize_ui(self): """ Uninitializes the Component ui. :return: Method success. :rtype: bool """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component ui cannot be uninitialized!".format(self.__class__.__name__, self.name)) def add_widget(self): """ Adds the Component Widget to the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.addDockWidget(Qt.DockWidgetArea(self.__dock_area), self) return True def remove_widget(self): """ Removes the Component Widget from the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Removing '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.removeDockWidget(self) self.setParent(None) return True def on_startup(self): """ Defines the slot triggered on Framework startup. """ LOGGER.debug("> Calling '{0}' Component Framework 'on_startup' method.".format( self.__class__.__name__)) factory_default_script_editor_file = umbra.ui.common.get_resource_path( self.__factory_default_script_editor_file) if foundations.common.path_exists(factory_default_script_editor_file) and \ not foundations.common.path_exists(self.__default_script_editor_file): shutil.copyfile(factory_default_script_editor_file, self.__default_script_editor_file) if foundations.common.path_exists(self.__default_script_editor_file): self.load_file(self.__default_script_editor_file) else: self.new_file() startup_script = self.__engine.parameters.startup_script if foundations.common.path_exists(startup_script): self.load_file(startup_script) and self.evaluate_script() self.restore_session() for argument in self.__engine.arguments[1:]: file = os.path.abspath(argument) if foundations.common.path_exists(file): os.path.isfile(file) and self.load_file(file) return True def on_close(self): """ Defines the slot triggered on Framework close. """ LOGGER.debug("> Calling '{0}' Component Framework 'on_close' method.".format( self.__class__.__name__)) map(self.unregister_file, self.list_files()) if self.store_session() and self.close_all_files(leave_first_editor=False): return True def __initialize_menu_bar(self): """ Initializes Component menu_bar. """ self.__file_menu = QMenu("&File", parent=self.__menu_bar) self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|&New", shortcut=QKeySequence.New, slot=self.__new_file_action__triggered)) self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|&Load ...", shortcut=QKeySequence.Open, slot=self.__load_file_action__triggered)) self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Source ...", slot=self.__source_file_action__triggered)) self.__file_menu.addSeparator() self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Add Project ...", slot=self.__add_project_action__triggered)) self.__file_menu.addSeparator() self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|&Save", shortcut=QKeySequence.Save, slot=self.__save_file_action__triggered)) self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Save As ...", shortcut=QKeySequence.SaveAs, slot=self.__save_file_as_action__triggered)) self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Save All", slot=self.__save_all_files_action__triggered)) self.__file_menu.addSeparator() self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Revert", slot=self.__revert_file_action__triggered)) self.__file_menu.addSeparator() self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Close ...", shortcut=QKeySequence.Close, slot=self.__close_file_action__triggered)) self.__file_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Close All ...", shortcut=Qt.SHIFT + Qt.ControlModifier + Qt.Key_W, slot=self.__close_all_files_action__triggered)) self.__file_menu.addSeparator() for action in self.__recent_files_actions: self.__file_menu.addAction(action) self.__set_recent_files_actions() self.__menu_bar.addMenu(self.__file_menu) self.__edit_menu = QMenu("&Edit", parent=self.__menu_bar) self.__edit_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Edit|&Undo", shortcut=QKeySequence.Undo, slot=self.__undo_action__triggered)) self.__edit_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Edit|&Redo", shortcut=QKeySequence.Redo, slot=self.__redo_action__triggered)) self.__edit_menu.addSeparator() self.__edit_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Edit|Cu&t", shortcut=QKeySequence.Cut, slot=self.__cut_action__triggered)) self.__edit_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Edit|&Copy", shortcut=QKeySequence.Copy, slot=self.__copy_action__triggered)) self.__edit_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Edit|&Paste", shortcut=QKeySequence.Paste, slot=self.__paste_action__triggered)) self.__edit_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Edit|Delete", slot=self.__delete_action__triggered)) self.__edit_menu.addSeparator() self.__edit_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Edit|Select All", shortcut=QKeySequence.SelectAll, slot=self.__select_all_action__triggered)) self.__menu_bar.addMenu(self.__edit_menu) self.__source_menu = QMenu("&Source", parent=self.__menu_bar) self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Delete Line(s)", shortcut=Qt.ControlModifier + Qt.Key_D, slot=self.__delete_lines_action__triggered)) self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Duplicate Line(s)", shortcut=Qt.SHIFT + Qt.ControlModifier + Qt.Key_D, slot=self.__duplicate_lines_action__triggered)) self.__source_menu.addSeparator() self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Move Up", shortcut=Qt.SHIFT + Qt.ControlModifier + Qt.ALT + Qt.Key_Up, slot=self.__move_up_action__triggered)) self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Move Down", shortcut=Qt.SHIFT + Qt.ControlModifier + Qt.ALT + Qt.Key_Down, slot=self.__move_down_action__triggered)) self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Indent Selection", shortcut=Qt.Key_Tab, slot=self.__indent_selection_action__triggered)) self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Unindent Selection", shortcut=Qt.Key_Backtab, slot=self.__unindent_selection_action__triggered)) self.__source_menu.addSeparator() self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Convert Indentation To Tabs", slot=self.__convert_indentation_to_tabs_action__triggered)) self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Convert Indentation To Spaces", slot=self.__convert_indentation_to_spaces_action__triggered)) self.__source_menu.addSeparator() self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Remove Trailing WhiteSpaces", slot=self.__remove_trailing_white_spaces_action__triggered)) self.__source_menu.addSeparator() self.__source_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Source|Toggle Comments", shortcut=Qt.ControlModifier + Qt.Key_Slash, slot=self.__toggle_comments_action__triggered)) self.__menu_bar.addMenu(self.__source_menu) self.__navigate_menu = QMenu("&Navigate", parent=self.__menu_bar) self.__navigate_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Navigate|Goto Line ...", shortcut=Qt.ControlModifier + Qt.Key_L, slot=self.__go_to_line_action__triggered)) self.__navigate_menu.addSeparator() self.__menu_bar.addMenu(self.__navigate_menu) self.__search_menu = QMenu("&Search", parent=self.__menu_bar) self.__search_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Search|Search And Replace ...", shortcut=Qt.ControlModifier + Qt.Key_F, slot=self.__search_and_replace_action__triggered)) self.__search_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Search|Search In Files ...", shortcut=Qt.ALT + Qt.ControlModifier + Qt.Key_F, slot=self.__search_in_files_action__triggered)) self.__search_menu.addSeparator() self.__search_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Search|Search Next", shortcut=Qt.ControlModifier + Qt.Key_K, slot=self.__search_next_action__triggered)) self.__search_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Search|Search Previous", shortcut=Qt.SHIFT + Qt.ControlModifier + Qt.Key_K, slot=self.__search_previous_action__triggered)) self.__menu_bar.addMenu(self.__search_menu) self.__command_menu = QMenu("&Command", parent=self.__menu_bar) self.__command_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Command|&Evaluate Selection", shortcut=Qt.ControlModifier + Qt.Key_Return, slot=self.__evaluate_selection_action__triggered)) self.__command_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&Command|Evaluate &Script", shortcut=Qt.SHIFT + Qt.CTRL + Qt.Key_Return, slot=self.__evaluate_script_action__triggered)) self.__menu_bar.addMenu(self.__command_menu) self.__view_menu = QMenu("&View", parent=self.__menu_bar) self.__view_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&View|Increase Font Size", shortcut=Qt.ControlModifier + Qt.Key_Plus, slot=self.__increase_font_size_action__triggered)) self.__view_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&View|Decrease Font Size", shortcut=Qt.ControlModifier + Qt.Key_Minus, slot=self.__decrease_font_size_action__triggered)) self.__view_menu.addSeparator() self.__view_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&View|Toggle Word Wrap", slot=self.__toggle_word_wrap_action__triggered)) self.__view_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&View|Toggle White Spaces", slot=self.__toggle_white_spaces_action__triggered)) self.__view_menu.addSeparator() self.__view_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&View|Loop Through Editors", shortcut=Qt.AltModifier + Qt.SHIFT + Qt.Key_Tab, slot=self.__loop_through_editors_action__triggered)) self.__menu_bar.addMenu(self.__view_menu) @foundations.trace.untracable def __Script_Editor_Output_plainTextEdit_set_ui(self): """ Sets the **Script_Editor_Output_plainTextEdit** Widget. """ self.Script_Editor_Output_plainTextEdit.setReadOnly(True) self.Script_Editor_Output_plainTextEdit.highlighter = umbra.ui.highlighters.DefaultHighlighter( self.Script_Editor_Output_plainTextEdit.document(), LOGGING_LANGUAGE.rules, LOGGING_LANGUAGE.theme) self.Script_Editor_Output_plainTextEdit.setTabStopWidth( self.__indent_width) self.Script_Editor_Output_plainTextEdit.setWordWrapMode( QTextOption.NoWrap) if platform.system() == "Windows" or platform.system() == "Microsoft": fontFamily, fontSize = self.__default_fonts_settings["Windows"] elif platform.system() == "Darwin": fontFamily, fontSize = self.__default_fonts_settings["Darwin"] elif platform.system() == "Linux": fontFamily, fontSize = self.__default_fonts_settings["Linux"] font = QFont(fontFamily) font.setPointSize(fontSize) self.Script_Editor_Output_plainTextEdit.setFont(font) self.Script_Editor_Output_plainTextEdit.contextMenuEvent = \ self.__Script_Editor_Output_plainTextEdit_contextMenuEvent self.__Script_Editor_Output_plainTextEdit_set_default_view_state() @foundations.trace.untracable def __Script_Editor_Output_plainTextEdit_set_default_view_state(self): """ Sets the **Script_Editor_Output_plainTextEdit** Widget default View state. """ self.Script_Editor_Output_plainTextEdit.moveCursor(QTextCursor.End) self.Script_Editor_Output_plainTextEdit.ensureCursorVisible() @foundations.trace.untracable def __Script_Editor_Output_plainTextEdit_refresh_ui(self): """ Updates the **Script_Editor_Output_plainTextEdit** Widget. """ memory_handler_stack_depth = len( self.__engine.logging_session_handler_stream.stream) if memory_handler_stack_depth != self.__memory_handler_stack_depth: for line in self.__engine.logging_session_handler_stream.stream[ self.__memory_handler_stack_depth:memory_handler_stack_depth]: self.Script_Editor_Output_plainTextEdit.moveCursor( QTextCursor.End) self.Script_Editor_Output_plainTextEdit.insertPlainText(line) self.__Script_Editor_Output_plainTextEdit_set_default_view_state() self.__memory_handler_stack_depth = memory_handler_stack_depth def __Script_Editor_Output_plainTextEdit_contextMenuEvent(self, event): """ Reimplements the :meth:`QPlainTextEdit.contextMenuEvent` method. :param event: QEvent. :type event: QEvent """ menu = self.Script_Editor_Output_plainTextEdit.createStandardContextMenu() menu.addSeparator() menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|Edit Selected Path", slot=self.__edit_selected_path_action__triggered)) menu.exec_(event.globalPos()) def __Script_Editor_tabWidget_set_ui(self): """ Sets the **Script_Editor_tabWidget** Widget. """ self.Script_Editor_tabWidget.setTabsClosable(True) self.Script_Editor_tabWidget.setMovable(True) def __Script_Editor_tabWidget__tabCloseRequested(self, index): """ Defines the slot triggered by **Script_Editor_tabWidget** Widget when a tab is requested to be closed. :param index: Tab index. :type index: int """ LOGGER.debug("> Closing tab with index '{0}'.".format(index)) self.Script_Editor_tabWidget.setCurrentIndex(index) return self.close_file() def __Script_Editor_tabWidget__currentChanged(self, index): """ Defines the slot triggered by **Script_Editor_tabWidget** Widget when the current tab is changed. :param index: Tab index. :type index: int """ LOGGER.debug("> Current tab changed to '{0}' index.".format(index)) self.Editor_Status_editorStatus._EditorStatus__Languages_comboBox_set_default_view_state() self.__set_window_title() def __Script_Editor_tabWidget__content_dropped(self, event): """ Defines the slot triggered by content when dropped in the **Script_Editor_tabWidget** Widget. :param event: Event. :type event: QEvent """ self.__handle_dropped_content(event) def __Script_Editor_tabWidget_tabBar__tabMoved(self, to_index, from_index): """ Defines the slot triggered by a **Script_Editor_tabWidget** Widget tab when moved. :param to_index: Index to. :type to_index: int :param from_index: Index from. :type from_index: int """ editor = self.get_current_editor() if not editor: return editor_node = foundations.common.get_first_item( self.__model.get_editor_nodes(editor)) file_node = editor_node.parent project_node = file_node.parent self.__model.move_node(project_node, from_index, to_index) def __engine__content_dropped(self, event): """ Defines the slot triggered by content when dropped into the engine. :param event: Event. :type event: QEvent """ self.__handle_dropped_content(event) def __engine_layouts_manager__layout_restored(self, current_layout): """ Defines the slot triggered by the engine layout when changed. :param current_layout: Current layout. :type current_layout: unicode """ self.Editor_Status_editorStatus.setVisible(not self.isHidden()) def __engine_file_system_events_manager__file_changed(self, file): """ Defines the slot triggered by the **file_system_events_manager** when a file is changed. :param file: File changed. :type file: unicode """ file = foundations.strings.to_string(file) self.search_in_files._SearchInFiles__uncache(file) self.reload_file(file) def __engine_file_system_events_manager__file_invalidated(self, file): """ Defines the slot triggered by the **file_system_events_manager** when a file is invalidated. :param file: File changed. :type file: unicode """ file = foundations.strings.to_string(file) self.search_in_files._SearchInFiles__uncache(file) editor = self.get_editor(file) editor and editor.set_modified(True) def __engine_file_system_events_manager__directory_changed(self, directory): """ Defines the slot triggered by the **file_system_events_manager** when a directory is changed. :param directory: Directory changed. :type directory: unicode """ for project_node in self.__model.list_project_nodes(): if project_node.path == directory: self.__model.update_project_nodes(project_node) else: for node in foundations.walkers.nodes_walker(project_node): if node.path == directory: self.__model.update_project_nodes(node) break def __engine_file_system_events_manager__directory_invalidated(self, directory): """ Defines the slot triggered by the **file_system_events_manager** when a directory is invalidated. :param directory: Directory invalidated. :type directory: unicode """ for project_node in self.__model.list_project_nodes(): if project_node.path == directory: self.__model.unregister_project(project_node) break def __script_editor__visibilityChanged(self, visibility): """ Defines the slot triggered by the **script_editor** Component when visibility changed. :param visibility: Widget visibility. :type visibility: bool """ self.Editor_Status_editorStatus.setVisible(visibility) def __new_file_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|&New'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.new_file() def __model__file_registered(self, file_node): """ Defines the slot triggered by Model when a file is registered. :param file_node: Registered file FileNode. :type file_node: FileNode """ self.register_node_path(file_node) def __model__file_unregistered(self, file_node): """ Defines the slot triggered by Model when a file is unregistered. :param file_node: Unregistered file FileNode. :type file_node: FileNode """ self.unregister_node_path(file_node) def __model__directory_registered(self, directory_node): """ Defines the slot triggered by Model when a directory is registered. :param directory_node: Registered directory DirectoryNode. :type directory_node: DirectoryNode """ self.register_node_path(directory_node) def __model__directory_unregistered(self, directory_node): """ Defines the slot triggered by Model when a directory is unregistered. :param directory_node: Unregistered directory DirectoryNode. :type directory_node: DirectoryNode """ self.unregister_node_path(directory_node) def __model__project_registered(self, project_node): """ Defines the slot triggered by Model when a project is registered. :param project_node: Registered project ProjectNode. :type project_node: ProjectNode """ self.register_node_path(project_node) def __model__project_unregistered(self, project_node): """ Defines the slot triggered by Model when a project is unregistered. :param project_node: Unregistered project ProjectNode. :type project_node: ProjectNode """ self.unregister_node_path(project_node) def __model__editor_registered(self, editor_node): """ Defines the slot triggered by Model when an editor is registered. :param editor_node: Registered editor EditorNode. :type editor_node: EditorNode """ self.add_editor_tab(editor_node.editor) def __model__editor_unregistered(self, editor_node): """ Defines the slot triggered by Model when an editor is unregistered. :param editor_node: Unregistered editor EditorNode. :type editor_node: EditorNode """ self.remove_editor_tab(editor_node.editor) def __load_file_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|&Load ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.load_file_ui() def __source_file_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Source ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if self.load_file_ui(): return self.evaluate_script() def __add_project_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Add Project ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.add_project_ui() def __save_file_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|&Save'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.save_file() def __save_file_as_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Save As ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.save_fileAs() def __save_all_files_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Save All'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.save_all_files() def __revert_file_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Revert'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.revert_file() def __close_file_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Close ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.close_file() def __close_all_files_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Close All ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.close_all_files() def __load_recent_file__triggered(self, checked): """ Defines the slot triggered by any recent file related action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ file = self.sender().data if foundations.common.path_exists(file): return self.load_file(file) def __undo_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Undo'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False self.get_current_editor().undo() return True def __redo_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Redo'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False self.get_current_editor().redo() return True def __cut_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|Cu&t'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ current_widget = self.get_focus_widget() if not current_widget: return False if current_widget.objectName() == "Script_Editor_Output_plainTextEdit": current_widget.copy() else: current_widget.cut() return True def __copy_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Copy'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ current_widget = self.get_focus_widget() if not current_widget: return False current_widget.copy() return True def __paste_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Paste'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False self.get_current_editor().paste() return True def __delete_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|Delete'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False self.get_current_editor().delete() return True def __select_all_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|Select All'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ current_widget = self.get_focus_widget() if not current_widget: return False current_widget.selectAll() return True def __delete_lines_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Delete Line(s)'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().delete_lines() def __duplicate_lines_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Duplicate Line(s)'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().duplicate_lines() def __move_up_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Move Up'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().move_lines_up() def __move_down_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Move Down'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().move_lines_down() def __indent_selection_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Indent Selection'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().indent() def __unindent_selection_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Unindent Selection'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().unindent() def __convert_indentation_to_tabs_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Convert Identation To Tabs'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().convert_indentation_to_tabs() def __convert_indentation_to_spaces_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Convert Identation To Spaces'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().convert_indentation_to_spaces() def __remove_trailing_white_spaces_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Remove Trailing WhiteSpaces'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().remove_trailing_white_spaces() def __toggle_comments_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Toggle Comments'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().toggle_comments() def __go_to_line_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Navigate|Goto Line ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.go_to_line() def __search_and_replace_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search And Replace ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.search_and_replace_ui() def __search_in_files_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search In Files ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.search_in_files_ui() def __search_next_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search Next'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().search_next() def __search_previous_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search Previous'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ if not self.has_editor_tab(): return False return self.get_current_editor().search_previous() def __evaluate_selection_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Command|&Evaluate Selection'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.evaluate_selection() def __evaluate_script_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Command|Evaluate &Script'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.evaluate_script() def __increase_font_size_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Increase Font Size'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ current_widget = self.get_focus_widget() if not current_widget: return False return current_widget.zoom_in() def __decrease_font_size_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Decrease Font Size'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ current_widget = self.get_focus_widget() if not current_widget: return False return current_widget.zoom_out() def __toggle_word_wrap_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Toggle Word Wrap'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ current_widget = self.get_focus_widget() if not current_widget: return False return current_widget.toggle_word_wrap() def __toggle_white_spaces_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Toggle White Spaces'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ current_widget = self.get_focus_widget() if not current_widget: return False return current_widget.toggle_white_spaces() def __loop_through_editors_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Loop Through Editors'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.loop_through_editors() def __edit_selected_path_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Edit Selected Path'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.load_path( foundations.strings.to_string(self.Script_Editor_Output_plainTextEdit.get_selected_text())) def __editor__patterns_replaced(self, patterns): """ Defines the slot triggered by an editor when patterns have been replaced. """ replacedPatternsCount = len(patterns) replacedPatternsCount and self.__engine.notifications_manager.notify( "{0} | '{1}' pattern(s) replaced!".format(self.__class__.__name__, replacedPatternsCount)) def __editor__title_changed(self): """ Defines the slot triggered by an editor when title is changed. """ self.__set_tab_title(self.get_editorTab(self.sender())) self.__set_window_title() def __editor__file_loaded(self): """ Defines the slot triggered by an editor when file is loaded. """ self.register_node_path(self.sender()) def __editor__file_saved(self): """ Defines the slot triggered by an editor when file is saved. """ self.register_node_path(self.sender()) def __editor__language_changed(self): """ Defines the slot triggered by an editor when language is changed. """ self.Editor_Status_editorStatus._EditorStatus__Languages_comboBox_set_default_view_state() def __editor__modification_changed(self, changed): """ Defines the slot triggered by an editor when document is modified. :param changed: File modification state. :type changed: bool """ if self.sender() is not None: self.search_in_files._SearchInFiles__uncache(self.sender().file) def __initialize_languages_model(self): """ Initializes the languages Model. """ languages = [PYTHON_LANGUAGE, LOGGING_LANGUAGE, TEXT_LANGUAGE] existingGrammarFiles = [os.path.normpath( language.file) for language in languages] for directory in RuntimeGlobals.resources_directories: for file in foundations.walkers.files_walker(directory, ("\.{0}$".format(self.__extension),), ("\._",)): if os.path.normpath(file) in existingGrammarFiles: continue languageDescription = get_language_description(file) if not languageDescription: continue LOGGER.debug("> Adding '{0}' language to model.".format( languageDescription)) languages.append(languageDescription) self.__languages_model = LanguagesModel( self, sorted(languages, key=lambda x: (x.name))) self.__get_supported_file_types_string() @umbra.engine.encapsulate_processing def __handle_dropped_content(self, event): """ Handles dopped content event. :param event: Content dropped event. :type event: QEvent """ if not event.mimeData().hasUrls(): return urls = event.mimeData().urls() self.__engine.start_processing("Loading Files ...", len(urls)) for url in event.mimeData().urls(): path = foundations.strings.to_string(url.path()) LOGGER.debug("> Handling dropped '{0}' file.".format(path)) path = (platform.system() == "Windows" or platform.system() == "Microsoft") and \ re.search(r"^\/[A-Z]:", path) and path[1:] or path self.load_path(path) and self.restore_development_layout() self.__engine.step_processing() self.__engine.stop_processing() def __get_supported_file_types_string(self): """ Returns the supported file types dialog string. """ languages = ["All Files (*)"] for language in self.__languages_model.languages: languages.append("{0} Files ({1})".format(language.name, " ".join(language.extensions.split("|")).replace("\\", "*"))) return ";;".join(languages) def __set_recent_files_actions(self): """ Sets the recent files actions. """ recentFiles = [foundations.strings.to_string(file) for file in self.__settings.get_key(self.__settings_section, "recentFiles").toStringList() if foundations.common.path_exists(file)] if not recentFiles: return numberRecentFiles = min(len(recentFiles), self.__maximum_recent_files) for i in range(self.__maximum_recent_files): if i >= numberRecentFiles: self.__recent_files_actions[i].setVisible(False) continue LOGGER.debug( "> Adding '{0}' file to recent files actions.".format(recentFiles[i])) self.__recent_files_actions[i].setText("{0} {1}".format(i + 1, os.path.basename( foundations.strings.to_string(recentFiles[i])))) self.__recent_files_actions[i].data = foundations.strings.to_string( recentFiles[i]) self.__recent_files_actions[i].setVisible(True) def __store_recent_file(self, file): """ Stores given recent file into the settings. :param file: File to store. :type file: unicode """ LOGGER.debug("> Storing '{0}' file in recent files.".format(file)) recentFiles = [foundations.strings.to_string(recentFile) for recentFile in self.__settings.get_key(self.__settings_section, "recentFiles").toStringList() if foundations.common.path_exists(recentFile)] if not recentFiles: recentFiles = [] if file in recentFiles: recentFiles.pop(recentFiles.index(file)) recentFiles.insert(0, file) del recentFiles[self.__maximum_recent_files:] recentFiles = self.__settings.set_key( self.__settings_section, "recentFiles", recentFiles) self.recent_files_changed.emit() def __set_window_title(self): """ Sets the Component window title. """ if self.has_editor_tab(): windowTitle = "{0} - {1}".format( self.__default_window_title, self.get_current_editor().file) else: windowTitle = "{0}".format(self.__default_window_title) LOGGER.debug( "> Setting 'Script Editor' window title to '{0}'.".format(windowTitle)) self.setWindowTitle(windowTitle) def __set_tab_title(self, index): """ Sets the name and toolTip of the **Script_Editor_tabWidget** Widget tab with given index. :param index: Index of the tab containing the Model editor. :type index: int """ editor = self.get_widget(index) if not editor: return title, tool_tip = foundations.strings.to_string( editor.title), foundations.strings.to_string(editor.file) LOGGER.debug( "> Setting '{0}' window title and '{1}' toolTip to tab with '{2}' index.".format(title, tool_tip, index)) # TODO: https://bugreports.qt-project.org/browse/QTBUG-27084 color = QColor(224, 224, 224) if editor.is_modified( ) else QColor(160, 160, 160) self.Script_Editor_tabWidget.tabBar().setTabTextColor(index, color) tabText = self.Script_Editor_tabWidget.tabText(index) tabText != title and self.Script_Editor_tabWidget.setTabText( index, title) self.Script_Editor_tabWidget.setTabToolTip(index, tool_tip) def __has_editor_lock(self, editor): """ Returns if given editor has a lock. :param editor: Editor. :type editor: Editor :return: Has editor lock. :rtype: bool """ return hasattr(editor, "__lock") def __lock_editor(self, editor): """ Locks given editor. :param editor: Editor. :type editor: Editor """ setattr(editor, "__lock", True) def __unlock_editor(self, editor): """ Locks given editor. :param editor: Editor. :type editor: Editor """ delattr(editor, "__lock") def __get_untitled_file_name(self): """ Returns an untitled file name. :return: Untitled file name. :rtype: unicode """ untitledNameId = Editor._Editor__untitled_name_id for file in self.list_files(): if not os.path.dirname(file) == self.__default_session_directory: continue search = re.search(r"\d+", os.path.basename(file)) if not search: continue untitledNameId = max(int(search.group(0)), untitledNameId) + 1 name = "{0} {1}.{2}".format( self.__default_file_name, untitledNameId, self.__default_file_extension) Editor._Editor__untitled_name_id += 1 LOGGER.debug("> Next untitled file name: '{0}'.".format(name)) return name def register_file(self, file): """ Registers given file in the **file_system_events_manager**. :param file: File. :type file: unicode :return: Method success. :rtype: bool """ not self.__engine.file_system_events_manager.is_path_registered(file) and \ self.__engine.file_system_events_manager.register_path(file) return True def unregister_file(self, file): """ Unregisters given file in the **file_system_events_manager**. :param file: File. :type file: unicode :return: Method success. :rtype: bool """ self.__engine.file_system_events_manager.is_path_registered(file) and \ self.__engine.file_system_events_manager.unregister_path(file) return True def register_node_path(self, node): """ Registers given Node path in the **file_system_events_manager**. :param node: Node. :type node: FileNode or DirectoryNode or ProjectNode :return: Method success. :rtype: bool """ path = node.file if hasattr(node, "file") else node.path path = foundations.strings.to_string(path) if not foundations.common.path_exists(path): return False return self.register_file(path) def unregister_node_path(self, node): """ Unregisters given Node path from the **file_system_events_manager**. :param node: Node. :type node: FileNode or DirectoryNode or ProjectNode :return: Method success. :rtype: bool """ path = node.file if hasattr(node, "file") else node.path path = foundations.strings.to_string(path) return self.unregister_file(path) def load_file_ui(self): """ Loads user chosen file(s) into **Script_Editor_tabWidget** Widget tab Model editor(s). :return: Method success. :rtype: bool :note: May require user interaction. """ editor = self.get_current_editor() file = editor and editor.file or None browsedPath = os.path.dirname(file) if foundations.common.path_exists( file) else RuntimeGlobals.last_browsed_path files = umbra.ui.common.store_last_browsed_path(QFileDialog.getOpenFileNames(self, "Load File(s):", browsedPath, self.__get_supported_file_types_string())) if not files: return False success = True for file in files: success *= self.load_file(file) return success def add_project_ui(self): """ Adds user chosen project **Script_Editor_tabWidget** Widget tab Model. :return: Method success. :rtype: bool :note: May require user interaction. """ directory = umbra.ui.common.store_last_browsed_path(QFileDialog.getExistingDirectory(self, "Add Project:", RuntimeGlobals.last_browsed_path)) if not directory: return False return self.add_project(directory) def search_and_replace_ui(self): """ Performs a search and replace in the current **Script_Editor_tabWidget** Widget tab Model editor. :return: Method success. :rtype: bool :note: May require user interaction. """ self.__search_and_replace.show() return True def search_in_files_ui(self): """ Performs a search in the current user chosen files. :return: Method success. :rtype: bool :note: May require user interaction. """ self.__search_in_files.show() return True def get_widget(self, index): """ Returns the **Script_Editor_tabWidget** Widget associated with given index. :param index: Tab index. :type index: int :return: Widget. :rtype: QWidget """ if index is not None: return self.Script_Editor_tabWidget.widget(index) def get_focus_widget(self): """ Returns the Widget with focus. :return: Widget with focus. :rtype: QWidget """ current_widget = QApplication.focusWidget() if current_widget is None: return False if current_widget.objectName() == "Script_Editor_Output_plainTextEdit" or \ isinstance(current_widget, Editor): return current_widget def get_editorTab(self, editor): """ Returns the **Script_Editor_tabWidget** Widget tab associated with the given editor. :param editor: Editor to search tab for. :type editor: Editor :return: Tab index. :rtype: Editor """ for i in range(self.Script_Editor_tabWidget.count()): if not self.get_widget(i) == editor: continue LOGGER.debug("> Editor '{0}': Tab index '{1}'.".format(editor, i)) return i def add_editor_tab(self, editor): """ Adds a new tab to the **Script_Editor_tabWidget** Widget and sets the given editor as child widget. :param editor: Editor. :type editor: Editor :return: New tab index. :rtype: int """ index = self.Script_Editor_tabWidget.addTab( editor, editor.get_file_short_name()) LOGGER.debug( "> Assigning '{0}' editor to '{1}' tab index.".format(editor, index)) self.Script_Editor_tabWidget.setCurrentIndex(index) self.__set_tab_title(index) # Signals / Slots. editor.patterns_replaced.connect(self.__editor__patterns_replaced) editor.title_changed.connect(self.__editor__title_changed) editor.file_loaded.connect(self.__editor__file_loaded) editor.file_saved.connect(self.__editor__file_saved) editor.language_changed.connect(self.__editor__language_changed) editor.modification_changed.connect( self.__editor__modification_changed) editor.cursorPositionChanged.connect( self.Editor_Status_editorStatus._EditorStatus__editor__cursorPositionChanged) return index def remove_editor_tab(self, editor): """ Removes the **Script_Editor_tabWidget** Widget tab with given editor. :param editor: Editor. :type editor: Editor :return: Method success. :rtype: bool """ LOGGER.debug("> Removing tab with Editor '{0}'.".format(editor)) self.Script_Editor_tabWidget.removeTab(self.get_editorTab(editor)) return True def find_editor_tab(self, file): """ Finds the **Script_Editor_tabWidget** Widget tab associated to the given file. :param file: File to search tab for. :type file: unicode :return: Tab index. :rtype: Editor """ for i in range(self.Script_Editor_tabWidget.count()): if not self.get_widget(i).file == file: continue LOGGER.debug("> File '{0}': Tab index '{1}'.".format(file, i)) return i def has_editor_tab(self): """ Returns if the **Script_Editor_tabWidget** Widget has at least one tab. :return: Has tab. :rtype: bool """ return self.Script_Editor_tabWidget.count() and True or False def get_current_editor(self): """ Returns the current **Script_Editor_tabWidget** Widget tab Model editor. :return: Current editor. :rtype: Editor """ if not self.has_editor_tab(): return return self.Script_Editor_tabWidget.currentWidget() def set_current_editor(self, file): """ Focus the **Script_Editor_tabWidget** Widget tab Model editor with given file. :param file: File. :type file: unicode :return: Method success. :rtype: bool """ index = self.find_editor_tab(file) if index is not None: self.Script_Editor_tabWidget.setCurrentIndex(index) return True def load_path(self, path): """ Loads given path. :param path: Path to load. :type path: unicode :return: Method success. :rtype: bool """ if not foundations.common.path_exists(path): return False if os.path.isfile(path): if path in self.list_files(): self.set_current_editor(path) else: self.load_file(path) else: if not path in self.list_projects(): self.add_project(path) return True def load_document(self, document, file): """ Loads given document into a new **Script_Editor_tabWidget** Widget tab Model editor. :param document: Document to load. :type document: QTextDocument :param file: Document file. :type file: unicode :return: Method success. :rtype: bool """ if not foundations.common.path_exists(file): raise foundations.exceptions.FileExistsError("{0} | '{1}' file doesn't exists!".format( self.__class__.__name__, file)) if self.get_editor(file): LOGGER.info("{0} | '{1}' is already loaded!".format( self.__class__.__name__, file)) return True self.close_first_file() language = self.__languages_model.get_language(self.__default_language) editor = Editor(parent=self, language=language) if not editor.new_file(): return False LOGGER.info("{0} | Loading '{1}' file document!".format( self.__class__.__name__, file)) language = self.__languages_model.get_file_language( file) or self.__languages_model.get_language(self.__default_language) if not editor.load_document(document, file, language): return False if self.__model.set_authoring_nodes(editor): self.__store_recent_file(file) self.file_loaded.emit(file) return True def add_project(self, path): """ Adds a project. :param path: Project path. :type path: unicode :return: Method success. :rtype: bool """ if not foundations.common.path_exists(path): return False path = os.path.normpath(path) if self.__model.get_project_nodes(path): self.__engine.notifications_manager.warnify( "{0} | '{1}' project is already opened!".format(self.__class__.__name__, path)) return False LOGGER.info("{0} | Adding '{1}' project!".format( self.__class__.__name__, path)) project_node = self.__model.register_project(path) if not project_node: return False self.__model.set_project_nodes(project_node) return True def remove_project(self, path): """ Removes a project. :param path: Project path. :type path: unicode :return: Method success. :rtype: bool """ project_node = foundations.common.get_first_item( self.__model.get_project_nodes(path)) if not project_node: self.__engine.notifications_manager.warnify( "{0} | '{1}' project is not opened!".format(self.__class__.__name__, path)) return False LOGGER.info("{0} | Removing '{1}' project!".format( self.__class__.__name__, path)) self.__model.delete_project_nodes(project_node) return True def new_file(self): """ Creates a new file into a new **Script_Editor_tabWidget** Widget tab. :return: Method success. :rtype: bool """ language = self.__languages_model.get_language( self.__default_script_language) editor = Editor(parent=self, language=language) file = editor.new_file() if not file: return False LOGGER.info("{0} | Creating '{1}' file!".format( self.__class__.__name__, file)) if self.__model.set_authoring_nodes(editor): self.__store_recent_file(file) self.file_loaded.emit(file) return True @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def load_file(self, file): """ Loads user chosen file in a new **Script_Editor_tabWidget** Widget tab Model editor. :param file: File to load. :type file: unicode :return: Method success. :rtype: bool """ if not foundations.common.path_exists(file): raise foundations.exceptions.FileExistsError("{0} | '{1}' file doesn't exists!".format( self.__class__.__name__, file)) if self.get_editor(file): LOGGER.info("{0} | '{1}' is already loaded!".format( self.__class__.__name__, file)) return True self.close_first_file() LOGGER.info("{0} | Loading '{1}' file!".format( self.__class__.__name__, file)) language = self.__languages_model.get_file_language( file) or self.__languages_model.get_language(self.__default_language) editor = Editor(parent=self, language=language) if not editor.load_file(file): return False if self.__model.set_authoring_nodes(editor): self.__store_recent_file(file) self.file_loaded.emit(file) return True @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def reload_file(self, file, is_modified=True): """ Reloads given file **Script_Editor_tabWidget** Widget tab Model editor content. :param file: File to reload. :type file: unicode :param is_modified: File modified state. :type is_modified: bool :return: Method success. :rtype: bool """ if not foundations.common.path_exists(file): raise foundations.exceptions.FileExistsError("{0} | '{1}' file doesn't exists!".format( self.__class__.__name__, file)) editor = self.get_editor(file) if not editor: return False if self.__has_editor_lock(editor): self.__unlock_editor(editor) return True LOGGER.info("{0} | Reloading '{1}' file!".format( self.__class__.__name__, file)) return editor.reload_file(is_modified) def save_file(self, file=None): """ Saves either given file or current **Script_Editor_tabWidget** Widget tab Model editor file. :param file: File to save. :type file: unicode :return: Method success. :rtype: bool """ editor = file and self.get_editor(file) or self.get_current_editor() if not editor: return False LOGGER.info("{0} | Saving '{1}' file!".format( self.__class__.__name__, editor.file)) self.__lock_editor(editor) if not editor.is_untitled and foundations.common.path_exists(editor.file): return editor.save_file() else: return self.save_fileAs() @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.UserError) def save_fileAs(self): """ Saves current **Script_Editor_tabWidget** Widget tab Model editor file as user chosen file. :return: Method success. :rtype: bool """ editor = self.get_current_editor() if not editor: return False file = umbra.ui.common.store_last_browsed_path( QFileDialog.getSaveFileName(self, "Save As:", editor.file)) if not file: return False candidate_editor = self.get_editor(file) if candidate_editor: if not candidate_editor is editor: raise foundations.exceptions.UserError("{0} | '{1}' file is already opened!".format( self.__class__.__name__, file)) else: return self.save_file(file) LOGGER.info("{0} | Saving '{1}' file!".format( self.__class__.__name__, file)) self.__lock_editor(editor) self.unregister_node_path(editor) if editor.save_fileAs(file): self.__model.update_authoring_nodes(editor) language = self.__languages_model.get_file_language( file) or self.__languages_model.get_language(self.__default_language) if editor.language.name != language.name: self.set_language(editor, language) return True @umbra.engine.encapsulate_processing def save_all_files(self): """ Saves all **Script_Editor_tabWidget** Widget tab Model editor files. :return: Method success. :rtype: bool """ self.__engine.start_processing( "Saving All Files ...", len(self.list_editors())) success = True for file in self.list_files(): success *= self.save_file(file) self.__engine.step_processing() self.__engine.stop_processing() return success @umbra.engine.encapsulate_processing def revert_file(self, file=None): """ Reverts either given file or current **Script_Editor_tabWidget** Widget tab Model editor file. :param file: File to revert. :type file: unicode :return: Method success. :rtype: bool """ editor = file and self.get_editor(file) or self.get_current_editor() if not editor: return False file = editor.file LOGGER.info("{0} | Reverting '{1}' file!".format( self.__class__.__name__, file)) if self.reload_file(file, is_modified=False): return True def close_file(self, file=None, leave_first_editor=True): """ Closes either given file or current **Script_Editor_tabWidget** Widget tab Model editor file. :param file: File to save. :type file: unicode :param leave_first_editor: Leave first editor. :type leave_first_editor: bool :return: Method success. :rtype: bool """ editor = file and self.get_editor(file) or self.get_current_editor() if not editor: return False file = editor.file LOGGER.info("{0} | Closing '{1}' file!".format( self.__class__.__name__, file)) if not editor.close_file(): return False if self.__model.delete_authoring_nodes(editor): if not self.has_editor_tab() and leave_first_editor: self.new_file() self.file_closed.emit(file) return True # @umbra.engine.encapsulate_processing def close_all_files(self, leave_first_editor=True): """ Closes every opened files and removes their associated **Script_Editor_tabWidget** Widget tabs. :return: Method success. :rtype: bool """ # self.__engine.start_processing("Closing All Files ...", len(self.list_editors())) success = True for file in self.list_files(): success *= True if self.close_file(file, leave_first_editor) else False if not success: break # self.__engine.step_processing() # self.__engine.stop_processing() return success def close_first_file(self): """ Attemtps to close the first **Script_Editor_tabWidget** Widget tab Model editor file. :return: Method success. :rtype: bool """ editor = self.get_current_editor() if len(self.__model.list_editors()) == 1 and editor.is_untitled and not editor.is_modified(): self.close_file(leave_first_editor=False) return True def list_editors(self): """ Returns the Model editors. :return: Editors. :rtype: list """ return self.__model.list_editors() def list_files(self): """ Returns the Model files. :return: FileNode nodes. :rtype: list """ return self.__model.list_files() def list_directories(self): """ Returns the Model directories. :return: DirectoryNode nodes. :rtype: list """ return self.__model.list_directories() def list_projects(self, ignore_default_project=True): """ Returns the Model projects. :return: ProjectNode nodes. :rtype: list """ return self.__model.list_projects() def get_editor(self, file): """ Returns the Model editor associated with given file. :param file: File to search editors for. :type file: unicode :return: Editor. :rtype: Editor """ for editor in self.__model.list_editors(): if editor.file == file: return editor def set_language(self, editor, language): """ Sets given language to given Model editor. :param editor: Editor to set language to. :type editor: Editor :param language: Language to set. :type language: Language :return: Method success. :rtype: bool """ LOGGER.debug("> Setting '{0}' language to '{1}' editor.".format( language.name, editor)) return editor.set_language(language) def go_to_line(self): """ Moves current **Script_Editor_tabWidget** Widget tab Model editor cursor to user defined line. :return: Method success. :rtype: bool :note: May require user interaction. """ editor = self.get_current_editor() if not editor: return False line, state = QInputDialog.getInt( self, "Goto Line Number", "Line number:", min=1) if not state: return False LOGGER.debug("> Chosen line number: '{0}'.".format(line)) return editor.go_to_line(line) def evaluate_selection(self): """ Evaluates current **Script_Editor_tabWidget** Widget tab Model editor selected content in the interactive console. :return: Method success. :rtype: bool """ editor = self.get_current_editor() if not editor: return False LOGGER.debug("> Evaluating 'Script Editor' selected content.") if self.evaluate_code( foundations.strings.to_string(editor.get_selected_text().replace(QChar(QChar.ParagraphSeparator), QString("\n")))): self.ui_refresh.emit() return True def evaluate_script(self): """ Evaluates current **Script_Editor_tabWidget** Widget tab Model editor content into the interactive console. :return: Method success. :rtype: bool """ editor = self.get_current_editor() if not editor: return False LOGGER.debug("> Evaluating 'Script Editor' content.") if self.evaluate_code(foundations.strings.to_string(editor.toPlainText().toUtf8())): self.ui_refresh.emit() return True def evaluate_code(self, code): """ Evaluates given code into the interactive console. :param code: Code to evaluate. :type code: unicode :return: Method success. :rtype: bool """ if not code: return False LOGGER.debug("> Evaluating given code.") code = code.endswith("\n") and code or "{0}\n".format(code) code = code.split("\n", 3) for i, line in enumerate(code[:-2]): if "coding" in line: code[i] = line.replace("=", "\=").replace(":", "\:") break code = "\n".join(code) sys.stdout.write(code) self.__console.runcode(code) return True def store_session(self): """ Stores the current session. :return: Method success. :rtype: bool """ session = [] for editor in self.list_editors(): file = editor.file ignore_file = True if editor.is_untitled and not editor.is_empty(): file = os.path.join(self.__default_session_directory, file) editor.write_file(file) elif os.path.dirname(file) == self.__default_session_directory: editor.save_file() session.append(file) for directory in self.list_projects(): if not os.path.exists(directory): continue session.append(directory) LOGGER.debug("> Storing session :'{0}'.".format(session)) self.__settings.set_key(self.__settings_section, "session", session) return True def restore_session(self): """ Restores the stored session. :return: Method success. :rtype: bool """ session = [foundations.strings.to_string(path) for path in self.__settings.get_key(self.__settings_section, "session").toStringList() if foundations.common.path_exists(path)] LOGGER.debug("> Restoring session :'{0}'.".format(session)) success = True for path in session: if os.path.isfile(path): success *= self.load_file(path) else: success *= self.add_project(path) return success def loop_through_editors(self, backward=False): """ Loops through the editor tabs. :param backward: Looping backward. :type backward: bool :return: Method success. :rtype: bool """ step = not backward and 1 or -1 idx = self.Script_Editor_tabWidget.currentIndex() + step if idx < 0: idx = self.Script_Editor_tabWidget.count() - 1 elif idx > self.Script_Editor_tabWidget.count() - 1: idx = 0 self.Script_Editor_tabWidget.setCurrentIndex(idx) return True def restore_development_layout(self): """ Restores the development layout. :return: Definition success. :rtype: bool """ if self.__engine.layouts_manager.current_layout != self.__development_layout and not self.isVisible(): self.__engine.layouts_manager.restore_layout( self.__development_layout) return True
class ScriptEditor(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): ''' Defines the :mod:`sibl_gui.components.addons.script_editor.script_editor` Component Interface class. ''' def __init__(self, parent=None, name=None, *args, **kwargs): ''' 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: \*\* ''' pass @property def dock_area(self): ''' Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int ''' pass @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int ''' pass @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Deleter for **self.__dock_area** attribute. ''' pass @property def engine(self): ''' Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject ''' pass @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject ''' pass @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Deleter for **self.__engine** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def settings_section(self): ''' Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode ''' pass @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode ''' pass @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Deleter for **self.__settings_section** attribute. ''' pass @property def development_layout(self): ''' Property for **self.__development_layout** attribute. :return: self.__development_layout. :rtype: unicode ''' pass @development_layout.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def development_layout(self): ''' Setter for **self.__development_layout** attribute. :param value: Attribute value. :type value: unicode ''' pass @development_layout.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def development_layout(self): ''' Deleter for **self.__development_layout** attribute. ''' pass @property def grammars_directory(self): ''' Property for **self.__grammars_directory** attribute. :return: self.__grammars_directory. :rtype: unicode ''' pass @grammars_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def grammars_directory(self): ''' Setter for **self.__grammars_directory** attribute. :param value: Attribute value. :type value: unicode ''' pass @grammars_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def grammars_directory(self): ''' Deleter for **self.__grammars_directory** attribute. ''' pass @property def extension(self): ''' Property for **self.__extension** attribute. :return: self.__extension. :rtype: unicode ''' pass @extension.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def extension(self): ''' Setter for **self.__extension** attribute. :param value: Attribute value. :type value: unicode ''' pass @extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def extension(self): ''' Deleter for **self.__extension** attribute. ''' pass @property def model(self): ''' Property for **self.__model** attribute. :return: self.__model. :rtype: ProjectsModel ''' pass @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Setter for **self.__model** attribute. :param value: Attribute value. :type value: ProjectsModel ''' pass @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Deleter for **self.__model** attribute. ''' pass @property def languages_model(self): ''' Property for **self.__languages_model** attribute. :return: self.__languages_model. :rtype: LanguagesModel ''' pass @languages_model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def languages_model(self): ''' Setter for **self.__languages_model** attribute. :param value: Attribute value. :type value: LanguagesModel ''' pass @languages_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def languages_model(self): ''' Deleter for **self.__languages_model** attribute. ''' pass @property def default_project(self): ''' Property for **self.__default_project** attribute. :return: self.__default_project. :rtype: unicode ''' pass @default_project.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project(self): ''' Setter for **self.__default_project** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_project.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project(self): ''' Deleter for **self.__default_project** attribute. ''' pass @property def default_language(self): ''' Property for **self.__default_language** attribute. :return: self.__default_language. :rtype: unicode ''' pass @default_language.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_language(self): ''' Setter for **self.__default_language** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_language(self): ''' Deleter for **self.__default_language** attribute. ''' pass @property def default_script_language(self): ''' Property for **self.__default_script_language** attribute. :return: self.__default_script_language. :rtype: unicode ''' pass @default_script_language.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_language(self): ''' Setter for **self.__default_script_language** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_script_language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_language(self): ''' Deleter for **self.__default_script_language** attribute. ''' pass @property def default_file_name(self): ''' Property for **self.__default_file_name** attribute. :return: self.__default_file_name. :rtype: unicode ''' pass @default_file_name.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self): ''' Setter for **self.__default_file_name** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_file_name.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self): ''' Deleter for **self.__default_file_name** attribute. ''' pass @property def default_file_extension(self): ''' Property for **self.__default_file_extension** attribute. :return: self.__default_file_extension. :rtype: unicode ''' pass @default_file_extension.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self): ''' Setter for **self.__default_file_extension** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_file_extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self): ''' Deleter for **self.__default_file_extension** attribute. ''' pass @property def default_window_title(self): ''' Property for **self.__default_window_title** attribute. :return: self.__default_window_title. :rtype: unicode ''' pass @default_window_title.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_window_title(self): ''' Setter for **self.__default_window_title** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_window_title.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_window_title(self): ''' Deleter for **self.__default_window_title** attribute. ''' pass @property def default_script_editor_directory(self): ''' Property for **self.__default_script_editor_directory** attribute. :return: self.__default_script_editor_directory. :rtype: unicode ''' pass @default_script_editor_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_directory(self): ''' Setter for **self.__default_script_editor_directory** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_script_editor_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_directory(self): ''' Deleter for **self.__default_script_editor_directory** attribute. ''' pass @property def default_session_directory(self): ''' Property for **self.__default_session_directory** attribute. :return: self.__default_session_directory. :rtype: unicode ''' pass @default_session_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_session_directory(self): ''' Setter for **self.__default_session_directory** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_session_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_session_directory(self): ''' Deleter for **self.__default_session_directory** attribute. ''' pass @property def default_script_editor_file(self): ''' Property for **self.__default_script_editor_file** attribute. :return: self.__default_script_editor_file. :rtype: unicode ''' pass @default_script_editor_file.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_file(self): ''' Setter for **self.__default_script_editor_file** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_script_editor_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_script_editor_file(self): ''' Deleter for **self.__default_script_editor_file** attribute. ''' pass @property def factory_default_script_editor_file(self): ''' Property for **self.__factory_default_script_editor_file** attribute. :return: self.__factory_default_script_editor_file. :rtype: unicode ''' pass @factory_default_script_editor_file.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def factory_default_script_editor_file(self): ''' Setter for **self.__factory_default_script_editor_file** attribute. :param value: Attribute value. :type value: unicode ''' pass @factory_default_script_editor_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def factory_default_script_editor_file(self): ''' Deleter for **self.__factory_default_script_editor_file** attribute. ''' pass @property def script_editor_file(self): ''' Property for **self.__script_editor_file** attribute. :return: self.__script_editor_file. :rtype: unicode ''' pass @script_editor_file.setter @foundations.exceptions.handle_exceptions(AssertionError) def script_editor_file(self): ''' Setter for **self.__script_editor_file** attribute. :param value: Attribute value. :type value: unicode ''' pass @script_editor_file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor_file(self): ''' Deleter for **self.__script_editor_file** attribute. ''' pass @property def maximum_recent_files(self): ''' Property for **self.__maximum_recent_files** attribute. :return: self.__maximum_recent_files. :rtype: int ''' pass @maximum_recent_files.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_recent_files(self): ''' Setter for **self.__maximum_recent_files** attribute. :param value: Attribute value. :type value: int ''' pass @maximum_recent_files.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_recent_files(self): ''' Deleter for **self.__maximum_recent_files** attribute. ''' pass @property def recent_files_actions(self): ''' Property for **self.__recent_files_actions** attribute. :return: self.__recent_files_actions. :rtype: list ''' pass @recent_files_actions.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def recent_files_actions(self): ''' Setter for **self.__recent_files_actions** attribute. :param value: Attribute value. :type value: list ''' pass @recent_files_actions.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def recent_files_actions(self): ''' Deleter for **self.__recent_files_actions** attribute. ''' pass @property def search_and_replace(self): ''' Property for **self.__search_and_replace** attribute. :return: self.__search_and_replace. :rtype: SearchAndReplace ''' pass @search_and_replace.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_and_replace(self): ''' Setter for **self.__search_and_replace** attribute. :param value: Attribute value. :type value: SearchAndReplace ''' pass @search_and_replace.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_and_replace(self): ''' Deleter for **self.__search_and_replace** attribute. ''' pass @property def search_in_files(self): ''' Property for **self.__search_in_files** attribute. :return: self.__search_in_files. :rtype: SearchInFiles ''' pass @search_in_files.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_in_files(self): ''' Setter for **self.__search_in_files** attribute. :param value: Attribute value. :type value: SearchInFiles ''' pass @search_in_files.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_in_files(self): ''' Deleter for **self.__search_in_files** attribute. ''' pass @property def indent_width(self): ''' Property for **self.__indent_width** attribute. :return: self.__indent_width. :rtype: int ''' pass @indent_width.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_width(self): ''' Setter for **self.__indent_width** attribute. :param value: Attribute value. :type value: int ''' pass @indent_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_width(self): ''' Deleter for **self.__indent_width** attribute. ''' pass @property def default_fonts_settings(self): ''' Property for **self.__default_fonts_settings** attribute. :return: self.__default_fonts_settings. :rtype: dict ''' pass @default_fonts_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self): ''' Setter for **self.__default_fonts_settings** attribute. :param value: Attribute value. :type value: dict ''' pass @default_fonts_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self): ''' Deleter for **self.__default_fonts_settings** attribute. ''' pass @property def console(self): ''' Property for **self.__console** attribute. :return: self.__console. :rtype: dict ''' pass @console.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def console(self): ''' Setter for **self.__console** attribute. :param value: Attribute value. :type value: dict ''' pass @console.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def console(self): ''' Deleter for **self.__console** attribute. ''' pass @property def memory_handler_stack_depth(self): ''' Property for **self.__memory_handler_stack_depth** attribute. :return: self.__memory_handler_stack_depth. :rtype: int ''' pass @memory_handler_stack_depth.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def memory_handler_stack_depth(self): ''' Setter for **self.__memory_handler_stack_depth** attribute. :param value: Attribute value. :type value: int ''' pass @memory_handler_stack_depth.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def memory_handler_stack_depth(self): ''' Deleter for **self.__memory_handler_stack_depth** attribute. ''' pass @property def menu_bar(self): ''' Property for **self.__menu_bar** attribute. :return: self.__menu_bar. :rtype: QToolbar ''' pass @menu_bar.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu_bar(self): ''' Setter for **self.__menu_bar** attribute. :param value: Attribute value. :type value: QToolbar ''' pass @menu_bar.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu_bar(self): ''' Deleter for **self.__menu_bar** attribute. ''' pass @property def file_menu(self): ''' Property for **self.__file_menu** attribute. :return: self.__file_menu. :rtype: QMenu ''' pass @file_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_menu(self): ''' Setter for **self.__file_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @file_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_menu(self): ''' Deleter for **self.__file_menu** attribute. ''' pass @property def edit_menu(self): ''' Property for **self.__edit_menu** attribute. :return: self.__edit_menu. :rtype: QMenu ''' pass @edit_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def edit_menu(self): ''' Setter for **self.__edit_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @edit_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def edit_menu(self): ''' Deleter for **self.__edit_menu** attribute. ''' pass @property def source_menu(self): ''' Property for **self.__source_menu** attribute. :return: self.__source_menu. :rtype: QMenu ''' pass @source_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def source_menu(self): ''' Setter for **self.__source_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @source_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def source_menu(self): ''' Deleter for **self.__source_menu** attribute. ''' pass @property def navigate_menu(self): ''' Property for **self.__navigate_menu** attribute. :return: self.__navigate_menu. :rtype: QMenu ''' pass @navigate_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def navigate_menu(self): ''' Setter for **self.__navigate_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @navigate_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def navigate_menu(self): ''' Deleter for **self.__navigate_menu** attribute. ''' pass @property def search_menu(self): ''' Property for **self.__search_menu** attribute. :return: self.__search_menu. :rtype: QMenu ''' pass @search_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_menu(self): ''' Setter for **self.__search_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @search_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_menu(self): ''' Deleter for **self.__search_menu** attribute. ''' pass @property def command_menu(self): ''' Property for **self.__command_menu** attribute. :return: self.__command_menu. :rtype: QMenu ''' pass @command_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def command_menu(self): ''' Setter for **self.__command_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @command_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def command_menu(self): ''' Deleter for **self.__command_menu** attribute. ''' pass @property def view_menu(self): ''' Property for **self.__view_menu** attribute. :return: self.__view_menu. :rtype: QMenu ''' pass @view_menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view_menu(self): ''' Setter for **self.__view_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @view_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view_menu(self): ''' Deleter for **self.__view_menu** attribute. ''' pass def activate(self, engine): ''' Activates the Component. :param engine: Container to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize_ui(self): ''' Initializes the Component ui. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def uninitialize_ui(self): ''' Uninitializes the Component ui. :return: Method success. :rtype: bool ''' pass def add_widget(self): ''' Adds the Component Widget to the engine. :return: Method success. :rtype: bool ''' pass def remove_widget(self): ''' Removes the Component Widget from the engine. :return: Method success. :rtype: bool ''' pass def on_startup(self): ''' Defines the slot triggered on Framework startup. ''' pass def on_close(self): ''' Defines the slot triggered on Framework close. ''' pass def __initialize_menu_bar(self): ''' Initializes Component menu_bar. ''' pass @foundations.trace.untracable def __Script_Editor_Output_plainTextEdit_set_ui(self): ''' Sets the **Script_Editor_Output_plainTextEdit** Widget. ''' pass @foundations.trace.untracable def __Script_Editor_Output_plainTextEdit_set_default_view_state(self): ''' Sets the **Script_Editor_Output_plainTextEdit** Widget default View state. ''' pass @foundations.trace.untracable def __Script_Editor_Output_plainTextEdit_refresh_ui(self): ''' Updates the **Script_Editor_Output_plainTextEdit** Widget. ''' pass def __Script_Editor_Output_plainTextEdit_contextMenuEvent(self, event): ''' Reimplements the :meth:`QPlainTextEdit.contextMenuEvent` method. :param event: QEvent. :type event: QEvent ''' pass def __Script_Editor_tabWidget_set_ui(self): ''' Sets the **Script_Editor_tabWidget** Widget. ''' pass def __Script_Editor_tabWidget__tabCloseRequested(self, index): ''' Defines the slot triggered by **Script_Editor_tabWidget** Widget when a tab is requested to be closed. :param index: Tab index. :type index: int ''' pass def __Script_Editor_tabWidget__currentChanged(self, index): ''' Defines the slot triggered by **Script_Editor_tabWidget** Widget when the current tab is changed. :param index: Tab index. :type index: int ''' pass def __Script_Editor_tabWidget__content_dropped(self, event): ''' Defines the slot triggered by content when dropped in the **Script_Editor_tabWidget** Widget. :param event: Event. :type event: QEvent ''' pass def __Script_Editor_tabWidget_tabBar__tabMoved(self, to_index, from_index): ''' Defines the slot triggered by a **Script_Editor_tabWidget** Widget tab when moved. :param to_index: Index to. :type to_index: int :param from_index: Index from. :type from_index: int ''' pass def __engine__content_dropped(self, event): ''' Defines the slot triggered by content when dropped into the engine. :param event: Event. :type event: QEvent ''' pass def __engine_layouts_manager__layout_restored(self, current_layout): ''' Defines the slot triggered by the engine layout when changed. :param current_layout: Current layout. :type current_layout: unicode ''' pass def __engine_file_system_events_manager__file_changed(self, file): ''' Defines the slot triggered by the **file_system_events_manager** when a file is changed. :param file: File changed. :type file: unicode ''' pass def __engine_file_system_events_manager__file_invalidated(self, file): ''' Defines the slot triggered by the **file_system_events_manager** when a file is invalidated. :param file: File changed. :type file: unicode ''' pass def __engine_file_system_events_manager__directory_changed(self, directory): ''' Defines the slot triggered by the **file_system_events_manager** when a directory is changed. :param directory: Directory changed. :type directory: unicode ''' pass def __engine_file_system_events_manager__directory_invalidated(self, directory): ''' Defines the slot triggered by the **file_system_events_manager** when a directory is invalidated. :param directory: Directory invalidated. :type directory: unicode ''' pass def __script_editor__visibilityChanged(self, visibility): ''' Defines the slot triggered by the **script_editor** Component when visibility changed. :param visibility: Widget visibility. :type visibility: bool ''' pass def __new_file_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|&New'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __model__file_registered(self, file_node): ''' Defines the slot triggered by Model when a file is registered. :param file_node: Registered file FileNode. :type file_node: FileNode ''' pass def __model__file_unregistered(self, file_node): ''' Defines the slot triggered by Model when a file is unregistered. :param file_node: Unregistered file FileNode. :type file_node: FileNode ''' pass def __model__directory_registered(self, directory_node): ''' Defines the slot triggered by Model when a directory is registered. :param directory_node: Registered directory DirectoryNode. :type directory_node: DirectoryNode ''' pass def __model__directory_unregistered(self, directory_node): ''' Defines the slot triggered by Model when a directory is unregistered. :param directory_node: Unregistered directory DirectoryNode. :type directory_node: DirectoryNode ''' pass def __model__project_registered(self, project_node): ''' Defines the slot triggered by Model when a project is registered. :param project_node: Registered project ProjectNode. :type project_node: ProjectNode ''' pass def __model__project_unregistered(self, project_node): ''' Defines the slot triggered by Model when a project is unregistered. :param project_node: Unregistered project ProjectNode. :type project_node: ProjectNode ''' pass def __model__editor_registered(self, editor_node): ''' Defines the slot triggered by Model when an editor is registered. :param editor_node: Registered editor EditorNode. :type editor_node: EditorNode ''' pass def __model__editor_unregistered(self, editor_node): ''' Defines the slot triggered by Model when an editor is unregistered. :param editor_node: Unregistered editor EditorNode. :type editor_node: EditorNode ''' pass def __load_file_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|&Load ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __source_file_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Source ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __add_project_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Add Project ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __save_file_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|&Save'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __save_file_as_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Save As ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __save_all_files_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Save All'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __revert_file_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Revert'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __close_file_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Close ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __close_all_files_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&File|Close All ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __load_recent_file__triggered(self, checked): ''' Defines the slot triggered by any recent file related action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __undo_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Undo'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __redo_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Redo'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __cut_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|Cu&t'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __copy_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Copy'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __paste_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|&Paste'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __delete_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|Delete'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __select_all_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Edit|Select All'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __delete_lines_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Delete Line(s)'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __duplicate_lines_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Duplicate Line(s)'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __move_up_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Move Up'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __move_down_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Move Down'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __indent_selection_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Indent Selection'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __unindent_selection_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Unindent Selection'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __convert_indentation_to_tabs_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Convert Identation To Tabs'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __convert_indentation_to_spaces_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Convert Identation To Spaces'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __remove_trailing_white_spaces_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Remove Trailing WhiteSpaces'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __toggle_comments_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Source|Toggle Comments'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __go_to_line_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Navigate|Goto Line ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __search_and_replace_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search And Replace ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __search_in_files_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search In Files ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __search_next_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search Next'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __search_previous_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Search|Search Previous'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __evaluate_selection_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Command|&Evaluate Selection'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __evaluate_script_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&Command|Evaluate &Script'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __increase_font_size_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Increase Font Size'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __decrease_font_size_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Decrease Font Size'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __toggle_word_wrap_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Toggle Word Wrap'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __toggle_white_spaces_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Toggle White Spaces'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __loop_through_editors_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|&View|Loop Through Editors'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __edit_selected_path_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.script_editor|Edit Selected Path'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __editor__patterns_replaced(self, patterns): ''' Defines the slot triggered by an editor when patterns have been replaced. ''' pass def __editor__title_changed(self): ''' Defines the slot triggered by an editor when title is changed. ''' pass def __editor__file_loaded(self): ''' Defines the slot triggered by an editor when file is loaded. ''' pass def __editor__file_saved(self): ''' Defines the slot triggered by an editor when file is saved. ''' pass def __editor__language_changed(self): ''' Defines the slot triggered by an editor when language is changed. ''' pass def __editor__modification_changed(self, changed): ''' Defines the slot triggered by an editor when document is modified. :param changed: File modification state. :type changed: bool ''' pass def __initialize_languages_model(self): ''' Initializes the languages Model. ''' pass @umbra.engine.encapsulate_processing def __handle_dropped_content(self, event): ''' Handles dopped content event. :param event: Content dropped event. :type event: QEvent ''' pass def __get_supported_file_types_string(self): ''' Returns the supported file types dialog string. ''' pass def __set_recent_files_actions(self): ''' Sets the recent files actions. ''' pass def __store_recent_file(self, file): ''' Stores given recent file into the settings. :param file: File to store. :type file: unicode ''' pass def __set_window_title(self): ''' Sets the Component window title. ''' pass def __set_tab_title(self, index): ''' Sets the name and toolTip of the **Script_Editor_tabWidget** Widget tab with given index. :param index: Index of the tab containing the Model editor. :type index: int ''' pass def __has_editor_lock(self, editor): ''' Returns if given editor has a lock. :param editor: Editor. :type editor: Editor :return: Has editor lock. :rtype: bool ''' pass def __lock_editor(self, editor): ''' Locks given editor. :param editor: Editor. :type editor: Editor ''' pass def __unlock_editor(self, editor): ''' Locks given editor. :param editor: Editor. :type editor: Editor ''' pass def __get_untitled_file_name(self): ''' Returns an untitled file name. :return: Untitled file name. :rtype: unicode ''' pass def register_file(self, file): ''' Registers given file in the **file_system_events_manager**. :param file: File. :type file: unicode :return: Method success. :rtype: bool ''' pass def unregister_file(self, file): ''' Unregisters given file in the **file_system_events_manager**. :param file: File. :type file: unicode :return: Method success. :rtype: bool ''' pass def register_node_path(self, node): ''' Registers given Node path in the **file_system_events_manager**. :param node: Node. :type node: FileNode or DirectoryNode or ProjectNode :return: Method success. :rtype: bool ''' pass def unregister_node_path(self, node): ''' Unregisters given Node path from the **file_system_events_manager**. :param node: Node. :type node: FileNode or DirectoryNode or ProjectNode :return: Method success. :rtype: bool ''' pass def load_file_ui(self): ''' Loads user chosen file(s) into **Script_Editor_tabWidget** Widget tab Model editor(s). :return: Method success. :rtype: bool :note: May require user interaction. ''' pass def add_project_ui(self): ''' Adds user chosen project **Script_Editor_tabWidget** Widget tab Model. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass def search_and_replace_ui(self): ''' Performs a search and replace in the current **Script_Editor_tabWidget** Widget tab Model editor. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass def search_in_files_ui(self): ''' Performs a search in the current user chosen files. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass def get_widget(self, index): ''' Returns the **Script_Editor_tabWidget** Widget associated with given index. :param index: Tab index. :type index: int :return: Widget. :rtype: QWidget ''' pass def get_focus_widget(self): ''' Returns the Widget with focus. :return: Widget with focus. :rtype: QWidget ''' pass def get_editorTab(self, editor): ''' Returns the **Script_Editor_tabWidget** Widget tab associated with the given editor. :param editor: Editor to search tab for. :type editor: Editor :return: Tab index. :rtype: Editor ''' pass def add_editor_tab(self, editor): ''' Adds a new tab to the **Script_Editor_tabWidget** Widget and sets the given editor as child widget. :param editor: Editor. :type editor: Editor :return: New tab index. :rtype: int ''' pass def remove_editor_tab(self, editor): ''' Removes the **Script_Editor_tabWidget** Widget tab with given editor. :param editor: Editor. :type editor: Editor :return: Method success. :rtype: bool ''' pass def find_editor_tab(self, file): ''' Finds the **Script_Editor_tabWidget** Widget tab associated to the given file. :param file: File to search tab for. :type file: unicode :return: Tab index. :rtype: Editor ''' pass def has_editor_tab(self): ''' Returns if the **Script_Editor_tabWidget** Widget has at least one tab. :return: Has tab. :rtype: bool ''' pass def get_current_editor(self): ''' Returns the current **Script_Editor_tabWidget** Widget tab Model editor. :return: Current editor. :rtype: Editor ''' pass def set_current_editor(self, file): ''' Focus the **Script_Editor_tabWidget** Widget tab Model editor with given file. :param file: File. :type file: unicode :return: Method success. :rtype: bool ''' pass def load_path(self, path): ''' Loads given path. :param path: Path to load. :type path: unicode :return: Method success. :rtype: bool ''' pass def load_document(self, document, file): ''' Loads given document into a new **Script_Editor_tabWidget** Widget tab Model editor. :param document: Document to load. :type document: QTextDocument :param file: Document file. :type file: unicode :return: Method success. :rtype: bool ''' pass def add_project_ui(self): ''' Adds a project. :param path: Project path. :type path: unicode :return: Method success. :rtype: bool ''' pass def remove_project(self, path): ''' Removes a project. :param path: Project path. :type path: unicode :return: Method success. :rtype: bool ''' pass def new_file(self): ''' Creates a new file into a new **Script_Editor_tabWidget** Widget tab. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def load_file_ui(self): ''' Loads user chosen file in a new **Script_Editor_tabWidget** Widget tab Model editor. :param file: File to load. :type file: unicode :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def reload_file(self, file, is_modified=True): ''' Reloads given file **Script_Editor_tabWidget** Widget tab Model editor content. :param file: File to reload. :type file: unicode :param is_modified: File modified state. :type is_modified: bool :return: Method success. :rtype: bool ''' pass def save_file(self, file=None): ''' Saves either given file or current **Script_Editor_tabWidget** Widget tab Model editor file. :param file: File to save. :type file: unicode :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.UserError) def save_fileAs(self): ''' Saves current **Script_Editor_tabWidget** Widget tab Model editor file as user chosen file. :return: Method success. :rtype: bool ''' pass @umbra.engine.encapsulate_processing def save_all_files(self): ''' Saves all **Script_Editor_tabWidget** Widget tab Model editor files. :return: Method success. :rtype: bool ''' pass @umbra.engine.encapsulate_processing def revert_file(self, file=None): ''' Reverts either given file or current **Script_Editor_tabWidget** Widget tab Model editor file. :param file: File to revert. :type file: unicode :return: Method success. :rtype: bool ''' pass def close_file(self, file=None, leave_first_editor=True): ''' Closes either given file or current **Script_Editor_tabWidget** Widget tab Model editor file. :param file: File to save. :type file: unicode :param leave_first_editor: Leave first editor. :type leave_first_editor: bool :return: Method success. :rtype: bool ''' pass def close_all_files(self, leave_first_editor=True): ''' Closes every opened files and removes their associated **Script_Editor_tabWidget** Widget tabs. :return: Method success. :rtype: bool ''' pass def close_first_file(self): ''' Attemtps to close the first **Script_Editor_tabWidget** Widget tab Model editor file. :return: Method success. :rtype: bool ''' pass def list_editors(self): ''' Returns the Model editors. :return: Editors. :rtype: list ''' pass def list_files(self): ''' Returns the Model files. :return: FileNode nodes. :rtype: list ''' pass def list_directories(self): ''' Returns the Model directories. :return: DirectoryNode nodes. :rtype: list ''' pass def list_projects(self, ignore_default_project=True): ''' Returns the Model projects. :return: ProjectNode nodes. :rtype: list ''' pass def get_editorTab(self, editor): ''' Returns the Model editor associated with given file. :param file: File to search editors for. :type file: unicode :return: Editor. :rtype: Editor ''' pass def set_language(self, editor, language): ''' Sets given language to given Model editor. :param editor: Editor to set language to. :type editor: Editor :param language: Language to set. :type language: Language :return: Method success. :rtype: bool ''' pass def go_to_line(self): ''' Moves current **Script_Editor_tabWidget** Widget tab Model editor cursor to user defined line. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass def evaluate_selection(self): ''' Evaluates current **Script_Editor_tabWidget** Widget tab Model editor selected content in the interactive console. :return: Method success. :rtype: bool ''' pass def evaluate_script(self): ''' Evaluates current **Script_Editor_tabWidget** Widget tab Model editor content into the interactive console. :return: Method success. :rtype: bool ''' pass def evaluate_code(self, code): ''' Evaluates given code into the interactive console. :param code: Code to evaluate. :type code: unicode :return: Method success. :rtype: bool ''' pass def store_session(self): ''' Stores the current session. :return: Method success. :rtype: bool ''' pass def restore_session(self): ''' Restores the stored session. :return: Method success. :rtype: bool ''' pass def loop_through_editors(self, backward=False): ''' Loops through the editor tabs. :param backward: Looping backward. :type backward: bool :return: Method success. :rtype: bool ''' pass def restore_development_layout(self): ''' Restores the development layout. :return: Definition success. :rtype: bool ''' pass
437
246
13
2
6
5
2
0.84
1
19
12
0
245
42
245
245
3,712
838
1,563
513
1,125
1,311
1,118
393
872
7
1
4
389
142,483
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/highlighters.py
umbra.ui.highlighters.FormatsTree
class FormatsTree(object): """ Defines the formats tree object representing higlighters theme. """ def __init__(self, theme=None): """ Initializes the class. :param theme: Theme. :type theme: dict """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) # --- Setting class attributes. --- self.__root_node = DefaultNode("Formats Tree") self._FormatsTree__initialize_tree(theme or DEFAULT_THEME) @property def root_node(self): """ Property for **self.__root_node** attribute. :return: self.__root_node. :rtype: AbstractCompositeNode """ return self.__root_node @root_node.setter @foundations.exceptions.handle_exceptions(AssertionError) def root_node(self, value): """ Setter for **self.__root_node** attribute. :param value: Attribute value. :type value: AbstractCompositeNode """ if value is not None: assert issubclass(value.__class__, AbstractCompositeNode), \ "'{0}' attribute: '{1}' is not a '{2}' subclass!".format( "root_node", value, AbstractCompositeNode.__name__) self.__root_node = value @root_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def root_node(self): """ Deleter for **self.__root_node** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".root_node(self.__class__.__name__, "root_node")) def __initialize_tree(self, theme): """ Initializes the object formats tree. :param theme: Theme. :type theme: dict """ for item in sorted(theme): current_node = self.__root_node for format in item.split("."): nodes = [ node for node in current_node.children if node.name == format] format_node = foundations.common.get_first_item(nodes) if not format_node: format_node = FormatNode(format, format=theme[item]) current_node.add_child(format_node) current_node = format_node def list_formats(self, node, path=(), formats=None): """ Lists the object formats in sorted order. :param node: Root node to start listing the formats from. :type node: AbstractCompositeNode :param path: Walked paths. :type path: tuple :param formats: Formats. :type formats: list :return: Formats. :rtype: list """ if formats == None: formats = [] for child in node.children: self.list_formats(child, path + (child.name,), formats) path and formats.append(".".join(path)) return sorted(formats) @foundations.decorators.memoize(None) def get_format(self, name): """ Returns the closest format or closest parent format associated to given name. :param name: Format name. :type name: unicode :return: Format. :rtype: QTextCharFormat """ formats = [format for format in self.list_formats( self.__root_node) if format in name] if not formats: return QTextCharFormat() name = max(formats) format = None current_node = self.__root_node for selector in name.split("."): nodes = [ node for node in current_node.children if node.name == selector] format_node = nodes and nodes[0] or None if not format_node: break current_node = format_node if not format_node.format: continue format = format_node.format return format
class FormatsTree(object): ''' Defines the formats tree object representing higlighters theme. ''' def __init__(self, theme=None): ''' Initializes the class. :param theme: Theme. :type theme: dict ''' pass @property def root_node(self): ''' Property for **self.__root_node** attribute. :return: self.__root_node. :rtype: AbstractCompositeNode ''' pass @root_node.setter @foundations.exceptions.handle_exceptions(AssertionError) def root_node(self): ''' Setter for **self.__root_node** attribute. :param value: Attribute value. :type value: AbstractCompositeNode ''' pass @root_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def root_node(self): ''' Deleter for **self.__root_node** attribute. ''' pass def __initialize_tree(self, theme): ''' Initializes the object formats tree. :param theme: Theme. :type theme: dict ''' pass def list_formats(self, node, path=(), formats=None): ''' Lists the object formats in sorted order. :param node: Root node to start listing the formats from. :type node: AbstractCompositeNode :param path: Walked paths. :type path: tuple :param formats: Formats. :type formats: list :return: Formats. :rtype: list ''' pass @foundations.decorators.memoize(None) def get_format(self, name): ''' Returns the closest format or closest parent format associated to given name. :param name: Format name. :type name: unicode :return: Format. :rtype: QTextCharFormat ''' pass
14
8
16
3
7
6
2
0.8
1
2
2
0
7
1
7
7
129
28
56
24
42
45
47
20
39
5
1
3
17
142,484
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.ProjectNode
class ProjectNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **Project** node. """ __family = "Project" def __init__(self, path=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param path: Project path. :type path: unicode :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__( self, name, parent, children, roles, node_flags, **kwargs) # --- Setting class attributes. --- self.__path = None self.path = path ProjectNode.__initialize_node(self, attributes_flags) @property def path(self): """ Property for **self.__path** attribute. :return: self.__path. :rtype: unicode """ return self.__path @path.setter @foundations.exceptions.handle_exceptions(AssertionError) def path(self, value): """ Setter for **self.__path** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "path", value) assert os.path.exists( value), "'{0}' attribute: '{1}' path doesn't exists!".format("source", value) self.__path = value @path.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def path(self): """ Deleter for **self.__path** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "path")) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class ProjectNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **Project** node. ''' def __init__(self, path=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param path: Project path. :type path: unicode :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def path(self): ''' Property for **self.__path** attribute. :return: self.__path. :rtype: unicode ''' pass @path.setter @foundations.exceptions.handle_exceptions(AssertionError) def path(self): ''' Setter for **self.__path** attribute. :param value: Attribute value. :type value: unicode ''' pass @path.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def path(self): ''' Deleter for **self.__path** attribute. ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
11
6
15
2
5
8
1
1.27
1
2
0
0
5
1
5
18
93
18
33
19
14
42
19
8
13
2
3
1
6
142,485
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/models.py
umbra.ui.models.GraphModel
class GraphModel(QAbstractItemModel): """ | Defines a `QAbstractItemModel <http://doc.qt.nokia.com/qabstractitemmodel.html>`_ subclass providing a graph model. | The Model provided by this object is very generic and abstract making it compatible with major Qt Views ( `QListView <http://doc.qt.nokia.com/qlistview.html>`_, `QTreeView <http://doc.qt.nokia.com/QTreeView.html>`_, `QTableView <http://doc.qt.nokia.com/qtableview.html>`_, `QComboBox <http://doc.qt.nokia.com/qcombobox.html>`_ ). """ __models_instances = weakref.WeakValueDictionary() """ :param __models_instances: Models instances. :type __models_instances: dict """ def __new__(cls, *args, **kwargs): """ Constructor of the class. :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Class instance. :rtype: AbstractNode """ instance = super(GraphModel, cls).__new__(cls) GraphModel._GraphModel__models_instances[id(instance)] = instance return instance def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param root_node: Root node. :type root_node: AbstractCompositeNode or GraphModelNode :param horizontal_headers: Headers. :type horizontal_headers: OrderedDict :param vertical_headers: Headers. :type vertical_headers: OrderedDict :param default_node: Default node. :type default_node: AbstractCompositeNode or GraphModelNode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QAbstractItemModel.__init__(self, parent) # --- Setting class attributes. --- self.__root_node = None self.root_node = root_node or umbra.ui.nodes.DefaultNode( name="InvisibleRootNode") self.__horizontal_headers = None self.horizontal_headers = horizontal_headers or OrderedDict( [("Graph Model", "graphModel")]) self.__vertical_headers = None self.vertical_headers = vertical_headers or OrderedDict() self.__default_node = None self.default_node = default_node or umbra.ui.nodes.GraphModelNode @property def root_node(self): """ Property for **self.__root_node** attribute. :return: self.__root_node. :rtype: AbstractCompositeNode or GraphModelNode """ return self.__root_node @root_node.setter @foundations.exceptions.handle_exceptions(AssertionError) def root_node(self, value): """ Setter for **self.__root_node** attribute. :param value: Attribute value. :type value: AbstractCompositeNode or GraphModelNode """ if value is not None: assert issubclass(value.__class__, AbstractCompositeNode), \ "'{0}' attribute: '{1}' is not a '{2}' subclass!".format( "root_node", value, AbstractCompositeNode.__name__) self.__root_node = value @root_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def root_node(self): """ Deleter for **self.__root_node** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "root_node")) @property def horizontal_headers(self): """ Property for **self.__horizontal_headers** attribute. :return: self.__horizontal_headers. :rtype: OrderedDict """ return self.__horizontal_headers @horizontal_headers.setter @foundations.exceptions.handle_exceptions(AssertionError) def horizontal_headers(self, value): """ Setter for **self.__horizontal_headers** attribute. :param value: Attribute value. :type value: OrderedDict """ if value is not None: assert type(value) is OrderedDict, "'{0}' attribute: '{1}' type is not 'OrderedDict'!".format( "horizontal_headers", value) self.__horizontal_headers = value @horizontal_headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def horizontal_headers(self): """ Deleter for **self.__horizontal_headers** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "horizontal_headers")) @property def vertical_headers(self): """ Property for **self.__vertical_headers** attribute. :return: self.__vertical_headers. :rtype: OrderedDict """ return self.__vertical_headers @vertical_headers.setter @foundations.exceptions.handle_exceptions(AssertionError) def vertical_headers(self, value): """ Setter for **self.__vertical_headers** attribute. :param value: Attribute value. :type value: OrderedDict """ if value is not None: assert type(value) is OrderedDict, "'{0}' attribute: '{1}' type is not 'OrderedDict'!".format( "vertical_headers", value) self.__vertical_headers = value @vertical_headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def vertical_headers(self): """ Deleter for **self.__vertical_headers** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "vertical_headers")) @property def default_node(self): """ Property for **self.__default_node** attribute. :return: self.__default_node. :rtype: AbstractCompositeNode or GraphModelNode """ return self.__default_node @default_node.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_node(self, value): """ Setter for **self.__default_node** attribute. :param value: Attribute value. :type value: AbstractCompositeNode or GraphModelNode """ if value is not None: assert issubclass(value, AbstractCompositeNode), \ "'{0}' attribute: '{1}' is not a '{2}' subclass!".format( "default_node", value, AbstractCompositeNode.__name__) self.__default_node = value @default_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_node(self): """ Deleter for **self.__default_node** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_node")) def rowCount(self, parent=QModelIndex()): """ Reimplements the :meth:`QAbstractItemModel.rowCount` method. :param parent: Parent node. :type parent: AbstractCompositeNode or GraphModelNode :return: Row count. :rtype: int """ if not parent.isValid(): parent_node = self.__root_node else: parent_node = parent.internalPointer() return parent_node.children_count() def columnCount(self, parent=QModelIndex()): """ Reimplements the :meth:`QAbstractItemModel.columnCount` method. :param parent: Parent node. :type parent: AbstractCompositeNode or GraphModelNode :return: Column count. :rtype: int """ return len(self.__horizontal_headers) def data(self, index, role=Qt.DisplayRole): """ Reimplements the :meth:`QAbstractItemModel.data` method. :param index: Index. :type index: QModelIndex :param role: Role. :type role: int :return: Data. :rtype: QVariant """ if not index.isValid(): return QVariant() node = self.get_node(index) if index.column() == 0: if hasattr(node, "roles"): if role == Qt.DecorationRole: return QIcon(node.roles.get(role, "")) else: return node.roles.get(role, QVariant()) else: attribute = self.get_attribute(node, index.column()) if attribute: if hasattr(attribute, "roles"): if role == Qt.DecorationRole: return QIcon(attribute.roles.get(role, "")) else: return attribute.roles.get(role, QVariant()) return QVariant() def setData(self, index, value, role=Qt.EditRole): """ Reimplements the :meth:`QAbstractItemModel.setData` method. :param index: Index. :type index: QModelIndex :param value: Value. :type value: QVariant :param role: Role. :type role: int :return: Method success. :rtype: bool """ if not index.isValid(): return False node = self.get_node(index) if role == Qt.DisplayRole or role == Qt.EditRole: value = foundations.strings.to_string(value.toString()) roles = {Qt.DisplayRole: value, Qt.EditRole: value} else: roles = {role: value} if index.column() == 0: if (node and hasattr(node, "roles")): node.roles.update(roles) node.name = value else: attribute = self.get_attribute(node, index.column()) if (attribute and hasattr(attribute, "roles")): attribute.roles.update(roles) attribute.value = value self.dataChanged.emit(index, index) return True def headerData(self, section, orientation, role=Qt.DisplayRole): """ Reimplements the :meth:`QAbstractItemModel.headerData` method. :param section: Section. :type section: int :param orientation: Orientation. ( Qt.Orientation ) :param role: Role. :type role: int :return: Header data. :rtype: QVariant """ if role == Qt.DisplayRole: if orientation == Qt.Horizontal: if section < len(self.__horizontal_headers): return self.__horizontal_headers.keys()[section] elif orientation == Qt.Vertical: if section < len(self.__vertical_headers): return self.__vertical_headers.keys()[section] return QVariant() def flags(self, index): """ Reimplements the :meth:`QAbstractItemModel.flags` method. :param index: Index. :type index: QModelIndex :return: Flags. ( Qt.ItemFlags ) """ if not index.isValid(): return Qt.NoItemFlags node = self.get_node(index) if index.column() == 0: return hasattr(node, "flags") and Qt.ItemFlags(node.flags) or Qt.NoItemFlags else: attribute = self.get_attribute(node, index.column()) return attribute and hasattr(attribute, "flags") and Qt.ItemFlags(attribute.flags) or Qt.NoItemFlags def parent(self, index): """ Reimplements the :meth:`QAbstractItemModel.parent` method. :param index: Index. :type index: QModelIndex :return: Parent. :rtype: QModelIndex """ if not index.isValid(): return QModelIndex() node = self.get_node(index) parent_node = node.parent if not parent_node: return QModelIndex() if parent_node == self.__root_node: return QModelIndex() row = parent_node.row() return self.createIndex(row, 0, parent_node) if row is not None else QModelIndex() def index(self, row, column=0, parent=QModelIndex()): """ Reimplements the :meth:`QAbstractItemModel.index` method. :param row: Row. :type row: int :param column: Column. :type column: int :param parent: Parent. :type parent: QModelIndex :return: Index. :rtype: QModelIndex """ parent_node = self.get_node(parent) child = parent_node.child(row) if child: return self.createIndex(row, column, child) else: return QModelIndex() def sort(self, column, order=Qt.AscendingOrder): """ Reimplements the :meth:`QAbstractItemModel.sort` method. :param column: Column. :type column: int :param order: Order. ( Qt.SortOrder ) """ if column > self.columnCount(): return self.beginResetModel() if column == 0: self.__root_node.sort_children(reverse_order=order) else: self.__root_node.sort_children( attribute=self.__horizontal_headers[self.__horizontal_headers.keys()[ column]], reverse_order=order) self.endResetModel() def insertRows(self, row, count, parent=QModelIndex()): """ Reimplements the :meth:`QAbstractItemModel.insertRows` method. :param row: Row. :type row: int :param count: Count. :type count: int :param parent: Parent. :type parent: QModelIndex :return: Method success. :rtype: bool """ parent_node = self.get_node(parent) self.beginInsertRows(parent, row, row + count - 1) success = True for i in range(count): childNode = self.__default_node() success *= True if parent_node.insert_child( childNode, row) else False self.endInsertRows() return success def removeRows(self, row, count, parent=QModelIndex()): """ Reimplements the :meth:`QAbstractItemModel.removeRows` method. :param row: Row. :type row: int :param count: Count. :type count: int :param parent: Parent. :type parent: QModelIndex :return: Method success. :rtype: bool """ parent_node = self.get_node(parent) self.beginRemoveRows(parent, row, row + count - 1) success = True for i in range(count): success *= True if parent_node.remove_child(row) else False self.endRemoveRows() return success def movesRows(self, from_parent, from_first_row, from_last_row, to_parent, to_row): """ Moves given rows from parent to parent row. """ return True def mimeTypes(self): """ Reimplements the :meth:`QAbstractItemModel.mimeTypes` method. :return: Mime types. :rtype: QStringList """ types = QStringList() types.append("application/x-umbragraphmodeldatalist") return types def mimeData(self, indexes): """ Reimplements the :meth:`QAbstractItemModel.mimeData` method. :param indexes: Indexes. :type indexes: QModelIndexList :return: MimeData. :rtype: QMimeData """ byte_stream = pickle.dumps([self.get_node(index) for index in indexes], pickle.HIGHEST_PROTOCOL) mime_data = QMimeData() mime_data.setData("application/x-umbragraphmodeldatalist", byte_stream) return mime_data def clear(self): """ Clears the Model. :return: Method success. :rtype: bool """ self.beginResetModel() self.root_node.children = [] self.endResetModel() def has_nodes(self): """ Returns if Model has nodes. :return: Has children. :rtype: bool """ return True if self.__root_node.children else False def get_node(self, index): """ Returns the Node at given index. :param index: Index. :type index: QModelIndex :return: Node. :rtype: AbstractCompositeNode or GraphModelNode """ if not index.isValid(): return self.__root_node return index.internalPointer() or self.__root_node def get_attribute(self, node, column): """ Returns the given Node attribute associated to the given column. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :param column: Column. :type column: int :return: Attribute. :rtype: Attribute """ if column > 0 and column < len(self.__horizontal_headers): return node.get(self.__horizontal_headers[self.__horizontal_headers.keys()[column]], None) def get_node_index(self, node): """ Returns given Node index. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :return: Index. :rtype: QModelIndex """ if node == self.__root_node: return QModelIndex() else: row = node.row() return self.createIndex(row, 0, node) if row is not None else QModelIndex() def get_attribute_index(self, node, column): """ Returns given Node attribute index at given column. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :param column: Attribute column. :type column: int :return: Index. :rtype: QModelIndex """ if column > 0 and column < len(self.__horizontal_headers): row = node.row() return self.createIndex(row, column, node) if row is not None else QModelIndex() def find_children(self, pattern=".*", flags=0): """ Finds the children matching the given patten. :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :return: Matching children. :rtype: list """ return self.__root_node.find_children(pattern, flags) def find_family(self, pattern=r".*", flags=0, node=None): """ Returns the Nodes from given family. :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :param node: Node to start walking from. :type node: AbstractNode or AbstractCompositeNode or GraphModelNode :return: Family nodes. :rtype: list """ return self.__root_node.find_family(pattern, flags, node or self.__root_node) # @foundations.decorators.memoize(cache=None) def find_node(self, attribute): """ Returns the Node with given attribute. :param attribute: Attribute. :type attribute: GraphModelAttribute :return: Node. :rtype: GraphModelNode """ for model in GraphModel._GraphModel__models_instances.itervalues(): for node in foundations.walkers.nodes_walker(model.root_node): if attribute in node.get_attributes(): return node @staticmethod # @foundations.decorators.memoize(cache=None) def find_model(object): """ Returns the model(s) associated with given object. :param object: Node / Attribute. :type object: GraphModelNode or GraphModelAttribute :return: Model(s). :rtype: list """ models = [] for model in GraphModel._GraphModel__models_instances.itervalues(): for node in foundations.walkers.nodes_walker(model.root_node): if node is object: models.append(model) for attribute in node.get_attributes(): if attribute is object: models.append(model) return models def enable_model_triggers(self, state): """ Enables Model Nodes and attributes triggers. :param state: Inform model state. :type state: bool :return: Method success. :rtype: bool """ for node in foundations.walkers.nodes_walker(self.root_node): node.trigger_model = state for attribute in node.get_attributes(): attribute.trigger_model = state def node_changed(self, node): """ Calls :meth:`QAbstractItemModel.dataChanged` with given Node index. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :return: Method success. :rtype: bool """ index = self.get_node_index(node) if index is not None: self.dataChanged.emit(index, index) return True else: return False def attribute_changed(self, node, column): """ Calls :meth:`QAbstractItemModel.dataChanged` with given Node attribute index. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :param column: Attribute column. :type column: int :return: Method success. :rtype: bool """ index = self.get_attribute_index(node, column) if index is not None: self.dataChanged.emit(index, index) return True else: return False
class GraphModel(QAbstractItemModel): ''' | Defines a `QAbstractItemModel <http://doc.qt.nokia.com/qabstractitemmodel.html>`_ subclass providing a graph model. | The Model provided by this object is very generic and abstract making it compatible with major Qt Views ( `QListView <http://doc.qt.nokia.com/qlistview.html>`_, `QTreeView <http://doc.qt.nokia.com/QTreeView.html>`_, `QTableView <http://doc.qt.nokia.com/qtableview.html>`_, `QComboBox <http://doc.qt.nokia.com/qcombobox.html>`_ ). ''' def __new__(cls, *args, **kwargs): ''' Constructor of the class. :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* :return: Class instance. :rtype: AbstractNode ''' pass def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param root_node: Root node. :type root_node: AbstractCompositeNode or GraphModelNode :param horizontal_headers: Headers. :type horizontal_headers: OrderedDict :param vertical_headers: Headers. :type vertical_headers: OrderedDict :param default_node: Default node. :type default_node: AbstractCompositeNode or GraphModelNode ''' pass @property def root_node(self): ''' Property for **self.__root_node** attribute. :return: self.__root_node. :rtype: AbstractCompositeNode or GraphModelNode ''' pass @root_node.setter @foundations.exceptions.handle_exceptions(AssertionError) def root_node(self): ''' Setter for **self.__root_node** attribute. :param value: Attribute value. :type value: AbstractCompositeNode or GraphModelNode ''' pass @root_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def root_node(self): ''' Deleter for **self.__root_node** attribute. ''' pass @property def horizontal_headers(self): ''' Property for **self.__horizontal_headers** attribute. :return: self.__horizontal_headers. :rtype: OrderedDict ''' pass @horizontal_headers.setter @foundations.exceptions.handle_exceptions(AssertionError) def horizontal_headers(self): ''' Setter for **self.__horizontal_headers** attribute. :param value: Attribute value. :type value: OrderedDict ''' pass @horizontal_headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def horizontal_headers(self): ''' Deleter for **self.__horizontal_headers** attribute. ''' pass @property def vertical_headers(self): ''' Property for **self.__vertical_headers** attribute. :return: self.__vertical_headers. :rtype: OrderedDict ''' pass @vertical_headers.setter @foundations.exceptions.handle_exceptions(AssertionError) def vertical_headers(self): ''' Setter for **self.__vertical_headers** attribute. :param value: Attribute value. :type value: OrderedDict ''' pass @vertical_headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def vertical_headers(self): ''' Deleter for **self.__vertical_headers** attribute. ''' pass @property def default_node(self): ''' Property for **self.__default_node** attribute. :return: self.__default_node. :rtype: AbstractCompositeNode or GraphModelNode ''' pass @default_node.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_node(self): ''' Setter for **self.__default_node** attribute. :param value: Attribute value. :type value: AbstractCompositeNode or GraphModelNode ''' pass @default_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_node(self): ''' Deleter for **self.__default_node** attribute. ''' pass def rowCount(self, parent=QModelIndex()): ''' Reimplements the :meth:`QAbstractItemModel.rowCount` method. :param parent: Parent node. :type parent: AbstractCompositeNode or GraphModelNode :return: Row count. :rtype: int ''' pass def columnCount(self, parent=QModelIndex()): ''' Reimplements the :meth:`QAbstractItemModel.columnCount` method. :param parent: Parent node. :type parent: AbstractCompositeNode or GraphModelNode :return: Column count. :rtype: int ''' pass def data(self, index, role=Qt.DisplayRole): ''' Reimplements the :meth:`QAbstractItemModel.data` method. :param index: Index. :type index: QModelIndex :param role: Role. :type role: int :return: Data. :rtype: QVariant ''' pass def setData(self, index, value, role=Qt.EditRole): ''' Reimplements the :meth:`QAbstractItemModel.setData` method. :param index: Index. :type index: QModelIndex :param value: Value. :type value: QVariant :param role: Role. :type role: int :return: Method success. :rtype: bool ''' pass def headerData(self, section, orientation, role=Qt.DisplayRole): ''' Reimplements the :meth:`QAbstractItemModel.headerData` method. :param section: Section. :type section: int :param orientation: Orientation. ( Qt.Orientation ) :param role: Role. :type role: int :return: Header data. :rtype: QVariant ''' pass def flags(self, index): ''' Reimplements the :meth:`QAbstractItemModel.flags` method. :param index: Index. :type index: QModelIndex :return: Flags. ( Qt.ItemFlags ) ''' pass def parent(self, index): ''' Reimplements the :meth:`QAbstractItemModel.parent` method. :param index: Index. :type index: QModelIndex :return: Parent. :rtype: QModelIndex ''' pass def index(self, row, column=0, parent=QModelIndex()): ''' Reimplements the :meth:`QAbstractItemModel.index` method. :param row: Row. :type row: int :param column: Column. :type column: int :param parent: Parent. :type parent: QModelIndex :return: Index. :rtype: QModelIndex ''' pass def sort(self, column, order=Qt.AscendingOrder): ''' Reimplements the :meth:`QAbstractItemModel.sort` method. :param column: Column. :type column: int :param order: Order. ( Qt.SortOrder ) ''' pass def insertRows(self, row, count, parent=QModelIndex()): ''' Reimplements the :meth:`QAbstractItemModel.insertRows` method. :param row: Row. :type row: int :param count: Count. :type count: int :param parent: Parent. :type parent: QModelIndex :return: Method success. :rtype: bool ''' pass def removeRows(self, row, count, parent=QModelIndex()): ''' Reimplements the :meth:`QAbstractItemModel.removeRows` method. :param row: Row. :type row: int :param count: Count. :type count: int :param parent: Parent. :type parent: QModelIndex :return: Method success. :rtype: bool ''' pass def movesRows(self, from_parent, from_first_row, from_last_row, to_parent, to_row): ''' Moves given rows from parent to parent row. ''' pass def mimeTypes(self): ''' Reimplements the :meth:`QAbstractItemModel.mimeTypes` method. :return: Mime types. :rtype: QStringList ''' pass def mimeData(self, indexes): ''' Reimplements the :meth:`QAbstractItemModel.mimeData` method. :param indexes: Indexes. :type indexes: QModelIndexList :return: MimeData. :rtype: QMimeData ''' pass def clear(self): ''' Clears the Model. :return: Method success. :rtype: bool ''' pass def has_nodes(self): ''' Returns if Model has nodes. :return: Has children. :rtype: bool ''' pass def get_node(self, index): ''' Returns the Node at given index. :param index: Index. :type index: QModelIndex :return: Node. :rtype: AbstractCompositeNode or GraphModelNode ''' pass def get_attribute(self, node, column): ''' Returns the given Node attribute associated to the given column. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :param column: Column. :type column: int :return: Attribute. :rtype: Attribute ''' pass def get_node_index(self, node): ''' Returns given Node index. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :return: Index. :rtype: QModelIndex ''' pass def get_attribute_index(self, node, column): ''' Returns given Node attribute index at given column. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :param column: Attribute column. :type column: int :return: Index. :rtype: QModelIndex ''' pass def find_children(self, pattern=".*", flags=0): ''' Finds the children matching the given patten. :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :return: Matching children. :rtype: list ''' pass def find_family(self, pattern=r".*", flags=0, node=None): ''' Returns the Nodes from given family. :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :param node: Node to start walking from. :type node: AbstractNode or AbstractCompositeNode or GraphModelNode :return: Family nodes. :rtype: list ''' pass def find_node(self, attribute): ''' Returns the Node with given attribute. :param attribute: Attribute. :type attribute: GraphModelAttribute :return: Node. :rtype: GraphModelNode ''' pass @staticmethod def find_model(object): ''' Returns the model(s) associated with given object. :param object: Node / Attribute. :type object: GraphModelNode or GraphModelAttribute :return: Model(s). :rtype: list ''' pass def enable_model_triggers(self, state): ''' Enables Model Nodes and attributes triggers. :param state: Inform model state. :type state: bool :return: Method success. :rtype: bool ''' pass def node_changed(self, node): ''' Calls :meth:`QAbstractItemModel.dataChanged` with given Node index. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :return: Method success. :rtype: bool ''' pass def attribute_changed(self, node, column): ''' Calls :meth:`QAbstractItemModel.dataChanged` with given Node attribute index. :param node: Node. :type node: AbstractCompositeNode or GraphModelNode :param column: Attribute column. :type column: int :return: Method success. :rtype: bool ''' pass
63
42
15
2
6
7
2
1.12
1
5
2
5
40
4
41
41
701
133
268
101
200
300
217
83
175
8
1
4
95
142,486
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/nodes.py
umbra.ui.nodes.Mixin_GraphModelObject
class Mixin_GraphModelObject(object): """ Defines a mixin used to bring common capabilities in Application Nodes classes. """ def __init__(self): """ Initializes the class. """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) # --- Setting class attributes. --- self.__roles = None self.__flags = None self.__trigger_model = False @property def roles(self): """ Property for **self.__roles** attribute. :return: self.__roles. :rtype: dict """ return self.__roles @roles.setter @foundations.exceptions.handle_exceptions(AssertionError) def roles(self, value): """ Setter for **self.__roles** attribute. :param value: Attribute value. :type value: dict """ if value is not None: assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format( "roles", value) for key in value: assert type(key) is Qt.ItemDataRole, "'{0}' attribute: '{1}' type is not 'Qt.ItemDataRole'!".format( "roles", key) self.__roles = value @roles.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def roles(self): """ Deleter for **self.__roles** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "roles")) @property def flags(self): """ Property for **self.__flags** attribute. :return: self.__flags. :rtype: int """ return self.__flags @flags.setter @foundations.exceptions.handle_exceptions(AssertionError) def flags(self, value): """ Setter for **self.__flags** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "flags", value) self.__flags = value @flags.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def flags(self): """ Deleter for **self.__flags** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "flags")) @property def trigger_model(self): """ Property for **self.__trigger_model** attribute. :return: self.__trigger_model. :rtype: bool """ return self.__trigger_model @trigger_model.setter @foundations.exceptions.handle_exceptions(AssertionError) def trigger_model(self, value): """ Setter for **self.__trigger_model** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format( "trigger_model", value) self.__trigger_model = value @trigger_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def trigger_model(self): """ Deleter for **self.__trigger_model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "trigger_model"))
class Mixin_GraphModelObject(object): ''' Defines a mixin used to bring common capabilities in Application Nodes classes. ''' def __init__(self): ''' Initializes the class. ''' pass @property def roles(self): ''' Property for **self.__roles** attribute. :return: self.__roles. :rtype: dict ''' pass @roles.setter @foundations.exceptions.handle_exceptions(AssertionError) def roles(self): ''' Setter for **self.__roles** attribute. :param value: Attribute value. :type value: dict ''' pass @roles.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def roles(self): ''' Deleter for **self.__roles** attribute. ''' pass @property def flags(self): ''' Property for **self.__flags** attribute. :return: self.__flags. :rtype: int ''' pass @flags.setter @foundations.exceptions.handle_exceptions(AssertionError) def flags(self): ''' Setter for **self.__flags** attribute. :param value: Attribute value. :type value: int ''' pass @flags.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def flags(self): ''' Deleter for **self.__flags** attribute. ''' pass @property def trigger_model(self): ''' Property for **self.__trigger_model** attribute. :return: self.__trigger_model. :rtype: bool ''' pass @trigger_model.setter @foundations.exceptions.handle_exceptions(AssertionError) def trigger_model(self): ''' Setter for **self.__trigger_model** attribute. :param value: Attribute value. :type value: bool ''' pass @trigger_model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def trigger_model(self): ''' Deleter for **self.__trigger_model** attribute. ''' pass
26
11
10
2
4
4
1
0.9
1
4
0
2
10
3
10
10
126
29
51
24
25
46
32
15
21
3
1
2
14
142,487
KelSolaar/Umbra
KelSolaar_Umbra/umbra/managers/layouts_manager.py
umbra.managers.layouts_manager.Layout
class Layout(foundations.data_structures.Structure): """ Defines a storage object for :class:`LayoutsManager` class layout. """ def __init__(self, **kwargs): """ Initializes the class. :param \*\*kwargs: name, identity, shortcut. :type \*\*kwargs: dict """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) foundations.data_structures.Structure.__init__(self, **kwargs)
class Layout(foundations.data_structures.Structure): ''' Defines a storage object for :class:`LayoutsManager` class layout. ''' def __init__(self, **kwargs): ''' Initializes the class. :param \*\*kwargs: name, identity, shortcut. :type \*\*kwargs: dict ''' pass
2
2
11
3
3
5
1
2
1
0
0
0
1
0
1
1
16
4
4
2
2
8
4
2
2
1
1
0
1
142,488
KelSolaar/Umbra
KelSolaar_Umbra/umbra/globals/ui_constants.py
umbra.globals.ui_constants.UiConstants
class UiConstants(): """ Defines **Umbra** package ui constants. """ ui_file = "Umbra.ui" """ :param ui_file: Application ui file. :type ui_file: unicode """ processing_ui_file = "Processing.ui" """ :param processing_ui_file: Processing ui file. :type processing_ui_file: unicode """ reporter_ui_file = "Reporter.ui" """ :param reporter_ui_file: Reporter ui file. :type reporter_ui_file: unicode """ windows_stylesheet_file = "styles/Windows_styleSheet.qss" """ :param windows_stylesheet_file: Application Windows Os stylesheet file. :type windows_stylesheet_file: unicode """ darwin_stylesheet_file = "styles/Darwin_styleSheet.qss" """ :param darwin_stylesheet_file: Application Mac Os X Os stylesheet file. :type darwin_stylesheet_file: unicode """ linux_stylesheet_file = "styles/Linux_styleSheet.qss" """ :param linux_stylesheet_file: Application Linux Os stylesheet file. :type linux_stylesheet_file: unicode """ windows_full_screen_stylesheet_file = "styles/Windows_FullScreen_styleSheet.qss" """ :param windows_full_screen_stylesheet_file: Application Windows Os fullscreen stylesheet file. :type windows_full_screen_stylesheet_file: unicode """ darwin_full_screen_stylesheet_file = "styles/Darwin_FullScreen_styleSheet.qss" """ :param darwin_full_screen_stylesheet_file: Application Mac Os X Os fullscreen stylesheet file. :type darwin_full_screen_stylesheet_file: unicode """ linux_full_screen_stylesheet_file = "styles/Linux_FullScreen_styleSheet.qss" """ :param linux_full_screen_stylesheet_file: Application Linux Os fullscreen stylesheet file. :type linux_full_screen_stylesheet_file: unicode """ windows_style = "plastique" """ :param windows_style: Application Windows Os style. :type windows_style: unicode """ darwin_style = "plastique" """ :param darwin_style: Application Mac Os X Os style. :type darwin_style: unicode """ linux_style = "plastique" """ :param linux_style: Application Linux Os style. :type linux_style: unicode """ settings_file = "preferences/Default_Settings.rc" """ :param settings_file: Application defaults settings file. :type settings_file: unicode """ layouts_file = "layouts/Default_Layouts.rc" """ :param layouts_file: Application defaults layouts file. :type layouts_file: unicode """ application_windows_icon = "images/Icon_Dark.png" """ :param application_windows_icon: Application icon file. :type application_windows_icon: unicode """ splash_screen_image = "images/Umbra_SpashScreen.png" """ :param splash_screen_image: Application splashscreen image. :type splash_screen_image: unicode """ logo_image = "images/Umbra_Logo.png" """ :param logo_image: Application logo image. :type logo_image: unicode """ default_toolbar_icon_size = 32 """ :param default_toolbar_icon_size: Application toolbar icons size. :type default_toolbar_icon_size: int """ custom_layouts_icon = "images/Custom_Layouts.png" """ :param custom_layouts_icon: Application **Custom Layouts** icon. :type custom_layouts_icon: unicode """ custom_layouts_hover_icon = "images/Custom_Layouts_Hover.png" """ :param custom_layouts_hover_icon: Application **Custom Layouts** hover icon. :type custom_layouts_hover_icon: unicode """ custom_layouts_active_icon = "images/Custom_Layouts_Active.png" """ :param custom_layouts_active_icon: Application **Custom Layouts** active icon. :type custom_layouts_active_icon: unicode """ miscellaneous_icon = "images/Miscellaneous.png" """ :param miscellaneous_icon: Application **Miscellaneous** icon. :type miscellaneous_icon: unicode """ miscellaneous_hover_icon = "images/Miscellaneous_Hover.png" """ :param miscellaneous_hover_icon: Application **Miscellaneous** hover icon. :type miscellaneous_hover_icon: unicode """ miscellaneous_active_icon = "images/Miscellaneous_Active.png" """ :param miscellaneous_active_icon: Application **Miscellaneous** active icon. :type miscellaneous_active_icon: unicode """ development_icon = "images/Development.png" """ :param development_icon: Application **Development** icon. :type development_icon: unicode """ development_hover_icon = "images/Development_Hover.png" """ :param development_hover_icon: Application **Development** hover icon. :type development_hover_icon: unicode """ development_active_icon = "images/Development_Active.png" """ :param development_active_icon: Application **Development** active icon. :type development_active_icon: unicode """ preferences_icon = "images/Preferences.png" """ :param preferences_icon: Application **Preferences** icon. :type preferences_icon: unicode """ preferences_hover_icon = "images/Preferences_Hover.png" """ :param preferences_hover_icon: Application **Preferences** hover icon. :type preferences_hover_icon: unicode """ preferences_active_icon = "images/Preferences_Active.png" """ :param preferences_active_icon: Application **Preferences** active icon. :type preferences_active_icon: unicode """ startup_layout = "startup_centric" """ :param startup_layout: Application startup layout. :type startup_layout: unicode """ help_file = "http://thomasmansencal.com/Sharing/Umbra/Support/Documentation/Help/Umbra_Manual.html" """ :param help_file: Application online help file. :type help_file: unicode """ api_file = "http://thomasmansencal.com/Sharing/Umbra/Support/Documentation/Api/index.html" """ :param api_file: Application online Api file. :type api_file: unicode """ development_layout = "development_centric" """ :param development_layout: Application development layout. :type development_layout: unicode """ python_grammar_file = "grammars/Python/Python.grc" """ :param python_grammar_file: Python language grammar file. :type python_grammar_file: unicode """ logging_grammar_file = "grammars/Logging/Logging.grc" """ :param logging_grammar_file: Logging language grammar file. :type logging_grammar_file: unicode """ text_grammar_file = "grammars/Text/Text.grc" """ :param text_grammar_file: Text language grammar file. :type text_grammar_file: unicode """ invalid_link_html_file = "htmls/Invalid_Link.html" """ :param invalid_link_html_file: Invalid link html file. :type invalid_link_html_file: unicode """ crittercism_id = "5075c158d5f9b9796b000002" """ :param crittercism_id: Crittercism Id. :type crittercism_id: unicode """
class UiConstants(): ''' Defines **Umbra** package ui constants. ''' pass
1
1
0
0
0
0
0
3.98
0
0
0
0
0
0
0
0
217
18
40
40
39
159
40
40
39
0
0
0
0
142,489
KelSolaar/Umbra
KelSolaar_Umbra/umbra/globals/runtime_globals.py
umbra.globals.runtime_globals.RuntimeGlobals
class RuntimeGlobals(): """ Defines **Umbra** package runtime constants. """ parameters = None """Application startup parameters.""" arguments = None """Application startup arguments.""" logging_console_handler = None """Logging console handler instance.""" logging_file_handler = None """Logging file handler instance.""" logging_session_handler = None """Logging session handler instance.""" logging_session_handler_stream = None """Logging session handler stream.""" logging_formatters = None """Logging formatters.""" logging_active_formatter = None """Logging current formatter.""" verbosity_level = None """Logging current verbosity level.""" logging_file = None """Application logging file.""" requests_stack = None """Application requests stack.""" engine = None """Application engine instance.""" patches_manager = None """Application patches manager instance.""" components_manager = None """Application components manager instance.""" actions_manager = None """Application actions manager instance.""" file_system_events_manager = None """Application file system events manager instance.""" notifications_manager = None """Application notifications manager instance.""" layouts_manager = None """Application layouts manager instance.""" reporter = None """Application reporter instance.""" application = None """Application instance.""" user_application_data_directory = None """Application user data directory.""" resources_directories = [] """Resources paths.""" ui_file = None """Application ui file.""" patches_file = None """Application patches file.""" settings_file = None """Application settings file.""" settings = None """Application settings instance.""" last_browsed_path = os.getcwd() """Last browsed path.""" splashscreen_image = None """Application splashscreen picture.""" splashscreen = None """Application splashscreen instance."""
class RuntimeGlobals(): ''' Defines **Umbra** package runtime constants. ''' pass
1
1
0
0
0
0
0
1.07
0
0
0
0
0
0
0
0
76
14
30
30
29
32
30
30
29
0
0
0
0
142,490
KelSolaar/Umbra
KelSolaar_Umbra/umbra/globals/constants.py
umbra.globals.constants.Constants
class Constants(): """ Defines **Umbra** package default constants. """ application_name = "Umbra" """ :param application_name: Package Application name. :type application_name: unicode """ major_version = "1" """ :param major_version: Package major version. :type major_version: unicode """ minor_version = "0" """ :param minor_version: Package minor version. :type minor_version: unicode """ change_version = "9" """ :param change_version: Package change version. :type change_version: unicode """ version = ".".join((major_version, minor_version, change_version)) """ :param version: Package version. :type version: unicode """ logger = "Umbra_Logger" """ :param logger: Package logger name. :type logger: unicode """ verbosity_level = 3 """ :param verbosity_level: Default logging verbosity level. :type verbosity_level: int """ verbosity_labels = ("Critical", "Error", "Warning", "Info", "Debug") """ :param verbosity_labels: Logging verbosity labels. :type verbosity_labels: tuple """ logging_default_formatter = "Default" """ :param logging_default_formatter: Default logging formatter name. :type logging_default_formatter: unicode """ logging_separators = "*" * 96 """ :param logging_separators: Logging separators. :type logging_separators: unicode """ default_codec = umbra.DEFAULT_CODEC """ :param default_codec: Default codec. :type default_codec: unicode """ codec_error = umbra.CODEC_ERROR """ :param codec_error: Default codec error behavior. :type codec_error: unicode """ application_directory = os.sep.join(("Umbra", ".".join((major_version, minor_version)))) """ :param application_directory: Package Application directory. :type application_directory: unicode """ if platform.system() in ("Windows", "Microsoft") or platform.system() == "Darwin": provider_directory = "HDRLabs" """ :param provider_directory: Package provider directory. :type provider_directory: unicode """ elif platform.system() == "Linux": provider_directory = ".HDRLabs" """ :param provider_directory: Package provider directory. :type provider_directory: unicode """ patches_directory = "patches" """ :param patches_directory: Application patches directory. :type patches_directory: unicode """ settings_directory = "settings" """ :param settings_directory: Application settings directory. :type settings_directory: unicode """ user_components_directory = "components" """ :param user_components_directory: Application user components directory. :type user_components_directory: unicode """ logging_directory = "logging" """ :param logging_directory: Application logging directory. :type logging_directory: unicode """ io_directory = "io" """ :param io_directory: Application io directory. :type io_directory: unicode """ preferences_directories = (patches_directory, settings_directory, user_components_directory, logging_directory, io_directory) """ :param preferences_directories: Application preferences directories. :type preferences_directories: tuple """ factory_components_directory = "components/factory" """ :param factory_components_directory: Application factory components directory. :type factory_components_directory: unicode """ factory_addons_components_directory = "components/addons" """ :param factory_addons_components_directory: Application addons components directory. :type factory_addons_components_directory: unicode """ resources_directory = "resources" """ :param resources_directory: Application resources directory. :type resources_directory: unicode """ patches_file = "Umbra_Patches.rc" """ :param patches_file: Application settings file. :type patches_file: unicode """ settings_file = "Umbra_Settings.rc" """ :param settings_file: Application settings file. :type settings_file: unicode """ logging_file = "Umbra_Logging_{0}.log" """ :param logging_file: Application logging file. :type logging_file: unicode """ libraries_directory = "libraries" """ :param libraries_directory: Application libraries directory. :type libraries_directory: unicode """ default_timer_cycle = 125 """ :param default_timer_cycle: Default timer cycle length in milliseconds. :type default_timer_cycle: int """ null_object = "None" """ :param null_object: Default null object string. :type null_object: unicode """
class Constants(): ''' Defines **Umbra** package default constants. '''
1
1
0
0
0
0
0
3.32
0
0
0
0
0
0
0
0
172
12
37
30
36
123
32
30
31
0
0
1
0
142,491
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.ResourceExistsError
class ResourceExistsError(foundations.exceptions.AbstractOsError): """ Defines non existing resource exception. """ pass
class ResourceExistsError(foundations.exceptions.AbstractOsError): ''' Defines non existing resource exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
1
0
0
142,492
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.PathRegistrationError
class PathRegistrationError(AbstractFileSystemEventsManagerError): """ Defines path registration exception. """ pass
class PathRegistrationError(AbstractFileSystemEventsManagerError): ''' Defines path registration exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,493
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/variable_QPushButton.py
umbra.ui.widgets.variable_QPushButton.Variable_QPushButton
class Variable_QPushButton(QPushButton): """ Defines a `QPushButton <http://doc.qt.nokia.com/qpushbutton.html>`_ subclass providing a button with different colors and labels depending on its clicked state. """ def __init__(self, parent=None, state=True, colors=(QColor(240, 240, 240), QColor(160, 160, 160)), labels=("Yes", "No")): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param state: Current button state. :type state: bool :param colors: Button colors. :type colors: tuple :param labels: Button texts. :type labels: tuple """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QPushButton.__init__(self, parent) # --- Setting class attributes. --- self.__state = None self.state = state self.__colors = None self.colors = colors self.__labels = None self.labels = labels # Initializing the button self.setCheckable(True) if self.__state: self.__set_true_state() else: self.__set_false_state() # Signals / Slots. self.clicked.connect(self.__variable_QPushButton__clicked) @property def state(self): """ Property for **self.__state** attribute. :return: self.__state. :rtype: bool """ return self.__state @state.setter @foundations.exceptions.handle_exceptions(AssertionError) def state(self, value): """ Setter for **self.__state** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format( "state", value) self.__state = value @state.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def state(self): """ Deleter for **self.__state** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "state")) @property def colors(self): """ Property for **self.__colors** attribute. :return: self.__colors. :rtype: tuple """ return self.__colors @colors.setter @foundations.exceptions.handle_exceptions(AssertionError) def colors(self, value): """ Setter for **self.__colors** attribute. :param value: Attribute value. :type value: tuple """ if value is not None: assert type(value) is tuple, "'{0}' attribute: '{1}' type is not 'tuple'!".format( "colors", value) assert len(value) == 2, "'{0}' attribute: '{1}' length should be '2'!".format( "colors", value) for index in range(len(value)): assert type( value[index]) is QColor, "'{0}' attribute element '{1}': '{2}' type is not 'QColor'!".format( "colors", index, value) self.__colors = value @colors.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def colors(self): """ Deleter for **self.__colors** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "colors")) @property def labels(self): """ Property for **self.__labels** attribute. :return: self.__labels. :rtype: tuple """ return self.__labels @labels.setter @foundations.exceptions.handle_exceptions(AssertionError) def labels(self, value): """ Setter for **self.__labels** attribute. :param value: Attribute value. :type value: tuple """ if value is not None: assert type(value) is tuple, "'{0}' attribute: '{1}' type is not 'tuple'!".format( "labels", value) assert len(value) == 2, "'{0}' attribute: '{1}' length should be '2'!".format( "labels", value) for index in range(len(value)): assert type(value[index]) is unicode, \ "'{0}' attribute element '{1}': '{2}' type is not 'unicode'!".format( "labels", index, value) self.__labels = value @labels.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def labels(self): """ Deleter for **self.__labels** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "labels")) def __variable_QPushButton__clicked(self, checked): """ Defines the slot triggered by a **Variable_QPushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ if self.__state: self.__set_false_state() else: self.__set_true_state() def __set_true_state(self): """ Sets the variable button true state. """ LOGGER.debug("> Setting variable QPushButton() to 'True' state.") self.__state = True palette = QPalette() palette.setColor( QPalette.Button, foundations.common.get_first_item(self.__colors)) self.setPalette(palette) self.setChecked(True) self.setText(foundations.common.get_first_item(self.__labels)) def __set_false_state(self): """ Sets the variable QPushButton true state. """ LOGGER.debug("> Setting variable QPushButton() to 'False' state.") self.__state = False palette = QPalette() palette.setColor(QPalette.Button, self.__colors[1]) self.setPalette(palette) self.setChecked(False) self.setText(self.__labels[1])
class Variable_QPushButton(QPushButton): ''' Defines a `QPushButton <http://doc.qt.nokia.com/qpushbutton.html>`_ subclass providing a button with different colors and labels depending on its clicked state. ''' def __init__(self, parent=None, state=True, colors=(QColor(240, 240, 240), QColor(160, 160, 160)), labels=("Yes", "No")): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param state: Current button state. :type state: bool :param colors: Button colors. :type colors: tuple :param labels: Button texts. :type labels: tuple ''' pass @property def state(self): ''' Property for **self.__state** attribute. :return: self.__state. :rtype: bool ''' pass @state.setter @foundations.exceptions.handle_exceptions(AssertionError) def state(self): ''' Setter for **self.__state** attribute. :param value: Attribute value. :type value: bool ''' pass @state.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def state(self): ''' Deleter for **self.__state** attribute. ''' pass @property def colors(self): ''' Property for **self.__colors** attribute. :return: self.__colors. :rtype: tuple ''' pass @colors.setter @foundations.exceptions.handle_exceptions(AssertionError) def colors(self): ''' Setter for **self.__colors** attribute. :param value: Attribute value. :type value: tuple ''' pass @colors.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def colors(self): ''' Deleter for **self.__colors** attribute. ''' pass @property def labels(self): ''' Property for **self.__labels** attribute. :return: self.__labels. :rtype: tuple ''' pass @labels.setter @foundations.exceptions.handle_exceptions(AssertionError) def labels(self): ''' Setter for **self.__labels** attribute. :param value: Attribute value. :type value: tuple ''' pass @labels.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def labels(self): ''' Deleter for **self.__labels** attribute. ''' pass def __variable_QPushButton__clicked(self, checked): ''' Defines the slot triggered by a **Variable_QPushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __set_true_state(self): ''' Sets the variable button true state. ''' pass def __set_false_state(self): ''' Sets the variable QPushButton true state. ''' pass
29
14
13
2
6
5
2
0.73
1
4
0
0
13
3
13
13
204
43
93
35
59
68
65
21
51
3
1
2
20
142,494
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/search_QLineEdit.py
umbra.ui.widgets.search_QLineEdit.Search_QLineEdit
class Search_QLineEdit(QLineEdit): """ Defines a `QLineEdit <http://doc.qt.nokia.com/qlinedit.html>`_ subclass providing a search field with clearing capabilities. """ def __init__(self, parent=None, ui_search_image=None, ui_search_clicked_image=None, ui_clear_image=None, ui_clear_clicked_image=None): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param ui_search_image: Search button image path. :type ui_search_image: unicode :param ui_search_clicked_image: Search button clicked image path. :type ui_search_clicked_image: unicode :param ui_clear_image: Clear button image path. :type ui_clear_image: unicode :param ui_clear_clicked_image: Clear button clicked image path. :type ui_clear_clicked_image: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QLineEdit.__init__(self, parent) # --- Setting class attributes. --- self.__ui_search_image = None self.ui_search_image = ui_search_image or umbra.ui.common.get_resource_path( "images/Search_Glass.png") self.__ui_search_clicked_image = None self.ui_search_clicked_image = ui_search_clicked_image or umbra.ui.common.get_resource_path( "images/Search_Glass_Clicked.png") self.__ui_clear_image = None self.ui_clear_image = ui_clear_image or umbra.ui.common.get_resource_path( "images/Search_Clear.png") self.__ui_clear_clicked_image = None self.ui_clear_clicked_image = ui_clear_clicked_image or umbra.ui.common.get_resource_path( "images/Search_Clear_Clicked.png") self.__search_active_label = Active_QLabel(self, QPixmap( self.__ui_search_image), QPixmap( self.__ui_search_image), QPixmap(self.__ui_search_clicked_image)) self.__search_active_label.setObjectName("Search_Field_active_label") self.__search_active_label.showEvent = lambda event: reduce(lambda *args: None, (self.__set_style_sheet(), Active_QLabel.showEvent(self.__search_active_label, event))) self.__search_active_label.hideEvent = lambda event: reduce(lambda *args: None, (self.__set_style_sheet(), Active_QLabel.hideEvent(self.__search_active_label, event))) self.__clear_button = QToolButton(self) self.__clear_button.setObjectName("Clear_Field_button") self.__completer = QCompleter() self.setCompleter(self.__completer) self.__completer_visible_items_count = 16 Search_QLineEdit.__initialize_ui(self) self.__set_clear_button_visibility(self.text()) # Signals / Slots. self.__clear_button.clicked.connect(self.clear) self.textChanged.connect(self.__set_clear_button_visibility) @property def ui_search_image(self): """ Property for **self.__ui_search_image** attribute. :return: self.__ui_search_image. :rtype: unicode """ return self.__ui_search_image @ui_search_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_search_image(self, value): """ Setter for **self.__ui_search_image** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "ui_search_image", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "ui_search_image", value) self.__ui_search_image = value @ui_search_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_search_image(self): """ Deleter for **self.__ui_search_image** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_search_image")) @property def ui_search_clicked_image(self): """ Property for **self.__ui_search_clicked_image** attribute. :return: self.__ui_search_clicked_image. :rtype: unicode """ return self.__ui_search_clicked_image @ui_search_clicked_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_search_clicked_image(self, value): """ Setter for **self.__ui_search_clicked_image** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "ui_search_clicked_image", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "ui_search_clicked_image", value) self.__ui_search_clicked_image = value @ui_search_clicked_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_search_clicked_image(self): """ Deleter for **self.__ui_search_clicked_image** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_search_clicked_image")) @property def ui_clear_image(self): """ Property for **self.__ui_clear_image** attribute. :return: self.__ui_clear_image. :rtype: unicode """ return self.__ui_clear_image @ui_clear_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_clear_image(self, value): """ Setter for **self.__ui_clear_image** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "ui_clear_image", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "ui_clear_image", value) self.__ui_clear_image = value @ui_clear_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_clear_image(self): """ Deleter for **self.__ui_clear_image** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_clear_image")) @property def ui_clear_clicked_image(self): """ Property for **self.__ui_clear_clicked_image** attribute. :return: self.__ui_clear_clicked_image. :rtype: unicode """ return self.__ui_clear_clicked_image @ui_clear_clicked_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_clear_clicked_image(self, value): """ Setter for **self.__ui_clear_clicked_image** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "ui_clear_clicked_image", value) assert os.path.exists(value), "'{0}' attribute: '{1}' file doesn't exists!".format( "ui_clear_clicked_image", value) self.__ui_clear_clicked_image = value @ui_clear_clicked_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_clear_clicked_image(self): """ Deleter for **self.__ui_clear_clicked_image** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_clear_clicked_image")) @property def search_active_label(self): """ Property for **self.__search_active_label** attribute. :return: self.__search_active_label. :rtype: QPushButton """ return self.__search_active_label @search_active_label.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_active_label(self, value): """ Setter for **self.__search_active_label** attribute. :param value: Attribute value. :type value: QPushButton """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "search_active_label")) @search_active_label.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_active_label(self): """ Deleter for **self.__search_active_label** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_active_label")) @property def clear_button(self): """ Property for **self.__clear_button** attribute. :return: self.__clear_button. :rtype: QPushButton """ return self.__clear_button @clear_button.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def clear_button(self, value): """ Setter for **self.__clear_button** attribute. :param value: Attribute value. :type value: QPushButton """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "clear_button")) @clear_button.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def clear_button(self): """ Deleter for **self.__clear_button** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "clear_button")) @property def completer(self): """ Property for **self.__completer** attribute. :return: self.__completer. :rtype: QCompleter """ return self.__completer @completer.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self, value): """ Setter for **self.__completer** attribute. :param value: Attribute value. :type value: QCompleter """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "completer")) @completer.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self): """ Deleter for **self.__completer** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "completer")) @property def completer_visible_items_count(self): """ Property for **self.__completer_visible_items_count** attribute. :return: self.__completer_visible_items_count. :rtype: int """ return self.__completer_visible_items_count @completer_visible_items_count.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer_visible_items_count(self, value): """ Setter for **self.__completer_visible_items_count** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "completer_visible_items_count")) @completer_visible_items_count.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer_visible_items_count(self): """ Deleter for **self.__completer_visible_items_count** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "completer_visible_items_count")) def resizeEvent(self, event): """ Reimplements the :meth:`QLineEdit.QResizeEvent` method. :param event: Resize event. :type event: QResizeEvent """ frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth) search_active_labelSize = self.__search_active_label.sizeHint() self.__search_active_label.move(self.rect().left() + frame_width, (self.rect().bottom() - search_active_labelSize.height()) / 2 + frame_width / 2) clear_buttonSize = self.__clear_button.sizeHint() self.__clear_button.move(self.rect().right() - frame_width - clear_buttonSize.width(), (self.rect().bottom() - clear_buttonSize.height()) / 2 + frame_width / 2) def __initialize_ui(self): """ Initializes the Widget ui. """ self.__clear_button.setCursor(Qt.ArrowCursor) if self.__ui_clear_image and self.__ui_clear_clicked_image: pixmap = QPixmap(self.__ui_clear_image) clicked_pixmap = QPixmap(self.__ui_clear_clicked_image) self.__clear_button.setIcon(QIcon(pixmap)) self.__clear_button.setMaximumSize(pixmap.size()) # Signals / Slots. self.__clear_button.pressed.connect(functools.partial( self.__clear_button.setIcon, QIcon(clicked_pixmap))) self.__clear_button.released.connect(functools.partial( self.__clear_button.setIcon, QIcon(pixmap))) else: self.__clear_button.setText("Clear") self.__set_style_sheet() frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth) self.setMinimumSize( max(self.minimumSizeHint().width(), self.__clear_button.sizeHint().height() + frame_width * 2), max(self.minimumSizeHint().height(), self.__clear_button.sizeHint().height() + frame_width * 2)) self.__completer.setCaseSensitivity(Qt.CaseInsensitive) self.__completer.setCompletionMode( QCompleter.UnfilteredPopupCompletion) self.__completer.setMaxVisibleItems( self.__completer_visible_items_count) def __set_style_sheet(self): """ Sets the Widget stylesheet. """ frame_width = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth) self.setStyleSheet(QString("QLineEdit {{ padding-left: {0}px; padding-right: {1}px; }}".format( self.__search_active_label.sizeHint().width( ) if self.__search_active_label.isVisible() else 0 + frame_width, self.__clear_button.sizeHint().width() + frame_width))) def __set_clear_button_visibility(self, text): """ Sets the clear button visibility. :param text: Current field text. :type text: QString """ if text: self.__clear_button.show() else: self.__clear_button.hide()
class Search_QLineEdit(QLineEdit): ''' Defines a `QLineEdit <http://doc.qt.nokia.com/qlinedit.html>`_ subclass providing a search field with clearing capabilities. ''' def __init__(self, parent=None, ui_search_image=None, ui_search_clicked_image=None, ui_clear_image=None, ui_clear_clicked_image=None): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param ui_search_image: Search button image path. :type ui_search_image: unicode :param ui_search_clicked_image: Search button clicked image path. :type ui_search_clicked_image: unicode :param ui_clear_image: Clear button image path. :type ui_clear_image: unicode :param ui_clear_clicked_image: Clear button clicked image path. :type ui_clear_clicked_image: unicode ''' pass @property def ui_search_image(self): ''' Property for **self.__ui_search_image** attribute. :return: self.__ui_search_image. :rtype: unicode ''' pass @ui_search_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_search_image(self): ''' Setter for **self.__ui_search_image** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_search_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_search_image(self): ''' Deleter for **self.__ui_search_image** attribute. ''' pass @property def ui_search_clicked_image(self): ''' Property for **self.__ui_search_clicked_image** attribute. :return: self.__ui_search_clicked_image. :rtype: unicode ''' pass @ui_search_clicked_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_search_clicked_image(self): ''' Setter for **self.__ui_search_clicked_image** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_search_clicked_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_search_clicked_image(self): ''' Deleter for **self.__ui_search_clicked_image** attribute. ''' pass @property def ui_clear_image(self): ''' Property for **self.__ui_clear_image** attribute. :return: self.__ui_clear_image. :rtype: unicode ''' pass @ui_clear_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_clear_image(self): ''' Setter for **self.__ui_clear_image** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_clear_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_clear_image(self): ''' Deleter for **self.__ui_clear_image** attribute. ''' pass @property def ui_clear_clicked_image(self): ''' Property for **self.__ui_clear_clicked_image** attribute. :return: self.__ui_clear_clicked_image. :rtype: unicode ''' pass @ui_clear_clicked_image.setter @foundations.exceptions.handle_exceptions(AssertionError) def ui_clear_clicked_image(self): ''' Setter for **self.__ui_clear_clicked_image** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_clear_clicked_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_clear_clicked_image(self): ''' Deleter for **self.__ui_clear_clicked_image** attribute. ''' pass @property def search_active_label(self): ''' Property for **self.__search_active_label** attribute. :return: self.__search_active_label. :rtype: QPushButton ''' pass @search_active_label.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_active_label(self): ''' Setter for **self.__search_active_label** attribute. :param value: Attribute value. :type value: QPushButton ''' pass @search_active_label.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_active_label(self): ''' Deleter for **self.__search_active_label** attribute. ''' pass @property def clear_button(self): ''' Property for **self.__clear_button** attribute. :return: self.__clear_button. :rtype: QPushButton ''' pass @clear_button.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def clear_button(self): ''' Setter for **self.__clear_button** attribute. :param value: Attribute value. :type value: QPushButton ''' pass @clear_button.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def clear_button(self): ''' Deleter for **self.__clear_button** attribute. ''' pass @property def completer(self): ''' Property for **self.__completer** attribute. :return: self.__completer. :rtype: QCompleter ''' pass @completer.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self): ''' Setter for **self.__completer** attribute. :param value: Attribute value. :type value: QCompleter ''' pass @completer.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self): ''' Deleter for **self.__completer** attribute. ''' pass @property def completer_visible_items_count(self): ''' Property for **self.__completer_visible_items_count** attribute. :return: self.__completer_visible_items_count. :rtype: int ''' pass @completer_visible_items_count.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer_visible_items_count(self): ''' Setter for **self.__completer_visible_items_count** attribute. :param value: Attribute value. :type value: int ''' pass @completer_visible_items_count.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer_visible_items_count(self): ''' Deleter for **self.__completer_visible_items_count** attribute. ''' pass def resizeEvent(self, event): ''' Reimplements the :meth:`QLineEdit.QResizeEvent` method. :param event: Resize event. :type event: QResizeEvent ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __set_style_sheet(self): ''' Sets the Widget stylesheet. ''' pass def __set_clear_button_visibility(self, text): ''' Sets the clear button visibility. :param text: Current field text. :type text: QString ''' pass
70
30
12
2
5
5
1
0.7
1
3
1
0
29
8
29
29
427
88
199
74
124
140
114
45
84
2
1
1
36
142,495
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/notification_QLabel.py
umbra.ui.widgets.notification_QLabel.Notification_QLabel
class Notification_QLabel(QLabel): """ Defines a `QLabel <http://doc.qt.nokia.com/qlabel.html>`_ subclass providing a notification label with fading capabilities. """ # Custom signals definitions. notification_clicked = pyqtSignal(QString) """ This signal is emited by the :class:`Notification_QLabel` class when it receives a mouse press event. :return: Current notification text. :rtype: QString """ faded_in = pyqtSignal() """ This signal is emited by the :class:`Notification_QLabel` class when it has faded in. """ faded_out = pyqtSignal() """ This signal is emited by the :class:`Notification_QLabel` class when it has faded out. """ def __init__(self, parent=None, color=None, background_color=None, border_color=None, anchor=None, horizontal_padding=None, vertical_padding=None, horizontal_offset=None, vertical_offset=None, fade_speed=None, target_opacity=None, duration=None): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param color: Widget text color. :type color: QColor :param background_color: Widget background color. :type background_color: QColor :param border_color: Widget border color. :type border_color: QColor :param anchor: Widget anchoring area ( From 0 to 8 ). :type anchor: int :param horizontal_padding: Left padding relative to parent Widget. :type horizontal_padding: int :param vertical_padding: Bottom padding relative to parent Widget. :type vertical_padding: int :param horizontal_offset: Widget horizontal offset. :type horizontal_offset: int :param vertical_offset: Widget vertical offset. :type vertical_offset: int :param fade_speed: Notification fading speed. :type fade_speed: float :param target_opacity: Notification maximum target opacity. :type target_opacity: float :param duration: Notification duration in milliseconds. :type duration: int """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QLabel.__init__(self, parent) # --- Setting class attributes. --- self.__opacity = 0 self.__style = """ QLabel, QLabel link {{ color: {0}; background-color: {1}; border: 4px solid; border-color: {2}; font-size: 14px; padding: 16px; }} """ self.__color = QColor(220, 220, 220) self.__background_color = QColor(32, 32, 32) self.__border_color = QColor(220, 220, 220) self.color = color if color is not None else self.__color self.background_color = background_color if background_color is not None else self.__background_color self.border_color = border_color if border_color is not None else self.__border_color self.__anchor = None self.anchor = anchor if anchor is not None else 4 self.__horizontal_padding = None self.horizontal_padding = horizontal_padding if horizontal_padding is not None else 0 self.__vertical_padding = None self.vertical_padding = vertical_padding if vertical_padding is not None else 48 self.__horizontal_offset = None self.horizontal_offset = horizontal_offset if horizontal_offset is not None else 0 self.__vertical_offset = None self.vertical_offset = vertical_offset if vertical_offset is not None else 0 self.__fade_speed = fade_speed self.fade_speed = fade_speed if fade_speed is not None else 0.15 self.__target_opacity = None self.target_opacity = target_opacity if target_opacity is not None else 0.75 self.__duration = None self.duration = duration if duration is not None else 2500 self.__vector = 0 self.__timer = QTimer(self) self.__timer.setInterval(25) self.__timer.timeout.connect(self.__set_opacity) # TODO: Check future Qt releases to remove this hack. RuntimeGlobals.layouts_manager and RuntimeGlobals.layouts_manager.layout_restored.connect( self.__raise) self.__set_style_sheet() @property def color(self): """ Property for **self.__color** attribute. :return: self.__color. :rtype: QColor """ return self.__color @color.setter @foundations.exceptions.handle_exceptions(AssertionError) def color(self, value): """ Setter for **self.__color** attribute. :param value: Attribute value. :type value: QColor """ if value is not None: assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format( "color", value) self.__color = value self.__set_style_sheet() @color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def color(self): """ Deleter for **self.__color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "color")) @property def background_color(self): """ Property for **self.__background_color** attribute. :return: self.__background_color. :rtype: QColor """ return self.__background_color @background_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def background_color(self, value): """ Setter for **self.__background_color** attribute. :param value: Attribute value. :type value: QColor """ if value is not None: assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format( "background_color", value) self.__background_color = value self.__set_style_sheet() @background_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def background_color(self): """ Deleter for **self.__background_color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "background_color")) @property def border_color(self): """ Property for **self.__border_color** attribute. :return: self.__border_color. :rtype: QColor """ return self.__border_color @border_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def border_color(self, value): """ Setter for **self.__border_color** attribute. :param value: Attribute value. :type value: QColor """ if value is not None: assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format( "border_color", value) self.__border_color = value self.__set_style_sheet() @border_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def border_color(self): """ Deleter for **self.__border_color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "border_color")) @property def anchor(self): """ Property for **self.__anchor** attribute. :return: self.__anchor. :rtype: int """ return self.__anchor @anchor.setter @foundations.exceptions.handle_exceptions(AssertionError) def anchor(self, value): """ Setter for **self.__anchor** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "anchor", value) assert value in range( 0, 9), "'{0}' attribute: '{1}' need to be in '0' to '8' range!".format("anchor", value) self.__anchor = value @anchor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def anchor(self): """ Deleter for **self.__anchor** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "anchor")) @property def horizontal_padding(self): """ Property for **self.__horizontal_padding** attribute. :return: self.__horizontal_padding. :rtype: int """ return self.__horizontal_padding @horizontal_padding.setter @foundations.exceptions.handle_exceptions(AssertionError) def horizontal_padding(self, value): """ Setter for **self.__horizontal_padding** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "horizontal_padding", value) assert value >= 0, "'{0}' attribute: '{1}' need to be positive!".format( "horizontal_padding", value) self.__horizontal_padding = value @horizontal_padding.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def horizontal_padding(self): """ Deleter for **self.__horizontal_padding** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "horizontal_padding")) @property def vertical_padding(self): """ Property for **self.__vertical_padding** attribute. :return: self.__vertical_padding. :rtype: int """ return self.__vertical_padding @vertical_padding.setter @foundations.exceptions.handle_exceptions(AssertionError) def vertical_padding(self, value): """ Setter for **self.__vertical_padding** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "vertical_padding", value) assert value > 0, "'{0}' attribute: '{1}' need to be positive!".format( "vertical_padding", value) self.__vertical_padding = value @vertical_padding.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def vertical_padding(self): """ Deleter for **self.__vertical_padding** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "vertical_padding")) @property def horizontal_offset(self): """ Property for **self.__horizontal_offset** attribute. :return: self.__horizontal_offset. :rtype: int """ return self.__horizontal_offset @horizontal_offset.setter @foundations.exceptions.handle_exceptions(AssertionError) def horizontal_offset(self, value): """ Setter for **self.__horizontal_offset** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "horizontal_offset", value) self.__horizontal_offset = value @horizontal_offset.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def horizontal_offset(self): """ Deleter for **self.__horizontal_offset** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "horizontal_offset")) @property def vertical_offset(self): """ Property for **self.__vertical_offset** attribute. :return: self.__vertical_offset. :rtype: int """ return self.__vertical_offset @vertical_offset.setter @foundations.exceptions.handle_exceptions(AssertionError) def vertical_offset(self, value): """ Setter for **self.__vertical_offset** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "vertical_offset", value) self.__vertical_offset = value @vertical_offset.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def vertical_offset(self): """ Deleter for **self.__vertical_offset** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "vertical_offset")) @property def fade_speed(self): """ Property for **self.__fade_speed** attribute. :return: self.__fade_speed. :rtype: float """ return self.__fade_speed @fade_speed.setter @foundations.exceptions.handle_exceptions(AssertionError) def fade_speed(self, value): """ Setter for **self.__fade_speed** attribute. :param value: Attribute value. :type value: float """ if value is not None: assert type(value) is float, "'{0}' attribute: '{1}' type is not 'float'!".format( "fade_speed", value) assert value >= 0, "'{0}' attribute: '{1}' need to be exactly positive!".format( "fade_speed", value) self.__fade_speed = value @fade_speed.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def fade_speed(self): """ Deleter for **self.__fade_speed** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "fade_speed")) @property def target_opacity(self): """ Property for **self.__target_opacity** attribute. :return: self.__target_opacity. :rtype: float """ return self.__target_opacity @target_opacity.setter @foundations.exceptions.handle_exceptions(AssertionError) def target_opacity(self, value): """ Setter for **self.__target_opacity** attribute. :param value: Attribute value. :type value: float """ if value is not None: assert type(value) is float, "'{0}' attribute: '{1}' type is not 'float'!".format( "target_opacity", value) assert value >= 0, "'{0}' attribute: '{1}' need to be positive!".format( "target_opacity", value) assert value <= 1, "'{0}' attribute: '{1}' need to be less or equal than '1'!".format( "target_opacity", value) self.__target_opacity = value @target_opacity.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def target_opacity(self): """ Deleter for **self.__target_opacity** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "target_opacity")) @property def duration(self): """ Property for **self.__duration** attribute. :return: self.__duration. :rtype: int """ return self.__duration @duration.setter @foundations.exceptions.handle_exceptions(AssertionError) def duration(self, value): """ Setter for **self.__duration** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "duration", value) assert value >= 0, "'{0}' attribute: '{1}' need to be exactly positive!".format( "duration", value) self.__duration = value @duration.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def duration(self): """ Deleter for **self.__duration** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "duration")) @property def opacity(self): """ Property for **self.__opacity** attribute. :return: self.__opacity. :rtype: float """ return self.__opacity @opacity.setter @foundations.exceptions.handle_exceptions(AssertionError) def opacity(self, value): """ Setter for **self.__opacity** attribute. :param value: Attribute value. :type value: float """ if value is not None: assert type(value) in (int, float), "'{0}' attribute: '{1}' type is not 'int' or 'float'!".format("opacity", value) if value > 1: value = 1 elif value < 0: value = 0 self.__opacity = float(value) self.__set_style_sheet() @opacity.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def opacity(self): """ Deleter for **self.__opacity** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "opacity")) @property def style(self): """ Property for **self.__style** attribute. :return: self.__style. :rtype: unicode """ return self.__style @style.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self, value): """ Setter for **self.__style** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "style")) @style.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): """ Deleter for **self.__style** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "style")) def setParent(self, parent): """ Reimplements the :meth:`QLabel.setParent` method. :param parent: Parent. :type parent: QObject """ QLabel.setParent(self, parent) self.__set_position() def resizeEvent(self, event): """ Reimplements the :meth:`QLabel.resizeEvent` method. :param event: QEvent. :type event: QEvent """ QLabel.resizeEvent(self, event) self.__set_position() def mousePressEvent(self, event): """ Reimplements the :meth:`QLabel.mousePressEvent` method. :param event: QEvent. :type event: QEvent """ self.notification_clicked.emit(self.text()) def showEvent(self, event): """ Reimplements the :meth:`QLabel.showEvent` method. :param event: QEvent. :type event: QEvent """ QLabel.showEvent(self, event) self.__set_position() def __raise(self, *args): """ Ensures that the Widget stays on top of the parent stack forcing the redraw. :param \*args: Arguments. :type \*args: \* """ children = self.parent().children().remove(self) if children: self.stackUnder(children[-1]) else: self.lower() self.raise_() def __set_position(self): """ Sets the Widget position relatively to its parent. """ rectangle = hasattr(self.parent(), "viewport") and self.parent( ).viewport().rect() or self.parent().rect() if not rectangle: return self.adjustSize() if self.__anchor == 0: point_x = rectangle.width() / 2 - self.width() / 2 point_y = self.__vertical_padding elif self.__anchor == 1: point_x = rectangle.width() - self.width() - self.__horizontal_padding point_y = self.__vertical_padding elif self.__anchor == 2: point_x = rectangle.width() - self.width() - self.__horizontal_padding point_y = rectangle.height() / 2 - self.height() / 2 elif self.__anchor == 3: point_x = rectangle.width() - self.width() - self.__horizontal_padding point_y = rectangle.height() - self.height() - self.__vertical_padding elif self.__anchor == 4: point_x = rectangle.width() / 2 - self.width() / 2 point_y = rectangle.height() - self.height() - self.__vertical_padding elif self.__anchor == 5: point_x = self.__horizontal_padding point_y = rectangle.height() - self.height() - self.__vertical_padding elif self.__anchor == 6: point_x = self.__horizontal_padding point_y = rectangle.height() / 2 - self.height() / 2 elif self.__anchor == 7: point_x = self.__horizontal_padding point_y = self.__vertical_padding elif self.__anchor == 8: point_x = rectangle.width() / 2 - self.width() / 2 point_y = rectangle.height() / 2 - self.height() / 2 self.setGeometry(point_x + self.__horizontal_offset, point_y + self.__vertical_offset, self.width(), self.height()) def __fade_in(self): """ Starts the Widget fade in. """ self.__timer.stop() self.__vector = self.__fade_speed self.__timer.start() def __fade_out(self): """ Starts the Widget fade out. """ self.__timer.stop() self.__vector = -self.__fade_speed self.__timer.start() def __set_opacity(self): """ Sets the Widget opacity. """ if self.__vector > 0: if self.isHidden(): self.show() if self.opacity <= self.__target_opacity: self.opacity += self.__vector else: self.__timer.stop() self.faded_in.emit() self.__duration and QTimer.singleShot( self.__duration, self.__fade_out) elif self.__vector < 0: if self.opacity > 0: self.opacity += self.__vector else: self.__timer.stop() self.faded_out.emit() self.hide() def __set_style_sheet(self): """ Sets the Widget stylesheet. """ colors = map( lambda x: "rgb({0}, {1}, {2}, {3})".format( x.red(), x.green(), x.blue(), int(self.__opacity * 255)), (self.__color, self.__background_color, self.__border_color)) self.setStyleSheet(self.__style.format(*colors)) def show_message(self, message, duration=2500): """ Shows given message. :param message: Message. :type message: unicode :param duration: Notification duration in milliseconds. :type duration: int :return: Method success. :rtype: bool """ self.setText(message) self.__duration = duration self.__set_position() if message: self.__fade_in() else: self.__fade_out() return True def hide_message(self): """ Hides the current message. :return: Method success. :rtype: bool """ self.__fade_out() return True def refresh_position(self): """ Refreshes the Widget position. :return: Method success. :rtype: bool """ self.__set_position() return True
class Notification_QLabel(QLabel): ''' Defines a `QLabel <http://doc.qt.nokia.com/qlabel.html>`_ subclass providing a notification label with fading capabilities. ''' def __init__(self, parent=None, color=None, background_color=None, border_color=None, anchor=None, horizontal_padding=None, vertical_padding=None, horizontal_offset=None, vertical_offset=None, fade_speed=None, target_opacity=None, duration=None): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param color: Widget text color. :type color: QColor :param background_color: Widget background color. :type background_color: QColor :param border_color: Widget border color. :type border_color: QColor :param anchor: Widget anchoring area ( From 0 to 8 ). :type anchor: int :param horizontal_padding: Left padding relative to parent Widget. :type horizontal_padding: int :param vertical_padding: Bottom padding relative to parent Widget. :type vertical_padding: int :param horizontal_offset: Widget horizontal offset. :type horizontal_offset: int :param vertical_offset: Widget vertical offset. :type vertical_offset: int :param fade_speed: Notification fading speed. :type fade_speed: float :param target_opacity: Notification maximum target opacity. :type target_opacity: float :param duration: Notification duration in milliseconds. :type duration: int ''' pass @property def color(self): ''' Property for **self.__color** attribute. :return: self.__color. :rtype: QColor ''' pass @color.setter @foundations.exceptions.handle_exceptions(AssertionError) def color(self): ''' Setter for **self.__color** attribute. :param value: Attribute value. :type value: QColor ''' pass @color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def color(self): ''' Deleter for **self.__color** attribute. ''' pass @property def background_color(self): ''' Property for **self.__background_color** attribute. :return: self.__background_color. :rtype: QColor ''' pass @background_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def background_color(self): ''' Setter for **self.__background_color** attribute. :param value: Attribute value. :type value: QColor ''' pass @background_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def background_color(self): ''' Deleter for **self.__background_color** attribute. ''' pass @property def border_color(self): ''' Property for **self.__border_color** attribute. :return: self.__border_color. :rtype: QColor ''' pass @border_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def border_color(self): ''' Setter for **self.__border_color** attribute. :param value: Attribute value. :type value: QColor ''' pass @border_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def border_color(self): ''' Deleter for **self.__border_color** attribute. ''' pass @property def anchor(self): ''' Property for **self.__anchor** attribute. :return: self.__anchor. :rtype: int ''' pass @anchor.setter @foundations.exceptions.handle_exceptions(AssertionError) def anchor(self): ''' Setter for **self.__anchor** attribute. :param value: Attribute value. :type value: int ''' pass @anchor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def anchor(self): ''' Deleter for **self.__anchor** attribute. ''' pass @property def horizontal_padding(self): ''' Property for **self.__horizontal_padding** attribute. :return: self.__horizontal_padding. :rtype: int ''' pass @horizontal_padding.setter @foundations.exceptions.handle_exceptions(AssertionError) def horizontal_padding(self): ''' Setter for **self.__horizontal_padding** attribute. :param value: Attribute value. :type value: int ''' pass @horizontal_padding.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def horizontal_padding(self): ''' Deleter for **self.__horizontal_padding** attribute. ''' pass @property def vertical_padding(self): ''' Property for **self.__vertical_padding** attribute. :return: self.__vertical_padding. :rtype: int ''' pass @vertical_padding.setter @foundations.exceptions.handle_exceptions(AssertionError) def vertical_padding(self): ''' Setter for **self.__vertical_padding** attribute. :param value: Attribute value. :type value: int ''' pass @vertical_padding.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def vertical_padding(self): ''' Deleter for **self.__vertical_padding** attribute. ''' pass @property def horizontal_offset(self): ''' Property for **self.__horizontal_offset** attribute. :return: self.__horizontal_offset. :rtype: int ''' pass @horizontal_offset.setter @foundations.exceptions.handle_exceptions(AssertionError) def horizontal_offset(self): ''' Setter for **self.__horizontal_offset** attribute. :param value: Attribute value. :type value: int ''' pass @horizontal_offset.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def horizontal_offset(self): ''' Deleter for **self.__horizontal_offset** attribute. ''' pass @property def vertical_offset(self): ''' Property for **self.__vertical_offset** attribute. :return: self.__vertical_offset. :rtype: int ''' pass @vertical_offset.setter @foundations.exceptions.handle_exceptions(AssertionError) def vertical_offset(self): ''' Setter for **self.__vertical_offset** attribute. :param value: Attribute value. :type value: int ''' pass @vertical_offset.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def vertical_offset(self): ''' Deleter for **self.__vertical_offset** attribute. ''' pass @property def fade_speed(self): ''' Property for **self.__fade_speed** attribute. :return: self.__fade_speed. :rtype: float ''' pass @fade_speed.setter @foundations.exceptions.handle_exceptions(AssertionError) def fade_speed(self): ''' Setter for **self.__fade_speed** attribute. :param value: Attribute value. :type value: float ''' pass @fade_speed.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def fade_speed(self): ''' Deleter for **self.__fade_speed** attribute. ''' pass @property def target_opacity(self): ''' Property for **self.__target_opacity** attribute. :return: self.__target_opacity. :rtype: float ''' pass @target_opacity.setter @foundations.exceptions.handle_exceptions(AssertionError) def target_opacity(self): ''' Setter for **self.__target_opacity** attribute. :param value: Attribute value. :type value: float ''' pass @target_opacity.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def target_opacity(self): ''' Deleter for **self.__target_opacity** attribute. ''' pass @property def duration(self): ''' Property for **self.__duration** attribute. :return: self.__duration. :rtype: int ''' pass @duration.setter @foundations.exceptions.handle_exceptions(AssertionError) def duration(self): ''' Setter for **self.__duration** attribute. :param value: Attribute value. :type value: int ''' pass @duration.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def duration(self): ''' Deleter for **self.__duration** attribute. ''' pass @property def opacity(self): ''' Property for **self.__opacity** attribute. :return: self.__opacity. :rtype: float ''' pass @opacity.setter @foundations.exceptions.handle_exceptions(AssertionError) def opacity(self): ''' Setter for **self.__opacity** attribute. :param value: Attribute value. :type value: float ''' pass @opacity.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def opacity(self): ''' Deleter for **self.__opacity** attribute. ''' pass @property def style(self): ''' Property for **self.__style** attribute. :return: self.__style. :rtype: unicode ''' pass @style.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): ''' Setter for **self.__style** attribute. :param value: Attribute value. :type value: unicode ''' pass @style.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): ''' Deleter for **self.__style** attribute. ''' pass def setParent(self, parent): ''' Reimplements the :meth:`QLabel.setParent` method. :param parent: Parent. :type parent: QObject ''' pass def resizeEvent(self, event): ''' Reimplements the :meth:`QLabel.resizeEvent` method. :param event: QEvent. :type event: QEvent ''' pass def mousePressEvent(self, event): ''' Reimplements the :meth:`QLabel.mousePressEvent` method. :param event: QEvent. :type event: QEvent ''' pass def showEvent(self, event): ''' Reimplements the :meth:`QLabel.showEvent` method. :param event: QEvent. :type event: QEvent ''' pass def __raise(self, *args): ''' Ensures that the Widget stays on top of the parent stack forcing the redraw. :param \*args: Arguments. :type \*args: \* ''' pass def __set_position(self): ''' Sets the Widget position relatively to its parent. ''' pass def __fade_in(self): ''' Starts the Widget fade in. ''' pass def __fade_out(self): ''' Starts the Widget fade out. ''' pass def __set_opacity(self): ''' Sets the Widget opacity. ''' pass def __set_style_sheet(self): ''' Sets the Widget stylesheet. ''' pass def show_message(self, message, duration=2500): ''' Shows given message. :param message: Message. :type message: unicode :param duration: Notification duration in milliseconds. :type duration: int :return: Method success. :rtype: bool ''' pass def hide_message(self): ''' Hides the current message. :return: Method success. :rtype: bool ''' pass def refresh_position(self): ''' Refreshes the Widget position. :return: Method success. :rtype: bool ''' pass
119
54
12
2
5
5
2
0.77
1
6
1
0
53
15
53
53
787
159
355
128
224
273
234
77
180
12
1
2
95
142,496
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/delayed_QSplashScreen.py
umbra.ui.widgets.delayed_QSplashScreen.Delayed_QSplashScreen
class Delayed_QSplashScreen(QSplashScreen): """ Defines a `QSplashScreen <http://doc.qt.nokia.com/qsplashscreen.html>`_ subclass providing delayed messages capabilities. """ def __init__(self, pixmap, wait_time=0, text_color=Qt.black, *args, **kwargs): """ Initializes the class. :param pixmap: Current pixmap path. :type pixmap: unicode :param wait_time: wait time. :type wait_time: int :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QSplashScreen.__init__(self, pixmap, *args, **kwargs) self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint) # --- Setting class attributes. --- self.__wait_time = None self.wait_time = wait_time self.__text_color = None self.text_color = text_color @property def wait_time(self): """ Property for **self.__wait_time** attribute. :return: self.__wait_time :rtype: int or float """ return self.__wait_time @wait_time.setter @foundations.exceptions.handle_exceptions(AssertionError) def wait_time(self, value): """ Setter for **self.__wait_time** attribute. :param value: Attribute value. :type value: int or float """ if value is not None: assert type(value) in (int, float), "'{0}' attribute: '{1}' type is not 'int' or 'float'!".format( "wait_time", value) assert value >= 0, "'{0}' attribute: '{1}' need to be positive!".format( "wait_time", value) self.__wait_time = value @wait_time.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def wait_time(self): """ Deleter for **self.__wait_time** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "wait_time")) @property def text_color(self): """ Property for **self.__text_color** attribute. :return: self.__text_color :rtype: int or QColor """ return self.__text_color @text_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def text_color(self, value): """ Setter for **self.__text_color** attribute. :param value: Attribute value. :type value: int or QColor """ if value is not None: assert type(value) in (Qt.GlobalColor, QColor), \ "'{0}' attribute: '{1}' type is not 'int' or 'QColor'!".format( "text_color", value) self.__text_color = value @text_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def text_color(self): """ Deleter for **self.__text_color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "text_color")) def show_message(self, message, text_alignement=Qt.AlignLeft, text_color=None, wait_time=None): """ Reimplements the :meth:`QSplashScreen.show_message` method. :param message: Message to display on the splashscreen. :type message: unicode :param text_alignement: Text message alignment. :type text_alignement: object :param text_color: Text message color. :type text_color: object :param wait_time: Wait time. :type wait_time: int """ QSplashScreen.showMessage( self, message, text_alignement, self.__text_color if text_color is None else text_color) # Force QSplashscreen refresh. QApplication.processEvents() foundations.core.wait( self.__wait_time if wait_time is None else wait_time)
class Delayed_QSplashScreen(QSplashScreen): ''' Defines a `QSplashScreen <http://doc.qt.nokia.com/qsplashscreen.html>`_ subclass providing delayed messages capabilities. ''' def __init__(self, pixmap, wait_time=0, text_color=Qt.black, *args, **kwargs): ''' Initializes the class. :param pixmap: Current pixmap path. :type pixmap: unicode :param wait_time: wait time. :type wait_time: int :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def wait_time(self): ''' Property for **self.__wait_time** attribute. :return: self.__wait_time :rtype: int or float ''' pass @wait_time.setter @foundations.exceptions.handle_exceptions(AssertionError) def wait_time(self): ''' Setter for **self.__wait_time** attribute. :param value: Attribute value. :type value: int or float ''' pass @wait_time.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def wait_time(self): ''' Deleter for **self.__wait_time** attribute. ''' pass @property def text_color(self): ''' Property for **self.__text_color** attribute. :return: self.__text_color :rtype: int or QColor ''' pass @text_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def text_color(self): ''' Setter for **self.__text_color** attribute. :param value: Attribute value. :type value: int or QColor ''' pass @text_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def text_color(self): ''' Deleter for **self.__text_color** attribute. ''' pass def show_message(self, message, text_alignement=Qt.AlignLeft, text_color=None, wait_time=None): ''' Reimplements the :meth:`QSplashScreen.show_message` method. :param message: Message to display on the splashscreen. :type message: unicode :param text_alignement: Text message alignment. :type text_alignement: object :param text_color: Text message color. :type text_color: object :param wait_time: Wait time. :type wait_time: int ''' pass
19
9
13
2
4
6
2
1.2
1
3
0
0
8
2
8
8
126
27
45
17
26
54
30
11
21
3
1
1
12
142,497
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/codeEditor_QPlainTextEdit.py
umbra.ui.widgets.codeEditor_QPlainTextEdit.LinesNumbers_QWidget
class LinesNumbers_QWidget(QWidget): """ Defines a `QWidget <http://doc.qt.nokia.com/qwidget.html>`_ subclass providing a lines numbers widget. """ def __init__(self, parent, *args, **kwargs): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QWidget.__init__(self, parent, *args, **kwargs) # --- Setting class attributes. --- self.__editor = parent self.__margin = 16 self.__separator_width = 4 self.__background_color = QColor(48, 48, 48) self.__color = QColor(192, 192, 192) self.__separator_color = QColor(48, 48, 48) self.set_editor_viewport_margins(0) @property def editor(self): """ Property for **self.__editor** attribute. :return: self.__editor. :rtype: QWidget """ return self.__editor @editor.setter def editor(self, value): """ Setter for **self.__editor** attribute. :param value: Attribute value. :type value: QWidget """ self.__editor = value @editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def editor(self): """ Deleter for **self.__editor** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "editor")) @property def margin(self): """ Property for **self.__margin** attribute. :return: self.__margin. :rtype: int """ return self.__margin @margin.setter @foundations.exceptions.handle_exceptions(AssertionError) def margin(self, value): """ Setter for **self.__margin** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "margin", value) assert value > 0, "'{0}' attribute: '{1}' need to be exactly positive!".format( "margin", value) self.__margin = value @margin.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def margin(self): """ Deleter for **self.__margin** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "margin")) @property def separator_width(self): """ Property for **self.__separator_width** attribute. :return: self.__separator_width. :rtype: int """ return self.__separator_width @separator_width.setter @foundations.exceptions.handle_exceptions(AssertionError) def separator_width(self, value): """ Setter for **self.__separator_width** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "separator_width", value) assert value > 0, "'{0}' attribute: '{1}' need to be exactly positive!".format( "separator_width", value) self.__separator_width = value @separator_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def separator_width(self): """ Deleter for **self.__separator_width** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "separator_width")) @property def background_color(self): """ Property for **self.__background_color** attribute. :return: self.__background_color. :rtype: QColor """ return self.__background_color @background_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def background_color(self, value): """ Setter for **self.__background_color** attribute. :param value: Attribute value. :type value: QColor """ if value is not None: assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format( "background_color", value) self.__background_color = value @background_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def background_color(self): """ Deleter for **self.__background_color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "background_color")) @property def color(self): """ Property for **self.__color** attribute. :return: self.__color. :rtype: QColor """ return self.__color @color.setter @foundations.exceptions.handle_exceptions(AssertionError) def color(self, value): """ Setter for **self.__color** attribute. :param value: Attribute value. :type value: QColor """ if value is not None: assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format( "color", value) self.__color = value @color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def color(self): """ Deleter for **self.__color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "color")) @property def separator_color(self): """ Property for **self.__separator_color** attribute. :return: self.__separator_color. :rtype: QColor """ return self.__separator_color @separator_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def separator_color(self, value): """ Setter for **self.__separator_color** attribute. :param value: Attribute value. :type value: QColor """ if value is not None: assert type(value) is QColor, "'{0}' attribute: '{1}' type is not 'QColor'!".format( "separator_color", value) self.__separator_color = value @separator_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def separator_color(self): """ Deleter for **self.__separator_color** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "separator_color")) def sizeHint(self): """ Reimplements the :meth:`QWidget.sizeHint` method. :return: Size hint. :rtype: QSize """ return QSize(self.get_width(), 0) def paintEvent(self, event): """ Reimplements the :meth:`QWidget.paintEvent` method. :param event: Event. :type event: QEvent """ def __set_bold(state): """ Sets the current painter font bold state. :return: Definiton success. :rtype: bool """ font = painter.font() font.setBold(state) painter.setFont(font) return True painter = QPainter(self) painter.fillRect(event.rect(), self.__background_color) pen = QPen(QBrush(), self.__separator_width) pen.setColor(self.__separator_color) painter.setPen(pen) top_right_corner = event.rect().topRight() bottom_right_corner = event.rect().bottomRight() painter.drawLine(top_right_corner.x(), top_right_corner.y( ), bottom_right_corner.x(), bottom_right_corner.y()) painter.setPen(self.__color) viewport_height = self.__editor.viewport().height() metrics = QFontMetrics(self.__editor.document().defaultFont()) current_block = self.__editor.document().findBlock( self.__editor.textCursor().position()) block = self.__editor.firstVisibleBlock() block_number = block.blockNumber() painter.setFont(self.__editor.document().defaultFont()) while block.isValid(): block_number += 1 position = self.__editor.blockBoundingGeometry( block).topLeft() + self.__editor.contentOffset() if position.y() > viewport_height: break if not block.isVisible(): continue block == current_block and __set_bold(True) or __set_bold(False) painter.drawText( self.width() - metrics.width(foundations.strings.to_string(block_number)) - self.__margin / 3, round(position.y() + metrics.ascent() + metrics.descent() - (self.__editor.blockBoundingRect(block).height() * 8.0 / 100)), foundations.strings.to_string(block_number)) block = block.next() painter.end() QWidget.paintEvent(self, event) def get_width(self): """ Returns the Widget target width. :return: Widget target width. :rtype: int """ return self.__margin + \ self.__editor.fontMetrics().width( foundations.strings.to_string(max(1, self.__editor.blockCount()))) def set_editor_viewport_margins(self, newBlocksCount): """ Sets the editor viewport margins. :param newBlocksCount: Updated editor blocks count. :type newBlocksCount: int :return: Method success. :rtype: bool """ self.__editor.setViewportMargins(self.get_width(), 0, 0, 0) return True def update_rectangle(self, rectangle, scroll_y): """ Updates the given Widget rectangle. :param rectangle: Rectangle to update. :type rectangle: QRect :param scroll_y: Amount of pixels the viewport was scrolled. :type scroll_y: int :return: Method success. :rtype: bool """ if scroll_y: self.scroll(0, scroll_y) else: self.update(0, rectangle.y(), self.width(), rectangle.height()) if rectangle.contains(self.__editor.viewport().rect()): self.set_editor_viewport_margins(0) return True def update_geometry(self): """ Updates the Widget geometry. :return: Method success. :rtype: bool """ self.setGeometry(self.__editor.contentsRect().left(), self.__editor.contentsRect().top(), self.get_width(), self.__editor.contentsRect().height()) return True
class LinesNumbers_QWidget(QWidget): ''' Defines a `QWidget <http://doc.qt.nokia.com/qwidget.html>`_ subclass providing a lines numbers widget. ''' def __init__(self, parent, *args, **kwargs): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def editor(self): ''' Property for **self.__editor** attribute. :return: self.__editor. :rtype: QWidget ''' pass @editor.setter def editor(self): ''' Setter for **self.__editor** attribute. :param value: Attribute value. :type value: QWidget ''' pass @editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def editor(self): ''' Deleter for **self.__editor** attribute. ''' pass @property def margin(self): ''' Property for **self.__margin** attribute. :return: self.__margin. :rtype: int ''' pass @margin.setter @foundations.exceptions.handle_exceptions(AssertionError) def margin(self): ''' Setter for **self.__margin** attribute. :param value: Attribute value. :type value: int ''' pass @margin.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def margin(self): ''' Deleter for **self.__margin** attribute. ''' pass @property def separator_width(self): ''' Property for **self.__separator_width** attribute. :return: self.__separator_width. :rtype: int ''' pass @separator_width.setter @foundations.exceptions.handle_exceptions(AssertionError) def separator_width(self): ''' Setter for **self.__separator_width** attribute. :param value: Attribute value. :type value: int ''' pass @separator_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def separator_width(self): ''' Deleter for **self.__separator_width** attribute. ''' pass @property def background_color(self): ''' Property for **self.__background_color** attribute. :return: self.__background_color. :rtype: QColor ''' pass @background_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def background_color(self): ''' Setter for **self.__background_color** attribute. :param value: Attribute value. :type value: QColor ''' pass @background_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def background_color(self): ''' Deleter for **self.__background_color** attribute. ''' pass @property def color(self): ''' Property for **self.__color** attribute. :return: self.__color. :rtype: QColor ''' pass @color.setter @foundations.exceptions.handle_exceptions(AssertionError) def color(self): ''' Setter for **self.__color** attribute. :param value: Attribute value. :type value: QColor ''' pass @color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def color(self): ''' Deleter for **self.__color** attribute. ''' pass @property def separator_color(self): ''' Property for **self.__separator_color** attribute. :return: self.__separator_color. :rtype: QColor ''' pass @separator_color.setter @foundations.exceptions.handle_exceptions(AssertionError) def separator_color(self): ''' Setter for **self.__separator_color** attribute. :param value: Attribute value. :type value: QColor ''' pass @separator_color.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def separator_color(self): ''' Deleter for **self.__separator_color** attribute. ''' pass def sizeHint(self): ''' Reimplements the :meth:`QWidget.sizeHint` method. :return: Size hint. :rtype: QSize ''' pass def paintEvent(self, event): ''' Reimplements the :meth:`QWidget.paintEvent` method. :param event: Event. :type event: QEvent ''' pass def __set_bold(state): ''' Sets the current painter font bold state. :return: Definiton success. :rtype: bool ''' pass def get_width(self): ''' Returns the Widget target width. :return: Widget target width. :rtype: int ''' pass def set_editor_viewport_margins(self, newBlocksCount): ''' Sets the editor viewport margins. :param newBlocksCount: Updated editor blocks count. :type newBlocksCount: int :return: Method success. :rtype: bool ''' pass def update_rectangle(self, rectangle, scroll_y): ''' Updates the given Widget rectangle. :param rectangle: Rectangle to update. :type rectangle: QRect :param scroll_y: Amount of pixels the viewport was scrolled. :type scroll_y: int :return: Method success. :rtype: bool ''' pass def update_geometry(self): ''' Updates the Widget geometry. :return: Method success. :rtype: bool ''' pass
56
27
13
2
5
5
1
0.85
1
2
0
0
25
6
25
25
372
84
156
62
100
132
109
44
82
4
1
2
36
142,498
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/codeEditor_QPlainTextEdit.py
umbra.ui.widgets.codeEditor_QPlainTextEdit.CodeEditor_QPlainTextEdit
class CodeEditor_QPlainTextEdit(Basic_QPlainTextEdit): """ Defines a code editor base class. """ language_changed = pyqtSignal() """ This signal is emited by the :class:`Editor` class when :obj:`ComponentsManagerUi.language` class property language is changed. """ def __init__(self, parent=None, language=umbra.ui.languages.PYTHON_LANGUAGE, indent_marker=" " * 4, indent_width=4, comment_marker="#", *args, **kwargs): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param language: Editor language. :type language: Language :param indent_marker: Indentation marker. :type indent_marker: unicode :param indent_width: Indentation spaces count. :type indent_width: int :param comment_marker: Comment marker. :type comment_marker: unicode :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) Basic_QPlainTextEdit.__init__(self, parent, *args, **kwargs) # --- Setting class attributes. --- self.__language = language self.__indent_marker = None self.indent_marker = indent_marker self.__indent_width = None self.indent_width = indent_width self.__comment_marker = None self.comment_marker = comment_marker self.__margin_area_LinesNumbers_widget = None self.__highlighter = None self.__completer = None self.__occurrences_highlight_color = QColor(80, 80, 80) self.__pre_input_accelerators = [] self.__post_input_accelerators = [] self.__visual_accelerators = [] self.__text_cursor_anchor = None CodeEditor_QPlainTextEdit.__initialize_ui(self) @property def language(self): """ Property for **self.__language** attribute. :return: self.__language. :rtype: Language """ return self.__language @language.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def language(self, value): """ Setter for **self.__language** attribute. :param value: Attribute value. :type value: Language """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "language")) @language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def language(self): """ Deleter for **self.__language** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "language")) @property def indent_marker(self): """ Property for **self.__indent_marker** attribute. :return: self.__indent_marker. :rtype: unicode """ return self.__indent_marker @indent_marker.setter @foundations.exceptions.handle_exceptions(AssertionError) def indent_marker(self, value): """ Setter for **self.__indent_marker** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "indent_marker", value) assert re.search(r"\s", value), "'{0}' attribute: '{1}' is not a whitespace character!".format( "indent_marker", value) self.__indent_marker = value @indent_marker.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_marker(self): """ Deleter for **self.__indent_marker** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "indent_marker")) @property def indent_width(self): """ Property for **self.__indent_width** attribute. :return: self.__indent_width. :rtype: int """ return self.__indent_width @indent_width.setter @foundations.exceptions.handle_exceptions(AssertionError) def indent_width(self, value): """ Setter for **self.__indent_width** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "indent_width", value) self.__indent_width = value @indent_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_width(self): """ Deleter for **self.__indent_width** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "indent_width")) @property def comment_marker(self): """ Property for **self.__comment_marker** attribute. :return: self.__comment_marker. :rtype: unicode """ return self.__comment_marker @comment_marker.setter @foundations.exceptions.handle_exceptions(AssertionError) def comment_marker(self, value): """ Setter for **self.__comment_marker** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "comment_marker", value) self.__comment_marker = value @comment_marker.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def comment_marker(self): """ Deleter for **self.__comment_marker** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "comment_marker")) @property def margin_area_LinesNumbers_widget(self): """ Property for **self.__margin_area_LinesNumbers_widget** attribute. :return: self.__margin_area_LinesNumbers_widget. :rtype: LinesNumbers_QWidget """ return self.__margin_area_LinesNumbers_widget @margin_area_LinesNumbers_widget.setter @foundations.exceptions.handle_exceptions(AssertionError) def margin_area_LinesNumbers_widget(self, value): """ Setter for **self.__margin_area_LinesNumbers_widget** attribute. :param value: Attribute value. :type value: LinesNumbers_QWidget """ if value is not None: assert type(value) is LinesNumbers_QWidget, \ "'{0}' attribute: '{1}' type is not 'LinesNumbers_QWidget'!".format( "checked", value) self.__margin_area_LinesNumbers_widget = value @margin_area_LinesNumbers_widget.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def margin_area_LinesNumbers_widget(self): """ Deleter for **self.__margin_area_LinesNumbers_widget** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "margin_area_LinesNumbers_widget")) @property def highlighter(self): """ Property for **self.__highlighter** attribute. :return: self.__highlighter. :rtype: QSyntaxHighlighter """ return self.__highlighter @highlighter.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def highlighter(self, value): """ Setter for **self.__highlighter** attribute. :param value: Attribute value. :type value: QSyntaxHighlighter """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "highlighter")) @highlighter.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def highlighter(self): """ Deleter for **self.__highlighter** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "highlighter")) @property def completer(self): """ Property for **self.__completer** attribute. :return: self.__completer. :rtype: QCompleter """ return self.__completer @completer.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self, value): """ Setter for **self.__completer** attribute. :param value: Attribute value. :type value: QCompleter """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "completer")) @completer.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self): """ Deleter for **self.__completer** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "completer")) @property def pre_input_accelerators(self): """ Property for **self.__pre_input_accelerators** attribute. :return: self.__pre_input_accelerators. :rtype: tuple or list """ return self.__pre_input_accelerators @pre_input_accelerators.setter @foundations.exceptions.handle_exceptions(AssertionError) def pre_input_accelerators(self, value): """ Setter for **self.__pre_input_accelerators** attribute. :param value: Attribute value. :type value: tuple or list """ if value is not None: assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format( "pre_input_accelerators", value) self.__pre_input_accelerators = value @pre_input_accelerators.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def pre_input_accelerators(self): """ Deleter for **self.__pre_input_accelerators** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "pre_input_accelerators")) @property def post_input_accelerators(self): """ Property for **self.__post_input_accelerators** attribute. :return: self.__post_input_accelerators. :rtype: tuple or list """ return self.__post_input_accelerators @post_input_accelerators.setter @foundations.exceptions.handle_exceptions(AssertionError) def post_input_accelerators(self, value): """ Setter for **self.__post_input_accelerators** attribute. :param value: Attribute value. :type value: tuple or list """ if value is not None: assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format( "post_input_accelerators", value) self.__post_input_accelerators = value @post_input_accelerators.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def post_input_accelerators(self): """ Deleter for **self.__post_input_accelerators** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "post_input_accelerators")) @property def visual_accelerators(self): """ Property for **self.__visual_accelerators** attribute. :return: self.__visual_accelerators. :rtype: tuple or list """ return self.__visual_accelerators @visual_accelerators.setter @foundations.exceptions.handle_exceptions(AssertionError) def visual_accelerators(self, value): """ Setter for **self.__visual_accelerators** attribute. :param value: Attribute value. :type value: tuple or list """ if value is not None: assert type(value) in (tuple, list), "'{0}' attribute: '{1}' type is not 'tuple' or 'list'!".format( "visual_accelerators", value) self.__visual_accelerators = value @visual_accelerators.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def visual_accelerators(self): """ Deleter for **self.__visual_accelerators** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "visual_accelerators")) def __initialize_ui(self): """ Initializes the Widget ui. """ self.__margin_area_LinesNumbers_widget = LinesNumbers_QWidget(self) self.__set_extra_selections() self.__set_language_description() # Signals / Slots. self.blockCountChanged.connect( self.__margin_area_LinesNumbers_widget.set_editor_viewport_margins) self.updateRequest.connect( self.__margin_area_LinesNumbers_widget.update_rectangle) self.cursorPositionChanged.connect(self.__set_extra_selections) def resizeEvent(self, event): """ Reimplements the :meth:`Basic_QPlainTextEdit.resizeEvent` method. :param event: Event. :type event: QEvent """ Basic_QPlainTextEdit.resizeEvent(self, event) self.__margin_area_LinesNumbers_widget.update_geometry() @edit_block def keyPressEvent(self, event): """ Reimplements the :meth:`Basic_QPlainTextEdit.keyPressEvent` method. :param event: Event. :type event: QEvent """ processEvent = True for accelerator in self.__pre_input_accelerators: processEvent *= accelerator(self, event) if not processEvent: return Basic_QPlainTextEdit.keyPressEvent(self, event) for accelerator in self.__post_input_accelerators: accelerator(self, event) def __set_extra_selections(self): """ Sets current document extra selections. """ self.setExtraSelections(()) for accelerator in self.__visual_accelerators: accelerator(self) def __insert_completion(self, completion): """ Inserts the completion text in the current document. :param completion: Completion text. :type completion: QString """ LOGGER.debug("> Inserting '{0}' completion.".format(completion)) text_cursor = self.textCursor() extra = (completion.length() - self.__completer.completion_prefix().length()) text_cursor.insertText(completion.right(extra)) self.setTextCursor(text_cursor) def __set_language_description(self): """ Sets the language accelerators. """ LOGGER.debug("> Setting language description.") if not self.__language: return if self.__language.highlighter: self.set_highlighter(self.__language.highlighter(self.document(), self.__language.rules, self.__language.theme)) self.highlighter.rehighlight() else: self.remove_highlighter() if self.__language.completer: self.set_completer(self.__language.completer( self.parent(), self.__language.name, self.__language.tokens)) else: self.remove_completer() self.indent_marker = self.__language.indent_marker self.comment_marker = self.__language.comment_marker self.pre_input_accelerators = self.__language.pre_input_accelerators self.post_input_accelerators = self.__language.post_input_accelerators self.visual_accelerators = self.__language.visual_accelerators color = "rgb({0}, {1}, {2})" background = self.__language.theme.get("default").background() foreground = self.__language.theme.get("default").foreground() self.setStyleSheet( "QPlainTextEdit{{ background-color: {0}; color: {1}; }}".format(color.format(background.color().red(), background.color().green(), background.color().blue()), color.format(foreground.color().red(), foreground.color().green(), foreground.color().blue()))) self.__tab_width = self.fontMetrics().width(" " * self.indent_width) self.setTabStopWidth(self.__tab_width) def set_language(self, language): """ Sets the language. :param language: Language to set. :type language: Language :return: Method success. :rtype: bool """ LOGGER.debug( "> Setting editor language to '{0}'.".format(language.name)) self.__language = language or umbra.ui.languages.PYTHON_LANGUAGE self.__set_language_description() self.language_changed.emit() return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def set_highlighter(self, highlighter): """ Sets given highlighter as the current document highlighter. :param highlighter: Highlighter. :type highlighter: QSyntaxHighlighter :return: Method success. :rtype: bool """ if not issubclass(highlighter.__class__, QSyntaxHighlighter): raise foundations.exceptions.ProgrammingError("{0} | '{1}' is not a 'QSyntaxHighlighter' subclass!".format( self.__class__.__name__, highlighter)) if self.__highlighter: self.remove_highlighter() LOGGER.debug("> Setting '{0}' highlighter.".format(highlighter)) self.__highlighter = highlighter return True def remove_highlighter(self): """ Removes current highlighter. :return: Method success. :rtype: bool """ if self.__highlighter: LOGGER.debug("> Removing '{0}' highlighter.".format( self.__highlighter)) self.__highlighter.deleteLater() self.__highlighter = None return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def set_completer(self, completer): """ Sets given completer as the current completer. :param completer: Completer. :type completer: QCompleter :return: Method success. :rtype: bool """ if not issubclass(completer.__class__, QCompleter): raise foundations.exceptions.ProgrammingError("{0} | '{1}' is not a 'QCompleter' subclass!".format( self.__class__.__name__, completer)) if self.__completer: self.remove_completer() LOGGER.debug("> Setting '{0}' completer.".format(completer)) self.__completer = completer self.__completer.setWidget(self) # Signals / Slots. self.__completer.activated.connect(self.__insert_completion) return True def remove_completer(self): """ Removes current completer. :return: Method success. :rtype: bool """ if self.__completer: LOGGER.debug( "> Removing '{0}' completer.".format(self.__completer)) # Signals / Slots. self.__completer.activated.disconnect(self.__insert_completion) self.__completer.deleteLater() self.__completer = None return True def get_matching_symbols_pairs(self, cursor, opening_symbol, closing_symbol, backward=False): """ Returns the cursor for matching given symbols pairs. :param cursor: Cursor to match from. :type cursor: QTextCursor :param opening_symbol: Opening symbol. :type opening_symbol: unicode :param closing_symbol: Closing symbol to match. :type closing_symbol: unicode :return: Matching cursor. :rtype: QTextCursor """ if cursor.hasSelection(): start_position = cursor.selectionEnd() if backward else cursor.selectionStart() else: start_position = cursor.position() flags = QTextDocument.FindFlags() if backward: flags = flags | QTextDocument.FindBackward start_cursor = previous_start_cursor = cursor.document().find( opening_symbol, start_position, flags) end_cursor = previous_end_cursor = cursor.document().find( closing_symbol, start_position, flags) if backward: while start_cursor > end_cursor: start_cursor = cursor.document().find( opening_symbol, start_cursor.selectionStart(), flags) if start_cursor > end_cursor: end_cursor = cursor.document().find( closing_symbol, end_cursor.selectionStart(), flags) else: while start_cursor < end_cursor: start_cursor = cursor.document().find( opening_symbol, start_cursor.selectionEnd(), flags) if start_cursor < end_cursor: end_cursor = cursor.document().find( closing_symbol, end_cursor.selectionEnd(), flags) return end_cursor if end_cursor.position() != -1 else previous_end_cursor @edit_block def indent(self): """ Indents the document text under cursor. :return: Method success. :rtype: bool """ cursor = self.textCursor() if not cursor.hasSelection(): cursor.insertText(self.__indent_marker) else: block = self.document().findBlock(cursor.selectionStart()) while True: block_cursor = self.textCursor() block_cursor.setPosition(block.position()) block_cursor.insertText(self.__indent_marker) if block.contains(cursor.selectionEnd()): break block = block.next() return True @edit_block def unindent(self): """ Unindents the document text under cursor. :return: Method success. :rtype: bool """ cursor = self.textCursor() if not cursor.hasSelection(): cursor.movePosition(QTextCursor.StartOfBlock) line = foundations.strings.to_string( self.document().findBlockByNumber(cursor.blockNumber()).text()) indent_marker = re.match( r"({0})".format(self.__indent_marker), line) if indent_marker: foundations.common.repeat( cursor.deleteChar, len(indent_marker.group(1))) else: block = self.document().findBlock(cursor.selectionStart()) while True: block_cursor = self.textCursor() block_cursor.setPosition(block.position()) indent_marker = re.match(r"({0})".format( self.__indent_marker), block.text()) if indent_marker: foundations.common.repeat( block_cursor.deleteChar, len(indent_marker.group(1))) if block.contains(cursor.selectionEnd()): break block = block.next() return True @edit_block def toggle_comments(self): """ Toggles comments on the document selected lines. :return: Method success. :rtype: bool """ if not self.__comment_marker: return True cursor = self.textCursor() if not cursor.hasSelection(): cursor.movePosition(QTextCursor.StartOfBlock) line = foundations.strings.to_string( self.document().findBlockByNumber(cursor.blockNumber()).text()) if line.startswith(self.__comment_marker): foundations.common.repeat( cursor.deleteChar, len(self.__comment_marker)) else: cursor.insertText(self.__comment_marker) else: block = self.document().findBlock(cursor.selectionStart()) while True: block_cursor = self.textCursor() block_cursor.setPosition(block.position()) if foundations.strings.to_string(block.text()).startswith(self.__comment_marker): foundations.common.repeat( block_cursor.deleteChar, len(self.__comment_marker)) else: block_cursor.insertText(self.__comment_marker) if block.contains(cursor.selectionEnd()): break block = block.next() return True @anchor_text_cursor @edit_block def remove_trailing_white_spaces(self): """ Removes document trailing white spaces. :return: Method success. :rtype: bool """ cursor = self.textCursor() block = self.document().findBlockByLineNumber(0) while block.isValid(): cursor.setPosition(block.position()) if re.search(r"\s+$", block.text()): cursor.movePosition(QTextCursor.EndOfBlock) cursor.movePosition(QTextCursor.StartOfBlock, QTextCursor.KeepAnchor) cursor.insertText( foundations.strings.to_string(block.text()).rstrip()) block = block.next() cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) if not cursor.block().text().isEmpty(): cursor.insertText("\n") return True @anchor_text_cursor @edit_block def convert_indentation_to_tabs(self): """ Converts document indentation to tabs. :return: Method success. :rtype: bool """ cursor = self.textCursor() block = self.document().findBlockByLineNumber(0) while block.isValid(): cursor.setPosition(block.position()) search = re.match(r"^ +", block.text()) if search: cursor.movePosition(QTextCursor.StartOfBlock, QTextCursor.MoveAnchor) searchLength = len(search.group(0)) foundations.common.repeat( lambda: cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor), searchLength) cursor.insertText(self.__indent_marker * (searchLength / self.__indent_width)) block = block.next() return True @anchor_text_cursor @edit_block def convert_indentation_to_spaces(self): """ Converts document indentation to spaces. :return: Method success. :rtype: bool """ cursor = self.textCursor() block = self.document().findBlockByLineNumber(0) while block.isValid(): cursor.setPosition(block.position()) search = re.match(r"^\t+", block.text()) if search: cursor.movePosition(QTextCursor.StartOfBlock, QTextCursor.MoveAnchor) searchLength = len(search.group(0)) foundations.common.repeat( lambda: cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor), searchLength) cursor.insertText(" " * (searchLength * self.__indent_width)) block = block.next() return True
class CodeEditor_QPlainTextEdit(Basic_QPlainTextEdit): ''' Defines a code editor base class. ''' def __init__(self, parent=None, language=umbra.ui.languages.PYTHON_LANGUAGE, indent_marker=" " * 4, indent_width=4, comment_marker="#", *args, **kwargs): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param language: Editor language. :type language: Language :param indent_marker: Indentation marker. :type indent_marker: unicode :param indent_width: Indentation spaces count. :type indent_width: int :param comment_marker: Comment marker. :type comment_marker: unicode :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def language(self): ''' Property for **self.__language** attribute. :return: self.__language. :rtype: Language ''' pass @language.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def language(self): ''' Setter for **self.__language** attribute. :param value: Attribute value. :type value: Language ''' pass @language.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def language(self): ''' Deleter for **self.__language** attribute. ''' pass @property def indent_marker(self): ''' Property for **self.__indent_marker** attribute. :return: self.__indent_marker. :rtype: unicode ''' pass @indent_marker.setter @foundations.exceptions.handle_exceptions(AssertionError) def indent_marker(self): ''' Setter for **self.__indent_marker** attribute. :param value: Attribute value. :type value: unicode ''' pass @indent_marker.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_marker(self): ''' Deleter for **self.__indent_marker** attribute. ''' pass @property def indent_width(self): ''' Property for **self.__indent_width** attribute. :return: self.__indent_width. :rtype: int ''' pass @indent_width.setter @foundations.exceptions.handle_exceptions(AssertionError) def indent_width(self): ''' Setter for **self.__indent_width** attribute. :param value: Attribute value. :type value: int ''' pass @indent_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def indent_width(self): ''' Deleter for **self.__indent_width** attribute. ''' pass @property def comment_marker(self): ''' Property for **self.__comment_marker** attribute. :return: self.__comment_marker. :rtype: unicode ''' pass @comment_marker.setter @foundations.exceptions.handle_exceptions(AssertionError) def comment_marker(self): ''' Setter for **self.__comment_marker** attribute. :param value: Attribute value. :type value: unicode ''' pass @comment_marker.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def comment_marker(self): ''' Deleter for **self.__comment_marker** attribute. ''' pass @property def margin_area_LinesNumbers_widget(self): ''' Property for **self.__margin_area_LinesNumbers_widget** attribute. :return: self.__margin_area_LinesNumbers_widget. :rtype: LinesNumbers_QWidget ''' pass @margin_area_LinesNumbers_widget.setter @foundations.exceptions.handle_exceptions(AssertionError) def margin_area_LinesNumbers_widget(self): ''' Setter for **self.__margin_area_LinesNumbers_widget** attribute. :param value: Attribute value. :type value: LinesNumbers_QWidget ''' pass @margin_area_LinesNumbers_widget.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def margin_area_LinesNumbers_widget(self): ''' Deleter for **self.__margin_area_LinesNumbers_widget** attribute. ''' pass @property def highlighter(self): ''' Property for **self.__highlighter** attribute. :return: self.__highlighter. :rtype: QSyntaxHighlighter ''' pass @highlighter.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def highlighter(self): ''' Setter for **self.__highlighter** attribute. :param value: Attribute value. :type value: QSyntaxHighlighter ''' pass @highlighter.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def highlighter(self): ''' Deleter for **self.__highlighter** attribute. ''' pass @property def completer(self): ''' Property for **self.__completer** attribute. :return: self.__completer. :rtype: QCompleter ''' pass @completer.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self): ''' Setter for **self.__completer** attribute. :param value: Attribute value. :type value: QCompleter ''' pass @completer.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def completer(self): ''' Deleter for **self.__completer** attribute. ''' pass @property def pre_input_accelerators(self): ''' Property for **self.__pre_input_accelerators** attribute. :return: self.__pre_input_accelerators. :rtype: tuple or list ''' pass @pre_input_accelerators.setter @foundations.exceptions.handle_exceptions(AssertionError) def pre_input_accelerators(self): ''' Setter for **self.__pre_input_accelerators** attribute. :param value: Attribute value. :type value: tuple or list ''' pass @pre_input_accelerators.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def pre_input_accelerators(self): ''' Deleter for **self.__pre_input_accelerators** attribute. ''' pass @property def post_input_accelerators(self): ''' Property for **self.__post_input_accelerators** attribute. :return: self.__post_input_accelerators. :rtype: tuple or list ''' pass @post_input_accelerators.setter @foundations.exceptions.handle_exceptions(AssertionError) def post_input_accelerators(self): ''' Setter for **self.__post_input_accelerators** attribute. :param value: Attribute value. :type value: tuple or list ''' pass @post_input_accelerators.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def post_input_accelerators(self): ''' Deleter for **self.__post_input_accelerators** attribute. ''' pass @property def visual_accelerators(self): ''' Property for **self.__visual_accelerators** attribute. :return: self.__visual_accelerators. :rtype: tuple or list ''' pass @visual_accelerators.setter @foundations.exceptions.handle_exceptions(AssertionError) def visual_accelerators(self): ''' Setter for **self.__visual_accelerators** attribute. :param value: Attribute value. :type value: tuple or list ''' pass @visual_accelerators.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def visual_accelerators(self): ''' Deleter for **self.__visual_accelerators** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def resizeEvent(self, event): ''' Reimplements the :meth:`Basic_QPlainTextEdit.resizeEvent` method. :param event: Event. :type event: QEvent ''' pass @edit_block def keyPressEvent(self, event): ''' Reimplements the :meth:`Basic_QPlainTextEdit.keyPressEvent` method. :param event: Event. :type event: QEvent ''' pass def __set_extra_selections(self): ''' Sets current document extra selections. ''' pass def __insert_completion(self, completion): ''' Inserts the completion text in the current document. :param completion: Completion text. :type completion: QString ''' pass def __set_language_description(self): ''' Sets the language accelerators. ''' pass def set_language(self, language): ''' Sets the language. :param language: Language to set. :type language: Language :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def set_highlighter(self, highlighter): ''' Sets given highlighter as the current document highlighter. :param highlighter: Highlighter. :type highlighter: QSyntaxHighlighter :return: Method success. :rtype: bool ''' pass def remove_highlighter(self): ''' Removes current highlighter. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def set_completer(self, completer): ''' Sets given completer as the current completer. :param completer: Completer. :type completer: QCompleter :return: Method success. :rtype: bool ''' pass def remove_completer(self): ''' Removes current completer. :return: Method success. :rtype: bool ''' pass def get_matching_symbols_pairs(self, cursor, opening_symbol, closing_symbol, backward=False): ''' Returns the cursor for matching given symbols pairs. :param cursor: Cursor to match from. :type cursor: QTextCursor :param opening_symbol: Opening symbol. :type opening_symbol: unicode :param closing_symbol: Closing symbol to match. :type closing_symbol: unicode :return: Matching cursor. :rtype: QTextCursor ''' pass @edit_block def indent_marker(self): ''' Indents the document text under cursor. :return: Method success. :rtype: bool ''' pass @edit_block def unindent(self): ''' Unindents the document text under cursor. :return: Method success. :rtype: bool ''' pass @edit_block def toggle_comments(self): ''' Toggles comments on the document selected lines. :return: Method success. :rtype: bool ''' pass @anchor_text_cursor @edit_block def remove_trailing_white_spaces(self): ''' Removes document trailing white spaces. :return: Method success. :rtype: bool ''' pass @anchor_text_cursor @edit_block def convert_indentation_to_tabs(self): ''' Converts document indentation to tabs. :return: Method success. :rtype: bool ''' pass @anchor_text_cursor @edit_block def convert_indentation_to_spaces(self): ''' Converts document indentation to spaces. :return: Method success. :rtype: bool ''' pass
112
50
15
2
7
5
2
0.63
1
5
1
1
49
13
49
98
833
172
407
144
288
255
296
98
246
10
2
3
99
142,499
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/basic_QPlainTextEdit.py
umbra.ui.widgets.basic_QPlainTextEdit.Basic_QPlainTextEdit
class Basic_QPlainTextEdit(QPlainTextEdit): """ Defines a `QPlainTextEdit <http://doc.qt.nokia.com/qplaintextedit.html>`_ subclass providing a basic editor base class. """ # Custom signals definitions. patterns_replaced = pyqtSignal(list) """ This signal is emited by the :class:`Basic_QPlainTextEdit` class when patterns have been replaced. :return: Replaced patterns. :rtype: list """ def __init__(self, parent=None, *args, **kwargs): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QPlainTextEdit.__init__(self, parent, *args, **kwargs) # --- Setting class attributes. --- self.__search_pattern = None self.__minimum_font_point_size = 6 self.__maximum_font_point_size = 24 self.__text_cursor_anchor = None @property def search_pattern(self): """ Property for **self.__search_pattern** attribute. :return: self.__search_pattern. :rtype: unicode """ return self.__search_pattern @search_pattern.setter @foundations.exceptions.handle_exceptions(AssertionError) def search_pattern(self, value): """ Setter for **self.__search_pattern** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) in (unicode, QString), \ "'{0}' attribute: '{1}' type is not 'unicode' or 'QString'!".format( "search_pattern", value) self.__search_pattern = value @search_pattern.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_pattern(self): """ Deleter for **self.__search_pattern** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "search_pattern")) @property def minimum_font_point_size(self): """ Property for **self.__minimum_font_point_size** attribute. :return: self.__minimum_font_point_size. :rtype: int """ return self.__minimum_font_point_size @minimum_font_point_size.setter @foundations.exceptions.handle_exceptions(AssertionError) def minimum_font_point_size(self, value): """ Setter for **self.__minimum_font_point_size** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) in (int, float), "'{0}' attribute: '{1}' type is not 'int' or 'float'!".format( "minimum_font_point_size", value) assert value > 0, "'{0}' attribute: '{1}' need to be exactly positive!".format( "minimum_font_point_size", value) self.__minimum_font_point_size = value @minimum_font_point_size.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def minimum_font_point_size(self): """ Deleter for **self.__minimum_font_point_size** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "minimum_font_point_size")) @property def maximum_font_point_size(self): """ Property for **self.__maximum_font_point_size** attribute. :return: self.__maximum_font_point_size. :rtype: int """ return self.__maximum_font_point_size @maximum_font_point_size.setter @foundations.exceptions.handle_exceptions(AssertionError) def maximum_font_point_size(self, value): """ Setter for **self.__maximum_font_point_size** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) in (int, float), "'{0}' attribute: '{1}' type is not 'int' or 'float'!".format( "maximum_font_point_size", value) assert value > self.__minimum_font_point_size, \ "'{0}' attribute: '{1}' need to be exactly superior to '{2}'!".format( "maximum_font_point_size", value, self.__minimum_font_point_size) self.__maximum_font_point_size = value @maximum_font_point_size.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_font_point_size(self): """ Deleter for **self.__maximum_font_point_size** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "maximum_font_point_size")) @foundations.trace.untracable def wheelEvent(self, event): """ Reimplements the :meth:`QPlainTextEdit.wheelEvent` method. :param event: Event. :type event: QEvent """ if event.modifiers() == Qt.ControlModifier: if event.delta() == 120: self.zoom_in() elif event.delta() == -120: self.zoom_out() event.ignore() else: QPlainTextEdit.wheelEvent(self, event) def __select_text_under_cursor_blocks(self, cursor): """ Selects the document text under cursor blocks. :param cursor: Cursor. :type cursor: QTextCursor """ start_block = self.document().findBlock( cursor.selectionStart()).firstLineNumber() end_block = self.document().findBlock(cursor.selectionEnd()).firstLineNumber() cursor.setPosition( self.document().findBlockByLineNumber(start_block).position()) cursor.movePosition(QTextCursor.StartOfLine, QTextCursor.MoveAnchor) cursor.movePosition( QTextCursor.Down, QTextCursor.KeepAnchor, end_block - start_block) cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor) def get_selected_text_metrics(self): """ Returns current document selected text metrics. :return: Selected text metrics. :rtype: tuple """ selected_text = self.get_selected_text() if not selected_text: return tuple() return (selected_text, self.get_cursor_line(), self.get_cursor_column() - len(selected_text)) def get_default_text_option(self): """ Returns default text option. :return: Default text options. :rtype: QTextOption """ return self.document().defaultTextOption() def set_default_text_option(self, text_option): """ Sets default text option using given flag. :param text_option: Text option. :type text_option: QTextOption :return: Method success. :rtype: bool """ self.document().setDefaultTextOption(text_option) return True def store_text_cursor_anchor(self): """ Stores the document cursor anchor. :return: Method success. :rtype: bool """ self.__text_cursor_anchor = (self.textCursor(), self.horizontalScrollBar().sliderPosition(), self.verticalScrollBar().sliderPosition()) return True def restore_text_cursor_anchor(self): """ Restores the document cursor anchor. :return: Method success. :rtype: bool """ if not self.__text_cursor_anchor: return False text_cursor, horizontal_scroll_bar_slider_position, vertical_scroll_bar_slider_position = self.__text_cursor_anchor self.setTextCursor(text_cursor) self.horizontalScrollBar().setSliderPosition( horizontal_scroll_bar_slider_position) self.verticalScrollBar().setSliderPosition(vertical_scroll_bar_slider_position) return True def get_cursor_line(self): """ Returns the document cursor line. :return: Cursor line. :rtype: int """ return self.textCursor().blockNumber() def get_cursor_column(self): """ Returns the document cursor column. :return: Cursor column. :rtype: int """ return self.textCursor().columnNumber() def get_previous_character(self): """ Returns the character before the cursor. :return: Previous cursor character. :rtype: QString """ cursor = self.textCursor() cursor.movePosition(QTextCursor.PreviousCharacter, QTextCursor.KeepAnchor) return cursor.selectedText() def get_next_character(self): """ Returns the character after the cursor. :return: Next cursor character. :rtype: QString """ cursor = self.textCursor() cursor.movePosition(QTextCursor.NextCharacter, QTextCursor.KeepAnchor) return cursor.selectedText() def get_words(self): """ Returns the document words. :return: Document words. :rtype: list """ words = [] block = self.document().findBlockByLineNumber(0) while block.isValid(): blockWords = foundations.strings.get_words( foundations.strings.to_string(block.text())) if blockWords: words.extend(blockWords) block = block.next() return words def get_selected_text(self): """ Returns the document text under cursor. :return: Text under cursor. :rtype: QString """ return self.textCursor().selectedText() def get_word_under_cursor_legacy(self): """ Returns the document word under cursor ( Using Qt legacy "QTextCursor.WordUnderCursor" ). :return: Word under cursor. :rtype: QString """ cursor = self.textCursor() cursor.select(QTextCursor.WordUnderCursor) return cursor.selectedText() def get_word_under_cursor(self): """ Returns the document word under cursor. :return: Word under cursor. :rtype: QString """ if not re.match(r"^\w+$", foundations.strings.to_string(self.get_previous_character())): return QString() cursor = self.textCursor() cursor.movePosition(QTextCursor.PreviousWord, QTextCursor.MoveAnchor) cursor.movePosition(QTextCursor.EndOfWord, QTextCursor.KeepAnchor) return cursor.selectedText() def get_partial_word_under_cursor(self): """ Returns the document partial word under cursor ( From word start to cursor position ). :return: Partial word under cursor. :rtype: QString """ if not re.match(r"^\w+$", foundations.strings.to_string(self.get_previous_character())): return QString() cursor = self.textCursor() position = cursor.position() cursor.movePosition(QTextCursor.PreviousWord, QTextCursor.KeepAnchor) return cursor.selectedText() def is_modified(self): """ Returns if the document is modified. :return: Document modified state. :rtype: bool """ return self.document().isModified() def set_modified(self, state): """ Sets the document modified state. :param state: Modified state. :type state: bool :return: Method success. :rtype: bool """ self.document().setModified(state) return True def is_empty(self): """ Returns if the document is empty. :return: Document empty state. :rtype: bool """ return self.document().isEmpty() @edit_block def set_content(self, content): """ Sets document with given content while providing undo capability. :param content: Content to set. :type content: list :return: Method success. :rtype: bool """ cursor = self.textCursor() cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor) cursor.removeSelectedText() for line in content: self.moveCursor(QTextCursor.End) self.insertPlainText(line) return True def delete(self): """ Deletes the document text under cursor. :return: Method success. :rtype: bool """ self.textCursor().removeSelectedText() return True @edit_block def delete_lines(self): """ Deletes the document lines under cursor. :return: Method success. :rtype: bool """ cursor = self.textCursor() self.__select_text_under_cursor_blocks(cursor) cursor.removeSelectedText() cursor.deleteChar() return True @edit_block def duplicate_lines(self): """ Duplicates the document lines under cursor. :return: Method success. :rtype: bool """ cursor = self.textCursor() self.__select_text_under_cursor_blocks(cursor) text = cursor.selectedText() cursor.setPosition(cursor.block().next().position()) cursor.position() == cursor.document().firstBlock().position() and cursor.setPosition( cursor.document().lastBlock().position()) start_position = cursor.position() cursor.insertText(text) end_position = cursor.position() cursor.insertText(QChar(QChar.ParagraphSeparator)) cursor.setPosition(start_position, QTextCursor.MoveAnchor) cursor.setPosition(end_position, QTextCursor.KeepAnchor) self.setTextCursor(cursor) return True @edit_block def move_lines(self, direction=QTextCursor.Up): """ Moves the document lines under cursor. :param direction: Move direction ( QTextCursor.Down / QTextCursor.Up ). ( QTextCursor.MoveOperation ) :return: Method success. :rtype: bool """ cursor = self.textCursor() if (direction == QTextCursor.Up and cursor.block() == cursor.document().firstBlock()) or \ (direction == QTextCursor.Down and cursor.block() == cursor.document().lastBlock()): return False self.__select_text_under_cursor_blocks(cursor) text = cursor.selectedText() cursor.removeSelectedText() cursor.deleteChar() cursor.setPosition(cursor.block().next().position() if direction == QTextCursor.Down else cursor.block().previous().position()) if cursor.position() == cursor.document().firstBlock().position() and direction == QTextCursor.Down: cursor.movePosition(QTextCursor.End) cursor.insertText(QChar(QChar.ParagraphSeparator)) start_position = cursor.position() cursor.insertText(text) end_position = cursor.position() not cursor.atEnd() and cursor.insertText(QChar(QChar.ParagraphSeparator)) cursor.setPosition(start_position, QTextCursor.MoveAnchor) cursor.setPosition(end_position, QTextCursor.KeepAnchor) self.setTextCursor(cursor) return True def move_lines_up(self): """ Moves up the document lines under cursor. :return: Method success. :rtype: bool """ return self.move_lines(QTextCursor.Up) def move_lines_down(self): """ Moves down the document lines under cursor. :return: Method success. :rtype: bool """ return self.move_lines(QTextCursor.Down) @center_text_cursor def search(self, pattern, **kwargs): """ Searchs given pattern text in the document. Usage:: >>> script_editor = Umbra.components_manager.get_interface("factory.script_editor") True >>> codeEditor = script_editor.get_current_editor() True >>> codeEditor.search(search_pattern, case_sensitive=True, whole_word=True, regular_expressions=True, \ backward_search=True, wrap_around=True) True :param pattern: Pattern to search for. :type pattern: unicode :param \*\*kwargs: Search settings. :type \*\*kwargs: dict :return: Method success. :rtype: bool """ settings = foundations.data_structures.Structure(**{"case_sensitive": False, "whole_word": False, "regular_expressions": False, "backward_search": False, "wrap_around": True}) settings.update(kwargs) self.__search_pattern = pattern if settings.regular_expressions: pattern = QRegExp(pattern) pattern.setCaseSensitivity( Qt.CaseSensitive if settings.case_sensitive else Qt.CaseInsensitive) flags = QTextDocument.FindFlags() if settings.case_sensitive: flags = flags | QTextDocument.FindCaseSensitively if settings.whole_word: flags = flags | QTextDocument.FindWholeWords if settings.backward_search: flags = flags | QTextDocument.FindBackward cursor = self.document().find(pattern, self.textCursor(), flags) if not cursor.isNull(): self.setTextCursor(cursor) return True else: if settings.wrap_around: self.store_text_cursor_anchor() cursor = self.textCursor() if settings.backward_search: cursor.movePosition( QTextCursor.End, QTextCursor.MoveAnchor) else: cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) self.setTextCursor(cursor) settings.wrap_around = False if self.search(pattern, **settings): return True else: self.restore_text_cursor_anchor() @center_text_cursor def search_next(self): """ Searchs the next search pattern in the document. :return: Method success. :rtype: bool """ pattern = self.get_selected_text() or self.__search_pattern if not pattern: return False return self.search(pattern, **{"case_sensitive": True, "whole_word": False, "regular_expressions": False, "backward_search": False, "wrap_around": True}) @center_text_cursor def search_previous(self): """ Searchs the previous search pattern in the document. :return: Method success. :rtype: bool """ pattern = self.get_selected_text() or self.__search_pattern if not pattern: return False return self.search(pattern, **{"case_sensitive": True, "whole_word": False, "regular_expressions": False, "backward_search": True, "wrap_around": True}) @center_text_cursor @edit_block def replace(self, pattern, replacement_pattern, **kwargs): """ Replaces current given pattern occurence in the document with the replacement pattern. Usage:: >>> script_editor = Umbra.components_manager.get_interface("factory.script_editor") True >>> codeEditor = script_editor.get_current_editor() True >>> codeEditor.replace(search_pattern, replacement_pattern, case_sensitive=True, whole_word=True, \ regular_expressions=True, backward_search=True, wrap_around=True) True :param pattern: Pattern to replace. :type pattern: unicode :param replacement_pattern: Replacement pattern. :type replacement_pattern: unicode :param \*\*kwargs: Format settings. :type \*\*kwargs: dict :return: Method success. :rtype: bool """ settings = foundations.data_structures.Structure(**{"case_sensitive": False, "regular_expressions": False}) settings.update(kwargs) selected_text = self.get_selected_text() regex = "^{0}$".format( pattern if settings.regular_expressions else re.escape(foundations.strings.to_string(pattern))) flags = int() if settings.case_sensitive else re.IGNORECASE if not selected_text or not re.search(regex, selected_text, flags=flags): self.search(pattern, **kwargs) return False cursor = self.textCursor() metrics = self.get_selected_text_metrics() if cursor.isNull(): return False if not cursor.hasSelection(): return False cursor.insertText(replacement_pattern) self.patterns_replaced.emit([metrics]) self.search(pattern, **kwargs) return True @center_text_cursor @anchor_text_cursor @edit_block def replace_all(self, pattern, replacement_pattern, **kwargs): """ | Replaces every given pattern occurrences in the document with the replacement pattern. .. warning:: Initializing **wrap_around** keyword to **True** leads to infinite recursion loop if the search pattern and the replacement_pattern are the same. :param pattern: Pattern to replace. :type pattern: unicode :param replacement_pattern: Replacement pattern. :type replacement_pattern: unicode :param \*\*kwargs: Format settings. :type \*\*kwargs: dict :return: Method success. :rtype: bool """ edit_cursor = self.textCursor() edit_cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) self.setTextCursor(edit_cursor) patterns_replaced = [] while True: if not self.search(pattern, **kwargs): break cursor = self.textCursor() metrics = self.get_selected_text_metrics() if cursor.isNull(): break if not cursor.hasSelection(): break cursor.insertText(replacement_pattern) patterns_replaced.append(metrics) self.patterns_replaced.emit(patterns_replaced) return True @center_text_cursor def go_to_line(self, line): """ Moves the text cursor to given line. :param line: Line to go to. :type line: int :return: Method success. :rtype: bool """ cursor = self.textCursor() cursor.setPosition( self.document().findBlockByNumber(line - 1).position()) self.setTextCursor(cursor) return True def go_to_column(self, column): """ Moves the text cursor to given column. :param column: Column to go to. :type column: int :return: Method success. :rtype: bool """ cursor = self.textCursor() cursor.setPosition(cursor.block().position() + column) self.setTextCursor(cursor) return True def go_to_position(self, position): """ Moves the text cursor to given position. :param position: Position to go to. :type position: int :return: Method success. :rtype: bool """ cursor = self.textCursor() cursor.setPosition(position) self.setTextCursor(cursor) return True def toggle_word_wrap(self): """ Toggles document word wrap. :return: Method success. :rtype: bool """ self.setWordWrapMode(not self.wordWrapMode() and QTextOption.WordWrap or QTextOption.NoWrap) return True def toggle_white_spaces(self): """ Toggles document white spaces display. :return: Method success. :rtype: bool """ text_option = self.get_default_text_option() if text_option.flags().__int__(): text_option = QTextOption() text_option.setTabStop(self.tabStopWidth()) else: text_option.setFlags( text_option.flags() | QTextOption.ShowTabsAndSpaces | QTextOption.ShowLineAndParagraphSeparators) self.set_default_text_option(text_option) return True def set_font_increment(self, value): """ Increments the document font size. :param value: Font size increment. :type value: int :return: Method success. :rtype: bool """ font = self.font() point_size = font.pointSize() + value if point_size < self.__minimum_font_point_size or point_size > self.__maximum_font_point_size: return False font.setPointSize(point_size) self.setFont(font) return True def zoom_in(self): """ Increases the document font size. :return: Method success. :rtype: bool """ return self.set_font_increment(1) def zoom_out(self): """ Increases the document font size. :return: Method success. :rtype: bool """ return self.set_font_increment(-1)
class Basic_QPlainTextEdit(QPlainTextEdit): ''' Defines a `QPlainTextEdit <http://doc.qt.nokia.com/qplaintextedit.html>`_ subclass providing a basic editor base class. ''' def __init__(self, parent=None, *args, **kwargs): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def search_pattern(self): ''' Property for **self.__search_pattern** attribute. :return: self.__search_pattern. :rtype: unicode ''' pass @search_pattern.setter @foundations.exceptions.handle_exceptions(AssertionError) def search_pattern(self): ''' Setter for **self.__search_pattern** attribute. :param value: Attribute value. :type value: unicode ''' pass @search_pattern.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def search_pattern(self): ''' Deleter for **self.__search_pattern** attribute. ''' pass @property def minimum_font_point_size(self): ''' Property for **self.__minimum_font_point_size** attribute. :return: self.__minimum_font_point_size. :rtype: int ''' pass @minimum_font_point_size.setter @foundations.exceptions.handle_exceptions(AssertionError) def minimum_font_point_size(self): ''' Setter for **self.__minimum_font_point_size** attribute. :param value: Attribute value. :type value: int ''' pass @minimum_font_point_size.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def minimum_font_point_size(self): ''' Deleter for **self.__minimum_font_point_size** attribute. ''' pass @property def maximum_font_point_size(self): ''' Property for **self.__maximum_font_point_size** attribute. :return: self.__maximum_font_point_size. :rtype: int ''' pass @maximum_font_point_size.setter @foundations.exceptions.handle_exceptions(AssertionError) def maximum_font_point_size(self): ''' Setter for **self.__maximum_font_point_size** attribute. :param value: Attribute value. :type value: int ''' pass @maximum_font_point_size.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def maximum_font_point_size(self): ''' Deleter for **self.__maximum_font_point_size** attribute. ''' pass @foundations.trace.untracable def wheelEvent(self, event): ''' Reimplements the :meth:`QPlainTextEdit.wheelEvent` method. :param event: Event. :type event: QEvent ''' pass def __select_text_under_cursor_blocks(self, cursor): ''' Selects the document text under cursor blocks. :param cursor: Cursor. :type cursor: QTextCursor ''' pass def get_selected_text_metrics(self): ''' Returns current document selected text metrics. :return: Selected text metrics. :rtype: tuple ''' pass def get_default_text_option(self): ''' Returns default text option. :return: Default text options. :rtype: QTextOption ''' pass def set_default_text_option(self, text_option): ''' Sets default text option using given flag. :param text_option: Text option. :type text_option: QTextOption :return: Method success. :rtype: bool ''' pass def store_text_cursor_anchor(self): ''' Stores the document cursor anchor. :return: Method success. :rtype: bool ''' pass def restore_text_cursor_anchor(self): ''' Restores the document cursor anchor. :return: Method success. :rtype: bool ''' pass def get_cursor_line(self): ''' Returns the document cursor line. :return: Cursor line. :rtype: int ''' pass def get_cursor_column(self): ''' Returns the document cursor column. :return: Cursor column. :rtype: int ''' pass def get_previous_character(self): ''' Returns the character before the cursor. :return: Previous cursor character. :rtype: QString ''' pass def get_next_character(self): ''' Returns the character after the cursor. :return: Next cursor character. :rtype: QString ''' pass def get_words(self): ''' Returns the document words. :return: Document words. :rtype: list ''' pass def get_selected_text_metrics(self): ''' Returns the document text under cursor. :return: Text under cursor. :rtype: QString ''' pass def get_word_under_cursor_legacy(self): ''' Returns the document word under cursor ( Using Qt legacy "QTextCursor.WordUnderCursor" ). :return: Word under cursor. :rtype: QString ''' pass def get_word_under_cursor_legacy(self): ''' Returns the document word under cursor. :return: Word under cursor. :rtype: QString ''' pass def get_partial_word_under_cursor(self): ''' Returns the document partial word under cursor ( From word start to cursor position ). :return: Partial word under cursor. :rtype: QString ''' pass def is_modified(self): ''' Returns if the document is modified. :return: Document modified state. :rtype: bool ''' pass def set_modified(self, state): ''' Sets the document modified state. :param state: Modified state. :type state: bool :return: Method success. :rtype: bool ''' pass def is_empty(self): ''' Returns if the document is empty. :return: Document empty state. :rtype: bool ''' pass @edit_block def set_content(self, content): ''' Sets document with given content while providing undo capability. :param content: Content to set. :type content: list :return: Method success. :rtype: bool ''' pass def delete(self): ''' Deletes the document text under cursor. :return: Method success. :rtype: bool ''' pass @edit_block def delete_lines(self): ''' Deletes the document lines under cursor. :return: Method success. :rtype: bool ''' pass @edit_block def duplicate_lines(self): ''' Duplicates the document lines under cursor. :return: Method success. :rtype: bool ''' pass @edit_block def move_lines(self, direction=QTextCursor.Up): ''' Moves the document lines under cursor. :param direction: Move direction ( QTextCursor.Down / QTextCursor.Up ). ( QTextCursor.MoveOperation ) :return: Method success. :rtype: bool ''' pass def move_lines_up(self): ''' Moves up the document lines under cursor. :return: Method success. :rtype: bool ''' pass def move_lines_down(self): ''' Moves down the document lines under cursor. :return: Method success. :rtype: bool ''' pass @center_text_cursor def search_pattern(self): ''' Searchs given pattern text in the document. Usage:: >>> script_editor = Umbra.components_manager.get_interface("factory.script_editor") True >>> codeEditor = script_editor.get_current_editor() True >>> codeEditor.search(search_pattern, case_sensitive=True, whole_word=True, regular_expressions=True, backward_search=True, wrap_around=True) True :param pattern: Pattern to search for. :type pattern: unicode :param \*\*kwargs: Search settings. :type \*\*kwargs: dict :return: Method success. :rtype: bool ''' pass @center_text_cursor def search_next(self): ''' Searchs the next search pattern in the document. :return: Method success. :rtype: bool ''' pass @center_text_cursor def search_previous(self): ''' Searchs the previous search pattern in the document. :return: Method success. :rtype: bool ''' pass @center_text_cursor @edit_block def replace(self, pattern, replacement_pattern, **kwargs): ''' Replaces current given pattern occurence in the document with the replacement pattern. Usage:: >>> script_editor = Umbra.components_manager.get_interface("factory.script_editor") True >>> codeEditor = script_editor.get_current_editor() True >>> codeEditor.replace(search_pattern, replacement_pattern, case_sensitive=True, whole_word=True, regular_expressions=True, backward_search=True, wrap_around=True) True :param pattern: Pattern to replace. :type pattern: unicode :param replacement_pattern: Replacement pattern. :type replacement_pattern: unicode :param \*\*kwargs: Format settings. :type \*\*kwargs: dict :return: Method success. :rtype: bool ''' pass @center_text_cursor @anchor_text_cursor @edit_block def replace_all(self, pattern, replacement_pattern, **kwargs): ''' | Replaces every given pattern occurrences in the document with the replacement pattern. .. warning:: Initializing **wrap_around** keyword to **True** leads to infinite recursion loop if the search pattern and the replacement_pattern are the same. :param pattern: Pattern to replace. :type pattern: unicode :param replacement_pattern: Replacement pattern. :type replacement_pattern: unicode :param \*\*kwargs: Format settings. :type \*\*kwargs: dict :return: Method success. :rtype: bool ''' pass @center_text_cursor def go_to_line(self, line): ''' Moves the text cursor to given line. :param line: Line to go to. :type line: int :return: Method success. :rtype: bool ''' pass def go_to_column(self, column): ''' Moves the text cursor to given column. :param column: Column to go to. :type column: int :return: Method success. :rtype: bool ''' pass def go_to_position(self, position): ''' Moves the text cursor to given position. :param position: Position to go to. :type position: int :return: Method success. :rtype: bool ''' pass def toggle_word_wrap(self): ''' Toggles document word wrap. :return: Method success. :rtype: bool ''' pass def toggle_white_spaces(self): ''' Toggles document white spaces display. :return: Method success. :rtype: bool ''' pass def set_font_increment(self, value): ''' Increments the document font size. :param value: Font size increment. :type value: int :return: Method success. :rtype: bool ''' pass def zoom_in(self): ''' Increases the document font size. :return: Method success. :rtype: bool ''' pass def zoom_out(self): ''' Increases the document font size. :return: Method success. :rtype: bool ''' pass
79
50
15
3
7
6
2
0.87
1
4
0
1
49
4
49
49
845
188
352
120
273
305
288
100
238
10
1
3
87
142,500
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/application_QToolBar.py
umbra.ui.widgets.application_QToolBar.Application_QToolBar
class Application_QToolBar(QToolBar): """ Defines a `QToolBar <http://doc.qt.nokia.com/qtoolbar.html>`_ subclass providing the Application toolbar. """ def __init__(self, parent=None): """ Initializes the class. :param parent: Widget parent. :type parent: QObject """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QToolBar.__init__(self, parent) # --- Setting class attributes. --- self.__container = parent self.__settings = self.__container.settings self.__layouts_active_labels_collection = None self.__custom_layouts_menu = None self.__miscellaneous_menu = None self.__user_layouts = (umbra.managers.layouts_manager.Layout(name="1", identity="one", shortcut=Qt.Key_1), umbra.managers.layouts_manager.Layout( name="2", identity="two", shortcut=Qt.Key_2), umbra.managers.layouts_manager.Layout( name="3", identity="three", shortcut=Qt.Key_3), umbra.managers.layouts_manager.Layout( name="4", identity="four", shortcut=Qt.Key_4), umbra.managers.layouts_manager.Layout(name="5", identity="five", shortcut=Qt.Key_5)) Application_QToolBar.__initialize_ui(self) @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: Preferences """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: Preferences """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def layouts_active_labels_collection(self): """ Property for **self.__layouts_active_labels_collection** attribute. :return: self.__layouts_active_labels_collection. :rtype: Active_QLabelsCollection """ return self.__layouts_active_labels_collection @layouts_active_labels_collection.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts_active_labels_collection(self, value): """ Setter for **self.__layouts_active_labels_collection** attribute. :param value: Attribute value. :type value: Active_QLabelsCollection """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "layouts_active_labels_collection")) @layouts_active_labels_collection.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts_active_labels_collection(self): """ Deleter for **self.__layouts_active_labels_collection** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "layouts_active_labels_collection")) @property def custom_layouts_menu(self): """ Property for **self.__custom_layouts_menu** attribute. :return: self.__custom_layouts_menu. :rtype: QMenu """ return self.__custom_layouts_menu @custom_layouts_menu.setter @foundations.exceptions.handle_exceptions(AssertionError) def custom_layouts_menu(self, value): """ Setter for **self.__custom_layouts_menu** attribute. :param value: Attribute value. :type value: QMenu """ if value is not None: assert type(value) is QMenu, "'{0}' attribute: '{1}' type is not 'QMenu'!".format( "custom_layouts_menu", value) self.__custom_layouts_menu = value @custom_layouts_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def custom_layouts_menu(self): """ Deleter for **self.__custom_layouts_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "custom_layouts_menu")) @property def miscellaneous_menu(self): """ Property for **self.__miscellaneous_menu** attribute. :return: self.__miscellaneous_menu. :rtype: QMenu """ return self.__miscellaneous_menu @miscellaneous_menu.setter @foundations.exceptions.handle_exceptions(AssertionError) def miscellaneous_menu(self, value): """ Setter for **self.__miscellaneous_menu** attribute. :param value: Attribute value. :type value: QMenu """ if value is not None: assert type(value) is QMenu, "'{0}' attribute: '{1}' type is not 'QMenu'!".format( "miscellaneous_menu", value) self.__miscellaneous_menu = value @miscellaneous_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def miscellaneous_menu(self): """ Deleter for **self.__miscellaneous_menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "miscellaneous_menu")) def __initialize_ui(self): """ Initializes the Widget ui. """ LOGGER.debug("> Initializing Application toolBar!") self.setIconSize(QSize(UiConstants.default_toolbar_icon_size, UiConstants.default_toolbar_icon_size)) self.setAllowedAreas(Qt.TopToolBarArea) self.setFloatable(False) self.setMovable(False) self.set_layout_default_geometry() self.setObjectName("toolBar") self.setWindowTitle("{0} - toolBar".format(Constants.application_name)) self.set_toolbar_children_widgets() # Signals / Slots. self.__container.layouts_manager.layout_stored.connect( self.__layouts_manager__layout_stored) self.__container.layouts_manager.layout_restored.connect( self.__layouts_manager__layout_restored) def __layout_active_label__clicked(self, layout): """ Defines the slot triggered by a **Active_QLabel** Widget when clicked. :param layout: Layout name. :type layout: unicode """ self.__container.layouts_manager.restore_layout(layout) def __layouts_manager__layout_stored(self, layout): """ Defines the slot triggered by :class:`umbra.managers.layouts_manager.LayoutsManager` class when a layout is stored. :param layout: Layout name. :type layout: unicode """ layout_active_label = self.__layouts_active_labels_collection.get_toggled_active_label() layout_active_label and self.__settings.set_key("Layouts", "{0}_active_label".format( layout), layout_active_label.objectName()) def __layouts_manager__layout_restored(self, layout): """ Defines the slot triggered by :class:`umbra.managers.layouts_manager.LayoutsManager` class when a layout is restored. :param layout: Layout name. :type layout: unicode """ layout_active_label = self.__settings.get_key( "Layouts", "{0}_active_label".format(layout)).toString() for active_label in self.__layouts_active_labels_collection.active_labels: if not active_label.objectName() == layout_active_label: continue active_label.set_checked(True) def __help_display_misc_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|ToolBar|Miscellaneous|Help content ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ LOGGER.debug("> Opening url: '{0}'.".format(UiConstants.help_file)) QDesktopServices.openUrl(QUrl(QString(UiConstants.help_file))) return True def __api_display_misc_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|ToolBar|Miscellaneous|Api content ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ LOGGER.debug("> Opening url: '{0}'.".format(UiConstants.api_file)) QDesktopServices.openUrl(QUrl(QString(UiConstants.api_file))) return True def set_layout_default_geometry(self): """ Sets the toolBar layout default geometry. :return: Method success. :rtype: bool """ self.layout().setSpacing(8) self.layout().setContentsMargins(0, 0, 0, 0) return True def set_toolbar_children_widgets(self): """ Sets the toolBar children widgets. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding 'Application_Logo_label' widget!") self.addWidget(self.get_application_logo_label()) LOGGER.debug("> Adding 'Spacer_label' widget!") self.addWidget(self.get_spacer_label()) LOGGER.debug( "> Adding 'Development_active_label', 'Preferences_active_label' widgets!") for layout_active_label in self.get_layouts_active_labels(): self.addWidget(layout_active_label) LOGGER.debug("> Adding 'Custom_Layouts_active_label' widget!") self.addWidget(self.get_custom_layouts_active_label()) LOGGER.debug("> Adding 'Miscellaneous_active_label' widget!") self.addWidget(self.get_miscellaneous_active_label()) LOGGER.debug("> Adding 'Closure_Spacer_label' widget!") self.addWidget(self.get_closure_spacer_label()) return True def get_application_logo_label(self): """ Provides the default **Application_Logo_label** widget. :return: Application logo label. :rtype: QLabel """ logo_label = QLabel() logo_label.setObjectName("Application_Logo_label") logo_label.setPixmap( QPixmap(umbra.ui.common.get_resource_path(UiConstants.logo_image))) return logo_label def get_layout_active_label(self, resources, name, title, identity, shortcut): """ Returns a layout **Active_QLabel** widget. :param resources: Icons resources ( Default / Hover / Active ). :type resources: tuple :param name: Ui object name. :type name: unicode :param title: Layout registration title. :type title: unicode :param identity: Layout code name. :type identity: unicode :param shortcut: Layout associated shortcut. ( QtCore.Key ) :return: Layout active label. :rtype: Active_QLabel """ default_icon, hover_icon, active_icon = resources layout_active_label = Active_QLabel(self, QPixmap(umbra.ui.common.get_resource_path( default_icon)), QPixmap( umbra.ui.common.get_resource_path(hover_icon)), QPixmap( umbra.ui.common.get_resource_path(active_icon)), True) self.__container.layouts_manager.register_layout(identity, umbra.managers.layouts_manager.Layout(name=title, identity=identity, shortcut=shortcut)) self.__container.addAction( self.__container.actions_manager.register_action( "Actions|Umbra|ToolBar|Layouts|Restore layout {0}".format( title), shortcut=shortcut, shortcut_context=Qt.ApplicationShortcut, slot=functools.partial( self.__container.layouts_manager.restore_layout, identity))) layout_active_label.setObjectName(name) # Signals / Slots. layout_active_label.clicked.connect(functools.partial( self.__layout_active_label__clicked, identity)) return layout_active_label def get_layouts_active_labels(self): """ Returns the layouts **Active_QLabel** widgets. :return: Layouts active labels. :rtype: list """ self.__layouts_active_labels_collection = Active_QLabelsCollection( self) self.__layouts_active_labels_collection.add_active_label( self.get_layout_active_label((UiConstants.development_icon, UiConstants.development_hover_icon, UiConstants.development_active_icon), "Development_active_label", "Development", "development_centric", Qt.Key_9)) self.__layouts_active_labels_collection.add_active_label( self.get_layout_active_label((UiConstants.preferences_icon, UiConstants.preferences_hover_icon, UiConstants.preferences_active_icon), "Preferences_active_label", "Preferences", "preferences_centric", Qt.Key_0)) return self.__layouts_active_labels_collection.active_labels def get_custom_layouts_active_label(self): """ Provides the default **Custom_Layouts_active_label** widget. :return: Layout active label. :rtype: Active_QLabel """ layout_active_label = Active_QLabel(self, QPixmap(umbra.ui.common.get_resource_path( UiConstants.custom_layouts_icon)), QPixmap( umbra.ui.common.get_resource_path( UiConstants.custom_layouts_hover_icon)), QPixmap(umbra.ui.common.get_resource_path( UiConstants.custom_layouts_active_icon))) layout_active_label.setObjectName("Custom_Layouts_active_label") self.__custom_layouts_menu = QMenu("Layouts", layout_active_label) for layout in self.__user_layouts: self.__container.layouts_manager.register_layout( layout.identity, layout) self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action( "Actions|Umbra|ToolBar|Layouts|Restore layout {0}".format( layout.name), shortcut=layout.shortcut, slot=functools.partial(self.__container.layouts_manager.restore_layout, layout.identity))) self.__custom_layouts_menu.addSeparator() for layout in self.__user_layouts: self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action( "Actions|Umbra|ToolBar|Layouts|Store layout {0}".format( layout.name), shortcut=Qt.CTRL + layout.shortcut, slot=functools.partial(self.__container.layouts_manager.store_layout, layout.identity))) self.__custom_layouts_menu.addSeparator() self.__custom_layouts_menu.addAction(self.__container.actions_manager.register_action( "Actions|Umbra|ToolBar|Layouts|Toggle FullScreen", shortcut=Qt.ControlModifier + Qt.SHIFT + Qt.Key_F, slot=self.__container.toggle_full_screen)) layout_active_label.set_menu(self.__custom_layouts_menu) return layout_active_label def get_miscellaneous_active_label(self): """ Provides the default **Miscellaneous_active_label** widget. :return: Miscellaneous active label. :rtype: Active_QLabel """ miscellaneous_active_label = Active_QLabel(self, QPixmap( umbra.ui.common.get_resource_path( UiConstants.miscellaneous_icon)), QPixmap( umbra.ui.common.get_resource_path( UiConstants.miscellaneous_hover_icon)), QPixmap(umbra.ui.common.get_resource_path( UiConstants.miscellaneous_active_icon))) miscellaneous_active_label.setObjectName("Miscellaneous_active_label") self.__miscellaneous_menu = QMenu( "Miscellaneous", miscellaneous_active_label) self.__miscellaneous_menu.addAction(self.__container.actions_manager.register_action( "Actions|Umbra|ToolBar|Miscellaneous|Help content ...", shortcut="F1", slot=self.__help_display_misc_action__triggered)) self.__miscellaneous_menu.addAction(self.__container.actions_manager.register_action( "Actions|Umbra|ToolBar|Miscellaneous|Api content ...", slot=self.__api_display_misc_action__triggered)) self.__miscellaneous_menu.addSeparator() miscellaneous_active_label.set_menu(self.__miscellaneous_menu) return miscellaneous_active_label def get_spacer_label(self): """ Provides the default **Spacer_label** widget. :return: Logo spacer label. :rtype: QLabel """ spacer = QLabel() spacer.setObjectName("Spacer_label") spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) return spacer def get_closure_spacer_label(self): """ Provides the default **Closure_Spacer_label** widget. :return: Closure spacer label. :rtype: QLabel """ spacer = QLabel() spacer.setObjectName("Closure_Spacer_label") spacer.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding) return spacer
class Application_QToolBar(QToolBar): ''' Defines a `QToolBar <http://doc.qt.nokia.com/qtoolbar.html>`_ subclass providing the Application toolbar. ''' def __init__(self, parent=None): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: Preferences ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: Preferences ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def layouts_active_labels_collection(self): ''' Property for **self.__layouts_active_labels_collection** attribute. :return: self.__layouts_active_labels_collection. :rtype: Active_QLabelsCollection ''' pass @layouts_active_labels_collection.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts_active_labels_collection(self): ''' Setter for **self.__layouts_active_labels_collection** attribute. :param value: Attribute value. :type value: Active_QLabelsCollection ''' pass @layouts_active_labels_collection.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def layouts_active_labels_collection(self): ''' Deleter for **self.__layouts_active_labels_collection** attribute. ''' pass @property def custom_layouts_menu(self): ''' Property for **self.__custom_layouts_menu** attribute. :return: self.__custom_layouts_menu. :rtype: QMenu ''' pass @custom_layouts_menu.setter @foundations.exceptions.handle_exceptions(AssertionError) def custom_layouts_menu(self): ''' Setter for **self.__custom_layouts_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @custom_layouts_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def custom_layouts_menu(self): ''' Deleter for **self.__custom_layouts_menu** attribute. ''' pass @property def miscellaneous_menu(self): ''' Property for **self.__miscellaneous_menu** attribute. :return: self.__miscellaneous_menu. :rtype: QMenu ''' pass @miscellaneous_menu.setter @foundations.exceptions.handle_exceptions(AssertionError) def miscellaneous_menu(self): ''' Setter for **self.__miscellaneous_menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @miscellaneous_menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def miscellaneous_menu(self): ''' Deleter for **self.__miscellaneous_menu** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __layout_active_label__clicked(self, layout): ''' Defines the slot triggered by a **Active_QLabel** Widget when clicked. :param layout: Layout name. :type layout: unicode ''' pass def __layouts_manager__layout_stored(self, layout): ''' Defines the slot triggered by :class:`umbra.managers.layouts_manager.LayoutsManager` class when a layout is stored. :param layout: Layout name. :type layout: unicode ''' pass def __layouts_manager__layout_restored(self, layout): ''' Defines the slot triggered by :class:`umbra.managers.layouts_manager.LayoutsManager` class when a layout is restored. :param layout: Layout name. :type layout: unicode ''' pass def __help_display_misc_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|ToolBar|Miscellaneous|Help content ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __api_display_misc_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|ToolBar|Miscellaneous|Api content ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def set_layout_default_geometry(self): ''' Sets the toolBar layout default geometry. :return: Method success. :rtype: bool ''' pass def set_toolbar_children_widgets(self): ''' Sets the toolBar children widgets. :return: Method success. :rtype: bool ''' pass def get_application_logo_label(self): ''' Provides the default **Application_Logo_label** widget. :return: Application logo label. :rtype: QLabel ''' pass def get_layout_active_label(self, resources, name, title, identity, shortcut): ''' Returns a layout **Active_QLabel** widget. :param resources: Icons resources ( Default / Hover / Active ). :type resources: tuple :param name: Ui object name. :type name: unicode :param title: Layout registration title. :type title: unicode :param identity: Layout code name. :type identity: unicode :param shortcut: Layout associated shortcut. ( QtCore.Key ) :return: Layout active label. :rtype: Active_QLabel ''' pass def get_layouts_active_labels(self): ''' Returns the layouts **Active_QLabel** widgets. :return: Layouts active labels. :rtype: list ''' pass def get_custom_layouts_active_label(self): ''' Provides the default **Custom_Layouts_active_label** widget. :return: Layout active label. :rtype: Active_QLabel ''' pass def get_miscellaneous_active_label(self): ''' Provides the default **Miscellaneous_active_label** widget. :return: Miscellaneous active label. :rtype: Active_QLabel ''' pass def get_spacer_label(self): ''' Provides the default **Spacer_label** widget. :return: Logo spacer label. :rtype: QLabel ''' pass def get_closure_spacer_label(self): ''' Provides the default **Closure_Spacer_label** widget. :return: Closure spacer label. :rtype: QLabel ''' pass
57
32
15
3
7
5
1
0.68
1
7
5
0
31
6
31
31
525
118
242
65
185
165
146
50
114
3
1
2
38
142,501
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/widgets/active_QLabel.py
umbra.ui.widgets.active_QLabel.Active_QLabel
class Active_QLabel(QLabel): """ Defines a `QLabel <http://doc.qt.nokia.com/qlabel.html>`_ subclass providing a clickable label with hovering capabilities. """ # Custom signals definitions. clicked = pyqtSignal() """ This signal is emited by the :class:`Active_QLabel` class when it has been clicked. """ pressed = pyqtSignal() """ This signal is emited by the :class:`Active_QLabel` class when it has been pressed. """ released = pyqtSignal() """ This signal is emited by the :class:`Active_QLabel` class when it has been released. """ toggled = pyqtSignal(bool) """ This signal is emited by the :class:`Active_QLabel` class when it has been toggled. :return: Current checked state. :rtype: bool """ def __init__(self, parent=None, default_pixmap=None, hover_pixmap=None, active_pixmap=None, checkable=False, checked=False): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param default_pixmap: Label default pixmap. :type default_pixmap: QPixmap :param hover_pixmap: Label hover pixmap. :type hover_pixmap: QPixmap :param active_pixmap: Label active pixmap. :type active_pixmap: QPixmap :param checkable: Checkable state. :type checkable: bool :param checked: Checked state. :type checked: bool """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QLabel.__init__(self, parent) # --- Setting class attributes. --- self.__default_pixmap = None self.default_pixmap = default_pixmap or QPixmap() self.__hover_pixmap = None self.hover_pixmap = hover_pixmap or QPixmap() self.__active_pixmap = None self.active_pixmap = active_pixmap or QPixmap() self.__checkable = None self.checkable = checkable self.__checked = None self.checked = checked self.__menu = None if self.__checked: self.setPixmap(self.__active_pixmap) else: self.setPixmap(self.__default_pixmap) @property def default_pixmap(self): """ Property for **self.__default_pixmap** attribute. :return: self.__default_pixmap. :rtype: QPixmap """ return self.__default_pixmap @default_pixmap.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_pixmap(self, value): """ Setter for **self.__default_pixmap** attribute. :param value: Attribute value. :type value: QPixmap """ if value is not None: assert type(value) is QPixmap, "'{0}' attribute: '{1}' type is not 'QPixmap'!".format( "default_pixmap", value) self.__default_pixmap = value @default_pixmap.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_pixmap(self): """ Deleter for **self.__default_pixmap** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_pixmap")) @property def hover_pixmap(self): """ Property for **self.__hover_pixmap** attribute. :return: self.__hover_pixmap. :rtype: QPixmap """ return self.__hover_pixmap @hover_pixmap.setter @foundations.exceptions.handle_exceptions(AssertionError) def hover_pixmap(self, value): """ Setter for **self.__hover_pixmap** attribute. :param value: Attribute value. :type value: QPixmap """ if value is not None: assert type(value) is QPixmap, "'{0}' attribute: '{1}' type is not 'QPixmap'!".format( "hover_pixmap", value) self.__hover_pixmap = value @hover_pixmap.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def hover_pixmap(self): """ Deleter for **self.__hover_pixmap** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "hover_pixmap")) @property def active_pixmap(self): """ Property for **self.__active_pixmap** attribute. :return: self.__active_pixmap. :rtype: QPixmap """ return self.__active_pixmap @active_pixmap.setter @foundations.exceptions.handle_exceptions(AssertionError) def active_pixmap(self, value): """ Setter for **self.__active_pixmap** attribute. :param value: Attribute value. :type value: QPixmap """ if value is not None: assert type(value) is QPixmap, "'{0}' attribute: '{1}' type is not 'QPixmap'!".format( "active_pixmap", value) self.__active_pixmap = value @active_pixmap.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def active_pixmap(self): """ Deleter for **self.__active_pixmap** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "active_pixmap")) @property def checkable(self): """ Property for **self.__checkable** attribute. :return: self.__checkable. :rtype: bool """ return self.__checkable @checkable.setter @foundations.exceptions.handle_exceptions(AssertionError) def checkable(self, value): """ Setter for **self.__checkable** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format( "checkable", value) self.__checkable = value @checkable.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def checkable(self): """ Deleter for **self.__checkable** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "checkable")) @property def checked(self): """ Property for **self.__checked** attribute. :return: self.__checked. :rtype: bool """ return self.__checked @checked.setter @foundations.exceptions.handle_exceptions(AssertionError) def checked(self, value): """ Setter for **self.__checked** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format( "checked", value) self.set_checked(value) @checked.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def checked(self): """ Deleter for **self.__checked** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "checked")) @property def menu(self): """ Property for **self.__menu** attribute. :return: self.__menu. :rtype: QMenu """ return self.__menu @menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu(self, value): """ Setter for **self.__menu** attribute. :param value: Attribute value. :type value: QMenu """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "menu")) @menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu(self): """ Deleter for **self.__menu** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "menu")) def enterEvent(self, event): """ Reimplements the :meth:`QLabel.enterEvent` method. :param event: QEvent. :type event: QEvent """ if self.__checkable: not self.__checked and self.setPixmap(self.__hover_pixmap) else: self.setPixmap(self.__hover_pixmap) def leaveEvent(self, event): """ Reimplements the :meth:`QLabel.leaveEvent` method. :param event: QEvent. :type event: QEvent """ if self.__checkable: not self.__checked and self.setPixmap(self.__default_pixmap) else: self.setPixmap(self.__default_pixmap) def mousePressEvent(self, event): """ Reimplements the :meth:`QLabel.mousePressEvent` method. :param event: QEvent. :type event: QEvent """ self.setPixmap(self.__active_pixmap) self.__menu and self.__menu.exec_(QCursor.pos()) self.pressed.emit() def mouseReleaseEvent(self, event): """ Reimplements the :meth:`QLabel.mouseReleaseEvent` method. :param event: QEvent. :type event: QEvent """ if self.underMouse(): if self.__checkable: self.set_checked(not self.__checked) else: self.setPixmap(self.__active_pixmap) else: self.setPixmap(self.__default_pixmap) self.released.emit() self.clicked.emit() def set_checked(self, state): """ Sets the Widget checked state. :param state: New check state. :type state: bool :return: Method success. :rtype: bool """ if not self.__checkable: return False if state: self.__checked = True self.setPixmap(self.__active_pixmap) else: self.__checked = False self.setPixmap(self.__default_pixmap) self.toggled.emit(state) return True def set_menu(self, menu): """ Sets the Widget menu. :param menu: Menu. :type menu: QMenu :return: Method success. :rtype: bool """ self.__menu = menu if not self.parent(): return False parent = [ parent for parent in umbra.ui.common.parents_walker(self)].pop() for action in self.__menu.actions(): not action.shortcut().isEmpty() and parent.addAction(action) return True
class Active_QLabel(QLabel): ''' Defines a `QLabel <http://doc.qt.nokia.com/qlabel.html>`_ subclass providing a clickable label with hovering capabilities. ''' def __init__(self, parent=None, default_pixmap=None, hover_pixmap=None, active_pixmap=None, checkable=False, checked=False): ''' Initializes the class. :param parent: Widget parent. :type parent: QObject :param default_pixmap: Label default pixmap. :type default_pixmap: QPixmap :param hover_pixmap: Label hover pixmap. :type hover_pixmap: QPixmap :param active_pixmap: Label active pixmap. :type active_pixmap: QPixmap :param checkable: Checkable state. :type checkable: bool :param checked: Checked state. :type checked: bool ''' pass @property def default_pixmap(self): ''' Property for **self.__default_pixmap** attribute. :return: self.__default_pixmap. :rtype: QPixmap ''' pass @default_pixmap.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_pixmap(self): ''' Setter for **self.__default_pixmap** attribute. :param value: Attribute value. :type value: QPixmap ''' pass @default_pixmap.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_pixmap(self): ''' Deleter for **self.__default_pixmap** attribute. ''' pass @property def hover_pixmap(self): ''' Property for **self.__hover_pixmap** attribute. :return: self.__hover_pixmap. :rtype: QPixmap ''' pass @hover_pixmap.setter @foundations.exceptions.handle_exceptions(AssertionError) def hover_pixmap(self): ''' Setter for **self.__hover_pixmap** attribute. :param value: Attribute value. :type value: QPixmap ''' pass @hover_pixmap.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def hover_pixmap(self): ''' Deleter for **self.__hover_pixmap** attribute. ''' pass @property def active_pixmap(self): ''' Property for **self.__active_pixmap** attribute. :return: self.__active_pixmap. :rtype: QPixmap ''' pass @active_pixmap.setter @foundations.exceptions.handle_exceptions(AssertionError) def active_pixmap(self): ''' Setter for **self.__active_pixmap** attribute. :param value: Attribute value. :type value: QPixmap ''' pass @active_pixmap.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def active_pixmap(self): ''' Deleter for **self.__active_pixmap** attribute. ''' pass @property def checkable(self): ''' Property for **self.__checkable** attribute. :return: self.__checkable. :rtype: bool ''' pass @checkable.setter @foundations.exceptions.handle_exceptions(AssertionError) def checkable(self): ''' Setter for **self.__checkable** attribute. :param value: Attribute value. :type value: bool ''' pass @checkable.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def checkable(self): ''' Deleter for **self.__checkable** attribute. ''' pass @property def checked(self): ''' Property for **self.__checked** attribute. :return: self.__checked. :rtype: bool ''' pass @checked.setter @foundations.exceptions.handle_exceptions(AssertionError) def checked(self): ''' Setter for **self.__checked** attribute. :param value: Attribute value. :type value: bool ''' pass @checked.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def checked(self): ''' Deleter for **self.__checked** attribute. ''' pass @property def menu(self): ''' Property for **self.__menu** attribute. :return: self.__menu. :rtype: QMenu ''' pass @menu.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu(self): ''' Setter for **self.__menu** attribute. :param value: Attribute value. :type value: QMenu ''' pass @menu.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def menu(self): ''' Deleter for **self.__menu** attribute. ''' pass def enterEvent(self, event): ''' Reimplements the :meth:`QLabel.enterEvent` method. :param event: QEvent. :type event: QEvent ''' pass def leaveEvent(self, event): ''' Reimplements the :meth:`QLabel.leaveEvent` method. :param event: QEvent. :type event: QEvent ''' pass def mousePressEvent(self, event): ''' Reimplements the :meth:`QLabel.mousePressEvent` method. :param event: QEvent. :type event: QEvent ''' pass def mouseReleaseEvent(self, event): ''' Reimplements the :meth:`QLabel.mouseReleaseEvent` method. :param event: QEvent. :type event: QEvent ''' pass def set_checked(self, state): ''' Sets the Widget checked state. :param state: New check state. :type state: bool :return: Method success. :rtype: bool ''' pass def set_menu(self, menu): ''' Sets the Widget menu. :param menu: Menu. :type menu: QMenu :return: Method success. :rtype: bool ''' pass
56
26
12
2
5
5
2
0.93
1
2
0
0
25
6
25
25
387
82
158
62
96
147
106
38
80
3
1
2
39
142,502
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/views.py
umbra.ui.views.ReadOnlyFilter
class ReadOnlyFilter(QObject): """ Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass used as an event filter for the :class:`Abstract_QListView` and :class:`Abstract_QTreeView` classes. """ def eventFilter(self, object, event): """ Reimplements the **QObject.eventFilter** method. :param object: Object. :type object: QObject :param event: Event. :type event: QEvent :return: Event filtered. :rtype: bool """ if event.type() == QEvent.MouseButtonDblClick: view = object.parent() if view.read_only: self.__raise_user_error(view) return True return False @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.UserError) def __raise_user_error(self, view): """ Raises an error if the given View has been set read only and the user attempted to edit its content. :param view: View. :type view: QWidget """ raise foundations.exceptions.UserError("{0} | Cannot perform action, '{1}' View has been set read only!".format( self.__class__.__name__, view.objectName() or view))
class ReadOnlyFilter(QObject): ''' Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass used as an event filter for the :class:`Abstract_QListView` and :class:`Abstract_QTreeView` classes. ''' def eventFilter(self, object, event): ''' Reimplements the **QObject.eventFilter** method. :param object: Object. :type object: QObject :param event: Event. :type event: QEvent :return: Event filtered. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.UserError) def __raise_user_error(self, view): ''' Raises an error if the given View has been set read only and the user attempted to edit its content. :param view: View. :type view: QWidget ''' pass
4
3
14
2
5
7
2
1.38
1
0
0
0
2
0
2
2
37
6
13
6
8
18
10
4
7
3
1
2
4
142,503
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/views.py
umbra.ui.views.Mixin_AbstractBase
class Mixin_AbstractBase(object): """ Defines the base mixin used to bring common capabilities in Application Views classes. """ def __init__(self, message=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param message: View default message when Model is empty. :type message: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) # --- Setting class attributes. --- self.__message = None self.message = message or "No Item to view!" self.__notifier = Notification_QLabel(self, color=QColor(192, 192, 192), background_color=QColor( 24, 24, 24), border_color=QColor(32, 32, 32), anchor=8) @property def message(self): """ Property for **self.__message** attribute. :return: self.__message. :rtype: unicode """ return self.__message @message.setter @foundations.exceptions.handle_exceptions(AssertionError) def message(self, value): """ Setter for **self.__message** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) in (unicode, QString), \ "'{0}' attribute: '{1}' type is not 'unicode' or 'QString'!".format( "message", value) self.__message = value @message.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def message(self): """ Deleter for **self.__message** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "message")) def resizeEvent(self, event): """ Reimplements the :meth:`*.resizeEvent` method. :param event: QEvent. :type event: QEvent """ super(type(self), self).resizeEvent(event) self.__notifier.refresh_position() def paintEvent(self, event): """ Reimplements the :meth:`*.paintEvent` method. :param event: QEvent. :type event: QEvent """ super(type(self), self).paintEvent(event) show_message = True model = self.model() if issubclass(type(model), GraphModel): if model.has_nodes(): show_message = False elif issubclass(type(model), QAbstractItemModel) or \ issubclass(type(model), QAbstractListModel) or \ issubclass(type(model), QAbstractTableModel): if model.rowCount(): show_message = False if show_message: self.__notifier.show_message(self.__message, 0) else: self.__notifier.hide_message()
class Mixin_AbstractBase(object): ''' Defines the base mixin used to bring common capabilities in Application Views classes. ''' def __init__(self, message=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param message: View default message when Model is empty. :type message: unicode ''' pass @property def message(self): ''' Property for **self.__message** attribute. :return: self.__message. :rtype: unicode ''' pass @message.setter @foundations.exceptions.handle_exceptions(AssertionError) def message(self): ''' Setter for **self.__message** attribute. :param value: Attribute value. :type value: unicode ''' pass @message.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def message(self): ''' Deleter for **self.__message** attribute. ''' pass def resizeEvent(self, event): ''' Reimplements the :meth:`*.resizeEvent` method. :param event: QEvent. :type event: QEvent ''' pass def paintEvent(self, event): ''' Reimplements the :meth:`*.paintEvent` method. :param event: QEvent. :type event: QEvent ''' pass
12
7
14
3
6
5
2
0.77
1
4
2
2
6
2
6
6
100
22
44
14
32
34
29
11
22
6
1
2
12
142,504
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/ui/nodes.py
umbra.ui.nodes.FormatNode
class FormatNode(AbstractCompositeNode): """ Defines the format base Node object. """ __family = "Format" """ :param __family: Node family. :type __family: unicode """ def __init__(self, name=None, parent=None, children=None, format=None, **kwargs): """ Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: AbstractNode or AbstractCompositeNode :param children: Children. :type children: list :param format: Format. :type format: object :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) AbstractCompositeNode.__init__(self, name, parent, children, **kwargs) # --- Setting class attributes. --- self.__format = None self.format = format @property def format(self): """ Property for **self.__format** attribute. :return: self.__format. :rtype: object """ return self.__format @format.setter def format(self, value): """ Setter for **self.__format** attribute. :param value: Attribute value. :type value: object """ self.__format = value @format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def format(self): """ Deleter for **self.__format** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "format"))
class FormatNode(AbstractCompositeNode): ''' Defines the format base Node object. ''' def __init__(self, name=None, parent=None, children=None, format=None, **kwargs): ''' Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: AbstractNode or AbstractCompositeNode :param children: Children. :type children: list :param format: Format. :type format: object :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def format(self): ''' Property for **self.__format** attribute. :return: self.__format. :rtype: object ''' pass @format.setter def format(self): ''' Setter for **self.__format** attribute. :param value: Attribute value. :type value: object ''' pass @format.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def format(self): ''' Deleter for **self.__format** attribute. ''' pass
9
5
12
2
3
7
1
1.89
1
0
0
0
4
1
4
4
66
14
18
10
9
34
13
7
8
1
1
0
4
142,505
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.FileNode
class FileNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **File** node. """ __family = "File" def __init__(self, path=None, name=None, parent=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param path: File path. :type path: unicode :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__( self, name, parent, None, roles, node_flags, **kwargs) # --- Setting class attributes. --- self.__path = None self.path = path FileNode.__initialize_node(self, attributes_flags) @property def path(self): """ Property for **self.__path** attribute. :return: self.__path. :rtype: unicode """ return self.__path @path.setter @foundations.exceptions.handle_exceptions(AssertionError) def path(self, value): """ Setter for **self.__path** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "path", value) self.__path = value @path.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def path(self): """ Deleter for **self.__path** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "path")) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class FileNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **File** node. ''' def __init__(self, path=None, name=None, parent=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param path: File path. :type path: unicode :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def path(self): ''' Property for **self.__path** attribute. :return: self.__path. :rtype: unicode ''' pass @path.setter @foundations.exceptions.handle_exceptions(AssertionError) def path(self): ''' Setter for **self.__path** attribute. :param value: Attribute value. :type value: unicode ''' pass @path.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def path(self): ''' Deleter for **self.__path** attribute. ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
11
6
14
2
5
7
1
1.29
1
2
0
0
5
1
5
18
89
18
31
18
13
40
18
8
12
2
3
1
6
142,506
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.EditorNode
class EditorNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **Editor** node. """ __family = "Editor" def __init__(self, editor=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__( self, name, parent, children, roles, node_flags, **kwargs) # --- Setting class attributes. --- self.__editor = None self.editor = editor EditorNode.__initialize_node(self, attributes_flags) @property def editor(self): """ Property for **self.__editor** attribute. :return: self.__editor. :rtype: Editor """ return self.__editor @editor.setter @foundations.exceptions.handle_exceptions(AssertionError) def editor(self, value): """ Setter for **self.__editor** attribute. :param value: Attribute value. :type value: Editor """ if value is not None: assert type(value) is Editor, "'{0}' attribute: '{1}' type is not 'Editor'!".format( "editor", value) self.__editor = value @editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def editor(self): """ Deleter for **self.__editor** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "editor")) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class EditorNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **Editor** node. ''' def __init__(self, editor=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def editor(self): ''' Property for **self.__editor** attribute. :return: self.__editor. :rtype: Editor ''' pass @editor.setter @foundations.exceptions.handle_exceptions(AssertionError) def editor(self): ''' Setter for **self.__editor** attribute. :param value: Attribute value. :type value: Editor ''' pass @editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def editor(self): ''' Deleter for **self.__editor** attribute. ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
11
6
15
2
5
7
1
1.25
1
3
1
0
5
1
5
18
90
18
32
19
13
40
18
8
12
2
3
1
6
142,507
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.DirectoryNode
class DirectoryNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **Directory** node. """ __family = "Directory" def __init__(self, path=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param path: Directory path. :type path: unicode :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__( self, name, parent, children, roles, node_flags, **kwargs) # --- Setting class attributes. --- self.__path = None self.path = path DirectoryNode.__initialize_node(self, attributes_flags) @property def path(self): """ Property for **self.__path** attribute. :return: self.__path. :rtype: unicode """ return self.__path @path.setter @foundations.exceptions.handle_exceptions(AssertionError) def path(self, value): """ Setter for **self.__path** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "path", value) assert os.path.exists( value), "'{0}' attribute: '{1}' path doesn't exists!".format("source", value) self.__path = value @path.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def path(self): """ Deleter for **self.__path** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "path")) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class DirectoryNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class **Directory** node. ''' def __init__(self, path=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param path: Directory path. :type path: unicode :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def path(self): ''' Property for **self.__path** attribute. :return: self.__path. :rtype: unicode ''' pass @path.setter @foundations.exceptions.handle_exceptions(AssertionError) def path(self): ''' Setter for **self.__path** attribute. :param value: Attribute value. :type value: unicode ''' pass @path.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def path(self): ''' Deleter for **self.__path** attribute. ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
11
6
15
2
5
8
1
1.27
1
2
0
0
5
1
5
18
93
18
33
19
14
42
19
8
13
2
3
1
6
142,508
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.EngineInitializationError
class EngineInitializationError(AbstractEngineError): """ Defines engine initialization exception. """ pass
class EngineInitializationError(AbstractEngineError): ''' Defines engine initialization exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,509
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.EngineConfigurationError
class EngineConfigurationError(AbstractEngineError): """ Defines engine configuration exception. """ pass
class EngineConfigurationError(AbstractEngineError): ''' Defines engine configuration exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,510
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.CategoryExistsError
class CategoryExistsError(AbstractActionsManagerError): """ Defines non existing category exception. """ pass
class CategoryExistsError(AbstractActionsManagerError): ''' Defines non existing category exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,511
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.ActionExistsError
class ActionExistsError(AbstractActionsManagerError): """ Defines non existing action exception. """ pass
class ActionExistsError(AbstractActionsManagerError): ''' Defines non existing action exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,512
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/workers.py
umbra.components.factory.script_editor.workers.SearchResult
class SearchResult(foundations.data_structures.Structure): """ Defines a storage object for the :class:`Search_worker` class search result. """ def __init__(self, **kwargs): """ Initializes the class. :param \*\*kwargs: file, pattern, settings, occurrences. :type \*\*kwargs: dict """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) foundations.data_structures.Structure.__init__(self, **kwargs)
class SearchResult(foundations.data_structures.Structure): ''' Defines a storage object for the :class:`Search_worker` class search result. ''' def __init__(self, **kwargs): ''' Initializes the class. :param \*\*kwargs: file, pattern, settings, occurrences. :type \*\*kwargs: dict ''' pass
2
2
11
3
3
5
1
2
1
0
0
0
1
0
1
1
16
4
4
2
2
8
4
2
2
1
1
0
1
142,513
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/workers.py
umbra.components.factory.script_editor.workers.Occurence
class Occurence(foundations.data_structures.Structure): """ Defines a storage object for the :class:`Search_worker` class search occurence. """ def __init__(self, **kwargs): """ Initializes the class. :param \*\*kwargs: line, column, length, text. :type \*\*kwargs: dict """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) foundations.data_structures.Structure.__init__(self, **kwargs)
class Occurence(foundations.data_structures.Structure): ''' Defines a storage object for the :class:`Search_worker` class search occurence. ''' def __init__(self, **kwargs): ''' Initializes the class. :param \*\*kwargs: line, column, length, text. :type \*\*kwargs: dict ''' pass
2
2
11
3
3
5
1
2
1
0
0
0
1
0
1
1
16
4
4
2
2
8
4
2
2
1
1
0
1
142,514
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/workers.py
umbra.components.factory.script_editor.workers.CacheData
class CacheData(foundations.data_structures.Structure): """ Defines a storage object for the :class:`Search_worker` class cache data. """ def __init__(self, **kwargs): """ Initializes the class. :param \*\*kwargs: content, document. :type \*\*kwargs: dict """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) foundations.data_structures.Structure.__init__(self, **kwargs)
class CacheData(foundations.data_structures.Structure): ''' Defines a storage object for the :class:`Search_worker` class cache data. ''' def __init__(self, **kwargs): ''' Initializes the class. :param \*\*kwargs: content, document. :type \*\*kwargs: dict ''' pass
2
2
11
3
3
5
1
2
1
0
0
0
1
0
1
1
16
4
4
2
2
8
4
2
2
1
1
0
1
142,515
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/search_and_replace.py
umbra.components.factory.script_editor.search_and_replace.ValidationFilter
class ValidationFilter(QObject): """ Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass used as an event filter for the :class:`SearchAndReplace` class. """ def eventFilter(self, object, event): """ Reimplements the **QObject.eventFilter** method. :param object: Object. :type object: QObject :param event: Event. :type event: QEvent :return: Event filtered. :rtype: bool """ if event.type() == QEvent.KeyPress: if event.key() in (Qt.Key_Enter, Qt.Key_Return): object.search() elif event.key() in (Qt.Key_Escape,): object.close() return True else: return QObject.eventFilter(self, object, event)
class ValidationFilter(QObject): ''' Defines a `QObject <http://doc.qt.nokia.com/qobject.html>`_ subclass used as an event filter for the :class:`SearchAndReplace` class. ''' def eventFilter(self, object, event): ''' Reimplements the **QObject.eventFilter** method. :param object: Object. :type object: QObject :param event: Event. :type event: QEvent :return: Event filtered. :rtype: bool ''' pass
2
2
20
2
9
9
4
1.3
1
0
0
0
1
0
1
1
26
3
10
2
8
13
8
2
6
4
1
2
4
142,516
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.SearchOccurenceNode
class SearchOccurenceNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class search occurence node. """ __family = "SearchOccurence" """ :param __family: Node family. :type __family: unicode """ def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__(self, name, parent, children, roles, node_flags, **kwargs) SearchOccurenceNode.__initialize_node(self, attributes_flags) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class SearchOccurenceNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class search occurence node. ''' def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
3
3
21
3
7
11
1
2
1
1
0
0
2
0
2
15
54
9
15
11
5
30
8
4
5
1
3
0
2
142,517
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.SearchFileNode
class SearchFileNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class search file node. """ __family = "SearchFile" """ :param __family: Node family. :type __family: unicode """ def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__(self, name, parent, children, roles, node_flags, **kwargs) SearchFileNode.__initialize_node(self, attributes_flags) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class SearchFileNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class search file node. ''' def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
3
3
21
3
7
11
1
2
1
1
0
0
2
0
2
15
54
9
15
11
5
30
8
4
5
1
3
0
2
142,518
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.ReplaceResultNode
class ReplaceResultNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class replace result node. """ __family = "ReplaceResult" """ :param __family: Node family. :type __family: unicode """ def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__(self, name, parent, children, roles, node_flags, **kwargs) ReplaceResultNode.__initialize_node(self, attributes_flags) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class ReplaceResultNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class replace result node. ''' def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
3
3
21
3
7
11
1
2
1
1
0
0
2
0
2
15
54
9
15
11
5
30
8
4
5
1
3
0
2
142,519
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/nodes.py
umbra.components.factory.script_editor.nodes.PatternNode
class PatternNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.patterns.factory.script_editor.search_and_replace.SearchAndReplace` class search and replace pattern node. """ __family = "Pattern" """ :param __family: Node family. :type __family: unicode """ def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__(self, name, parent, children, roles, node_flags, **kwargs) PatternNode.__initialize_node(self, attributes_flags) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ pass
class PatternNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.patterns.factory.script_editor.search_and_replace.SearchAndReplace` class search and replace pattern node. ''' def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
3
3
21
3
7
11
1
2
1
1
0
0
2
0
2
15
54
9
15
11
5
30
8
4
5
1
3
0
2
142,520
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/models.py
umbra.components.factory.script_editor.models.SearchResultsModel
class SearchResultsModel(umbra.ui.models.GraphModel): """ Defines the Model used the by :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class to store the search results. """ def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None): """ 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 """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.models.GraphModel.__init__( self, parent, root_node, horizontal_headers, vertical_headers, default_node) def initialize_model(self, root_node): """ Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool """ LOGGER.debug("> Initializing model with '{0}' root node.".format(root_node)) self.beginResetModel() self.root_node = root_node self.enable_model_triggers(True) self.endResetModel() return True def get_metrics(self): """ Returns the Model metrics. :return: Nodes metrics. :rtype: dict """ search_file_nodes_count = search_occurence_nodesCount = 0 for node in foundations.walkers.nodes_walker(self.root_node): if node.family == "SearchFile": search_file_nodes_count += 1 elif node.family == "SearchOccurence": search_occurence_nodesCount += 1 return {"SearchFile": search_file_nodes_count, "SearchOccurence": search_occurence_nodesCount}
class SearchResultsModel(umbra.ui.models.GraphModel): ''' Defines the Model used the by :class:`umbra.patterns.factory.script_editor.search_in_files.SearchInFiles` class to store the search results. ''' def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None): ''' 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 ''' pass def initialize_model(self, root_node): ''' Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool ''' pass def get_metrics(self): ''' Returns the Model metrics. :return: Nodes metrics. :rtype: dict ''' pass
4
4
18
3
6
8
2
1.45
1
0
0
0
3
1
3
44
62
13
20
7
16
29
18
7
14
4
2
2
6
142,521
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/script_editor/models.py
umbra.components.factory.script_editor.models.PatternsModel
class PatternsModel(umbra.ui.models.GraphModel): """ Defines the Model used the by :class:`umbra.patterns.factory.script_editor.search_and_replace.SearchAndReplace` class to store the search and \ replace patterns. """ # Custom signals definitions. pattern_inserted = pyqtSignal(PatternNode) """ This signal is emited by the :class:`PatternsModel` class when a pattern has been inserted. :return: Inserted pattern node. :rtype: PatternNode """ # Custom signals definitions. pattern_removed = pyqtSignal(PatternNode) """ This signal is emited by the :class:`PatternsModel` class when a pattern has been removed. :return: Removed pattern node. :rtype: PatternNode """ def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None): """ 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 """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.models.GraphModel.__init__(self, parent, root_node, horizontal_headers, vertical_headers, PatternNode) def initialize_model(self, root_node): """ Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool """ LOGGER.debug("> Initializing model with '{0}' root node.".format(root_node)) self.beginResetModel() self.root_node = root_node self.enable_model_triggers(True) self.endResetModel() return True def insert_pattern(self, pattern, index): """ Inserts given pattern into the Model. :param pattern: Pattern. :type pattern: unicode :param index: Insertion index. :type index: int :return: Method success. :rtype: bool """ LOGGER.debug("> Inserting '{0}' at '{1}' index.".format(pattern, index)) self.remove_pattern(pattern) self.beginInsertRows(self.get_node_index(self.root_node), index, index) pattern_node = PatternNode(name=pattern) self.root_node.insert_child(pattern_node, index) self.endInsertRows() self.pattern_inserted.emit(pattern_node) return True def remove_pattern(self, pattern): """ Removes given pattern from the Model. :param pattern: Pattern. :type pattern: unicode :return: Method success. :rtype: bool """ for index, node in enumerate(self.root_node.children): if node.name != pattern: continue LOGGER.debug("> Removing '{0}' at '{1}' index.".format(pattern, index)) self.beginRemoveRows(self.get_node_index(self.root_node), index, index) pattern_node = self.root_node.child(index) self.root_node.remove_child(index) self.endRemoveRows() self.pattern_removed.emit(pattern_node) return True
class PatternsModel(umbra.ui.models.GraphModel): ''' Defines the Model used the by :class:`umbra.patterns.factory.script_editor.search_and_replace.SearchAndReplace` class to store the search and replace patterns. ''' def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None): ''' 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 ''' pass def initialize_model(self, root_node): ''' Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool ''' pass def insert_pattern(self, pattern, index): ''' Inserts given pattern into the Model. :param pattern: Pattern. :type pattern: unicode :param index: Insertion index. :type index: int :return: Method success. :rtype: bool ''' pass def remove_pattern(self, pattern): ''' Removes given pattern from the Model. :param pattern: Pattern. :type pattern: unicode :return: Method success. :rtype: bool ''' pass
5
5
20
4
8
9
2
1.55
1
2
1
0
4
1
4
45
106
22
33
11
28
51
33
11
28
3
2
2
6
142,522
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/components_manager_ui/nodes.py
umbra.components.factory.components_manager_ui.nodes.PathNode
class PathNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.components.factory.components_manager_ui.components_manager_ui.ComponentsManagerUi` Component Interface class Model path node. """ __family = "Path" """ :param __family: Node family. :type __family: unicode """ def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__(self, name, parent, children, roles, node_flags, **kwargs) PathNode.__initialize_node(self, attributes_flags) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ self["activated"] = umbra.ui.nodes.GraphModelAttribute(name="activated", flags=attributes_flags) self["category"] = umbra.ui.nodes.GraphModelAttribute(name="category", flags=attributes_flags) self["require"] = umbra.ui.nodes.GraphModelAttribute(name="require", flags=attributes_flags) self["version"] = umbra.ui.nodes.GraphModelAttribute(name="version", flags=attributes_flags)
class PathNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.components.factory.components_manager_ui.components_manager_ui.ComponentsManagerUi` Component Interface class Model path node. ''' def __init__(self, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass
3
3
24
3
10
11
1
1.36
1
2
1
0
2
0
2
15
61
9
22
11
12
30
11
4
8
1
3
0
2
142,523
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/factory/components_manager_ui/models.py
umbra.components.factory.components_manager_ui.models.ComponentsModel
class ComponentsModel(umbra.ui.models.GraphModel): """ Defines the Model used the by :class:`umbra.components.factory.components_manager_ui.components_manager_ui.ComponentsManagerUi` Component Interface class. """ def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None): """ 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 """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.models.GraphModel.__init__(self, parent, root_node, horizontal_headers, vertical_headers) def initialize_model(self, root_node): """ Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool """ LOGGER.debug("> Initializing model with '{0}' root node.".format(root_node)) self.beginResetModel() self.root_node = root_node self.enable_model_triggers(True) self.endResetModel() return True
class ComponentsModel(umbra.ui.models.GraphModel): ''' Defines the Model used the by :class:`umbra.components.factory.components_manager_ui.components_manager_ui.ComponentsManagerUi` Component Interface class. ''' def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None): ''' 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 ''' pass def initialize_model(self, root_node): ''' Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool ''' pass
3
3
17
3
5
9
1
2.09
1
0
0
0
2
1
2
43
42
8
11
4
8
23
11
4
8
1
2
0
2
142,524
KelSolaar/Umbra
KelSolaar_Umbra/umbra/components/addons/trace_ui/models.py
umbra.components.addons.trace_ui.models.ModulesModel
class ModulesModel(umbra.ui.models.GraphModel): """ Defines the Model used the by :class:`umbra.components.factory.trace_ui.trace_ui.TraceUi` Component Interface class. """ def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None): """ 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 """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) umbra.ui.models.GraphModel.__init__( self, parent, root_node, horizontal_headers, vertical_headers, default_node) def initialize_model(self, root_node): """ Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool """ LOGGER.debug("> Initializing model with '{0}' root node.".format(root_node)) self.beginResetModel() self.root_node = root_node self.enable_model_triggers(True) self.endResetModel() return True
class ModulesModel(umbra.ui.models.GraphModel): ''' Defines the Model used the by :class:`umbra.components.factory.trace_ui.trace_ui.TraceUi` Component Interface class. ''' def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None): ''' 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 ''' pass def initialize_model(self, root_node): ''' Initializes the Model using given root node. :param root_node: Graph root node. :type root_node: DefaultNode :return: Method success :rtype: bool ''' pass
3
3
19
3
6
10
1
2
1
0
0
0
2
1
2
43
44
8
12
4
9
24
11
4
8
1
2
0
2
142,525
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.LanguageGrammarError
class LanguageGrammarError(AbstractLanguageError): """ Defines language grammar exception. """ pass
class LanguageGrammarError(AbstractLanguageError): ''' Defines language grammar exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,526
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.LayoutExistError
class LayoutExistError(AbstractLayoutsManagerError): """ Defines non existing layout exception. """ pass
class LayoutExistError(AbstractLayoutsManagerError): ''' Defines non existing layout exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,527
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.LayoutRegistrationError
class LayoutRegistrationError(AbstractLayoutsManagerError): """ Defines layout registration exception. """ pass
class LayoutRegistrationError(AbstractLayoutsManagerError): ''' Defines layout registration exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,528
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.PatchApplyError
class PatchApplyError(AbstractPatchesManagerError): """ Defines patch apply exception. """ pass
class PatchApplyError(AbstractPatchesManagerError): ''' Defines patch apply exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,529
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/models.py
umbra.components.factory.script_editor.models.ProjectsModel
class ProjectsModel(umbra.ui.models.GraphModel): """ Defines the Model used by :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class. """ file_registered = pyqtSignal(FileNode) """ This signal is emited by the :class:`ProjectsModel` class when a file is registered. :return: Registered file FileNode. :rtype: FileNode """ file_unregistered = pyqtSignal(FileNode) """ This signal is emited by the :class:`ProjectsModel` class when a file is unregistered. :return: Unregistered file FileNode. :rtype: FileNode """ editor_registered = pyqtSignal(EditorNode) """ This signal is emited by the :class:`ProjectsModel` class when an editor is registered. :return: Registered editor EditorNode. :rtype: EditorNode """ editor_unregistered = pyqtSignal(EditorNode) """ This signal is emited by the :class:`ProjectsModel` class when an editor is unregistered. :return: Unregistered editor EditorNode. :rtype: EditorNode """ directory_registered = pyqtSignal(DirectoryNode) """ This signal is emited by the :class:`ProjectsModel` class when a directory is registered. :return: Registered directory DirectoryNode. :rtype: DirectoryNode """ directory_unregistered = pyqtSignal(DirectoryNode) """ This signal is emited by the :class:`ProjectsModel` class when a directory is unregistered. :return: Unregistered directory DirectoryNode. :rtype: DirectoryNode """ project_registered = pyqtSignal(ProjectNode) """ This signal is emited by the :class:`ProjectsModel` class when a project is registered. :return: Registered project ProjectNode. :rtype: ProjectNode """ project_unregistered = pyqtSignal(ProjectNode) """ This signal is emited by the :class:`ProjectsModel` class when a project is unregistered. :return: Unregistered project ProjectNode. :rtype: ProjectNode """ def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None, default_project=None): """ Initializes the class. :param default_project: Default project name. :type default_project: unicode :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 """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.models.GraphModel.__init__( self, parent, root_node, horizontal_headers, vertical_headers, default_node) # --- Setting class attributes. --- self.__default_project = None self.default_project = default_project or "default_project" self.__default_project_node = None ProjectsModel.__initialize_model(self) @property def default_project(self): """ Property for **self.__default_project** attribute. :return: self.__default_project. :rtype: unicode """ return self.__default_project @default_project.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_project(self, value): """ Setter for **self.__default_project** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, \ "'{0}' attribute: '{1}' type is not 'unicode'!".format( "default_project", value) self.__default_project = value @default_project.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project(self): """ Deleter for **self.__default_project** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_project")) @property def default_project_node(self): """ Property for **self.__default_project_node** attribute. :return: self.__default_project_node. :rtype: unicode """ return self.__default_project_node @default_project_node.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project_node(self, value): """ Setter for **self.__default_project_node** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_project_node")) @default_project_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project_node(self): """ Deleter for **self.__default_project_node** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_project_node")) def __initialize_model(self): """ Initializes the Model. """ LOGGER.debug("> Initializing model.") self.beginResetModel() self.root_node = umbra.ui.nodes.DefaultNode(name="InvisibleRootNode") self.__default_project_node = ProjectNode(name=self.__default_project, parent=self.root_node, node_flags=int( Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsEnabled)) self.enable_model_triggers(True) self.endResetModel() def list_editor_nodes(self, node=None): """ 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 """ return self.find_family("Editor", node=node or self.__default_project_node) def list_file_nodes(self, node=None): """ 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 """ return self.find_family("File", node=node or self.__default_project_node) def list_directory_nodes(self): """ Returns the Model :class:`umbra.components.factory.script_editor.nodes.DirectoryNode` class nodes. :return: DirectoryNode nodes. :rtype: list """ return self.find_family("Directory") def list_project_nodes(self, ignore_default_project_node=True): """ 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 """ project_nodes = self.find_family("Project") return filter(lambda x: x != self.__default_project_node, project_nodes) \ if ignore_default_project_node else project_nodes def list_editors(self, node=None): """ Returns the Model editors. :param node: Node to start walking from. :type node: AbstractNode or AbstractCompositeNode or Object :return: Editors. :rtype: list """ return [editor_node.editor for editor_node in self.list_editor_nodes(node) if editor_node.editor] def list_files(self, node=None): """ Returns the Model files. :param node: Node to start walking from. :type node: AbstractNode or AbstractCompositeNode or Object :return: FileNode nodes. :rtype: list """ return [file_node.path for file_node in self.list_file_nodes(node) if file_node.path] def list_directories(self): """ Returns the Model directories. :return: DirectoryNode nodes. :rtype: list """ return [directory_node.path for directory_node in self.list_directory_nodes() if directory_node.path] def list_projects(self, ignore_default_project_node=True): """ 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 """ return [project_node.path for project_node in self.list_project_nodes(ignore_default_project_node) if project_node.path] def get_editor_nodes(self, editor, node=None): """ 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 """ return [editor_node for editor_node in self.list_editor_nodes(node) if editor_node.editor == editor] def get_file_nodes(self, path, node=None): """ 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 """ return [file_node for file_node in self.list_file_nodes(node) if file_node.path == path] def get_directory_nodes(self, path): """ 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 """ return [directory_node for directory_node in self.list_directory_nodes() if directory_node.path == path] def get_project_nodes(self, path): """ 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 """ return [project_node for project_node in self.list_project_nodes() if project_node.path == path] def move_node(self, parent, from_index, to_index): """ 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 """ # TODO: Should be refactored once this ticket is fixed: # https://bugreports.qt-project.org/browse/PYSIDE-78 if not from_index >= 0 or \ not from_index < parent.children_count() or \ not to_index >= 0 or \ not to_index < parent.children_count(): return False parent_index = self.get_node_index(parent) self.beginRemoveRows(parent_index, from_index, from_index) child = parent.remove_child(from_index) self.endRemoveRows() start_index = parent.children_count() - 1 end_index = to_index - 1 tail = [] for i in range(start_index, end_index, -1): self.beginRemoveRows(parent_index, i, i) tail.append(parent.remove_child(i)) self.endRemoveRows() tail = list(reversed(tail)) tail.insert(0, child) for node in tail: row = parent.children_count() self.beginInsertRows(parent_index, row, row) parent.add_child(node) self.endInsertRows() return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_file(self, file, parent, ensure_uniqueness=False): """ 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 """ if ensure_uniqueness: if self.get_file_nodes(file): raise foundations.exceptions.ProgrammingError("{0} | '{1}' file is already registered!".format( self.__class__.__name__, file)) LOGGER.debug("> Registering '{0}' file.".format(file)) row = parent.children_count() self.beginInsertRows(self.get_node_index(parent), row, row) file_node = FileNode(name=os.path.basename(file), path=file, parent=parent) self.endInsertRows() self.file_registered.emit(file_node) return file_node @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_file(self, file_node, raise_exception=False): """ 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 """ if raise_exception: if not file_node in self.list_file_nodes(): raise foundations.exceptions.ProgrammingError("{0} | '{1}' file 'FileNode' isn't registered!".format( self.__class__.__name__, file_node)) LOGGER.debug( "> Unregistering '{0}' file 'FileNode'.".format(file_node)) parent = file_node.parent row = file_node.row() self.beginRemoveRows(self.get_node_index(parent), row, row) parent.remove_child(row) self.endRemoveRows() self.file_unregistered.emit(file_node) return file_node @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_directory(self, directory, parent, ensure_uniqueness=False): """ 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 """ if ensure_uniqueness: if self.get_directory_nodes(directory): raise foundations.exceptions.ProgrammingError("{0} | '{1}' directory is already registered!".format( self.__class__.__name__, directory)) LOGGER.debug("> Registering '{0}' directory.".format(directory)) row = parent.children_count() self.beginInsertRows(self.get_node_index(parent), row, row) directory_node = DirectoryNode(name=os.path.basename(directory), path=directory, parent=parent) self.endInsertRows() self.directory_registered.emit(directory_node) return directory_node @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_directory(self, directory_node, raise_exception=False): """ 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 """ if raise_exception: if not directory_node in self.list_directory_nodes(): raise foundations.exceptions.ProgrammingError( "{0} | '{1}' directory 'DirectoryNode' isn't registered!".format( self.__class__.__name__, directory_node)) LOGGER.debug( "> Unregistering '{0}' directory 'DirectoryNode'.".format(directory_node)) parent = directory_node.parent row = directory_node.row() self.beginRemoveRows(self.get_node_index(parent), row, row) parent.remove_child(row) self.endRemoveRows() self.directory_unregistered.emit(directory_node) return directory_node @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_editor(self, editor, parent, ensure_uniqueness=False): """ 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 """ if ensure_uniqueness: if self.get_editor_nodes(editor): raise foundations.exceptions.ProgrammingError("{0} | '{1}' editor is already registered!".format( self.__class__.__name__, editor)) LOGGER.debug("> Registering '{0}' editor.".format(editor)) row = parent.children_count() self.beginInsertRows(self.get_node_index(parent), row, row) editor_node = EditorNode(editor=editor, parent=parent) self.endInsertRows() self.editor_registered.emit(editor_node) return editor_node @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_editor(self, editor_node, raise_exception=False): """ 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 """ if raise_exception: if not editor_node in self.list_editor_nodes(): raise foundations.exceptions.ProgrammingError( "{0} | '{1}' editor 'EditorNode' isn't registered!".format( self.__class__.__name__, editor_node)) LOGGER.debug( "> Unregistering '{0}' editor 'EditorNode'.".format(editor_node)) parent = editor_node.parent row = editor_node.row() self.beginRemoveRows(self.get_node_index(parent), row, row) parent.remove_child(row) self.endRemoveRows() self.editor_unregistered.emit(editor_node) return editor_node @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_project(self, path, ensure_uniqueness=False): """ 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 """ if ensure_uniqueness: if self.get_project_nodes(path): raise foundations.exceptions.ProgrammingError("{0} | '{1}' project is already registered!".format( self.__class__.__name__, path)) LOGGER.debug("> Registering '{0}' project.".format(path)) row = self.root_node.children_count() self.beginInsertRows(self.get_node_index(self.root_node, ), row, row) project_node = ProjectNode(name=os.path.basename(path), path=path, parent=self.root_node) self.endInsertRows() self.project_registered.emit(project_node) return project_node @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_project(self, project_node, raise_exception=False): """ 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 """ if raise_exception: if not project_node in self.list_project_nodes(): raise foundations.exceptions.ProgrammingError( "{0} | '{1}' project 'ProjectNode' isn't registered!".format( self.__class__.__name__, project_node)) LOGGER.debug( "> Unregistering '{0}' project 'ProjectNode'.".format(project_node)) parent = project_node.parent row = project_node.row() self.beginRemoveRows(self.get_node_index(parent), row, row) parent.remove_child(row) self.endRemoveRows() self.project_unregistered.emit(project_node) return project_node def is_authoring_node(self, node): """ Returns if given Node is an authoring node. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Is authoring node. :rtype: bool """ for parent_node in foundations.walkers.nodes_walker(node, ascendants=True): if parent_node is self.__default_project_node: return True return False def set_authoring_nodes(self, editor): """ Sets the Model authoring Nodes using given editor. :param editor: Editor to set. :type editor: Editor :return: Method success. :rtype: bool """ project_node = self.default_project_node file_node = self.register_file(editor.file, project_node) editor_node = self.register_editor(editor, file_node) return True def delete_authoring_nodes(self, editor): """ Deletes the Model authoring Nodes associated with given editor. :param editor: Editor. :type editor: Editor :return: Method success. :rtype: bool """ editor_node = foundations.common.get_first_item( self.get_editor_nodes(editor)) file_node = editor_node.parent self.unregister_editor(editor_node) self.unregister_file(file_node, raise_exception=False) return True def update_authoring_nodes(self, editor): """ Updates given editor Model authoring nodes. :param editor: Editor. :type editor: Editor :return: Method success. :rtype: bool """ editor_node = foundations.common.get_first_item( self.get_editor_nodes(editor)) file_node = editor_node.parent file = editor.file file_node.name = editor_node.name = os.path.basename(file) file_node.path = editor_node.path = file self.node_changed(file_node) return True def set_project_nodes(self, root_node, maximum_depth=1): """ 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 """ root_directory = root_node.path for parent_directory, directories, files in foundations.walkers.depth_walker(root_directory, maximum_depth): if parent_directory == root_directory: parent_node = root_node else: parent_node = foundations.common.get_first_item( [node for node in foundations.walkers.nodes_walker(root_node) if node.family == "Directory" and node.path == parent_directory]) if not parent_node: continue paths = [node.path for node in parent_node.children] for directory in sorted(directories): if directory.startswith("."): continue path = os.path.join(parent_directory, directory) if path in paths: continue directory_node = self.register_directory(path, parent_node) for file in sorted(files): if file.startswith("."): continue path = os.path.join(parent_directory, file) if path in paths: continue if foundations.io.is_readable(path): if foundations.io.is_binary_file(path): continue file_node = self.register_file(path, parent_node) def delete_project_nodes(self, node): """ Deletes the Model project Nodes associated with given node. :param node: Node. :type node: ProjectNode """ self.unregister_project_nodes(node) self.unregister_project(node) def unregister_project_nodes(self, node): """ Unregisters given Node children. :param node: Node. :type node: ProjectNode or DirectoryNode """ for node in reversed(list(foundations.walkers.nodes_walker(node))): if node.family == "Directory": self.unregister_directory(node) elif node.family == "File": self.unregister_file(node) def update_project_nodes(self, node): """ Updates given root Node children. :param node: Node. :type node: ProjectNode or DirectoryNode """ self.unregister_project_nodes(node) self.set_project_nodes(node)
class ProjectsModel(umbra.ui.models.GraphModel): ''' Defines the Model used by :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class. ''' def __init__(self, parent=None, root_node=None, horizontal_headers=None, vertical_headers=None, default_node=None, default_project=None): ''' Initializes the class. :param default_project: Default project name. :type default_project: unicode :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 ''' pass @property def default_project(self): ''' Property for **self.__default_project** attribute. :return: self.__default_project. :rtype: unicode ''' pass @default_project.setter @foundations.exceptions.handle_exceptions(AssertionError) def default_project(self): ''' Setter for **self.__default_project** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_project.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project(self): ''' Deleter for **self.__default_project** attribute. ''' pass @property def default_project_node(self): ''' Property for **self.__default_project_node** attribute. :return: self.__default_project_node. :rtype: unicode ''' pass @default_project_node.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project_node(self): ''' Setter for **self.__default_project_node** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_project_node.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_project_node(self): ''' Deleter for **self.__default_project_node** attribute. ''' pass def __initialize_model(self): ''' Initializes the Model. ''' pass def list_editor_nodes(self, node=None): ''' 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 ''' pass def list_file_nodes(self, node=None): ''' 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 ''' pass def list_directory_nodes(self): ''' Returns the Model :class:`umbra.components.factory.script_editor.nodes.DirectoryNode` class nodes. :return: DirectoryNode nodes. :rtype: list ''' pass def list_project_nodes(self, ignore_default_project_node=True): ''' 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 ''' pass def list_editors(self, node=None): ''' Returns the Model editors. :param node: Node to start walking from. :type node: AbstractNode or AbstractCompositeNode or Object :return: Editors. :rtype: list ''' pass def list_files(self, node=None): ''' Returns the Model files. :param node: Node to start walking from. :type node: AbstractNode or AbstractCompositeNode or Object :return: FileNode nodes. :rtype: list ''' pass def list_directories(self): ''' Returns the Model directories. :return: DirectoryNode nodes. :rtype: list ''' pass def list_projects(self, ignore_default_project_node=True): ''' 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 ''' pass def get_editor_nodes(self, editor, node=None): ''' 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 ''' pass def get_file_nodes(self, path, node=None): ''' 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 ''' pass def get_directory_nodes(self, path): ''' 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 ''' pass def get_project_nodes(self, path): ''' 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 ''' pass def move_node(self, parent, from_index, to_index): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_file(self, file, parent, ensure_uniqueness=False): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_file(self, file_node, raise_exception=False): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_directory(self, directory, parent, ensure_uniqueness=False): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_directory(self, directory_node, raise_exception=False): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_editor(self, editor, parent, ensure_uniqueness=False): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_editor(self, editor_node, raise_exception=False): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_project(self, path, ensure_uniqueness=False): ''' 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 ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_project(self, project_node, raise_exception=False): ''' 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 ''' pass def is_authoring_node(self, node): ''' Returns if given Node is an authoring node. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Is authoring node. :rtype: bool ''' pass def set_authoring_nodes(self, editor): ''' Sets the Model authoring Nodes using given editor. :param editor: Editor to set. :type editor: Editor :return: Method success. :rtype: bool ''' pass def delete_authoring_nodes(self, editor): ''' Deletes the Model authoring Nodes associated with given editor. :param editor: Editor. :type editor: Editor :return: Method success. :rtype: bool ''' pass def update_authoring_nodes(self, editor): ''' Updates given editor Model authoring nodes. :param editor: Editor. :type editor: Editor :return: Method success. :rtype: bool ''' pass def set_project_nodes(self, root_node, maximum_depth=1): ''' 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 ''' pass def delete_project_nodes(self, node): ''' Deletes the Model project Nodes associated with given node. :param node: Node. :type node: ProjectNode ''' pass def unregister_project_nodes(self, node): ''' Unregisters given Node children. :param node: Node. :type node: ProjectNode or DirectoryNode ''' pass def update_project_nodes(self, node): ''' Updates given root Node children. :param node: Node. :type node: ProjectNode or DirectoryNode ''' pass
56
38
18
3
7
7
2
1.05
1
11
5
0
37
3
37
78
783
175
296
112
234
312
237
92
199
12
2
4
74
142,530
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/models.py
umbra.components.factory.script_editor.models.LanguagesModel
class LanguagesModel(QAbstractListModel): """ Defines a `QAbstractListModel <http://doc.qt.nokia.com/qabstractListmodel.html>`_ subclass used to store the :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class languages. """ def __init__(self, parent=None, languages=None): """ Initializes the class. :param parent: Parent object. :type parent: QObject :param languages: Languages. :type languages: list """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) QAbstractListModel.__init__(self, parent) # --- Setting class attributes. --- self.__languages = [] self.languages = languages @property def languages(self): """ Property for **self.__languages** attribute. :return: self.__languages. :rtype: list """ return self.__languages @languages.setter @foundations.exceptions.handle_exceptions(AssertionError) def languages(self, value): """ Setter for **self.__languages** attribute. :param value: Attribute value. :type value: list """ if value is not None: assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format( "languages", value) for element in value: assert type(element) is Language, "'{0}' attribute: '{1}' type is not 'Language'!".format( "languages", element) self.beginResetModel() self.__languages = value self.endResetModel() @languages.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def languages(self): """ Deleter for **self.__languages** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "languages")) def rowCount(self, parent=QModelIndex()): """ Reimplements the :meth:`QAbstractListModel.rowCount` method. :param parent: Parent. :type parent: QModelIndex :return: Row count. :rtype: int """ return len(self.__languages) def data(self, index, role=Qt.DisplayRole): """ Reimplements the :meth:`QAbstractListModel.data` method. :param index: Index. :type index: QModelIndex :param role: Role. :type role: int :return: Data. :rtype: QVariant """ if not index.isValid(): return QVariant() if role == Qt.DisplayRole: return QVariant(self.__languages[index.row()].name) return QVariant() def sort_languages(self, order=Qt.AscendingOrder): """ Sorts the Model languages. :param order: Order. ( Qt.SortOrder ) """ self.beginResetModel() self.__languages = sorted( self.__languages, key=lambda x: (x.name), reverse=order) self.endResetModel() @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_language(self, language): """ Registers given language in the :obj:`LanguagesModel.languages` class property. :param language: Language to register. :type language: Language :return: Method success. :rtype: bool """ if self.get_language(language): raise foundations.exceptions.ProgrammingError("{0} | '{1}' language is already registered!".format( self.__class__.__name__, language.name)) LOGGER.debug("> Registering '{0}' language.".format(language.name)) self.__languages.append(language) self.sort_languages() return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_language(self, name): """ 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 """ if not self.get_language(name): raise foundations.exceptions.ProgrammingError("{0} | '{1}' language isn't registered!".format( self.__class__.__name__, name)) LOGGER.debug("> Unregistering '{0}' language.".format(name)) for i, language in enumerate(self.__languages): if not language.name == name: continue del (self.__languages[i]) self.sort_languages() return True def get_language(self, name): """ Returns the language with given name. :param name: Language name. :type name: unicode :return: File language. :rtype: Language """ for language in self.__languages: if language.name == name: LOGGER.debug("> Language '{0}': '{1}'.".format(name, language)) return language def get_file_language(self, file): """ Returns the language of given file. :param file: File to get language of. :type file: unicode :return: File language. :rtype: Language """ for language in self.__languages: if re.search(language.extensions, file): LOGGER.debug("> '{0}' file detected language: '{1}'.".format( file, language.name)) return language
class LanguagesModel(QAbstractListModel): ''' Defines a `QAbstractListModel <http://doc.qt.nokia.com/qabstractListmodel.html>`_ subclass used to store the :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class languages. ''' def __init__(self, parent=None, languages=None): ''' Initializes the class. :param parent: Parent object. :type parent: QObject :param languages: Languages. :type languages: list ''' pass @property def languages(self): ''' Property for **self.__languages** attribute. :return: self.__languages. :rtype: list ''' pass @languages.setter @foundations.exceptions.handle_exceptions(AssertionError) def languages(self): ''' Setter for **self.__languages** attribute. :param value: Attribute value. :type value: list ''' pass @languages.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def languages(self): ''' Deleter for **self.__languages** attribute. ''' pass def rowCount(self, parent=QModelIndex()): ''' Reimplements the :meth:`QAbstractListModel.rowCount` method. :param parent: Parent. :type parent: QModelIndex :return: Row count. :rtype: int ''' pass def data(self, index, role=Qt.DisplayRole): ''' Reimplements the :meth:`QAbstractListModel.data` method. :param index: Index. :type index: QModelIndex :param role: Role. :type role: int :return: Data. :rtype: QVariant ''' pass def sort_languages(self, order=Qt.AscendingOrder): ''' Sorts the Model languages. :param order: Order. ( Qt.SortOrder ) ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def register_language(self, language): ''' Registers given language in the :obj:`LanguagesModel.languages` class property. :param language: Language to register. :type language: Language :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def unregister_language(self, name): ''' 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 ''' pass def get_language(self, name): ''' Returns the language with given name. :param name: Language name. :type name: unicode :return: File language. :rtype: Language ''' pass def get_file_language(self, file): ''' Returns the language of given file. :param file: File to get language of. :type file: unicode :return: File language. :rtype: Language ''' pass
19
12
14
3
5
6
2
1.09
1
4
1
0
11
1
11
11
182
40
68
22
49
74
57
17
45
4
1
2
23
142,531
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/editor_status.py
umbra.components.factory.script_editor.editor_status.EditorStatus
class EditorStatus(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): """ Defines the :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class status bar widget. """ def __init__(self, parent, *args, **kwargs): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(EditorStatus, self).__init__(parent, *args, **kwargs) # --- Setting class attributes. --- self.__container = parent self.__Lines_Columns_label_default_text = "Line {0} : Column {1}" EditorStatus.__initialize_ui(self) @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def Lines_Columns_label_default_text(self): """ Property for **self.__Lines_Columns_label_default_text** attribute. :return: self.__Lines_Columns_label_default_text. :rtype: unicode """ return self.__Lines_Columns_label_default_text @Lines_Columns_label_default_text.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def Lines_Columns_label_default_text(self, value): """ Setter for **self.__Lines_Columns_label_default_text** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "Lines_Columns_label_default_text")) @Lines_Columns_label_default_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def Lines_Columns_label_default_text(self): """ Deleter for **self.__Lines_Columns_label_default_text** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "Lines_Columns_label_default_text")) def __initialize_ui(self): """ Initializes the Widget ui. """ self.Lines_Columns_label.setAlignment(Qt.AlignRight) self.Lines_Columns_label.setText( self.__Lines_Columns_label_default_text.format(1, 1)) self.Languages_comboBox.setModel(self.__container.languages_model) # Signals / Slots. self.Languages_comboBox.currentIndexChanged.connect( self.__Languages_comboBox__currentIndexChanged) def __Languages_comboBox_set_default_view_state(self): """ Sets the **Languages_comboBox** Widget default View state. """ if not self.__container.has_editor_tab(): return editor = self.__container.get_current_editor() index = self.Languages_comboBox.findText(editor.language.name) self.Languages_comboBox.setCurrentIndex(index) def __Languages_comboBox__currentIndexChanged(self, index): """ Defines the slot triggered by the **Languages_comboBox** Widget when current index is changed. :param index: ComboBox current item index. :type index: int """ if not self.__container.has_editor_tab(): return language = self.__container.languages_model.get_language(foundations.strings.to_string( self.Languages_comboBox.currentText())) if not language: return editor = self.__container.get_current_editor() if editor.language == language: return editor.blockSignals(True) self.__container.set_language(editor, language) editor.blockSignals(False) def __editor__cursorPositionChanged(self): """ Defines the slot triggered by :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class editor when cursor position is changed. """ if not self.__container.has_editor_tab(): return editor = self.__container.get_current_editor() self.Lines_Columns_label.setText(self.__Lines_Columns_label_default_text.format(editor.get_cursor_line() + 1, editor.get_cursor_column() + 1))
class EditorStatus(foundations.ui.common.QWidget_factory(ui_file=UI_FILE)): ''' Defines the :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class status bar widget. ''' def __init__(self, parent, *args, **kwargs): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def Lines_Columns_label_default_text(self): ''' Property for **self.__Lines_Columns_label_default_text** attribute. :return: self.__Lines_Columns_label_default_text. :rtype: unicode ''' pass @Lines_Columns_label_default_text.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def Lines_Columns_label_default_text(self): ''' Setter for **self.__Lines_Columns_label_default_text** attribute. :param value: Attribute value. :type value: unicode ''' pass @Lines_Columns_label_default_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def Lines_Columns_label_default_text(self): ''' Deleter for **self.__Lines_Columns_label_default_text** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __Languages_comboBox_set_default_view_state(self): ''' Sets the **Languages_comboBox** Widget default View state. ''' pass def __Languages_comboBox__currentIndexChanged(self, index): ''' Defines the slot triggered by the **Languages_comboBox** Widget when current index is changed. :param index: ComboBox current item index. :type index: int ''' pass def __editor__cursorPositionChanged(self): ''' Defines the slot triggered by :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class editor when cursor position is changed. ''' pass
22
12
12
3
5
5
1
0.88
1
1
0
0
11
2
11
11
160
40
64
25
42
56
47
19
35
4
1
1
16
142,532
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/script_editor/editor.py
umbra.components.factory.script_editor.editor.Editor
class Editor(CodeEditor_QPlainTextEdit): """ Defines the default editor used by the :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class. """ __untitled_name_id = 1 """ :param __untitled_name_id: Editor untitled name id. :type __untitled_name_id: int """ # Custom signals definitions. title_changed = pyqtSignal() """ This signal is emited by the :class:`Editor` class when the current title is changed. """ file_loaded = pyqtSignal() """ This signal is emited by the :class:`Editor` class when the current file is loaded. """ file_saved = pyqtSignal() """ This signal is emited by the :class:`Editor` class when the current file is saved. """ file_reloaded = pyqtSignal() """ This signal is emited by the :class:`Editor` class when the current file is reloaded. """ file_closed = pyqtSignal() """ This signal is emited by the :class:`Editor` class when the current file is closed. """ contents_changed = pyqtSignal() """ This signal is emited by the :class:`Editor` class when the current editor document content has changed. """ modification_changed = pyqtSignal(bool) """ This signal is emited by the :class:`Editor` class when the current editor document content has been modified. """ def __init__(self, parent=None, file=None, language=PYTHON_LANGUAGE, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) CodeEditor_QPlainTextEdit.__init__( self, parent, language, *args, **kwargs) # --- Setting class attributes. --- self.__file = None self.file = file self.__default_fonts_settings = {"Windows": ("Consolas", 10), "Darwin": ("Monaco", 12), "Linux": ("Monospace", 10)} self.__tab_width = None self.__title = None self.__is_untitled = True self.__default_file_name = "Untitled" self.__default_file_extension = "py" Editor.__initialize_ui(self) file and self.load_file(file) @property def file(self): """ Property for **self.__file** attribute. :return: self.__file. :rtype: unicode """ return self.__file @file.setter @foundations.exceptions.handle_exceptions(AssertionError) def file(self, value): """ Setter for **self.__file** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "file", value) self.__file = value @file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file(self): """ Deleter for **self.__file** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "file")) @property def default_fonts_settings(self): """ Property for **self.__default_fonts_settings** attribute. :return: self.__default_fonts_settings. :rtype: dict """ return self.__default_fonts_settings @default_fonts_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self, value): """ Setter for **self.__default_fonts_settings** attribute. :param value: Attribute value. :type value: dict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_fonts_settings")) @default_fonts_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self): """ Deleter for **self.__default_fonts_settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_fonts_settings")) @property def tab_width(self): """ Property for **self.__tab_width** attribute. :return: self.__tab_width. :rtype: int """ return self.__tab_width @tab_width.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tab_width(self, value): """ Setter for **self.__tab_width** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "tab_width")) @tab_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tab_width(self): """ Deleter for **self.__tab_width** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tab_width")) @property def title(self): """ Property for **self.__title** attribute. :return: self.__title. :rtype: unicode """ return self.__title @title.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def title(self, value): """ Setter for **self.__title** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "title")) @title.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def title(self): """ Deleter for **self.__title** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "title")) @property def is_untitled(self): """ Property for **self.__is_untitled** attribute. :return: self.__is_untitled. :rtype: bool """ return self.__is_untitled @is_untitled.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def is_untitled(self, value): """ Setter for **self.__is_untitled** attribute. :param value: Attribute value. :type value: bool """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "is_untitled")) @is_untitled.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def is_untitled(self): """ Deleter for **self.__is_untitled** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "is_untitled")) @property def default_file_name(self): """ Property for **self.__default_file_name** attribute. :return: self.__default_file_name. :rtype: unicode """ return self.__default_file_name @default_file_name.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self, value): """ Setter for **self.__default_file_name** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_file_name")) @default_file_name.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self): """ Deleter for **self.__default_file_name** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_file_name")) @property def default_file_extension(self): """ Property for **self.__default_file_extension** attribute. :return: self.__default_file_extension. :rtype: unicode """ return self.__default_file_extension @default_file_extension.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self, value): """ Setter for **self.__default_file_extension** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "default_file_extension")) @default_file_extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self): """ Deleter for **self.__default_file_extension** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "default_file_extension")) def __initialize_ui(self): """ Initializes the Widget ui. """ self.setAttribute(Qt.WA_DeleteOnClose) self.setWordWrapMode(QTextOption.NoWrap) self.setAcceptDrops(True) if platform.system() == "Windows" or platform.system() == "Microsoft": fontFamily, fontSize = self.__default_fonts_settings["Windows"] elif platform.system() == "Darwin": fontFamily, fontSize = self.__default_fonts_settings["Darwin"] elif platform.system() == "Linux": fontFamily, fontSize = self.__default_fonts_settings["Linux"] font = QFont(fontFamily) font.setPointSize(fontSize) self.setFont(font) def __document__contents_changed(self): """ Defines the slot triggered by the editor when document content changes. """ self.set_title() def __document__modification_changed(self, changed): """ Defines the slot triggered by the editor when document is modified. :param changed: File modification state. :type changed: bool """ self.set_title() def __set_document_signals(self): """ Connects the editor document signals. """ # Signals / Slots. self.document().contentsChanged.connect(self.contents_changed.emit) self.document().contentsChanged.connect(self.__document__contents_changed) self.document().modificationChanged.connect(self.modification_changed.emit) self.document().modificationChanged.connect( self.__document__modification_changed) def set_title(self, title=None): """ Sets the editor title. :param title: Editor title. :type title: unicode :return: Method success. :rtype: bool """ if not title: # TODO: https://bugreports.qt-project.org/browse/QTBUG-27084 # titleTemplate = self.is_modified() and "{0} *" or "{0}" # title = titleTemplate.format(self.get_file_short_name()) title = self.get_file_short_name() LOGGER.debug("> Setting editor title to '{0}'.".format(title)) self.__title = title self.setWindowTitle(title) self.title_changed.emit() return True def set_file(self, file=None, is_modified=False, is_untitled=False): """ 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 """ LOGGER.debug("> Setting '{0}' editor file.".format(file)) self.__file = file self.__is_untitled = is_untitled self.set_modified(is_modified) self.set_title() return True def get_file_short_name(self): """ Returns the current editor file short name. :return: File short name. :rtype: unicode """ if not self.__file: return "" return os.path.basename(self.__file) def get_untitled_file_name(self): """ Returns an untitled editor file name. :return: Untitled file name. :rtype: unicode """ name = "{0} {1}.{2}".format( self.__default_file_name, Editor._Editor__untitled_name_id, self.default_file_extension) Editor._Editor__untitled_name_id += 1 LOGGER.debug("> Next untitled file name: '{0}'.".format(name)) return name def load_document(self, document, file=None, language=None): """ 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 """ document.setDocumentLayout(QPlainTextDocumentLayout(document)) self.setDocument(document) self.set_file(file) self.set_language(language) self.__set_document_signals() self.file_loaded.emit() return True def new_file(self): """ Creates a new editor file. :return: File name. :rtype: unicode """ file = self.get_untitled_file_name() LOGGER.debug("> Creating '{0}' file.".format(file)) self.set_file(file, is_modified=False, is_untitled=True) self.__set_document_signals() return file @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def load_file(self, file): """ Reads and loads given file into the editor. :param File: File to load. :type File: unicode :return: Method success. :rtype: bool """ if not foundations.common.path_exists(file): raise foundations.exceptions.FileExistsError( "{0} | '{1}' file doesn't exists!".format(self.__class__.__name__, file)) LOGGER.debug("> Loading '{0}' file.".format(file)) reader = foundations.io.File(file) self.setPlainText(reader.read()) self.set_file(file) self.__set_document_signals() self.file_loaded.emit() return True @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def reload_file(self, is_modified=True): """ Reloads the current editor file. :param is_modified: File modified state. :type is_modified: bool :return: Method success. :rtype: bool """ if not foundations.common.path_exists(self.__file): raise foundations.exceptions.FileExistsError("{0} | '{1}' file doesn't exists!".format( self.__class__.__name__, self.__file)) LOGGER.debug("> Reloading '{0}' file.".format(self.__file)) reader = foundations.io.File(self.__file) if reader.cache(): self.set_content(reader.content) self.set_file(self.__file, is_modified=is_modified) self.file_reloaded.emit() return True def save_file(self): """ Saves the editor file content. :return: Method success. :rtype: bool """ if not self.__is_untitled and foundations.common.path_exists(self.__file): return self.write_file(self.__file) else: return self.save_fileAs() def save_fileAs(self, file=None): """ Saves the editor file content either using given file or user chosen file. :return: Method success. :rtype: bool :note: May require user interaction. """ file = file or umbra.ui.common.store_last_browsed_path( QFileDialog.getSaveFileName(self, "Save As:", self.__file)) if not file: return False return self.write_file(foundations.strings.to_string(file)) def write_file(self, file): """ Writes the editor file content into given file. :param file: File to write. :type file: unicode :return: Method success. :rtype: bool """ LOGGER.debug("> Writing '{0}' file.".format(file)) writer = foundations.io.File(file) writer.content = [self.toPlainText().toUtf8()] if writer.write(): self.set_file(file) self.file_saved.emit() return True def close_file(self): """ Closes the editor file. :return: Method success. :rtype: bool """ if not self.is_modified(): LOGGER.debug("> Closing '{0}' file.".format(self.__file)) self.file_closed.emit() return True choice = message_box.message_box("Warning", "Warning", "'{0}' document has been modified!\nWould you like to save your changes?".format( self.get_file_short_name()), buttons=QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) if choice == QMessageBox.Save: if self.save_file(): LOGGER.debug("> Closing '{0}' file.".format(self.__file)) return True elif choice == QMessageBox.Discard: LOGGER.debug("> Discarding '{0}' file.".format(self.__file)) self.file_closed.emit() return True else: return False
class Editor(CodeEditor_QPlainTextEdit): ''' Defines the default editor used by the :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class. ''' def __init__(self, parent=None, file=None, language=PYTHON_LANGUAGE, *args, **kwargs): ''' 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: \*\* ''' pass @property def file(self): ''' Property for **self.__file** attribute. :return: self.__file. :rtype: unicode ''' pass @file.setter @foundations.exceptions.handle_exceptions(AssertionError) def file(self): ''' Setter for **self.__file** attribute. :param value: Attribute value. :type value: unicode ''' pass @file.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file(self): ''' Deleter for **self.__file** attribute. ''' pass @property def default_fonts_settings(self): ''' Property for **self.__default_fonts_settings** attribute. :return: self.__default_fonts_settings. :rtype: dict ''' pass @default_fonts_settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self): ''' Setter for **self.__default_fonts_settings** attribute. :param value: Attribute value. :type value: dict ''' pass @default_fonts_settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_fonts_settings(self): ''' Deleter for **self.__default_fonts_settings** attribute. ''' pass @property def tab_width(self): ''' Property for **self.__tab_width** attribute. :return: self.__tab_width. :rtype: int ''' pass @tab_width.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tab_width(self): ''' Setter for **self.__tab_width** attribute. :param value: Attribute value. :type value: int ''' pass @tab_width.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tab_width(self): ''' Deleter for **self.__tab_width** attribute. ''' pass @property def title(self): ''' Property for **self.__title** attribute. :return: self.__title. :rtype: unicode ''' pass @title.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def title(self): ''' Setter for **self.__title** attribute. :param value: Attribute value. :type value: unicode ''' pass @title.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def title(self): ''' Deleter for **self.__title** attribute. ''' pass @property def is_untitled(self): ''' Property for **self.__is_untitled** attribute. :return: self.__is_untitled. :rtype: bool ''' pass @is_untitled.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def is_untitled(self): ''' Setter for **self.__is_untitled** attribute. :param value: Attribute value. :type value: bool ''' pass @is_untitled.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def is_untitled(self): ''' Deleter for **self.__is_untitled** attribute. ''' pass @property def default_file_name(self): ''' Property for **self.__default_file_name** attribute. :return: self.__default_file_name. :rtype: unicode ''' pass @default_file_name.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self): ''' Setter for **self.__default_file_name** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_file_name.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_name(self): ''' Deleter for **self.__default_file_name** attribute. ''' pass @property def default_file_extension(self): ''' Property for **self.__default_file_extension** attribute. :return: self.__default_file_extension. :rtype: unicode ''' pass @default_file_extension.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self): ''' Setter for **self.__default_file_extension** attribute. :param value: Attribute value. :type value: unicode ''' pass @default_file_extension.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def default_file_extension(self): ''' Deleter for **self.__default_file_extension** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __document__contents_changed(self): ''' Defines the slot triggered by the editor when document content changes. ''' pass def __document__modification_changed(self, changed): ''' Defines the slot triggered by the editor when document is modified. :param changed: File modification state. :type changed: bool ''' pass def __set_document_signals(self): ''' Connects the editor document signals. ''' pass def set_title(self, title=None): ''' Sets the editor title. :param title: Editor title. :type title: unicode :return: Method success. :rtype: bool ''' pass def set_file(self, file=None, is_modified=False, is_untitled=False): ''' 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 ''' pass def get_file_short_name(self): ''' Returns the current editor file short name. :return: File short name. :rtype: unicode ''' pass def get_untitled_file_name(self): ''' Returns an untitled editor file name. :return: Untitled file name. :rtype: unicode ''' pass def load_document(self, document, file=None, language=None): ''' 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 ''' pass def new_file(self): ''' Creates a new editor file. :return: File name. :rtype: unicode ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def load_file(self, file): ''' Reads and loads given file into the editor. :param File: File to load. :type File: unicode :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.FileExistsError) def reload_file(self, is_modified=True): ''' Reloads the current editor file. :param is_modified: File modified state. :type is_modified: bool :return: Method success. :rtype: bool ''' pass def save_file(self): ''' Saves the editor file content. :return: Method success. :rtype: bool ''' pass def save_fileAs(self, file=None): ''' Saves the editor file content either using given file or user chosen file. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass def write_file(self, file): ''' Writes the editor file content into given file. :param file: File to write. :type file: unicode :return: Method success. :rtype: bool ''' pass def close_file(self): ''' Closes the editor file. :return: Method success. :rtype: bool ''' pass
76
39
13
2
5
5
1
0.98
1
1
0
0
38
7
38
136
609
133
240
85
164
236
175
62
136
5
3
2
54
142,533
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/preferences_manager/preferences_manager.py
umbra.components.factory.preferences_manager.preferences_manager.PreferencesManager
class PreferencesManager(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): """ | Defines the :mod:`umbra.components.factory.preferences_manager.preferences_manager` Component Interface class. | It exposes Application preferences inside a dedicated `QDockWidget <http://doc.qt.nokia.com/qdockwidget.html>`_ window. """ def __init__(self, parent=None, name=None, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(PreferencesManager, self).__init__(parent, name, *args, **kwargs) # --- Setting class attributes. --- self.deactivatable = False self.__dock_area = 2 self.__engine = None self.__settings = None @property def dock_area(self): """ Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int """ return self.__dock_area @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self, value): """ Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "dock_area")) @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): """ Deleter for **self.__dock_area** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "dock_area")) @property def engine(self): """ Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject """ return self.__engine @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self, value): """ Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "engine")) @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): """ Deleter for **self.__engine** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "engine")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) def activate(self, engine): """ Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__engine = engine self.__settings = self.__engine.settings self.activated = True return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def deactivate(self): """ Deactivates the Component. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component cannot be deactivated!".format(self.__class__.__name__, self.__name)) def initialize_ui(self): """ Initializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component ui.".format( self.__class__.__name__)) umbra.ui.common.set_toolBox_height(self.Preferences_Manager_toolBox) self.__Logging_Formatters_comboBox_set_ui() self.__Verbose_Level_comboBox_set_ui() self.__Restore_Geometry_On_Layout_Change_checkBox_set_ui() # Signals / Slots. self.__engine.verbosity_level_changed.connect( self.__engine__verbosity_level_changed) self.Logging_Formatters_comboBox.activated.connect( self.__Logging_Formatters_comboBox__activated) self.Verbose_Level_comboBox.activated.connect( self.__Verbose_Level_comboBox__activated) self.Restore_Geometry_On_Layout_Change_checkBox.stateChanged.connect( self.__Restore_Geometry_On_Layout_Change_checkBox__stateChanged) self.initialized_ui = True return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def uninitialize_ui(self): """ Uninitializes the Component ui. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component ui cannot be uninitialized!".format(self.__class__.__name__, self.name)) def add_widget(self): """ Adds the Component Widget to the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.addDockWidget(Qt.DockWidgetArea(self.__dock_area), self) return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def remove_widget(self): """ Removes the Component Widget from the engine. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component Widget cannot be removed!".format(self.__class__.__name__, self.name)) def __engine__verbosity_level_changed(self, verbosity_level): """ Defines the slot triggered by the engine when verbosity level has changed. :param verbosity_level: Current verbosity level. :type verbosity_level: int """ self.Verbose_Level_comboBox.setCurrentIndex(verbosity_level) def __Logging_Formatters_comboBox_set_ui(self): """ Fills **Logging_Formatter_comboBox** Widget. """ self.Logging_Formatters_comboBox.clear() LOGGER.debug("> Available logging formatters: '{0}'.".format( ", ".join(RuntimeGlobals.logging_formatters))) self.Logging_Formatters_comboBox.insertItems( 0, QStringList(RuntimeGlobals.logging_formatters.keys())) logging_formatter = self.__settings.get_key( "Settings", "logging_formatter").toString() self.__engine.logging_active_formatter = logging_formatter and logging_formatter or Constants.logging_default_formatter self.Logging_Formatters_comboBox.setCurrentIndex(self.Logging_Formatters_comboBox.findText( self.__engine.logging_active_formatter, Qt.MatchExactly)) def __Logging_Formatters_comboBox__activated(self, index): """ Defines the slot triggered by the **Logging_Formatter_comboBox** Widget when activated. :param index: ComboBox activated item index. :type index: int """ formatter = foundations.strings.to_string( self.Logging_Formatters_comboBox.currentText()) LOGGER.debug("> Setting logging formatter: '{0}'.".format(formatter)) RuntimeGlobals.logging_active_formatter = formatter self.set_logging_formatter() self.__settings.set_key( "Settings", "logging_formatter", self.Logging_Formatters_comboBox.currentText()) def __Verbose_Level_comboBox_set_ui(self): """ Fills **Verbose_Level_ComboBox** Widget. """ self.Verbose_Level_comboBox.clear() LOGGER.debug("> Available verbose levels: '{0}'.".format( Constants.verbosity_labels)) self.Verbose_Level_comboBox.insertItems( 0, QStringList(Constants.verbosity_labels)) self.__engine.verbosity_level = foundations.common.get_first_item( self.__settings.get_key("Settings", "verbosity_level").toInt()) self.Verbose_Level_comboBox.setCurrentIndex( self.__engine.verbosity_level) def __Verbose_Level_comboBox__activated(self, index): """ Defines the slot triggered by the **Verbose_Level_ComboBox** Widget when activated. :param index: ComboBox activated item index. :type index: int """ LOGGER.debug("> Setting verbose level: '{0}'.".format( self.Verbose_Level_comboBox.currentText())) self.__engine.verbosity_level = index foundations.verbose.set_verbosity_level(index) self.__settings.set_key("Settings", "verbosity_level", index) def __Restore_Geometry_On_Layout_Change_checkBox_set_ui(self): """ Sets the **Restore_Geometry_On_Layout_Change_checkBox** Widget. """ # Adding settings key if it doesn't exists. self.__settings.get_key("Settings", "restore_geometry_on_layout_change").isNull() and \ self.__settings.set_key( "Settings", "restore_geometry_on_layout_change", Qt.Unchecked) restore_geometry_on_layout_change = foundations.common.get_first_item( self.__settings.get_key("Settings", "restore_geometry_on_layout_change").toInt()) LOGGER.debug("> Setting '{0}' with value '{1}'.".format("Restore_Geometry_On_Layout_Change_checkBox", restore_geometry_on_layout_change)) self.Restore_Geometry_On_Layout_Change_checkBox.setCheckState( restore_geometry_on_layout_change) self.__engine.layouts_manager.restore_geometry_on_layout_change = True if restore_geometry_on_layout_change else False def __Restore_Geometry_On_Layout_Change_checkBox__stateChanged(self, state): """ Defines the slot triggered by **Restore_Geometry_On_Layout_Change_checkBox** Widget when state changed. :param state: Checkbox state. :type state: int """ LOGGER.debug( "> 'Restore Geometry On Layout Change' state: '{0}'.".format(state)) self.__settings.set_key( "Settings", "restore_geometry_on_layout_change", state) self.__engine.layouts_manager.restore_geometry_on_layout_change = state and True or False def set_logging_formatter(self): """ Sets the logging formatter. """ for handler in (RuntimeGlobals.logging_console_handler, RuntimeGlobals.logging_file_handler, RuntimeGlobals.logging_session_handler): handler and handler.setFormatter( RuntimeGlobals.logging_formatters[RuntimeGlobals.logging_active_formatter])
class PreferencesManager(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): ''' | Defines the :mod:`umbra.components.factory.preferences_manager.preferences_manager` Component Interface class. | It exposes Application preferences inside a dedicated `QDockWidget <http://doc.qt.nokia.com/qdockwidget.html>`_ window. ''' def __init__(self, parent=None, name=None, *args, **kwargs): ''' 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: \*\* ''' pass @property def dock_area(self): ''' Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int ''' pass @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int ''' pass @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Deleter for **self.__dock_area** attribute. ''' pass @property def engine(self): ''' Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject ''' pass @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject ''' pass @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Deleter for **self.__engine** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass def activate(self, engine): ''' Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def deactivate(self): ''' Deactivates the Component. ''' pass def initialize_ui(self): ''' Initializes the Component ui. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def uninitialize_ui(self): ''' Uninitializes the Component ui. ''' pass def add_widget(self): ''' Adds the Component Widget to the engine. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def remove_widget(self): ''' Removes the Component Widget from the engine. ''' pass def __engine__verbosity_level_changed(self, verbosity_level): ''' Defines the slot triggered by the engine when verbosity level has changed. :param verbosity_level: Current verbosity level. :type verbosity_level: int ''' pass def __Logging_Formatters_comboBox_set_ui(self): ''' Fills **Logging_Formatter_comboBox** Widget. ''' pass def __Logging_Formatters_comboBox__activated(self, index): ''' Defines the slot triggered by the **Logging_Formatter_comboBox** Widget when activated. :param index: ComboBox activated item index. :type index: int ''' pass def __Verbose_Level_comboBox_set_ui(self): ''' Fills **Verbose_Level_ComboBox** Widget. ''' pass def __Verbose_Level_comboBox__activated(self, index): ''' Defines the slot triggered by the **Verbose_Level_ComboBox** Widget when activated. :param index: ComboBox activated item index. :type index: int ''' pass def __Restore_Geometry_On_Layout_Change_checkBox_set_ui(self): ''' Sets the **Restore_Geometry_On_Layout_Change_checkBox** Widget. ''' pass def __Restore_Geometry_On_Layout_Change_checkBox__stateChanged(self, state): ''' Defines the slot triggered by **Restore_Geometry_On_Layout_Change_checkBox** Widget when state changed. :param state: Checkbox state. :type state: int ''' pass def set_logging_formatter(self): ''' Sets the logging formatter. ''' pass
43
25
11
2
5
5
1
0.9
1
3
2
0
24
6
24
24
321
76
129
47
86
116
93
35
68
2
1
1
26
142,534
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/components_manager_ui/views.py
umbra.components.factory.components_manager_ui.views.Components_QTreeView
class Components_QTreeView(umbra.ui.views.Abstract_QTreeView): """ Defines the view for Components. """ def __init__(self, parent, model=None, read_only=False, message=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param model: Model. :type model: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.views.Abstract_QTreeView.__init__( self, parent, read_only, message) # --- Setting class attributes. --- self.__container = parent self.__tree_view_indentation = 15 self.setModel(model) Components_QTreeView.__initialize_ui(self) @property def container(self): """ Property for **self.__container** attribute. :return: self.__container. :rtype: QObject """ return self.__container @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self, value): """ Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "container")) @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): """ Deleter for **self.__container** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "container")) @property def tree_view_indentation(self): """ Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int """ return self.__tree_view_indentation @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self, value): """ Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "tree_view_indentation")) @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): """ Deleter for **self.__tree_view_indentation** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tree_view_indentation")) def setModel(self, model): """ Reimplements the **umbra.ui.views.Abstract_QTreeView.setModel** method. :param model: Model to set. :type model: QObject """ if not model: return LOGGER.debug("> Setting '{0}' model.".format(model)) umbra.ui.views.Abstract_QTreeView.setModel(self, model) # Signals / Slots. self.model().modelAboutToBeReset.connect(self.__model__modelAboutToBeReset) self.model().modelReset.connect(self.__model__modelReset) def __model__modelAboutToBeReset(self): """ Defines the slot triggered by the Model when about to be reset. """ pass def __model__modelReset(self): """ Defines the slot triggered by the Model when reset. """ pass def __initialize_ui(self): """ Initializes the Widget ui. """ self.setAutoScroll(False) self.setDragDropMode(QAbstractItemView.NoDragDrop) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.setIndentation(self.__tree_view_indentation) self.setSelectionMode(QAbstractItemView.ExtendedSelection) self.setSortingEnabled(True) self.sortByColumn(0, Qt.AscendingOrder) self.__set_default_ui_state() # Signals / Slots. self.model().modelReset.connect(self.__set_default_ui_state) def __set_default_ui_state(self): """ Sets the Widget default ui state. """ LOGGER.debug("> Setting default View state!") if not self.model(): return self.expandAll() for column in range(len(self.model().horizontal_headers)): self.resizeColumnToContents(column)
class Components_QTreeView(umbra.ui.views.Abstract_QTreeView): ''' Defines the view for Components. ''' def __init__(self, parent, model=None, read_only=False, message=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param model: Model. :type model: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode ''' pass @property def container(self): ''' Property for **self.__container** attribute. :return: self.__container. :rtype: QObject ''' pass @container.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Setter for **self.__container** attribute. :param value: Attribute value. :type value: QObject ''' pass @container.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def container(self): ''' Deleter for **self.__container** attribute. ''' pass @property def tree_view_indentation(self): ''' Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int ''' pass @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int ''' pass @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Deleter for **self.__tree_view_indentation** attribute. ''' pass def setModel(self, model): ''' Reimplements the **umbra.ui.views.Abstract_QTreeView.setModel** method. :param model: Model to set. :type model: QObject ''' pass def __model__modelAboutToBeReset(self): ''' Defines the slot triggered by the Model when about to be reset. ''' pass def __model__modelReset(self): ''' Defines the slot triggered by the Model when reset. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __set_default_ui_state(self): ''' Sets the Widget default ui state. ''' pass
23
13
12
3
4
5
1
0.97
1
1
0
0
12
2
12
31
166
44
62
22
39
60
48
16
35
3
4
1
15
142,535
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/components_manager_ui/nodes.py
umbra.components.factory.components_manager_ui.nodes.ComponentNode
class ComponentNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.components.factory.components_manager_ui.components_manager_ui.ComponentsManagerUi` Component Interface class Model component node. """ __family = "Component" """ :param __family: Node family. :type __family: unicode """ def __init__(self, component, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param component: Component. :type component: Component or QWidgetComponent or QObjectComponent :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__( self, name, parent, children, roles, node_flags, **kwargs) # --- Setting class attributes. --- self.__component = component self.__tool_tip_text = """ <p><b>{0}</b></p> <p><b>Author: </b>{1}<br> <b>Category: </b>{2}<br> <b>Dependencies: </b>{3}<br> <b>Version: </b>{4}<br> <b>Description: </b>{5}<br></p> """ ComponentNode.__initialize_node(self, attributes_flags) @property def component(self): """ Property for **self.__component** attribute. :return: self.__component. :rtype: Component or QWidgetComponent or QObjectComponent """ return self.__component @component.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def component(self, value): """ Setter for **self.__component** attribute. :param value: Attribute value. :type value: Component or QWidgetComponent or QObjectComponent """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "component")) @component.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def component(self): """ Deleter for **self.__component** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "component")) @property def tool_tip_text(self): """ Property for **self.__tool_tip_text** attribute. :return: self.__tool_tip_text. :rtype: unicode """ return self.__tool_tip_text @tool_tip_text.setter @foundations.exceptions.handle_exceptions(AssertionError) def tool_tip_text(self, value): """ Setter for **self.__tool_tip_text** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "tool_tip_text", value) self.__tool_tip_text = value @tool_tip_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tool_tip_text(self): """ Deleter for **self.__tool_tip_text** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tool_tip_text")) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ attributes = dir(self.__component) for attribute in attributes: if attribute == "name": continue if not "_Profile__{0}".format(attribute) in attributes: continue value = getattr(self.__component, attribute) value = ", ".join(value) if type(value) in (tuple, list) else value roles = {Qt.DisplayRole: value, Qt.EditRole: value} self[attribute] = umbra.ui.nodes.GraphModelAttribute( attribute, value, roles, attributes_flags) self.update_tool_tip() def update_tool_tip(self): """ Updates the node tooltip. :return: Method success. :rtype: bool """ self.roles[Qt.ToolTipRole] = self.__tool_tip_text.format(self.component.name, self.component.author, self.component.category, ", ".join( self.component.require), self.component.version, self.component.description) return True
class ComponentNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.components.factory.components_manager_ui.components_manager_ui.ComponentsManagerUi` Component Interface class Model component node. ''' def __init__(self, component, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param component: Component. :type component: Component or QWidgetComponent or QObjectComponent :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def component(self): ''' Property for **self.__component** attribute. :return: self.__component. :rtype: Component or QWidgetComponent or QObjectComponent ''' pass @component.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def component(self): ''' Setter for **self.__component** attribute. :param value: Attribute value. :type value: Component or QWidgetComponent or QObjectComponent ''' pass @component.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def component(self): ''' Deleter for **self.__component** attribute. ''' pass @property def tool_tip_text(self): ''' Property for **self.__tool_tip_text** attribute. :return: self.__tool_tip_text. :rtype: unicode ''' pass @tool_tip_text.setter @foundations.exceptions.handle_exceptions(AssertionError) def tool_tip_text(self): ''' Setter for **self.__tool_tip_text** attribute. :param value: Attribute value. :type value: unicode ''' pass @tool_tip_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tool_tip_text(self): ''' Deleter for **self.__tool_tip_text** attribute. ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass def update_tool_tip(self): ''' Updates the node tooltip. :return: Method success. :rtype: bool ''' pass
20
10
15
2
7
6
2
0.9
1
5
1
0
9
2
9
22
169
32
72
31
44
65
37
17
27
5
3
2
14
142,536
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/factory/components_manager_ui/components_manager_ui.py
umbra.components.factory.components_manager_ui.components_manager_ui.ComponentsManagerUi
class ComponentsManagerUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): """ | Defines the :mod:`umbra.components.factory.components_manager_ui.components_manager_ui` Component Interface class. | It defines methods to interact with the :class:`manager.components_manager.Manager` class Application instance Components. """ # Custom signals definitions. refresh_nodes = pyqtSignal() """ This signal is emited by the :class:`ComponentsManagerUi` class when :obj:`ComponentsManagerUi.model` class property model Nodes nodes needs to be refreshed. """ activated_component = pyqtSignal(unicode) """ This signal is emited by the :class:`ComponentsManagerUi` class when a Component is activated. :return: Activated Component name. :rtype: unicode """ deactivated_component = pyqtSignal(unicode) """ This signal is emited by the :class:`ComponentsManagerUi` class when a Component is deactivated. :return: Deactivated Component name. :rtype: unicode """ reloaded_component = pyqtSignal(unicode) """ This signal is emited by the :class:`ComponentsManagerUi` class when a Component is reloaded. :return: Reloaded Component name. :rtype: unicode """ def __init__(self, parent=None, name=None, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(ComponentsManagerUi, self).__init__( parent, name, *args, **kwargs) # --- Setting class attributes. --- self.deactivatable = False self.__ui_resources_directory = "resources" self.__ui_activated_image = "Activated.png" self.__ui_deactivated_image = "Deactivated.png" self.__ui_category_affixe = "_Category.png" self.__dock_area = 1 self.__engine = None self.__settings = None self.__model = None self.__view = None self.__headers = OrderedDict([("Components", "name"), ("Activated", "activated"), ("Category", "category"), ("Dependencies", "require"), ("Version", "version")]) self.__tree_view_inner_margins = QMargins(0, 0, 0, 12) self.__components_informations_default_text = \ "<center><h4>* * *</h4>Select some Components to display related informations!<h4>* * *</h4></center>" self.__components_informations_text = """ <h4><center>{0}</center></h4> <p> <b>Category:</b> {1} <br/> <b>Author:</b> {2} <br/> <b>Email:</b> <a href="mailto:{3}"> <span style=" text-decoration: underline; color:#e0e0e0;">{3}</span></a> <br/> <b>Url:</b> <a href="{4}"> <span style=" text-decoration: underline; color:#e0e0e0;">{4}</span></a> <p> <b>Description:</b> {5} </p> </p> """ @property def ui_resources_directory(self): """ Property for **self.__ui_resources_directory** attribute. :return: self.__ui_resources_directory. :rtype: unicode """ return self.__ui_resources_directory @ui_resources_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_resources_directory(self, value): """ Setter for **self.__ui_resources_directory** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "ui_resources_directory")) @ui_resources_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_resources_directory(self): """ Deleter for **self.__ui_resources_directory** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_resources_directory")) @property def ui_activated_image(self): """ Property for **self.__ui_activated_image** attribute. :return: self.__ui_activated_image. :rtype: unicode """ return self.__ui_activated_image @ui_activated_image.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_activated_image(self, value): """ Setter for **self.__ui_activated_image** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "ui_activated_image")) @ui_activated_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_activated_image(self): """ Deleter for **self.__ui_activated_image** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_activated_image")) @property def ui_deactivated_image(self): """ Property for **self.__ui_deactivated_image** attribute. :return: self.__ui_deactivated_image. :rtype: unicode """ return self.__ui_deactivated_image @ui_deactivated_image.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_deactivated_image(self, value): """ Setter for **self.__ui_deactivated_image** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "ui_deactivated_image")) @ui_deactivated_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_deactivated_image(self): """ Deleter for **self.__ui_deactivated_image** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_deactivated_image")) @property def ui_category_affixe(self): """ Property for **self.__ui_category_affixe** attribute. :return: self.__ui_category_affixe. :rtype: unicode """ return self.__ui_category_affixe @ui_category_affixe.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_category_affixe(self, value): """ Setter for **self.__ui_category_affixe** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "ui_category_affixe")) @ui_category_affixe.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_category_affixe(self): """ Deleter for **self.__ui_category_affixe** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "ui_category_affixe")) @property def dock_area(self): """ Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int """ return self.__dock_area @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self, value): """ Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "dock_area")) @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): """ Deleter for **self.__dock_area** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "dock_area")) @property def engine(self): """ Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject """ return self.__engine @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self, value): """ Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "engine")) @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): """ Deleter for **self.__engine** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "engine")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def model(self): """ Property for **self.__model** attribute. :return: self.__model. :rtype: ComponentsModel """ return self.__model @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self, value): """ Setter for **self.__model** attribute. :param value: Attribute value. :type value: ComponentsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "model")) @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): """ Deleter for **self.__model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "model")) @property def view(self): """ Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget """ return self.__view @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self, value): """ Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "view")) @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): """ Deleter for **self.__view** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "view")) @property def headers(self): """ Property for **self.__headers** attribute. :return: self.__headers. :rtype: list """ return self.__headers @headers.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self, value): """ Setter for **self.__headers** attribute. :param value: Attribute value. :type value: list """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "headers")) @headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self): """ Deleter for **self.__headers** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "headers")) @property def tree_view_inner_margins(self): """ Property for **self.__tree_view_inner_margins** attribute. :return: self.__tree_view_inner_margins. :rtype: int """ return self.__tree_view_inner_margins @tree_view_inner_margins.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_inner_margins(self, value): """ Setter for **self.__tree_view_inner_margins** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "tree_view_inner_margins")) @tree_view_inner_margins.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_inner_margins(self): """ Deleter for **self.__tree_view_inner_margins** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tree_view_inner_margins")) @property def components_informations_default_text(self): """ Property for **self.__components_informations_default_text** attribute. :return: self.__components_informations_default_text. :rtype: unicode """ return self.__components_informations_default_text @components_informations_default_text.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_default_text(self, value): """ Setter for **self.__components_informations_default_text** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "components_informations_default_text")) @components_informations_default_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_default_text(self): """ Deleter for **self.__components_informations_default_text** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "components_informations_default_text")) @property def components_informations_text(self): """ Property for **self.__components_informations_text** attribute. :return: self.__components_informations_text. :rtype: unicode """ return self.__components_informations_text @components_informations_text.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_text(self, value): """ Setter for **self.__components_informations_text** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "components_informations_text")) @components_informations_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_text(self): """ Deleter for **self.__components_informations_text** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "components_informations_text")) def activate(self, engine): """ Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__ui_resources_directory = os.path.join( os.path.dirname(__file__), self.__ui_resources_directory) self.__engine = engine self.__settings = self.__engine.settings self.activated = True return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def deactivate(self): """ Deactivates the Component. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component cannot be deactivated!".format(self.__class__.__name__, self.__name)) def initialize_ui(self): """ Initializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component ui.".format( self.__class__.__name__)) self.__model = ComponentsModel(self, horizontal_headers=self.__headers) self.set_components() self.Components_Manager_Ui_treeView.setParent(None) self.Components_Manager_Ui_treeView = Components_QTreeView( self, self.__model) self.Components_Manager_Ui_treeView.setObjectName( "Components_Manager_Ui_treeView") self.Components_Manager_Ui_gridLayout.setContentsMargins( self.__tree_view_inner_margins) self.Components_Manager_Ui_gridLayout.addWidget( self.Components_Manager_Ui_treeView, 0, 0) self.__view = self.Components_Manager_Ui_treeView self.__view.setContextMenuPolicy(Qt.ActionsContextMenu) self.__view_add_actions() self.Components_Informations_textBrowser.setText( self.__components_informations_default_text) self.Components_Manager_Ui_splitter.setSizes([16777215, 1]) # Signals / Slots. self.__view.selectionModel().selectionChanged.connect( self.__view_selectionModel__selectionChanged) self.refresh_nodes.connect(self.__model__refresh_nodes) self.initialized_ui = True return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def uninitialize_ui(self): """ Uninitializes the Component ui. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component ui cannot be uninitialized!".format(self.__class__.__name__, self.name)) def add_widget(self): """ Adds the Component Widget to the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.addDockWidget(Qt.DockWidgetArea(self.__dock_area), self) return True @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def remove_widget(self): """ Removes the Component Widget from the engine. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' Component Widget cannot be removed!".format(self.__class__.__name__, self.name)) def on_startup(self): """ Defines the slot triggered by Framework startup. :return: Method success. :rtype: bool """ LOGGER.debug("> Calling '{0}' Component Framework 'on_startup' method.".format( self.__class__.__name__)) self.refresh_nodes.emit() return True def __model__refresh_nodes(self): """ Defines the slot triggered by the Model when nodes need refresh. """ LOGGER.debug("> Refreshing '{0}' Model!".format( "Components_Manager_Ui_treeView")) self.set_components() def __view_add_actions(self): """ Sets the **Components_Manager_Ui_treeView** actions. """ self.Components_Manager_Ui_treeView.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.ComponentsManagerUi|Activate Component(s)", slot=self.__view_activate_components_action__triggered)) self.Components_Manager_Ui_treeView.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.ComponentsManagerUi|Deactivate Component(s)", slot=self.__view_deactivate_components_action__triggered)) separator_action = QAction(self.Components_Manager_Ui_treeView) separator_action.setSeparator(True) self.Components_Manager_Ui_treeView.addAction(separator_action) self.Components_Manager_Ui_treeView.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.ComponentsManagerUi|Reload Component(s)", slot=self.__view_reload_components_action__triggered)) separator_action = QAction(self.Components_Manager_Ui_treeView) separator_action.setSeparator(True) self.Components_Manager_Ui_treeView.addAction(separator_action) def __view_activate_components_action__triggered(self, checked): """ Defines the slot triggered by \*\*'Actions|Umbra|Components|factory.ComponentsManagerUi|Activate Component(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.activate_components_ui() def __view_deactivate_components_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|factory.ComponentsManagerUi|Deactivate Component(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.deactivate_components_ui() def __view_reload_components_action__triggered(self, checked): """ Defines the slot triggered by \*\*'Actions|Umbra|Components|factory.ComponentsManagerUi|Reload Component(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.reload_components_ui() def __view_selectionModel__selectionChanged(self, selected_items, deselected_items): """ Sets the **Additional_Informations_textEdit** Widget. :param selected_items: Selected items. :type selected_items: QItemSelection :param deselected_items: Deselected items. :type deselected_items: QItemSelection """ LOGGER.debug("> Initializing '{0}' Widget.".format( "Additional_Informations_textEdit")) selected_components = self.get_selected_components() content = [] if selected_components: for item in selected_components: content.append(self.__components_informations_text.format(item.name, item.category, item.author, item.email, item.url, item.description)) else: content.append(self.__components_informations_default_text) separator = "" if len( content) == 1 else "<p><center>* * *<center/></p>" self.Components_Informations_textBrowser.setText( separator.join(content)) def __store_deactivated_components(self): """ Stores deactivated Components in settings file. """ deactivated_components = [] for node in foundations.walkers.nodes_walker(self.__model.root_node): if node.family == "Component": node.component.interface.activated or deactivated_components.append( node.component.name) LOGGER.debug("> Storing '{0}' deactivated Components.".format( ", ".join(deactivated_components))) self.__settings.set_key( "Settings", "deactivated_components", ",".join(deactivated_components)) @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, manager.exceptions.ComponentActivationError) @umbra.engine.encapsulate_processing def activate_components_ui(self): """ Activates user selected Components. :return: Method success. :rtype: bool :note: May require user interaction. """ selected_components = self.get_selected_components() self.__engine.start_processing( "Activating Components ...", len(selected_components)) activation_failed_components = [] for component in selected_components: if not component.interface.activated: success = self.activate_component(component.name) or False if not success: activation_failed_components.append(component) else: self.__engine.notifications_manager.warnify("{0} | '{1}' Component is already activated!".format( self.__class__.__name__, component.name)) self.__engine.step_processing() self.__engine.stop_processing() self.__store_deactivated_components() if not activation_failed_components: return True else: raise manager.exceptions.ComponentActivationError( "{0} | Exception(s) raised while activating '{1}' Component(s)!".format(self.__class__.__name__, ", ".join(( activation_failed_component.name for activation_failed_component in activation_failed_components)))) @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, manager.exceptions.ComponentDeactivationError) @umbra.engine.encapsulate_processing def deactivate_components_ui(self): """ Deactivates user selected Components. :return: Method success. :rtype: bool :note: May require user interaction. """ selected_components = self.get_selected_components() self.__engine.start_processing( "Deactivating Components ...", len(selected_components)) deactivation_failed_components = [] for component in selected_components: if component.interface.activated: if component.interface.deactivatable: success = self.deactivate_component( component.name) or False if not success: deactivation_failed_components.append(component) else: self.__engine.notifications_manager.warnify( "{0} | '{1}' Component cannot be deactivated!".format(self.__class__.__name__, component.name)) else: self.__engine.notifications_manager.warnify( "{0} | '{1}' Component is already deactivated!".format(self.__class__.__name__, component.name)) self.__engine.step_processing() self.__engine.stop_processing() self.__store_deactivated_components() if not deactivation_failed_components: return True else: raise manager.exceptions.ComponentDeactivationError( "{0} | Exception(s) raised while deactivating '{1}' Component(s)!".format(self.__class__.__name__, ", ".join(( deactivation_failed_component.name for deactivation_failed_component in deactivation_failed_components)))) @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, manager.exceptions.ComponentReloadError) @umbra.engine.encapsulate_processing def reload_components_ui(self): """ Reloads user selected Components. :return: Method success. :rtype: bool :note: May require user interaction. """ selected_components = self.get_selected_components() self.__engine.start_processing( "Reloading Components ...", len(selected_components)) reload_failed_components = [] for component in selected_components: if component.interface.deactivatable: success = self.reload_component(component.name) or False if not success: reload_failed_components.append(component) else: self.__engine.notifications_manager.warnify( "{0} | '{1}' Component cannot be deactivated and won't be reloaded!".format(self.__class__.__name__, component.name)) self.__engine.step_processing() self.__engine.stop_processing() if not reload_failed_components: return True else: raise manager.exceptions.ComponentReloadError( "{0} | Exception(s) raised while reloading '{1}' Component(s)!".format(self.__class__.__name__, ", ".join( (reload_failed_component.name for reload_failed_component in reload_failed_components)))) @foundations.exceptions.handle_exceptions(manager.exceptions.ComponentExistsError, Exception) def activate_component(self, name): """ Activates given Component. :param name: Component name. :type name: unicode :return: Method success. :rtype: bool """ if not name in self.__engine.components_manager.components: raise manager.exceptions.ComponentExistsError( "{0} | '{1}' Component isn't registered in the Components Manager!".format(self.__class__.__name__, name)) component = self.__engine.components_manager.components[name] if component.interface.activated: LOGGER.warning("!> {0} | '{1}' Component is already activated!".format( self.__class__.__name__, name)) return False LOGGER.debug( "> Attempting '{0}' Component activation.".format(component.name)) component.interface.activate(self.__engine) if component.category in ("Default", "QObject"): component.interface.initialize() elif component.category == "QWidget": component.interface.initialize_ui() component.interface.add_widget() LOGGER.info("{0} | '{1}' Component has been activated!".format( self.__class__.__name__, component.name)) self.activated_component.emit(name) self.refresh_nodes.emit() return True @foundations.exceptions.handle_exceptions(manager.exceptions.ComponentExistsError, manager.exceptions.ComponentDeactivationError) def deactivate_component(self, name): """ Deactivates given Component. :param name: Component name. :type name: unicode :return: Method success. :rtype: bool """ if not name in self.__engine.components_manager.components: raise manager.exceptions.ComponentExistsError( "{0} | '{0}' Component isn't registered in the Components Manager!".format(self.__class__.__name__, name)) component = self.__engine.components_manager.components[name] if not component.interface.activated: LOGGER.warning("!> {0} | '{1}' Component is already deactivated!".format( self.__class__.__name__, name)) return False LOGGER.debug( "> Attempting '{0}' Component deactivation.".format(component.name)) if component.interface.deactivatable: if component.category in ("Default", "QObject"): component.interface.uninitialize() elif component.category == "QWidget": component.interface.uninitialize_ui() component.interface.remove_widget() component.interface.deactivate() LOGGER.info("{0} | '{1}' Component has been deactivated!".format( self.__class__.__name__, component.name)) self.deactivated_component.emit(name) self.refresh_nodes.emit() return True else: raise manager.exceptions.ComponentDeactivationError( "{0} | '{1}' Component cannot be deactivated!".format(self.__class__.__name__, component.name)) @foundations.exceptions.handle_exceptions(manager.exceptions.ComponentExistsError, manager.exceptions.ComponentReloadError) def reload_component(self, name): """ Reloads given Component. :param name: Component name. :type name: unicode :return: Method success. :rtype: bool """ if not name in self.__engine.components_manager.components: raise manager.exceptions.ComponentExistsError( "{0} | '{1}' Component isn't registered in the Components Manager!".format(self.__class__.__name__, name)) component = self.__engine.components_manager.components[name] LOGGER.debug( "> Attempting '{0}' Component reload.".format(component.name)) if component.interface.deactivatable: dependents = list( reversed(self.__engine.components_manager.list_dependents(component.name))) if filter(lambda x: not self.__engine.components_manager[x].deactivatable, dependents): LOGGER.warning( "!> {0} | '{1}' Component has non reloadable dependencies and won't be reloaded!".format( self.__class__.__name__, component.name)) return False LOGGER.info("{0} | '{1}' Component dependents: '{2}'.".format(self.__class__.__name__, component.name, ", ".join(dependents))) LOGGER.debug( "> Deactivating '{0}' Component dependents.".format(component.name)) dependents.append(component.name) for dependent in dependents: if self.__engine.components_manager[dependent].activated: self.deactivate_component(dependent) self.__engine.process_events() LOGGER.debug( "> Reloading '{0}' Component dependents.".format(component.name)) self.__engine.components_manager.reload_component(component.name) LOGGER.debug( "> Activating '{0}' Component dependents.".format(component.name)) for dependent in reversed(dependents): if not self.__engine.components_manager[dependent].activated: self.activate_component(dependent) self.__engine.process_events() LOGGER.info("{0} | '{1}' Component has been reloaded!".format( self.__class__.__name__, component.name)) self.reloaded_component.emit(component.name) return True else: raise manager.exceptions.ComponentReloadError( "{0} | '{1}' Component cannot be deactivated and won't be reloaded!".format(self.__class__.__name__, component.name)) def get_components(self): """ Returns the Components. :return: Components. :rtype: list """ return self.__engine.components_manager.components def list_components(self): """ Lists the Components names. :return: Components names. :rtype: list """ return self.__engine.components_manager.list_components() def set_components(self): """ Sets the Components Model nodes. """ node_flags = attributes_flags = int( Qt.ItemIsSelectable | Qt.ItemIsEnabled) root_node = umbra.ui.nodes.DefaultNode(name="InvisibleRootNode") paths = {} for path in self.__engine.components_manager.paths: basename = os.path.basename(path) if not paths.get(basename): paths[basename] = {} paths[basename].update(dict((name, component) for (name, component) in self.__engine.components_manager if basename == os.path.basename(os.path.dirname(component.directory)))) for path, components in paths.iteritems(): path_node = PathNode(name=path.title(), parent=root_node, node_flags=node_flags, attributes_flags=attributes_flags) for component in components.itervalues(): if not component.interface: continue component_node = ComponentNode(component, name=component.title, parent=path_node, node_flags=node_flags, attributes_flags=attributes_flags, activated=umbra.ui.nodes.GraphModelAttribute(name="activated", flags=attributes_flags, roles={ Qt.DisplayRole: foundations.strings.to_string( component.interface.activated), Qt.DecorationRole: os.path.join( self.__ui_resources_directory, component.interface.activated and self.__ui_activated_image or self.__ui_deactivated_image)})) component_node.roles[Qt.DecorationRole] = os.path.join(self.__ui_resources_directory, "{0}{1}".format(component.category, self.__ui_category_affixe)) root_node.sort_children() self.__model.initialize_model(root_node) return True def get_selected_nodes(self): """ Returns the View selected nodes. :return: View selected nodes. :rtype: dict """ return self.__view.get_selected_nodes() def get_selected_components_nodes(self): """ Returns the View selected Components nodes. :return: View selected Components nodes. :rtype: list """ return [node for node in self.get_selected_nodes() if node.family == "Component"] def get_selected_components(self): """ Returns the View selected Components. :return: View selected Components. :rtype: list """ return [node.component for node in self.get_selected_components_nodes()]
class ComponentsManagerUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): ''' | Defines the :mod:`umbra.components.factory.components_manager_ui.components_manager_ui` Component Interface class. | It defines methods to interact with the :class:`manager.components_manager.Manager` class Application instance Components. ''' def __init__(self, parent=None, name=None, *args, **kwargs): ''' 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: \*\* ''' pass @property def ui_resources_directory(self): ''' Property for **self.__ui_resources_directory** attribute. :return: self.__ui_resources_directory. :rtype: unicode ''' pass @ui_resources_directory.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_resources_directory(self): ''' Setter for **self.__ui_resources_directory** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_resources_directory.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_resources_directory(self): ''' Deleter for **self.__ui_resources_directory** attribute. ''' pass @property def ui_activated_image(self): ''' Property for **self.__ui_activated_image** attribute. :return: self.__ui_activated_image. :rtype: unicode ''' pass @ui_activated_image.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_activated_image(self): ''' Setter for **self.__ui_activated_image** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_activated_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_activated_image(self): ''' Deleter for **self.__ui_activated_image** attribute. ''' pass @property def ui_deactivated_image(self): ''' Property for **self.__ui_deactivated_image** attribute. :return: self.__ui_deactivated_image. :rtype: unicode ''' pass @ui_deactivated_image.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_deactivated_image(self): ''' Setter for **self.__ui_deactivated_image** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_deactivated_image.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_deactivated_image(self): ''' Deleter for **self.__ui_deactivated_image** attribute. ''' pass @property def ui_category_affixe(self): ''' Property for **self.__ui_category_affixe** attribute. :return: self.__ui_category_affixe. :rtype: unicode ''' pass @ui_category_affixe.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_category_affixe(self): ''' Setter for **self.__ui_category_affixe** attribute. :param value: Attribute value. :type value: unicode ''' pass @ui_category_affixe.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def ui_category_affixe(self): ''' Deleter for **self.__ui_category_affixe** attribute. ''' pass @property def dock_area(self): ''' Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int ''' pass @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int ''' pass @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Deleter for **self.__dock_area** attribute. ''' pass @property def engine(self): ''' Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject ''' pass @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject ''' pass @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Deleter for **self.__engine** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def model(self): ''' Property for **self.__model** attribute. :return: self.__model. :rtype: ComponentsModel ''' pass @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Setter for **self.__model** attribute. :param value: Attribute value. :type value: ComponentsModel ''' pass @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Deleter for **self.__model** attribute. ''' pass @property def view(self): ''' Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget ''' pass @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget ''' pass @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Deleter for **self.__view** attribute. ''' pass @property def headers(self): ''' Property for **self.__headers** attribute. :return: self.__headers. :rtype: list ''' pass @headers.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self): ''' Setter for **self.__headers** attribute. :param value: Attribute value. :type value: list ''' pass @headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self): ''' Deleter for **self.__headers** attribute. ''' pass @property def tree_view_inner_margins(self): ''' Property for **self.__tree_view_inner_margins** attribute. :return: self.__tree_view_inner_margins. :rtype: int ''' pass @tree_view_inner_margins.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_inner_margins(self): ''' Setter for **self.__tree_view_inner_margins** attribute. :param value: Attribute value. :type value: int ''' pass @tree_view_inner_margins.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_inner_margins(self): ''' Deleter for **self.__tree_view_inner_margins** attribute. ''' pass @property def components_informations_default_text(self): ''' Property for **self.__components_informations_default_text** attribute. :return: self.__components_informations_default_text. :rtype: unicode ''' pass @components_informations_default_text.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_default_text(self): ''' Setter for **self.__components_informations_default_text** attribute. :param value: Attribute value. :type value: unicode ''' pass @components_informations_default_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_default_text(self): ''' Deleter for **self.__components_informations_default_text** attribute. ''' pass @property def components_informations_text(self): ''' Property for **self.__components_informations_text** attribute. :return: self.__components_informations_text. :rtype: unicode ''' pass @components_informations_text.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_text(self): ''' Setter for **self.__components_informations_text** attribute. :param value: Attribute value. :type value: unicode ''' pass @components_informations_text.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def components_informations_text(self): ''' Deleter for **self.__components_informations_text** attribute. ''' pass def activate(self, engine): ''' Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def deactivate(self): ''' Deactivates the Component. ''' pass def initialize_ui(self): ''' Initializes the Component ui. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def uninitialize_ui(self): ''' Uninitializes the Component ui. ''' pass def add_widget(self): ''' Adds the Component Widget to the engine. :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def remove_widget(self): ''' Removes the Component Widget from the engine. ''' pass def on_startup(self): ''' Defines the slot triggered by Framework startup. :return: Method success. :rtype: bool ''' pass def __model__refresh_nodes(self): ''' Defines the slot triggered by the Model when nodes need refresh. ''' pass def __view_add_actions(self): ''' Sets the **Components_Manager_Ui_treeView** actions. ''' pass def __view_activate_components_action__triggered(self, checked): ''' Defines the slot triggered by \*\*'Actions|Umbra|Components|factory.ComponentsManagerUi|Activate Component(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_deactivate_components_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|factory.ComponentsManagerUi|Deactivate Component(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_reload_components_action__triggered(self, checked): ''' Defines the slot triggered by \*\*'Actions|Umbra|Components|factory.ComponentsManagerUi|Reload Component(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_selectionModel__selectionChanged(self, selected_items, deselected_items): ''' Sets the **Additional_Informations_textEdit** Widget. :param selected_items: Selected items. :type selected_items: QItemSelection :param deselected_items: Deselected items. :type deselected_items: QItemSelection ''' pass def __store_deactivated_components(self): ''' Stores deactivated Components in settings file. ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, manager.exceptions.ComponentActivationError) @umbra.engine.encapsulate_processing def activate_components_ui(self): ''' Activates user selected Components. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, manager.exceptions.ComponentDeactivationError) @umbra.engine.encapsulate_processing def deactivate_components_ui(self): ''' Deactivates user selected Components. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, manager.exceptions.ComponentReloadError) @umbra.engine.encapsulate_processing def reload_components_ui(self): ''' Reloads user selected Components. :return: Method success. :rtype: bool :note: May require user interaction. ''' pass @foundations.exceptions.handle_exceptions(manager.exceptions.ComponentExistsError, Exception) def activate_components_ui(self): ''' Activates given Component. :param name: Component name. :type name: unicode :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(manager.exceptions.ComponentExistsError, manager.exceptions.ComponentDeactivationError) def deactivate_components_ui(self): ''' Deactivates given Component. :param name: Component name. :type name: unicode :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(manager.exceptions.ComponentExistsError, manager.exceptions.ComponentReloadError) def reload_components_ui(self): ''' Reloads given Component. :param name: Component name. :type name: unicode :return: Method success. :rtype: bool ''' pass def get_components(self): ''' Returns the Components. :return: Components. :rtype: list ''' pass def list_components(self): ''' Lists the Components names. :return: Components names. :rtype: list ''' pass def set_components(self): ''' Sets the Components Model nodes. ''' pass def get_selected_nodes(self): ''' Returns the View selected nodes. :return: View selected nodes. :rtype: dict ''' pass def get_selected_components_nodes(self): ''' Returns the View selected Components nodes. :return: View selected Components nodes. :rtype: list ''' pass def get_selected_components_nodes(self): ''' Returns the View selected Components. :return: View selected Components. :rtype: list ''' pass
144
67
14
3
7
5
2
0.65
1
12
6
0
66
17
66
66
1,115
241
531
173
382
345
317
120
250
8
1
4
105
142,537
KelSolaar/Umbra
KelSolaar_Umbra/umbra/managers/notifications_manager.py
umbra.managers.notifications_manager.Notification
class Notification(foundations.data_structures.Structure): """ Defines a storage object for :class:`NotificationsManager` class notification. """ def __init__(self, **kwargs): """ Initializes the class. :param \*\*kwargs: message, time. :type \*\*kwargs: dict """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) foundations.data_structures.Structure.__init__(self, **kwargs)
class Notification(foundations.data_structures.Structure): ''' Defines a storage object for :class:`NotificationsManager` class notification. ''' def __init__(self, **kwargs): ''' Initializes the class. :param \*\*kwargs: message, time. :type \*\*kwargs: dict ''' pass
2
2
11
3
3
5
1
2
1
0
0
0
1
0
1
1
16
4
4
2
2
8
4
2
2
1
1
0
1
142,538
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/addons/trace_ui/views.py
umbra.components.addons.trace_ui.views.Modules_QTreeView
class Modules_QTreeView(umbra.ui.views.Abstract_QTreeView): """ Defines the view for modules. """ def __init__(self, parent, model=None, read_only=False, message=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param model: Model. :type model: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.views.Abstract_QTreeView.__init__( self, parent, read_only, message) # --- Setting class attributes. --- self.__tree_view_indentation = 15 self.setModel(model) Modules_QTreeView.__initialize_ui(self) @property def tree_view_indentation(self): """ Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int """ return self.__tree_view_indentation @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self, value): """ Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "tree_view_indentation")) @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): """ Deleter for **self.__tree_view_indentation** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tree_view_indentation")) def __initialize_ui(self): """ Initializes the Widget ui. """ self.setAutoScroll(True) self.setSelectionMode(QAbstractItemView.ExtendedSelection) self.setIndentation(self.__tree_view_indentation) self.setRootIsDecorated(False) self.setDragDropMode(QAbstractItemView.NoDragDrop) self.setSortingEnabled(True) self.sortByColumn(0, Qt.AscendingOrder) self.__set_default_ui_state() # Signals / Slots. self.model().modelReset.connect(self.__set_default_ui_state) def __set_default_ui_state(self): """ Sets the Widget default ui state. """ LOGGER.debug("> Setting default View state!") if not self.model(): return self.expandAll() for column in range(len(self.model().horizontal_headers)): self.resizeColumnToContents(column) def setModel(self, model): """ Reimplements the **umbra.ui.views.Abstract_QTreeView.setModel** method. :param model: Model to set. :type model: QObject """ LOGGER.debug("> Setting '{0}' model.".format(model)) if not model: return umbra.ui.views.Abstract_QTreeView.setModel(self, model)
class Modules_QTreeView(umbra.ui.views.Abstract_QTreeView): ''' Defines the view for modules. ''' def __init__(self, parent, model=None, read_only=False, message=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param model: Model. :type model: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode ''' pass @property def tree_view_indentation(self): ''' Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int ''' pass @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int ''' pass @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Deleter for **self.__tree_view_indentation** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __set_default_ui_state(self): ''' Sets the Widget default ui state. ''' pass def setModel(self, model): ''' Reimplements the **umbra.ui.views.Abstract_QTreeView.setModel** method. :param model: Model to set. :type model: QObject ''' pass
13
8
14
3
5
5
1
0.95
1
1
0
0
7
1
7
26
112
30
42
13
29
40
35
10
27
3
4
1
10
142,539
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/addons/trace_ui/nodes.py
umbra.components.addons.trace_ui.nodes.ModuleNode
class ModuleNode(umbra.ui.nodes.GraphModelNode): """ Defines :class:`umbra.components.factory.trace_ui.trace_ui.TraceUi` Component Interface class **Module** node. """ __family = "Module" def __init__(self, module=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): """ Initializes the class. :param module: Module. :type module: ModuleType :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.nodes.GraphModelNode.__init__( self, name, parent, children, roles, node_flags, **kwargs) # --- Setting class attributes. --- self.__module = module ModuleNode.__initialize_node(self, attributes_flags) @property def module(self): """ Property for **self.__module** attribute. :return: self.__module. :rtype: object """ return self.__module @module.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def module(self, value): """ Setter for **self.__module** attribute. :param value: Attribute value. :type value: object """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "module")) @module.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def module(self): """ Deleter for **self.__module** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "module")) def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int """ self["traced"] = umbra.ui.nodes.GraphModelAttribute(name="traced", value=foundations.trace.is_traced( self.__module), flags=attributes_flags) self.update_node_attributes() def update_node_attributes(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): """ Updates the Node attributes. :param attributes_flags: Attributes flags. :type attributes_flags: int :return: Method success. :rtype: bool """ self.traced.value = foundations.trace.is_traced(self.__module) self.traced.roles[Qt.DisplayRole] = foundations.strings.to_string( self.traced.value).title()
class ModuleNode(umbra.ui.nodes.GraphModelNode): ''' Defines :class:`umbra.components.factory.trace_ui.trace_ui.TraceUi` Component Interface class **Module** node. ''' def __init__(self, module=None, name=None, parent=None, children=None, roles=None, node_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled), **kwargs): ''' Initializes the class. :param module: Module. :type module: ModuleType :param name: Node name. :type name: unicode :param parent: Node parent. :type parent: GraphModelNode :param children: Children. :type children: list :param roles: Roles. :type roles: dict :param node_flags: Node flags. :type node_flags: int :param attributes_flags: Attributes flags. :type attributes_flags: int :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* ''' pass @property def module(self): ''' Property for **self.__module** attribute. :return: self.__module. :rtype: object ''' pass @module.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def module(self): ''' Setter for **self.__module** attribute. :param value: Attribute value. :type value: object ''' pass @module.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def module(self): ''' Deleter for **self.__module** attribute. ''' pass def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Initializes the node. :param attributes_flags: Attributes flags. :type attributes_flags: int ''' pass def update_node_attributes(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)): ''' Updates the Node attributes. :param attributes_flags: Attributes flags. :type attributes_flags: int :return: Method success. :rtype: bool ''' pass
12
7
15
2
5
8
1
1.36
1
2
1
0
6
1
6
19
106
21
36
20
16
49
19
9
12
1
3
0
6
142,540
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/addons/tcp_server_ui/tcp_server_ui.py
umbra.components.addons.tcp_server_ui.tcp_server_ui.TCPServerUi
class TCPServerUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): """ | Defines the :mod:`umbra.components.factory.tcp_serverUi.tcp_serverUi` Component Interface class. | It provides various methods to operate the TCP Server. """ def __init__(self, parent=None, name=None, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(TCPServerUi, self).__init__(parent, name, *args, **kwargs) # --- Setting class attributes. --- self.deactivatable = True self.__engine = None self.__settings = None self.__settings_section = None self.__preferences_manager = None self.__tcp_server = None self.__address = foundations.common.get_host_address() self.__port = 16384 @property def engine(self): """ Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject """ return self.__engine @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self, value): """ Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "engine")) @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): """ Deleter for **self.__engine** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "engine")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def settings_section(self): """ Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode """ return self.__settings_section @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self, value): """ Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings_section")) @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): """ Deleter for **self.__settings_section** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings_section")) @property def preferences_manager(self): """ Property for **self.__preferences_manager** attribute. :return: self.__preferences_manager. :rtype: QWidget """ return self.__preferences_manager @preferences_manager.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self, value): """ Setter for **self.__preferences_manager** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "preferences_manager")) @preferences_manager.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self): """ Deleter for **self.__preferences_manager** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "preferences_manager")) @property def tcp_server(self): """ Property for **self.__tcp_server** attribute. :return: self.__tcp_server. :rtype: QWidget """ return self.__tcp_server @tcp_server.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tcp_server(self, value): """ Setter for **self.__tcp_server** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "tcp_server")) @tcp_server.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tcp_server(self): """ Deleter for **self.__tcp_server** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tcp_server")) @property def address(self): """ Property for **self.__address** attribute. :return: self.__address. :rtype: unicode """ return self.__address @address.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self, value): """ Setter for **self.__address** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "address", value) self.__address = value @address.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self): """ Deleter for **self.__address** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "address")) @property def port(self): """ Property for **self.__port** attribute. :return: self.__port. :rtype: int """ return self.__port @port.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self, value): """ Setter for **self.__port** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "port", value) assert type(value) >= 0 and type(value) >= 65535, \ "'{0}' attribute: '{1}' value must be in 0-65535 range!".format( "port", value) self.__port = value @port.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self): """ Deleter for **self.__port** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "port")) def activate(self, engine): """ Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__engine = engine self.__settings = self.__engine.settings self.__settings_section = self.name self.__preferences_manager = self.__engine.components_manager[ "factory.preferences_manager"] self.__tcp_server = TCPServer( self.__address, self.__port, RequestsStackDataHandler) self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__engine = None self.__settings = None self.__settings_section = None self.__preferences_manager = None self.__tcp_server.online and self.__tcp_server.stop() self.__tcp_server = None self.activated = False return True def initialize_ui(self): """ Initializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component ui.".format( self.__class__.__name__)) self.__Port_spinBox_set_ui() self.__Autostart_TCP_Server_checkBox_set_ui() # Signals / Slots. self.Port_spinBox.valueChanged.connect( self.__Port_spinBox__valueChanged) self.Autostart_TCP_Server_checkBox.stateChanged.connect( self.__Autostart_TCP_Server_checkBox__stateChanged) self.Start_TCP_Server_pushButton.clicked.connect( self.__Start_TCP_Server_pushButton__clicked) self.Stop_TCP_Server_pushButton.clicked.connect( self.__Stop_TCP_Server_pushButton__clicked) self.initialized_ui = True return True def uninitialize_ui(self): """ Uninitializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component ui.".format( self.__class__.__name__)) # Signals / Slots. self.Port_spinBox.valueChanged.disconnect( self.__Port_spinBox__valueChanged) self.Autostart_TCP_Server_checkBox.stateChanged.disconnect( self.__Autostart_TCP_Server_checkBox__stateChanged) self.Start_TCP_Server_pushButton.clicked.disconnect( self.__Start_TCP_Server_pushButton__clicked) self.Stop_TCP_Server_pushButton.clicked.disconnect( self.__Stop_TCP_Server_pushButton__clicked) self.initialized_ui = False return True def add_widget(self): """ Adds the Component Widget to the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding '{0}' Component Widget.".format( self.__class__.__name__)) self.__preferences_manager.Others_Preferences_gridLayout.addWidget( self.TCP_Server_Ui_groupBox) return True def remove_widget(self): """ Removes the Component Widget from the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Removing '{0}' Component Widget.".format( self.__class__.__name__)) self.__preferences_manager.findChild( QGridLayout, "Others_Preferences_gridLayout").removeWidget(self) self.TCP_Server_Ui_groupBox.setParent(None) return True def on_startup(self): """ Defines the slot triggered on Framework startup. """ LOGGER.debug("> Calling '{0}' Component Framework 'on_startup' method.".format( self.__class__.__name__)) if self.Autostart_TCP_Server_checkBox.isChecked(): if not self.__tcp_server.online: self.__tcp_server.port = self.Port_spinBox.value() self.__tcp_server.start() return True def on_close(self): """ Defines the slot triggered on Framework close. """ self.__tcp_server.online and self.__tcp_server.stop() return True def __Port_spinBox_set_ui(self): """ Sets the **Port_spinBox** Widget. """ # Adding settings key if it doesn't exists. self.__settings.get_key(self.__settings_section, "port").isNull() and \ self.__settings.set_key( self.__settings_section, "port", self.__port) port = foundations.common.get_first_item( self.__settings.get_key(self.__settings_section, "port").toInt()) LOGGER.debug("> Setting '{0}' with value '{1}'.".format("Port_spinBox", port)) self.Port_spinBox.setValue(port) self.__port = port def __Port_spinBox__valueChanged(self, value): """ Defines the slot triggered by the **Port_spinBox** Widget when value changed. :param value: Port value. :type value: int """ LOGGER.debug("> 'Port' value: '{0}'.".format(value)) self.__settings.set_key(self.__settings_section, "port", value) self.__port = value def __Autostart_TCP_Server_checkBox_set_ui(self): """ Sets the **Autostart_TCP_Server_checkBox** Widget. """ # Adding settings key if it doesn't exists. self.__settings.get_key(self.__settings_section, "autostart_tcp_server").isNull() and \ self.__settings.set_key( self.__settings_section, "autostart_tcp_server", Qt.Checked) autostart_tcp_server = foundations.common.get_first_item( self.__settings.get_key(self.__settings_section, "autostart_tcp_server").toInt()) LOGGER.debug("> Setting '{0}' with value '{1}'.".format("Autostart_TCP_Server_checkBox", autostart_tcp_server)) self.Autostart_TCP_Server_checkBox.setCheckState(autostart_tcp_server) def __Autostart_TCP_Server_checkBox__stateChanged(self, state): """ Defines the slot triggered by **Autostart_TCP_Server_checkBox** Widged when state changed. :param state: Checkbox state. :type state: int """ autostart_tcp_server = self.Autostart_TCP_Server_checkBox.checkState() LOGGER.debug("> 'Autostart TCP Server' state: '{0}'.".format( autostart_tcp_server)) self.__settings.set_key(self.__settings_section, "autostart_tcp_server", autostart_tcp_server) def __Start_TCP_Server_pushButton__clicked(self, checked): """ Defines the slot triggered by **Start_TCP_Server_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.start_tcp_server(self.Port_spinBox.value()) def __Stop_TCP_Server_pushButton__clicked(self, checked): """ Defines the slot triggered by **Stop_TCP_Server_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool """ self.stop_tcp_server() def start_tcp_server(self, port): """ Starts the TCP server using given port. :param port: Port. :type port: int :return: Method success. :rtype: bool """ self.__tcp_server.port = port if not self.__tcp_server.online: if self.__tcp_server.start(): self.__engine.notifications_manager.notify( "{0} | TCP Server has started with '{1}' address on '{2}' port!".format( self.__class__.__name__, self.__address, self.__port)) return True else: self.__engine.notifications_manager.warnify( "{0} | TCP Server is already online!".format(self.__class__.__name__)) return False def stop_tcp_server(self): """ Stops the TCP server. :return: Method success. :rtype: bool """ if self.__tcp_server.online: if self.__tcp_server.stop(): self.__engine.notifications_manager.notify( "{0} | TCP Server has stopped!".format(self.__class__.__name__)) return True else: self.__engine.notifications_manager.warnify( "{0} | TCP Server is not online!".format(self.__class__.__name__)) return False
class TCPServerUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): ''' | Defines the :mod:`umbra.components.factory.tcp_serverUi.tcp_serverUi` Component Interface class. | It provides various methods to operate the TCP Server. ''' def __init__(self, parent=None, name=None, *args, **kwargs): ''' 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: \*\* ''' pass @property def engine(self): ''' Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject ''' pass @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject ''' pass @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Deleter for **self.__engine** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def settings_section(self): ''' Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode ''' pass @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode ''' pass @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Deleter for **self.__settings_section** attribute. ''' pass @property def preferences_manager(self): ''' Property for **self.__preferences_manager** attribute. :return: self.__preferences_manager. :rtype: QWidget ''' pass @preferences_manager.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self): ''' Setter for **self.__preferences_manager** attribute. :param value: Attribute value. :type value: QWidget ''' pass @preferences_manager.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self): ''' Deleter for **self.__preferences_manager** attribute. ''' pass @property def tcp_server(self): ''' Property for **self.__tcp_server** attribute. :return: self.__tcp_server. :rtype: QWidget ''' pass @tcp_server.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tcp_server(self): ''' Setter for **self.__tcp_server** attribute. :param value: Attribute value. :type value: QWidget ''' pass @tcp_server.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tcp_server(self): ''' Deleter for **self.__tcp_server** attribute. ''' pass @property def address(self): ''' Property for **self.__address** attribute. :return: self.__address. :rtype: unicode ''' pass @address.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self): ''' Setter for **self.__address** attribute. :param value: Attribute value. :type value: unicode ''' pass @address.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self): ''' Deleter for **self.__address** attribute. ''' pass @property def port(self): ''' Property for **self.__port** attribute. :return: self.__port. :rtype: int ''' pass @port.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self): ''' Setter for **self.__port** attribute. :param value: Attribute value. :type value: int ''' pass @port.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self): ''' Deleter for **self.__port** attribute. ''' pass def activate(self, engine): ''' Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize_ui(self): ''' Initializes the Component ui. :return: Method success. :rtype: bool ''' pass def uninitialize_ui(self): ''' Uninitializes the Component ui. :return: Method success. :rtype: bool ''' pass def add_widget(self): ''' Adds the Component Widget to the engine. :return: Method success. :rtype: bool ''' pass def remove_widget(self): ''' Removes the Component Widget from the engine. :return: Method success. :rtype: bool ''' pass def on_startup(self): ''' Defines the slot triggered on Framework startup. ''' pass def on_close(self): ''' Defines the slot triggered on Framework close. ''' pass def __Port_spinBox_set_ui(self): ''' Sets the **Port_spinBox** Widget. ''' pass def __Port_spinBox__valueChanged(self, value): ''' Defines the slot triggered by the **Port_spinBox** Widget when value changed. :param value: Port value. :type value: int ''' pass def __Autostart_TCP_Server_checkBox_set_ui(self): ''' Sets the **Autostart_TCP_Server_checkBox** Widget. ''' pass def __Autostart_TCP_Server_checkBox__stateChanged(self, state): ''' Defines the slot triggered by **Autostart_TCP_Server_checkBox** Widged when state changed. :param state: Checkbox state. :type state: int ''' pass def __Start_TCP_Server_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Start_TCP_Server_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def __Stop_TCP_Server_pushButton__clicked(self, checked): ''' Defines the slot triggered by **Stop_TCP_Server_pushButton** Widget when clicked. :param checked: Checked state. :type checked: bool ''' pass def start_tcp_server(self, port): ''' Starts the TCP server using given port. :param port: Port. :type port: int :return: Method success. :rtype: bool ''' pass def stop_tcp_server(self): ''' Stops the TCP server. :return: Method success. :rtype: bool ''' pass
74
39
12
2
5
5
1
0.85
1
4
1
0
38
10
38
38
534
128
219
73
145
187
153
52
114
3
1
2
46
142,541
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/addons/tcp_client_ui/tcp_client_ui.py
umbra.components.addons.tcp_client_ui.tcp_client_ui.TCPClientUi
class TCPClientUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): """ Defines the :mod:`umbra.components.factory.tcp_client_ui.tcp_client_ui` Component Interface class. """ def __init__(self, parent=None, name=None, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(TCPClientUi, self).__init__(parent, name, *args, **kwargs) # --- Setting class attributes. --- self.deactivatable = True self.__engine = None self.__settings = None self.__settings_section = None self.__preferences_manager = None self.__script_editor = None self.__address = foundations.common.get_host_address() self.__port = 16384 self.__file_command = "execfile(\"{0}\")" self.__connection_end = "<!RE>" @property def engine(self): """ Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject """ return self.__engine @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self, value): """ Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "engine")) @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): """ Deleter for **self.__engine** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "engine")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def settings_section(self): """ Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode """ return self.__settings_section @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self, value): """ Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings_section")) @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): """ Deleter for **self.__settings_section** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings_section")) @property def preferences_manager(self): """ Property for **self.__preferences_manager** attribute. :return: self.__preferences_manager. :rtype: QWidget """ return self.__preferences_manager @preferences_manager.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self, value): """ Setter for **self.__preferences_manager** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "preferences_manager")) @preferences_manager.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self): """ Deleter for **self.__preferences_manager** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "preferences_manager")) @property def script_editor(self): """ Property for **self.__script_editor** attribute. :return: self.__script_editor. :rtype: QWidget """ return self.__script_editor @script_editor.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self, value): """ Setter for **self.__script_editor** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "script_editor")) @script_editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): """ Deleter for **self.__script_editor** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "script_editor")) @property def address(self): """ Property for **self.__address** attribute. :return: self.__address. :rtype: unicode """ return self.__address @address.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self, value): """ Setter for **self.__address** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "address", value) self.Address_lineEdit.setText(value) self.__address = value @address.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self): """ Deleter for **self.__address** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "address")) @property def port(self): """ Property for **self.__port** attribute. :return: self.__port. :rtype: int """ return self.__port @port.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self, value): """ Setter for **self.__port** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "port", value) assert type(value) >= 0 and type(value) >= 65535, \ "'{0}' attribute: '{1}' value must be in 0-65535 range!".format( "port", value) self.Port_spinBox.setValue(value) self.__port = value @port.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self): """ Deleter for **self.__port** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "port")) @property def file_command(self): """ Property for **self.__file_command** attribute. :return: self.__file_command. :rtype: unicode """ return self.__file_command @file_command.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_command(self, value): """ Setter for **self.__file_command** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "file_command", value) self.__file_command = value @file_command.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_command(self): """ Deleter for **self.__file_command** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "file_command")) @property def connection_end(self): """ Property for **self.__connection_end** attribute. :return: self.__connection_end. :rtype: unicode """ return self.__connection_end @connection_end.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def connection_end(self, value): """ Setter for **self.__connection_end** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "connection_end", value) self.__connection_end = value @connection_end.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def connection_end(self): """ Deleter for **self.__connection_end** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "connection_end")) def activate(self, engine): """ Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__engine = engine self.__settings = self.__engine.settings self.__settings_section = self.name self.__preferences_manager = self.__engine.components_manager[ "factory.preferences_manager"] self.__script_editor = self.__engine.components_manager["factory.script_editor"] self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__engine = None self.__settings = None self.__settings_section = None self.__preferences_manager = None self.activated = False return True def initialize_ui(self): """ Initializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component ui.".format( self.__class__.__name__)) self.__Port_spinBox_set_ui() self.__Address_lineEdit_set_ui() self.__File_Command_lineEdit_set_ui() self.__Connection_End_lineEdit_set_ui() self.__add_actions() # Signals / Slots. self.Port_spinBox.valueChanged.connect( self.__Port_spinBox__valueChanged) self.Address_lineEdit.editingFinished.connect( self.__Address_lineEdit__editFinished) self.File_Command_lineEdit.editingFinished.connect( self.__File_Command_lineEdit__editFinished) self.Connection_End_lineEdit.editingFinished.connect( self.__Connection_End_lineEdit__editFinished) self.initialized_ui = True return True def uninitialize_ui(self): """ Uninitializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component ui.".format( self.__class__.__name__)) self.__remove_actions() # Signals / Slots. self.Port_spinBox.valueChanged.disconnect( self.__Port_spinBox__valueChanged) self.Address_lineEdit.editingFinished.disconnect( self.__Address_lineEdit__editFinished) self.File_Command_lineEdit.editingFinished.disconnect( self.__File_Command_lineEdit__editFinished) self.Connection_End_lineEdit.editingFinished.disconnect( self.__Connection_End_lineEdit__editFinished) self.initialized_ui = False return True def add_widget(self): """ Adds the Component Widget to the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding '{0}' Component Widget.".format( self.__class__.__name__)) self.__preferences_manager.Others_Preferences_gridLayout.addWidget( self.TCP_Client_Ui_groupBox) return True def remove_widget(self): """ Removes the Component Widget from the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Removing '{0}' Component Widget.".format( self.__class__.__name__)) self.__preferences_manager.findChild( QGridLayout, "Others_Preferences_gridLayout").removeWidget(self) self.TCP_Client_Ui_groupBox.setParent(None) return True def __add_actions(self): """ Sets Component actions. """ LOGGER.debug("> Adding '{0}' Component actions.".format( self.__class__.__name__)) self.__script_editor.command_menu.addSeparator() self.__script_editor.command_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.tcp_serverUi|&Command|Send Selection To Server", shortcut=Qt.ControlModifier + Qt.AltModifier + Qt.Key_Return, slot=self.__send_selection_to_server_action__triggered)) self.__script_editor.command_menu.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.tcp_serverUi|&Command|&Send Current File To Server", shortcut=Qt.SHIFT + Qt.AltModifier + Qt.CTRL + Qt.Key_Return, slot=self.__send_file_to_server_action__triggered)) def __remove_actions(self): """ Removes actions. """ LOGGER.debug("> Removing '{0}' Component actions.".format( self.__class__.__name__)) send_selection_to_server_action = "Actions|Umbra|Components|addons.tcp_serverUi|&Command|Send Selection To Server" send_file_to_server_action = "Actions|Umbra|Components|addons.tcp_serverUi|&Command|&Send Current File To Server" for action in (send_selection_to_server_action, send_file_to_server_action): self.__script_editor.command_menu.removeAction( self.__engine.actions_manager.get_action(action)) self.__engine.actions_manager.unregister_action(action) def __Address_lineEdit_set_ui(self): """ Fills **Address_lineEdit** Widget. """ # Adding settings key if it doesn't exists. self.__settings.get_key(self.__settings_section, "address").isNull() and \ self.__settings.set_key( self.__settings_section, "address", self.__address) address = self.__settings.get_key( self.__settings_section, "address").toString() LOGGER.debug("> Setting '{0}' with value '{1}'.".format("Address_lineEdit", address)) self.__address = address self.Address_lineEdit.setText(address) def __Address_lineEdit__editFinished(self): """ Defines the slot triggered by **Address_lineEdit** Widget when edited. """ address = self.Address_lineEdit.text() self.__settings.set_key(self.__settings_section, "address", address) self.__address = address def __Port_spinBox_set_ui(self): """ Sets the **Port_spinBox** Widget. """ # Adding settings key if it doesn't exists. self.__settings.get_key(self.__settings_section, "port").isNull() and \ self.__settings.set_key( self.__settings_section, "port", self.__port) port = foundations.common.get_first_item( self.__settings.get_key(self.__settings_section, "port").toInt()) LOGGER.debug("> Setting '{0}' with value '{1}'.".format("Port_spinBox", port)) self.__port = port self.Port_spinBox.setValue(port) def __Port_spinBox__valueChanged(self, value): """ Defines the slot triggered by the **Port_spinBox** Widget when value changed. :param value: Port value. :type value: int """ LOGGER.debug("> 'Port' value: '{0}'.".format(value)) self.__port = int(value) self.__settings.set_key(self.__settings_section, "port", value) def __File_Command_lineEdit_set_ui(self): """ Fills **File_Command_lineEdit** Widget. """ # Adding settings key if it doesn't exists. self.__settings.get_key(self.__settings_section, "file_command").isNull() and \ self.__settings.set_key( self.__settings_section, "file_command", self.__file_command) file_command = self.__settings.get_key( self.__settings_section, "file_command").toString() LOGGER.debug("> Setting '{0}' with value '{1}'.".format("File_Command_lineEdit", file_command)) self.__file_command = file_command self.File_Command_lineEdit.setText(file_command) def __File_Command_lineEdit__editFinished(self): """ Defines the slot triggered by **File_Command_lineEdit** Widget when edited. """ file_command = self.File_Command_lineEdit.text() self.__settings.set_key(self.__settings_section, "file_command", file_command) self.__file_command = file_command def __Connection_End_lineEdit_set_ui(self): """ Fills **Connection_End_lineEdit** Widget. """ # Adding settings key if it doesn't exists. self.__settings.get_key(self.__settings_section, "connection_end").isNull() and \ self.__settings.set_key( self.__settings_section, "connection_end", self.__connection_end) connection_end = self.__settings.get_key( self.__settings_section, "connection_end").toString() LOGGER.debug("> Setting '{0}' with value '{1}'.".format("Connection_End_lineEdit", connection_end)) self.__connection_end = connection_end self.Connection_End_lineEdit.setText(connection_end) def __Connection_End_lineEdit__editFinished(self): """ Defines the slot triggered by **Connection_End_lineEdit** Widget when edited. """ connection_end = self.Connection_End_lineEdit.text() self.__settings.set_key(self.__settings_section, "connection_end", connection_end) self.__connection_end = connection_end def __send_selection_to_server_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.tcp_serverUi|&Command|Send Selection To Server'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ editor = self.__script_editor.get_current_editor() if not editor: return False selected_text = foundations.strings.to_string( editor.get_selected_text().replace(QChar(QChar.ParagraphSeparator), QString("\n"))) if not selected_text: return False return self.send_data_to_server(selected_text) def __send_file_to_server_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.tcp_serverUi|&Command|&Send Current File To Server'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ editor = self.__script_editor.get_current_editor() if not editor: return False if self.__script_editor.save_file(): return self.send_data_to_server(foundations.strings.to_string(self.__file_command).format(editor.file)) def send_data_to_server(self, data, time_out=5): """ Sends given data to the Server. :param data: Data to send. :type data: unicode :param time_out: Connection timeout in seconds. :type time_out: float :return: Method success. :rtype: bool """ if not data.endswith(self.__connection_end): data = "{0}{1}".format(data, foundations.strings.to_string( self.__connection_end).decode("string_escape")) connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connection.settimeout(time_out) connection.connect( (foundations.strings.to_string(self.__address), int(self.__port))) connection.send(data) self.__engine.notifications_manager.notify( "{0} | Socket connection command dispatched!".format(self.__class__.__name__)) connection.close() return True
class TCPClientUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): ''' Defines the :mod:`umbra.components.factory.tcp_client_ui.tcp_client_ui` Component Interface class. ''' def __init__(self, parent=None, name=None, *args, **kwargs): ''' 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: \*\* ''' pass @property def engine(self): ''' Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject ''' pass @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject ''' pass @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Deleter for **self.__engine** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def settings_section(self): ''' Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode ''' pass @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode ''' pass @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Deleter for **self.__settings_section** attribute. ''' pass @property def preferences_manager(self): ''' Property for **self.__preferences_manager** attribute. :return: self.__preferences_manager. :rtype: QWidget ''' pass @preferences_manager.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self): ''' Setter for **self.__preferences_manager** attribute. :param value: Attribute value. :type value: QWidget ''' pass @preferences_manager.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def preferences_manager(self): ''' Deleter for **self.__preferences_manager** attribute. ''' pass @property def script_editor(self): ''' Property for **self.__script_editor** attribute. :return: self.__script_editor. :rtype: QWidget ''' pass @script_editor.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): ''' Setter for **self.__script_editor** attribute. :param value: Attribute value. :type value: QWidget ''' pass @script_editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): ''' Deleter for **self.__script_editor** attribute. ''' pass @property def address(self): ''' Property for **self.__address** attribute. :return: self.__address. :rtype: unicode ''' pass @address.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self): ''' Setter for **self.__address** attribute. :param value: Attribute value. :type value: unicode ''' pass @address.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def address(self): ''' Deleter for **self.__address** attribute. ''' pass @property def port(self): ''' Property for **self.__port** attribute. :return: self.__port. :rtype: int ''' pass @port.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self): ''' Setter for **self.__port** attribute. :param value: Attribute value. :type value: int ''' pass @port.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def port(self): ''' Deleter for **self.__port** attribute. ''' pass @property def file_command(self): ''' Property for **self.__file_command** attribute. :return: self.__file_command. :rtype: unicode ''' pass @file_command.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_command(self): ''' Setter for **self.__file_command** attribute. :param value: Attribute value. :type value: unicode ''' pass @file_command.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def file_command(self): ''' Deleter for **self.__file_command** attribute. ''' pass @property def connection_end(self): ''' Property for **self.__connection_end** attribute. :return: self.__connection_end. :rtype: unicode ''' pass @connection_end.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def connection_end(self): ''' Setter for **self.__connection_end** attribute. :param value: Attribute value. :type value: unicode ''' pass @connection_end.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def connection_end(self): ''' Deleter for **self.__connection_end** attribute. ''' pass def activate(self, engine): ''' Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize_ui(self): ''' Initializes the Component ui. :return: Method success. :rtype: bool ''' pass def uninitialize_ui(self): ''' Uninitializes the Component ui. :return: Method success. :rtype: bool ''' pass def add_widget(self): ''' Adds the Component Widget to the engine. :return: Method success. :rtype: bool ''' pass def remove_widget(self): ''' Removes the Component Widget from the engine. :return: Method success. :rtype: bool ''' pass def __add_actions(self): ''' Sets Component actions. ''' pass def __remove_actions(self): ''' Removes actions. ''' pass def __Address_lineEdit_set_ui(self): ''' Fills **Address_lineEdit** Widget. ''' pass def __Address_lineEdit__editFinished(self): ''' Defines the slot triggered by **Address_lineEdit** Widget when edited. ''' pass def __Port_spinBox_set_ui(self): ''' Sets the **Port_spinBox** Widget. ''' pass def __Port_spinBox__valueChanged(self, value): ''' Defines the slot triggered by the **Port_spinBox** Widget when value changed. :param value: Port value. :type value: int ''' pass def __File_Command_lineEdit_set_ui(self): ''' Fills **File_Command_lineEdit** Widget. ''' pass def __File_Command_lineEdit__editFinished(self): ''' Defines the slot triggered by **File_Command_lineEdit** Widget when edited. ''' pass def __Connection_End_lineEdit_set_ui(self): ''' Fills **Connection_End_lineEdit** Widget. ''' pass def __Connection_End_lineEdit__editFinished(self): ''' Defines the slot triggered by **Connection_End_lineEdit** Widget when edited. ''' pass def __send_selection_to_server_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.tcp_serverUi|&Command|Send Selection To Server'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __send_file_to_server_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.tcp_serverUi|&Command|&Send Current File To Server'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def send_data_to_server(self, data, time_out=5): ''' Sends given data to the Server. :param data: Data to send. :type data: unicode :param time_out: Connection timeout in seconds. :type time_out: float :return: Method success. :rtype: bool ''' pass
93
48
12
2
5
5
1
0.79
1
4
0
0
47
12
47
47
664
155
284
101
191
225
203
74
155
3
1
1
57
142,542
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/addons/projects_explorer/views.py
umbra.components.addons.projects_explorer.views.Projects_QTreeView
class Projects_QTreeView(umbra.ui.views.Abstract_QTreeView): """ Defines the view for Projects. """ def __init__(self, parent, model=None, read_only=False, message=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject :param model: Model. :type model: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) umbra.ui.views.Abstract_QTreeView.__init__( self, parent, read_only, message) # --- Setting class attributes. --- self.__tree_view_indentation = 15 self.setModel(model) Projects_QTreeView.__initialize_ui(self) @property def tree_view_indentation(self): """ Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int """ return self.__tree_view_indentation @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self, value): """ Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "tree_view_indentation")) @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): """ Deleter for **self.__tree_view_indentation** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "tree_view_indentation")) def __initialize_ui(self): """ Initializes the Widget ui. """ self.setAutoScroll(True) self.setIndentation(self.__tree_view_indentation) self.setRootIsDecorated(False) self.setDragDropMode(QAbstractItemView.DragOnly) self.header().hide() self.setSortingEnabled(True) self.sortByColumn(0, Qt.AscendingOrder) self.__set_default_ui_state() # Signals / Slots. self.model().modelReset.connect(self.__set_default_ui_state) def __set_default_ui_state(self): """ Sets the Widget default ui state. """ LOGGER.debug("> Setting default View state!") if not self.model(): return self.expandAll() def setModel(self, model): """ Reimplements the **umbra.ui.views.Abstract_QTreeView.setModel** method. :param model: Model to set. :type model: QObject """ LOGGER.debug("> Setting '{0}' model.".format(model)) if not model: return umbra.ui.views.Abstract_QTreeView.setModel(self, model)
class Projects_QTreeView(umbra.ui.views.Abstract_QTreeView): ''' Defines the view for Projects. ''' def __init__(self, parent, model=None, read_only=False, message=None): ''' Initializes the class. :param parent: Object parent. :type parent: QObject :param model: Model. :type model: QObject :param read_only: View is read only. :type read_only: bool :param message: View default message when Model is empty. :type message: unicode ''' pass @property def tree_view_indentation(self): ''' Property for **self.__tree_view_indentation** attribute. :return: self.__tree_view_indentation. :rtype: int ''' pass @tree_view_indentation.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Setter for **self.__tree_view_indentation** attribute. :param value: Attribute value. :type value: int ''' pass @tree_view_indentation.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def tree_view_indentation(self): ''' Deleter for **self.__tree_view_indentation** attribute. ''' pass def __initialize_ui(self): ''' Initializes the Widget ui. ''' pass def __set_default_ui_state(self): ''' Sets the Widget default ui state. ''' pass def setModel(self, model): ''' Reimplements the **umbra.ui.views.Abstract_QTreeView.setModel** method. :param model: Model to set. :type model: QObject ''' pass
13
8
13
3
5
5
1
1
1
0
0
0
7
1
7
26
110
30
40
12
27
40
33
9
25
2
4
1
9
142,543
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/addons/projects_explorer/projects_explorer.py
umbra.components.addons.projects_explorer.projects_explorer.ProjectsExplorer
class ProjectsExplorer(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): """ Defines the :mod:`sibl_gui.components.addons.projects_explorer.projects_explorer` Component Interface class. """ def __init__(self, parent=None, name=None, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(ProjectsExplorer, self).__init__(parent, name, *args, **kwargs) # --- Setting class attributes. --- self.deactivatable = True self.__dock_area = 1 self.__engine = None self.__settings = None self.__settings_section = None self.__script_editor = None self.__model = None self.__view = None self.__delegate = None self.__style = Style(default=""" QLabel, QLabel link { background-color: rgb(32, 32, 32); color: rgb(192, 192, 192); } """, hover=""" QLabel, QLabel link { background-color: rgb(64, 64, 64); color: rgb(192, 192, 192); } """, highlight=""" QLabel, QLabel link { background-color: rgb(128, 128, 128); color: rgb(224, 224, 224); } """) @property def dock_area(self): """ Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int """ return self.__dock_area @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self, value): """ Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "dock_area")) @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): """ Deleter for **self.__dock_area** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "dock_area")) @property def engine(self): """ Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject """ return self.__engine @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self, value): """ Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "engine")) @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): """ Deleter for **self.__engine** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "engine")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def settings_section(self): """ Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode """ return self.__settings_section @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self, value): """ Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings_section")) @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): """ Deleter for **self.__settings_section** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings_section")) @property def script_editor(self): """ Property for **self.__script_editor** attribute. :return: self.__script_editor. :rtype: QWidget """ return self.__script_editor @script_editor.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self, value): """ Setter for **self.__script_editor** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "script_editor")) @script_editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): """ Deleter for **self.__script_editor** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "script_editor")) @property def model(self): """ Property for **self.__model** attribute. :return: self.__model. :rtype: ProjectsProxyModel """ return self.__model @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self, value): """ Setter for **self.__model** attribute. :param value: Attribute value. :type value: ProjectsProxyModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "model")) @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): """ Deleter for **self.__model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "model")) @property def view(self): """ Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget """ return self.__view @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self, value): """ Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "view")) @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): """ Deleter for **self.__view** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "view")) @property def delegate(self): """ Property for **self.__delegate** attribute. :return: self.__delegate. :rtype: QItemDelegate """ return self.__delegate @delegate.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self, value): """ Setter for **self.__delegate** attribute. :param value: Attribute value. :type value: QItemDelegate """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "delegate")) @delegate.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self): """ Deleter for **self.__delegate** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "delegate")) @property def style(self): """ Property for **self.__style** attribute. :return: self.__style. :rtype: Style """ return self.__style @style.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self, value): """ Setter for **self.__style** attribute. :param value: Attribute value. :type value: Style """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "style")) @style.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): """ Deleter for **self.__style** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "style")) def activate(self, engine): """ Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__engine = engine self.__settings = self.__engine.settings self.__settings_section = self.name self.__script_editor = self.__engine.components_manager["factory.script_editor"] self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__engine = None self.__settings = None self.__settings_section = None self.__script_editor = None self.activated = False return True def initialize_ui(self): """ Initializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component ui.".format( self.__class__.__name__)) self.__model = ProjectsProxyModel(self) self.__model.setSourceModel(self.__script_editor.model) self.__delegate = RichText_QStyledItemDelegate(self, self.__style) self.Projects_Explorer_treeView.setParent(None) self.Projects_Explorer_treeView = Projects_QTreeView( self, self.__model) self.Projects_Explorer_treeView.setItemDelegate(self.__delegate) self.Projects_Explorer_treeView.setObjectName( "Projects_Explorer_treeView") self.Projects_Explorer_treeView.setContextMenuPolicy( Qt.ActionsContextMenu) self.Projects_Explorer_dockWidgetContents_gridLayout.addWidget( self.Projects_Explorer_treeView, 0, 0) self.__view = self.Projects_Explorer_treeView self.__view_add_actions() self.__add_actions() # Signals / Slots. self.__view.expanded.connect(self.__view__expanded) self.__view.doubleClicked.connect(self.__view__doubleClicked) self.__view.selectionModel().selectionChanged.connect( self.__view_selectionModel__selectionChanged) self.__script_editor.Script_Editor_tabWidget.currentChanged.connect( self.__script_editor_Script_Editor_tabWidget__currentChanged) self.__script_editor.model.project_registered.connect( self.__script_editor_model__project_registered) self.initialized_ui = True return True def uninitialize_ui(self): """ Uninitializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component ui.".format( self.__class__.__name__)) self.__remove_actions() # Signals / Slots. self.__view.expanded.disconnect(self.__view__expanded) self.__view.doubleClicked.disconnect(self.__view__doubleClicked) self.__view.selectionModel().selectionChanged.disconnect( self.__view_selectionModel__selectionChanged) self.__script_editor.Script_Editor_tabWidget.currentChanged.disconnect( self.__script_editor_Script_Editor_tabWidget__currentChanged) self.__script_editor.model.project_registered.disconnect( self.__script_editor_model__project_registered) self.__view_remove_actions() self.__model = None self.__delegate = None self.__view = None self.initialized_ui = False return True def add_widget(self): """ Adds the Component Widget to the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.addDockWidget(Qt.DockWidgetArea(self.__dock_area), self) return True def remove_widget(self): """ Removes the Component Widget from the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Removing '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.removeDockWidget(self) self.setParent(None) return True def __add_actions(self): """ Sets Component actions. """ LOGGER.debug("> Adding '{0}' Component actions.".format( self.__class__.__name__)) add_project_action = self.__engine.actions_manager.get_action( "Actions|Umbra|Components|factory.script_editor|&File|Add Project ...") remove_project_action = self.__engine.actions_manager.register_action( "Actions|Umbra|Components|factory.script_editor|&File|Remove Project", slot=self.__view_remove_project_action__triggered) self.__script_editor.file_menu.insertAction( add_project_action, remove_project_action) self.__script_editor.file_menu.removeAction(add_project_action) self.__script_editor.file_menu.insertAction( remove_project_action, add_project_action) def __remove_actions(self): """ Removes actions. """ LOGGER.debug("> Removing '{0}' Component actions.".format( self.__class__.__name__)) remove_project_action = "Actions|Umbra|Components|factory.script_editor|&File|Remove Project" self.__script_editor.command_menu.removeAction( self.__engine.actions_manager.get_action(remove_project_action)) self.__engine.actions_manager.unregister_action(remove_project_action) def __view_add_actions(self): """ Sets the View actions. """ self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Add Project ...", slot=self.__view_add_project_action__triggered)) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Remove Project", slot=self.__view_remove_project_action__triggered)) separator_action = QAction(self.__view) separator_action.setSeparator(True) self.__view.addAction(separator_action) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Add New File ...", slot=self.__view_add_new_file_action__triggered)) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Add New Directory ...", slot=self.__view_add_new_directory_action__triggered)) separator_action = QAction(self.__view) separator_action.setSeparator(True) self.__view.addAction(separator_action) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Rename ...", slot=self.__view_rename_action__triggered)) # self.__view.addAction(self.__engine.actions_manager.register_action( # "Actions|Umbra|Components|addons.projects_explorer|Copy ...", # slot=self.__view_copy_action__triggered)) # self.__view.addAction(self.__engine.actions_manager.register_action( # "Actions|Umbra|Components|addons.projects_explorer|Move ...", # slot=self.__view_move_action__triggered)) separator_action = QAction(self.__view) separator_action.setSeparator(True) self.__view.addAction(separator_action) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Delete ...", slot=self.__view_delete_action__triggered)) separator_action = QAction(self.__view) separator_action.setSeparator(True) self.__view.addAction(separator_action) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Find In Files ...", slot=self.__view_find_in_files_action__triggered)) separator_action = QAction(self.__view) separator_action.setSeparator(True) self.__view.addAction(separator_action) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.projects_explorer|Output Selected Path", slot=self.__view_output_selected_path_action__triggered)) def __view_remove_actions(self): """ Removes the View actions. """ add_project_action = "Actions|Umbra|Components|addons.projects_explorer|Add Project ..." remove_project_action = "Actions|Umbra|Components|addons.projects_explorer|Remove Project" add_new_file_action = "Actions|Umbra|Components|addons.projects_explorer|Add New File ..." add_new_directory_action = "Actions|Umbra|Components|addons.projects_explorer|Add New Directory ..." rename_action = "Actions|Umbra|Components|addons.projects_explorer|Rename ..." # copy_action = "Actions|Umbra|Components|addons.projects_explorer|Copy ..." # move_action = "Actions|Umbra|Components|addons.projects_explorer|Move ..." delete_action = "Actions|Umbra|Components|addons.projects_explorer|Delete ..." find_in_files_action = "Actions|Umbra|Components|addons.projects_explorer|Find In Files ..." output_selected_path_action = "Actions|Umbra|Components|addons.projects_explorer|Output Selected Path" for action in (add_project_action, remove_project_action, add_new_file_action, add_new_directory_action, rename_action, # copy_action, # move_action, delete_action, output_selected_path_action): self.__view.removeAction( self.__engine.actions_manager.get_action(action)) self.__engine.actions_manager.unregister_action(action) def __view__expanded(self, index): """ Defines the slot triggered by a View when an item is expanded. :param index: Expdanded item. :type index: QModelIndex """ node = self.__model.get_node(index) if node.family != "Directory": return self.__script_editor.model.set_project_nodes(node) def __view__doubleClicked(self, index): """ Defines the slot triggered by a View when double clicked. :param index: Clicked item index. :type index: QModelIndex """ node = self.__model.get_node(index) if not node.family == "File": return foundations.common.path_exists( node.path) and self.__script_editor.load_file(node.path) def __view_selectionModel__selectionChanged(self, selected_items, deselected_items): """ Defines the slot triggered by the View **selectionModel** when selection changed. :param selected_items: Selected items. :type selected_items: QItemSelection :param deselected_items: Deselected items. :type deselected_items: QItemSelection """ for node in self.__view.get_selected_nodes(): if node.family == "File": self.__script_editor.set_current_editor(node.path) def __script_editor_Script_Editor_tabWidget__currentChanged(self, index): """ Defines the slot triggered by :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class when the current tab is changed. :param index: Tab index. :type index: int """ editor = self.__script_editor.get_current_editor() if not editor: return editor_node = foundations.common.get_first_item( self.__script_editor.model.get_editor_nodes(editor)) if not editor_node: return indexes = [self.__model.mapFromSource( self.__model.sourceModel().get_node_index(editor_node.parent))] self.__view.clearSelection() self.__view.select_indexes(indexes) def __script_editor_model__project_registered(self, project_node): """ Defines the slot triggered by :class:`umbra.components.factory.script_editor.script_editor` class Model when a project is registered. :param project_node: Registered project ProjectNode. :type project_node: ProjectNode """ index = self.__model.mapFromSource( self.__script_editor.model.get_node_index(project_node)) self.__view.setExpanded(index, True) def __view_add_project_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Add Project ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.__script_editor.add_project_ui() def __view_remove_project_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Remove Project'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ node = foundations.common.get_first_item(self.get_selected_nodes()) if not node: return False return self.remove_project(node) def __view_add_new_file_action__triggered(self, checked): """ Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Add New File ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ node = foundations.common.get_first_item(self.get_selected_nodes()) if not node: return False return self.add_new_file(node) def __view_add_new_directory_action__triggered(self, checked): """ Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Add New Directory ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ node = foundations.common.get_first_item(self.get_selected_nodes()) if not node: return False return self.add_new_directory(node) def __view_rename_action__triggered(self, checked): """ Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Rename ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ node = foundations.common.get_first_item(self.get_selected_nodes()) if not node: return False return self.rename(node) # def __view_copy_action__triggered(self, checked): # """ # Defines the slot triggered by \*\*'"Actions|Umbra|Components|addons.projects_explorer|Copy ..."'** action. # # :param checked: Checked state. # :type :param: bool # :return: Method success. # :rtype: bool # """ # # print "Actions|Umbra|Components|addons.projects_explorer|Copy ..." # def __view_move_action__triggered(self, checked): # """ # Defines the slot triggered by \*\*'"Actions|Umbra|Components|addons.projects_explorer|Move ..."'** action. # # :param checked: Checked state. # :type :param: bool # :return: Method success. # :rtype: bool # """ # # print "Actions|Umbra|Components|addons.projects_explorer|Move ..." def __view_delete_action__triggered(self, checked): """ Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Delete ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ node = foundations.common.get_first_item(self.get_selected_nodes()) if not node: return False return self.delete(node) def __view_find_in_files_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Find In Files ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ node = foundations.common.get_first_item( self.__view.get_selected_nodes().iterkeys()) if not node: return False self.__script_editor.search_in_files.Where_lineEdit.setText(node.path) self.__script_editor.search_in_files.show() return True def __view_output_selected_path_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Output Selected Path'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool """ node = foundations.common.get_first_item( self.__view.get_selected_nodes().iterkeys()) if not node: return False LOGGER.info("{0} | '{1}'.".format(self.__class__.__name__, node.path)) return True @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.FileExistsError, foundations.exceptions.DirectoryExistsError, Exception) def __raise_file_system_exception(self, item, directory): """ Raises a common fileSystem exception. :param item: Name of the item generating the exception. :type item: unicode :param directory: Name of the target directory. :type directory: unicode """ path = os.path.join(directory, item) if os.path.isfile(path): raise foundations.exceptions.FileExistsError( "{0} | A file with '{1}' name already exists in '{2}' directory!".format(self.__class__.__name__, item, directory)) else: raise foundations.exceptions.DirectoryExistsError( "{0} | A directory with '{1}' name already exists in '{2}' directory!".format(self.__class__.__name__, item, directory)) def __set_authoring_nodes(self, source, target): """ Sets given editor authoring nodes. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode """ editor = self.__script_editor.get_editor(source) editor.set_file(target) self.__script_editor.model.update_authoring_nodes(editor) def __rename_path(self, source, target): """ Renames given source with given target name. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode """ if not foundations.common.path_exists(source): return parent_directory = os.path.dirname(source) is_path_registered = self.__engine.file_system_events_manager.is_path_registered( parent_directory) is_path_registered and self.__engine.file_system_events_manager.unregister_path( parent_directory) os.rename(source, target) is_path_registered and self.__engine.file_system_events_manager.register_path( parent_directory) def __delete_path(self, path): """ Deletes given path. :param path: Path to delete. :type path: unicode """ if not foundations.common.path_exists(path): return parent_directory = os.path.dirname(path) is_path_registered = self.__engine.file_system_events_manager.is_path_registered( parent_directory) is_path_registered and self.__engine.file_system_events_manager.unregister_path( parent_directory) foundations.io.remove(path) is_path_registered and self.__engine.file_system_events_manager.register_path( parent_directory) def __rename_file(self, source, target): """ Renames a file using given source and target names. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode """ for file_node in self.__script_editor.model.get_file_nodes(source, self.__script_editor.model.root_node): self.__script_editor.unregister_node_path(file_node) self.__rename_path(source, target) self.__script_editor.register_node_path(file_node) if self.__script_editor.model.is_authoring_node(file_node): self.__set_authoring_nodes(source, target) else: self.__script_editor.model.update_project_nodes( file_node.parent) def __rename_directory(self, source, target): """ Renames a directory using given source and target names. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode """ for node in itertools.chain(self.__script_editor.model.get_project_nodes(source), self.__script_editor.model.get_directory_nodes(source)): self.__script_editor.model.unregister_project_nodes(node) self.__script_editor.unregister_node_path(node) self.__rename_path(source, target) node.name = os.path.basename(target) node.path = target self.__script_editor.model.node_changed(node) self.__script_editor.register_node_path(node) self.__script_editor.model.set_project_nodes(node) def __rename_project(self, source, target): """ Renames a project using given source and target names. :param source: Source project. :type source: unicode :param target: Target project. :type target: unicode """ self.__rename_directory(source, target) def __delete_file(self, file): """ Deletes given file. :param file: File to delete. :type file: unicode """ for file_node in self.__script_editor.model.get_file_nodes(file, self.__script_editor.model.root_node): self.__script_editor.unregister_node_path(file_node) self.__delete_path(file) if self.__script_editor.model.is_authoring_node(file_node): self.__script_editor.get_editor(file).set_modified(True) else: self.__script_editor.model.unregister_file(file_node) def __delete_directory(self, directory): """ Deletes given directory. :param directory: Directory to delete. :type directory: unicode """ for node in itertools.chain(self.__script_editor.model.get_project_nodes(directory), self.__script_editor.model.get_directory_nodes(directory)): self.__script_editor.model.unregister_project_nodes(node) if node.family == "Directory": self.__script_editor.model.unregister_project_nodes(node) self.__script_editor.model.unregister_directory(node) elif node.family == "Project": self.__script_editor.remove_project(directory) self.__delete_path(directory) def get_selected_nodes(self): """ Returns the View selected nodes. :return: View selected nodes. :rtype: dict """ return self.__view.get_selected_nodes() def remove_project(self, node): """ Removes the project associated with given node. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool """ if node.family == "Project": self.__script_editor.remove_project(node.path) return True for node in foundations.walkers.nodes_walker(node, ascendants=True): if node.family == "Project" and not node is self.__script_editor.model.default_project_node: self.__script_editor.remove_project(node.path) return True def add_new_file(self, node): """ Adds a new file next to given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool """ if self.__script_editor.model.is_authoring_node(node): return self.__script_editor.new_file() file, state = QInputDialog.getText( self, "Add File", "Enter your new file name:") if not state: return False if node.family in ("Project", "Directory"): directory = node.path elif node.family == "File": directory = os.path.dirname(node.path) # file = foundations.strings.to_string(file) if not file in os.listdir(directory): file = os.path.join(directory, file) LOGGER.info("{0} | Adding '{1}' file!".format( self.__class__.__name__, file)) open(file, "w").close() else: self.__raise_file_system_exception(file, directory) return True def add_new_directory(self, node): """ Adds a new directory next to given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool """ if self.__script_editor.model.is_authoring_node(node): return False directory, state = QInputDialog.getText( self, "Add Directory", "Enter your new directory name:") if not state: return False if node.family in ("Project", "Directory"): parent_directory = node.path elif node.family == "File": parent_directory = os.path.dirname(node.path) directory = foundations.strings.to_string(directory) if not directory in os.listdir(parent_directory): directory = os.path.join(parent_directory, directory) LOGGER.info("{0} | Adding '{1}' directory!".format( self.__class__.__name__, directory)) os.makedirs(directory) else: self.__raise_file_system_exception(file, parent_directory) return True def rename(self, node): """ Renames given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool """ source = node.path base_name, state = QInputDialog.getText( self, "Rename", "Enter your new name:", text=os.path.basename(source)) if not state: return False base_name = foundations.strings.to_string(base_name) if base_name == os.path.basename(source): return False parent_directory = os.path.dirname(source) target = os.path.join(parent_directory, base_name) if self.__script_editor.model.is_authoring_node(node): if not foundations.common.path_exists(source): LOGGER.info("{0} | Renaming '{1}' untitled file to '{2}'!".format( self.__class__.__name__, source, target)) self.__set_authoring_nodes(source, target) return True if not base_name in os.listdir(parent_directory): if node.family == "File": LOGGER.info("{0} | Renaming '{1}' file to '{2}'!".format( self.__class__.__name__, source, target)) self.__rename_file(source, target) elif node.family == "Directory": LOGGER.info("{0} | Renaming '{1}' directory to '{2}'!".format( self.__class__.__name__, source, target)) self.__rename_directory(source, target) elif node.family == "Project": LOGGER.info("{0} | Renaming '{1}' project to '{2}'!".format( self.__class__.__name__, source, target)) self.__rename_project(source, target) else: self.__raise_file_system_exception(base_name, parent_directory) return True def delete(self, node): """ Deletes given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool """ path = node.path if self.__script_editor.model.is_authoring_node(node): if not foundations.common.path_exists(path): return False if message_box.message_box("Question", "Question", "Are you sure you want to delete '{0}' {1}?".format( path, "file" if os.path.isfile(path) else "directory"), buttons=QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes: if os.path.isfile(path): LOGGER.info("{0} | Deleting '{1}' file!".format( self.__class__.__name__, path)) self.__delete_file(path) else: LOGGER.info("{0} | Deleting '{1}' directory!".format( self.__class__.__name__, path)) self.__delete_directory(path) return True
class ProjectsExplorer(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): ''' Defines the :mod:`sibl_gui.components.addons.projects_explorer.projects_explorer` Component Interface class. ''' def __init__(self, parent=None, name=None, *args, **kwargs): ''' 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: \*\* ''' pass @property def dock_area(self): ''' Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int ''' pass @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int ''' pass @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Deleter for **self.__dock_area** attribute. ''' pass @property def engine(self): ''' Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject ''' pass @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject ''' pass @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Deleter for **self.__engine** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def settings_section(self): ''' Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode ''' pass @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode ''' pass @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Deleter for **self.__settings_section** attribute. ''' pass @property def script_editor(self): ''' Property for **self.__script_editor** attribute. :return: self.__script_editor. :rtype: QWidget ''' pass @script_editor.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): ''' Setter for **self.__script_editor** attribute. :param value: Attribute value. :type value: QWidget ''' pass @script_editor.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def script_editor(self): ''' Deleter for **self.__script_editor** attribute. ''' pass @property def model(self): ''' Property for **self.__model** attribute. :return: self.__model. :rtype: ProjectsProxyModel ''' pass @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Setter for **self.__model** attribute. :param value: Attribute value. :type value: ProjectsProxyModel ''' pass @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Deleter for **self.__model** attribute. ''' pass @property def view(self): ''' Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget ''' pass @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget ''' pass @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Deleter for **self.__view** attribute. ''' pass @property def delegate(self): ''' Property for **self.__delegate** attribute. :return: self.__delegate. :rtype: QItemDelegate ''' pass @delegate.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self): ''' Setter for **self.__delegate** attribute. :param value: Attribute value. :type value: QItemDelegate ''' pass @delegate.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def delegate(self): ''' Deleter for **self.__delegate** attribute. ''' pass @property def style(self): ''' Property for **self.__style** attribute. :return: self.__style. :rtype: Style ''' pass @style.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): ''' Setter for **self.__style** attribute. :param value: Attribute value. :type value: Style ''' pass @style.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def style(self): ''' Deleter for **self.__style** attribute. ''' pass def activate(self, engine): ''' Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize_ui(self): ''' Initializes the Component ui. :return: Method success. :rtype: bool ''' pass def uninitialize_ui(self): ''' Uninitializes the Component ui. :return: Method success. :rtype: bool ''' pass def add_widget(self): ''' Adds the Component Widget to the engine. :return: Method success. :rtype: bool ''' pass def remove_widget(self): ''' Removes the Component Widget from the engine. :return: Method success. :rtype: bool ''' pass def __add_actions(self): ''' Sets Component actions. ''' pass def __remove_actions(self): ''' Removes actions. ''' pass def __view_add_actions(self): ''' Sets the View actions. ''' pass def __view_remove_actions(self): ''' Removes the View actions. ''' pass def __view__expanded(self, index): ''' Defines the slot triggered by a View when an item is expanded. :param index: Expdanded item. :type index: QModelIndex ''' pass def __view__doubleClicked(self, index): ''' Defines the slot triggered by a View when double clicked. :param index: Clicked item index. :type index: QModelIndex ''' pass def __view_selectionModel__selectionChanged(self, selected_items, deselected_items): ''' Defines the slot triggered by the View **selectionModel** when selection changed. :param selected_items: Selected items. :type selected_items: QItemSelection :param deselected_items: Deselected items. :type deselected_items: QItemSelection ''' pass def __script_editor_Script_Editor_tabWidget__currentChanged(self, index): ''' Defines the slot triggered by :class:`umbra.components.factory.script_editor.script_editor.ScriptEditor` Component Interface class when the current tab is changed. :param index: Tab index. :type index: int ''' pass def __script_editor_model__project_registered(self, project_node): ''' Defines the slot triggered by :class:`umbra.components.factory.script_editor.script_editor` class Model when a project is registered. :param project_node: Registered project ProjectNode. :type project_node: ProjectNode ''' pass def __view_add_project_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Add Project ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_remove_project_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Remove Project'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_add_new_file_action__triggered(self, checked): ''' Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Add New File ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_add_new_directory_action__triggered(self, checked): ''' Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Add New Directory ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_rename_action__triggered(self, checked): ''' Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Rename ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_delete_action__triggered(self, checked): ''' Defines the slot triggered by **'"Actions|Umbra|Components|addons.projects_explorer|Delete ..."'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_find_in_files_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Find In Files ...'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_output_selected_path_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.projects_explorer|Output Selected Path'** action. :param checked: Checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.FileExistsError, foundations.exceptions.DirectoryExistsError, Exception) def __raise_file_system_exception(self, item, directory): ''' Raises a common fileSystem exception. :param item: Name of the item generating the exception. :type item: unicode :param directory: Name of the target directory. :type directory: unicode ''' pass def __set_authoring_nodes(self, source, target): ''' Sets given editor authoring nodes. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode ''' pass def __rename_path(self, source, target): ''' Renames given source with given target name. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode ''' pass def __delete_path(self, path): ''' Deletes given path. :param path: Path to delete. :type path: unicode ''' pass def __rename_file(self, source, target): ''' Renames a file using given source and target names. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode ''' pass def __rename_directory(self, source, target): ''' Renames a directory using given source and target names. :param source: Source file. :type source: unicode :param target: Target file. :type target: unicode ''' pass def __rename_project(self, source, target): ''' Renames a project using given source and target names. :param source: Source project. :type source: unicode :param target: Target project. :type target: unicode ''' pass def __delete_file(self, file): ''' Deletes given file. :param file: File to delete. :type file: unicode ''' pass def __delete_directory(self, directory): ''' Deletes given directory. :param directory: Directory to delete. :type directory: unicode ''' pass def get_selected_nodes(self): ''' Returns the View selected nodes. :return: View selected nodes. :rtype: dict ''' pass def remove_project(self, node): ''' Removes the project associated with given node. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool ''' pass def add_new_file(self, node): ''' Adds a new file next to given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool ''' pass def add_new_directory(self, node): ''' Adds a new directory next to given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool ''' pass def rename(self, node): ''' Renames given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool ''' pass def delete(self, node): ''' Deletes given Node associated path. :param node: Node. :type node: ProjectNode or DirectoryNode or FileNode :return: Method success. :rtype: bool ''' pass
113
67
15
3
7
6
2
0.76
1
6
4
0
66
13
66
66
1,160
251
516
157
400
393
381
126
314
9
1
2
117
142,544
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.PathExistsError
class PathExistsError(AbstractFileSystemEventsManagerError): """ Defines non existing path exception. """ pass
class PathExistsError(AbstractFileSystemEventsManagerError): ''' Defines non existing path exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,545
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.PatchRegistrationError
class PatchRegistrationError(AbstractPatchesManagerError): """ Defines patch registration exception. """ pass
class PatchRegistrationError(AbstractPatchesManagerError): ''' Defines patch registration exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,546
KelSolaar/Umbra
KelSolaar_Umbra/umbra/exceptions.py
umbra.exceptions.PatchInterfaceError
class PatchInterfaceError(AbstractPatchesManagerError): """ Defines patch interface exception. """ pass
class PatchInterfaceError(AbstractPatchesManagerError): ''' Defines patch interface exception. ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
0
6
1
2
1
1
3
2
1
1
0
2
0
0
142,547
KelSolaar/Umbra
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/KelSolaar_Umbra/umbra/components/addons/trace_ui/trace_ui.py
umbra.components.addons.trace_ui.trace_ui.TraceUi
class TraceUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): """ Defines the :mod:`umbra.components.addons.trace_ui.trace_ui` Component Interface class. """ # Custom signals definitions. refresh_nodes = pyqtSignal() """ This signal is emited by the :class:`TraceUi` class when :obj:`TraceUi.model` class property model nodes needs to be refreshed. """ def __init__(self, parent=None, name=None, *args, **kwargs): """ 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: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format( self.__class__.__name__)) super(TraceUi, self).__init__(parent, name, *args, **kwargs) # --- Setting class attributes. --- self.deactivatable = True self.__dock_area = 1 self.__engine = None self.__settings = None self.__settings_section = None self.__model = None self.__view = None self.__headers = OrderedDict([("Module", "name"), ("Traced", "traced")]) @property def dock_area(self): """ Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int """ return self.__dock_area @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self, value): """ Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "dock_area")) @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): """ Deleter for **self.__dock_area** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "dock_area")) @property def engine(self): """ Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject """ return self.__engine @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self, value): """ Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "engine")) @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): """ Deleter for **self.__engine** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "engine")) @property def settings(self): """ Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings """ return self.__settings @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self, value): """ Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings")) @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): """ Deleter for **self.__settings** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings")) @property def settings_section(self): """ Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode """ return self.__settings_section @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self, value): """ Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "settings_section")) @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): """ Deleter for **self.__settings_section** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "settings_section")) @property def model(self): """ Property for **self.__model** attribute. :return: self.__model. :rtype: CollectionsModel """ return self.__model @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self, value): """ Setter for **self.__model** attribute. :param value: Attribute value. :type value: CollectionsModel """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "model")) @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): """ Deleter for **self.__model** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "model")) @property def view(self): """ Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget """ return self.__view @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self, value): """ Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "view")) @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): """ Deleter for **self.__view** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "view")) @property def headers(self): """ Property for **self.__headers** attribute. :return: self.__headers. :rtype: OrderedDict """ return self.__headers @headers.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self, value): """ Setter for **self.__headers** attribute. :param value: Attribute value. :type value: OrderedDict """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is read only!".format(self.__class__.__name__, "headers")) @headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self): """ Deleter for **self.__headers** attribute. """ raise foundations.exceptions.ProgrammingError( "{0} | '{1}' attribute is not deletable!".format(self.__class__.__name__, "view")) def activate(self, engine): """ Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool """ LOGGER.debug("> Activating '{0}' Component.".format( self.__class__.__name__)) self.__engine = engine self.__settings = self.__engine.settings self.__settings_section = self.name self.activated = True return True def deactivate(self): """ Deactivates the Component. :return: Method success. :rtype: bool """ LOGGER.debug("> Deactivating '{0}' Component.".format( self.__class__.__name__)) self.__engine = None self.__settings = None self.__settings_section = None self.activated = False return True def initialize_ui(self): """ Initializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing '{0}' Component ui.".format( self.__class__.__name__)) self.Trace_Modules_Filter_lineEdit = Search_QLineEdit(self) self.Trace_Modules_Filter_lineEdit.search_active_label.hide() self.Trace_Modules_Filter_lineEdit.setPlaceholderText( "Objects Trace Filter ...") self.Trace_Modules_Filter_horizontalLayout.addWidget( self.Trace_Modules_Filter_lineEdit) self.__model = ModulesModel(self, horizontal_headers=self.__headers) self.Modules_treeView.setParent(None) self.Modules_treeView = Modules_QTreeView(self, self.__model) self.Modules_treeView.setObjectName("Modules_treeView") self.Modules_treeView.setContextMenuPolicy(Qt.ActionsContextMenu) self.Trace_Ui_dockWidgetContents_gridLayout.addWidget( self.Modules_treeView, 0, 0) self.__view = self.Modules_treeView self.__view_add_actions() self.set_modules() # Signals / Slots. self.refresh_nodes.connect(self.__model__refresh_nodes) self.initialized_ui = True return True def uninitialize_ui(self): """ Uninitializes the Component ui. :return: Method success. :rtype: bool """ LOGGER.debug("> Uninitializing '{0}' Component ui.".format( self.__class__.__name__)) # Signals / Slots. self.refresh_nodes.disconnect(self.__model__refresh_nodes) self.__view_remove_actions() self.__model = None self.__view = None self.initialized_ui = False return True def add_widget(self): """ Adds the Component Widget to the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Adding '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.addDockWidget(Qt.DockWidgetArea(self.__dock_area), self) return True def remove_widget(self): """ Removes the Component Widget from the engine. :return: Method success. :rtype: bool """ LOGGER.debug("> Removing '{0}' Component Widget.".format( self.__class__.__name__)) self.__engine.removeDockWidget(self) self.setParent(None) return True def __model__refresh_nodes(self): """ Defines the slot triggered by the Model when Nodes need refresh. """ self.set_modules() def __model__refresh_attributes(self): """ Refreshes the Model Nodes attributes. """ for node in foundations.walkers.nodes_walker(self.__model.root_node): if foundations.trace.is_traced(node.module) == node.traced.value: continue node.update_node_attributes() def __view_add_actions(self): """ Sets the View actions. """ self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.trace_ui|Trace Module(s)", slot=self.__view_trace_modules_action__triggered)) self.__view.addAction(self.__engine.actions_manager.register_action( "Actions|Umbra|Components|addons.trace_ui|Untrace Module(s)", slot=self.__view_untrace_modules_action__triggered)) def __view_remove_actions(self): """ Removes the View actions. """ trace_modules_action = "Actions|Umbra|Components|addons.trace_ui|Trace Module(s)" untrace_modules_action = "Actions|Umbra|Components|addons.trace_ui|Untrace Module(s)" for action in (trace_modules_action, untrace_modules_action): self.__view.removeAction( self.__engine.actions_manager.get_action(action)) self.__engine.actions_manager.unregister_action(action) def __view_trace_modules_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.trace_ui|Trace Module(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ pattern = foundations.strings.to_string( self.Trace_Modules_Filter_lineEdit.text()) or r".*" flags = re.IGNORECASE if self.Case_Sensitive_Matching_pushButton.isChecked() else 0 return self.trace_modules(self.get_selected_modules(), pattern, flags) def __view_untrace_modules_action__triggered(self, checked): """ Defines the slot triggered by **'Actions|Umbra|Components|addons.trace_ui|Untrace Module(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool """ return self.untrace_modules(self.get_selected_modules()) def get_selected_nodes(self): """ Returns the View selected nodes. :return: View selected nodes. :rtype: dict """ return self.__view.get_selected_nodes() def get_selected_modules(self): """ Returns the View selected modules. :return: View selected modules. :rtype: list """ return [node.module for node in self.get_selected_nodes()] @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.UserError) def trace_modules(self, modules, pattern=r".*", flags=re.IGNORECASE): """ Traces given modules using given filter pattern. :param modules: Modules to trace. :type modules: list :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :return: Method success. :rtype: bool """ try: pattern = re.compile(pattern, flags) except Exception: raise foundations.exceptions.UserError( "{0} | Invalid objects trace filter pattern: Regex compilation failed!".format(self.__class__.__name__)) for module in modules: foundations.trace.trace_module( module, foundations.verbose.tracer, pattern) self.__model__refresh_attributes() return True def untrace_modules(self, modules): """ Untraces given modules. :param modules: Modules to untrace. :type modules: list :return: Method success. :rtype: bool """ for module in modules: foundations.trace.untrace_module(module) self.__model__refresh_attributes() return True def get_modules(self): """ Sets the registered Modules. :return: Registered modules. :rtype: list """ return foundations.trace.REGISTERED_MODULES def set_modules(self, modules=None): """ Sets the modules Model nodes. :param modules: Modules to set. :type modules: list :return: Method success. :rtype: bool """ node_flags = int(Qt.ItemIsSelectable | Qt.ItemIsEnabled) modules = modules or self.get_modules() root_node = umbra.ui.nodes.DefaultNode(name="InvisibleRootNode") for module in modules: module_node = ModuleNode(module=module, name=foundations.strings.to_string( module.__name__), parent=root_node, node_flags=node_flags, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)) root_node.sort_children() self.__model.initialize_model(root_node) return True
class TraceUi(QWidgetComponentFactory(ui_file=COMPONENT_UI_FILE)): ''' Defines the :mod:`umbra.components.addons.trace_ui.trace_ui` Component Interface class. ''' def __init__(self, parent=None, name=None, *args, **kwargs): ''' 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: \*\* ''' pass @property def dock_area(self): ''' Property for **self.__dock_area** attribute. :return: self.__dock_area. :rtype: int ''' pass @dock_area.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Setter for **self.__dock_area** attribute. :param value: Attribute value. :type value: int ''' pass @dock_area.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def dock_area(self): ''' Deleter for **self.__dock_area** attribute. ''' pass @property def engine(self): ''' Property for **self.__engine** attribute. :return: self.__engine. :rtype: QObject ''' pass @engine.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Setter for **self.__engine** attribute. :param value: Attribute value. :type value: QObject ''' pass @engine.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def engine(self): ''' Deleter for **self.__engine** attribute. ''' pass @property def settings(self): ''' Property for **self.__settings** attribute. :return: self.__settings. :rtype: QSettings ''' pass @settings.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Setter for **self.__settings** attribute. :param value: Attribute value. :type value: QSettings ''' pass @settings.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings(self): ''' Deleter for **self.__settings** attribute. ''' pass @property def settings_section(self): ''' Property for **self.__settings_section** attribute. :return: self.__settings_section. :rtype: unicode ''' pass @settings_section.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Setter for **self.__settings_section** attribute. :param value: Attribute value. :type value: unicode ''' pass @settings_section.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def settings_section(self): ''' Deleter for **self.__settings_section** attribute. ''' pass @property def model(self): ''' Property for **self.__model** attribute. :return: self.__model. :rtype: CollectionsModel ''' pass @model.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Setter for **self.__model** attribute. :param value: Attribute value. :type value: CollectionsModel ''' pass @model.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def model(self): ''' Deleter for **self.__model** attribute. ''' pass @property def view(self): ''' Property for **self.__view** attribute. :return: self.__view. :rtype: QWidget ''' pass @view.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Setter for **self.__view** attribute. :param value: Attribute value. :type value: QWidget ''' pass @view.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def view(self): ''' Deleter for **self.__view** attribute. ''' pass @property def headers(self): ''' Property for **self.__headers** attribute. :return: self.__headers. :rtype: OrderedDict ''' pass @headers.setter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self): ''' Setter for **self.__headers** attribute. :param value: Attribute value. :type value: OrderedDict ''' pass @headers.deleter @foundations.exceptions.handle_exceptions(foundations.exceptions.ProgrammingError) def headers(self): ''' Deleter for **self.__headers** attribute. ''' pass def activate(self, engine): ''' Activates the Component. :param engine: Engine to attach the Component to. :type engine: QObject :return: Method success. :rtype: bool ''' pass def deactivate(self): ''' Deactivates the Component. :return: Method success. :rtype: bool ''' pass def initialize_ui(self): ''' Initializes the Component ui. :return: Method success. :rtype: bool ''' pass def uninitialize_ui(self): ''' Uninitializes the Component ui. :return: Method success. :rtype: bool ''' pass def add_widget(self): ''' Adds the Component Widget to the engine. :return: Method success. :rtype: bool ''' pass def remove_widget(self): ''' Removes the Component Widget from the engine. :return: Method success. :rtype: bool ''' pass def __model__refresh_nodes(self): ''' Defines the slot triggered by the Model when Nodes need refresh. ''' pass def __model__refresh_attributes(self): ''' Refreshes the Model Nodes attributes. ''' pass def __view_add_actions(self): ''' Sets the View actions. ''' pass def __view_remove_actions(self): ''' Removes the View actions. ''' pass def __view_trace_modules_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.trace_ui|Trace Module(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def __view_untrace_modules_action__triggered(self, checked): ''' Defines the slot triggered by **'Actions|Umbra|Components|addons.trace_ui|Untrace Module(s)'** action. :param checked: Action checked state. :type checked: bool :return: Method success. :rtype: bool ''' pass def get_selected_nodes(self): ''' Returns the View selected nodes. :return: View selected nodes. :rtype: dict ''' pass def get_selected_modules(self): ''' Returns the View selected modules. :return: View selected modules. :rtype: list ''' pass @foundations.exceptions.handle_exceptions(umbra.exceptions.notify_exception_handler, foundations.exceptions.UserError) def trace_modules(self, modules, pattern=r".*", flags=re.IGNORECASE): ''' Traces given modules using given filter pattern. :param modules: Modules to trace. :type modules: list :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :return: Method success. :rtype: bool ''' pass def untrace_modules(self, modules): ''' Untraces given modules. :param modules: Modules to untrace. :type modules: list :return: Method success. :rtype: bool ''' pass def get_modules(self): ''' Sets the registered Modules. :return: Registered modules. :rtype: list ''' pass def set_modules(self, modules=None): ''' Sets the modules Model nodes. :param modules: Modules to set. :type modules: list :return: Method success. :rtype: bool ''' pass
77
41
12
2
4
5
1
0.98
1
8
5
0
40
12
40
40
565
138
216
89
138
211
155
66
114
3
1
2
48