Example #1
0
 def cleanFilename(cls, filename):
     if not filename:
         return StringUtils.getRandomString(12)
     out = StringUtils.slugify(filename)
     if not out:
         return StringUtils.getRandomString(12)
     return out
Example #2
0
    def _handleAddApp(self):
        defaultPath = self.appConfig.get('LAST_APP_PATH', OsUtils.getDocumentsPath())

        path = PyGlassBasicDialogManager.browseForDirectory(
            parent=self,
            caption=StringUtils.dedent("""
                Specify the root path to a PyGlass application, in which a resource folder
                resides"""),
            defaultPath=defaultPath)
        if not path:
            return

        label = PyGlassBasicDialogManager.openTextQuery(
            parent=self,
            header='Enter Application Name',
            message='Specify the name of this application for display within Alembic Migrator',
            defaultText=os.path.basename(path.rstrip(os.sep)) )

        apps = self.appConfig.get('APPLICATIONS', dict())
        appData = {
            'label':label,
            'path':path,
            'databases':dict(),
            'id':TimeUtils.getUidTimecode('App', StringUtils.slugify(label))}
        apps[appData['id']] = appData
        self.appConfig.set('APPLICATIONS', apps)

        self.refresh()
        resultItem = self.appsListWidget.findItems(appData['id'], QtCore.Qt.MatchExactly)
        if resultItem:
            resultItem[0].setSelected(True)
Example #3
0
 def cleanFilename(cls, filename):
     if not filename:
         return StringUtils.getRandomString(12)
     out = StringUtils.slugify(filename)
     if not out:
         return StringUtils.getRandomString(12)
     return out
Example #4
0
    def _handleAddDatabase(self):
        result = PyGlassBasicDialogManager.openTextQuery(
            parent=self,
            header='Enter Database Name',
            message='Enter the name of the database as it would appear in the Database URL, e.g. '
                    +'"activity" or "employees/artists"')
        if not result:
            return

        data = {
            'id':TimeUtils.getUidTimecode('DATABASE', StringUtils.slugify(result)),
            'label':StringUtils.toText(result).title(),
            'name':result }

        apps = self.appConfig.get('APPLICATIONS')
        app  = apps[self.currentAppID]
        app['databases'][data['id']] = data
        self.appConfig.set('APPLICATIONS', apps)

        self._refreshAppDisplay()
        resultItem = self.databasesListWidget.findItems(result, QtCore.Qt.MatchExactly)
        if resultItem:
            resultItem[0].setSelected(True)