def testGetModule(self): """ This method tests :func:`foundations.core.getModule` definition. """ self.assertEqual(type(core.getModule(object)), types.ModuleType) self.assertEqual(core.getModule(object), inspect.getmodule(object))
def activate( self, container ): ''' This Method Activates The Component. @param container: Container To Attach The Component To. ( QObject ) ''' LOGGER.debug( "> Activating '{0}' Component.".format( self.__class__.__name__ ) ) self.uiFile = os.path.join( os.path.dirname( core.getModule( self ).__file__ ), self._uiPath ) self._uiResources = os.path.join( os.path.dirname( core.getModule( self ).__file__ ), self._uiResources ) self._container = container self._miscMenu = self._container.miscMenu self.addActions_() self._activate()
def activate( self, container ): ''' This Method Activates The Component. @param container: Container To Attach The Component To. ( QObject ) ''' LOGGER.debug( "> Activating '{0}' Component.".format( self.__class__.__name__ ) ) self.uiFile = os.path.join( os.path.dirname( core.getModule( self ).__file__ ), self._uiPath ) self._uiResources = os.path.join( os.path.dirname( core.getModule( self ).__file__ ), self._uiResources ) self._container = container self._signalsSlotsCenter = QObject() self._coreDatabaseBrowser = self._container.componentsManager.components["core.databaseBrowser"].interface self._activate()
def activate( self, container ): ''' This Method Activates The Component. @param container: Container To Attach The Component To. ( QObject ) ''' LOGGER.debug( "> Activating '{0}' Component.".format( self.__class__.__name__ ) ) self.uiFile = os.path.join( os.path.dirname( core.getModule( self ).__file__ ), self._uiPath ) self._container = container self._signalsSlotsCenter = QObject() self._settings = self._container.settings self._activate()
def activate( self, container ): ''' This Method Activates The Component. @param container: Container To Attach The Component To. ( QObject ) ''' LOGGER.debug( "> Activating '{0}' Component.".format( self.__class__.__name__ ) ) self.uiFile = os.path.join( os.path.dirname( core.getModule( self ).__file__ ), self._uiPath ) self._container = container self._signalsSlotsCenter = QObject() self._coreTemplatesOutliner = self._container.componentsManager.components["core.templatesOutliner"].interface self._addonsLoaderScript = self._container.componentsManager.components["addons.loaderScript"].interface self._activate()
def updateTemplateContent( session, template ): ''' This Definition Update A Template Content. @param session: Database Session. ( Session ) @param template: Template To Template Content. ( DbTemplate ) @return: Database Commit Success. ( Boolean ) ''' LOGGER.debug( "> Updating '{0}' Template Content.".format( template ) ) template.osStats = ",".join( [str( stat ) for stat in os.stat( template.path )] ) if template.setContent() : return commit( session ) else : LOGGER.warning( "!> {0} | '{1}' Template Content Update Failed !".format( core.getModule( updateTemplateContent ).__name__, template.name ) ) return False
def updateSetContent( session, set ): ''' This Definition Update A Set Content. @param session: Database Session. ( Session ) @param set: Set To Set Content. ( DbSet ) @return: Database Commit Success. ( Boolean ) ''' LOGGER.debug( "> Updating '{0}' Set Content.".format( set ) ) set.osStats = ",".join( [str( stat ) for stat in os.stat( set.path )] ) if set.setContent() : return commit( session ) else : LOGGER.warning( "!> {0} | '{1}' Set Content Update Failed !".format( core.getModule( updateSetContent ).__name__, set.name ) ) return False
def updateSetLocation( session, set, path ): ''' This Definition Updates A Set Location. @param session: Database Session. ( Session ) @param set: Set To Update. ( DbSet ) @param path: Set Path. ( Path ) @return: Database Commit Success. ( Boolean ) ''' LOGGER.debug( "> Updating '{0}' Set Location.".format( set ) ) if not filterSets( session, "^{0}$".format( re.escape( path ) ), "path" ) : set.path = path return updateSetContent( session, set ) else: LOGGER.warning( "!> {0} | '{1}' Set Path Already Exists In Database !".format( core.getModule( updateSetLocation ).__name__, path ) ) return False
def addCollection( session, collection, type, comment ): ''' This Definition Adds A Collection To The Database. @param session: Database Session. ( Session ) @param collection: Collection Name. ( String ) @param type: Collection Type. ( String ) @param comment: Collection Comment. ( String ) @return: Database Commit Success. ( Boolean ) ''' LOGGER.debug( "> Adding : '{0}' Collection Of Type '{1}' To Database.".format( collection, type ) ) if not filterCollections( session, "^{0}$".format( collection ), "name" ) : dbItem = dbUtilities.types.DbCollection( name = collection, type = type, comment = comment ) return addItem( session, dbItem ) else: LOGGER.warning( "!> {0} | '{1}' Collection Already Exists In Database !".format( core.getModule( addCollection ).__name__, collection ) ) return False
def activate( self, container ): ''' This Method Activates The Component. @param container: Container To Attach The Component To. ( QObject ) ''' LOGGER.debug( "> Activating '{0}' Component.".format( self.__class__.__name__ ) ) self.uiFile = os.path.join( os.path.dirname( core.getModule( self ).__file__ ), self._uiPath ) self._container = container self._signalsSlotsCenter = QObject() self._coreDatabaseBrowser = self._container.componentsManager.components["core.databaseBrowser"].interface self._coreTemplatesOutliner = self._container.componentsManager.components["core.templatesOutliner"].interface self._ioDirectory = os.path.join( self._container.userApplicationDatasDirectory, Constants.ioDirectory, self._ioDirectory ) not os.path.exists( self._ioDirectory ) and os.makedirs( self._ioDirectory ) self._activate()
def addSet( session, name, path, collection ): ''' This Definition Adds A New Set To The Database. @param session: Database Session. ( Session ) @param name: Set Name. ( String ) @param path: Set Path. ( String ) @param collection: Collection Id. ( String ) @return: Database Commit Success. ( Boolean ) ''' LOGGER.debug( "> Adding : '{0}' Set To Database.".format( name ) ) if not filterSets( session, "^{0}$".format( re.escape( path ) ), "path" ) : osStats = ",".join( [str( stat ) for stat in os.stat( path )] ) dbItem = dbUtilities.types.DbSet( name = name, path = path, collection = collection, osStats = osStats ) if dbItem.setContent() : return addItem( session, dbItem ) else: LOGGER.warning( "!> {0} | '{1}' Set Path Already Exists In Database !".format( core.getModule( addSet ).__name__, path ) ) return False
def componentDeactivationErrorHandler( exception, origin, *args, **kwargs ): ''' This Definition Provides An Exception Handler For Component Deactivation. @param exception: Exception. ( Exception ) @param origin: Function / Method Raising The Exception. ( String ) ''' ui.common.uiBasicExceptionHandler( Exception( "{0} | An Exception Occurred While Deactivating '{1}' Component :\n{2}".format( core.getModule( componentActivationErrorHandler ).__name__, args[1].name, traceback.format_exc() ) ), origin, *args, **kwargs )
def updateTemplateLocation( session, template, path ): ''' This Definition Updates A Template Location. @param session: Database Session. ( Session ) @param template: Template To Update. ( DbTemplate ) @param path: Template Path. ( Path ) @return: Database Commit Success. ( Boolean ) ''' LOGGER.debug( "> Updating '{0}' Template Location.".format( template ) ) if not filterTemplates( session, "^{0}$".format( re.escape( path ) ), "path" ) : template.path = path return updateTemplateContent( session, template ) else: LOGGER.warning( "!> {0} | '{1}' Template Path Already Exists In Database !".format( core.getModule( updateTemplateLocation ).__name__, path ) ) return False