当前位置: 首页>>代码示例>>Python>>正文


Python StringUtils.dedent方法代码示例

本文整理汇总了Python中pyaid.string.StringUtils.StringUtils.dedent方法的典型用法代码示例。如果您正苦于以下问题:Python StringUtils.dedent方法的具体用法?Python StringUtils.dedent怎么用?Python StringUtils.dedent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyaid.string.StringUtils.StringUtils的用法示例。


在下文中一共展示了StringUtils.dedent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _handleAddApp

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import dedent [as 别名]
    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)
开发者ID:sernst,项目名称:PyGlassAlembic,代码行数:33,代码来源:AlembicMainWidget.py

示例2: createWidget

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import dedent [as 别名]
    def createWidget(self, class_name, parent=None, name=''):
        # Case where target should be used as widget.
        if parent is None and self._target:
            return self._target

        # Otherwise create a new widget
        else:
            # create a new widget for child widgets
            widget = QtUiTools.QUiLoader.createWidget(self, class_name, parent, name)

            # Adds attribute for the new child widget on the target to mimic PyQt4.uic.loadUi.
            if self._target:
                try:
                    setattr(self._target, name, widget)
                except AttributeError:
                    print(StringUtils.dedent("""
                        [ERROR]: Load UI file attempt encountered existing attribute "%s" with
                        the same name as an element in the source file. """ % name))
                    raise

            return widget
开发者ID:sernst,项目名称:PyGlass,代码行数:23,代码来源:UiFileLoader.py

示例3: setActiveWidget

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import dedent [as 别名]
    def setActiveWidget(self, widgetID, containerWidget =None, force =False, args =None, doneArgs =None):
        if widgetID and not widgetID in self._widgetClasses:
            print(StringUtils.dedent("""
                [WARNING]: Invalid widget ID "%s" in %s. No such widget assigned
                """ % (widgetID, self)))
            return False

        if containerWidget is None:
            containerWidget = self._containerWidget
        if containerWidget is None:
            print('[WARNING]: %s has no specified container widget' % self)
            return False

        if not force and self._currentWidget and self._currentWidget.widgetID == widgetID:
            return True

        if widgetID:
            widget = self.getChildWidget(widgetID, allowCreation=True)
        else:
            widget = None

        containerLayout = containerWidget.layout()
        if not containerLayout:
            containerLayout = self._getLayout(containerWidget, QtGui.QVBoxLayout)

        self.clearActiveWidget(containerWidget=containerWidget, doneArgs=doneArgs)
        self._currentWidget = widget

        if widget:
            containerLayout.addWidget(widget)
            containerWidget.setContentsMargins(0, 0, 0, 0)

        self.refreshGui()
        if args is None:
            args = dict()

        if widget and self._isWidgetActive:
            widget.activateWidgetDisplay(lastPeerWidgetID=self._lastChildWidgetID, **args)

        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:42,代码来源:PyGlassWidget.py

示例4: modelsInit

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import dedent [as 别名]
    def modelsInit(cls, databaseUrl, initPath, initName):
        out = dict()
        zipIndex = initPath[0].find(cls._ZIP_FIND)
        if zipIndex == -1:
            moduleList = os.listdir(initPath[0])
        else:
            splitIndex = zipIndex + len(cls._ZIP_FIND)
            zipPath = initPath[0][: splitIndex - 1]
            modulePath = initPath[0][splitIndex:]
            z = zipfile.ZipFile(zipPath)
            moduleList = []
            for item in z.namelist():
                item = os.sep.join(item.split("/"))
                if item.startswith(modulePath):
                    moduleList.append(item.rsplit(os.sep, 1)[-1])

        # Warn if module initialization occurs before pyglass environment initialization and
        # then attempt to initialize the environment automatically to prevent errors
        if not PyGlassEnvironment.isInitialized:
            cls.logger.write(
                StringUtils.dedent(
                    """
                [WARNING]: Database initialization called before PyGlassEnvironment initialization.
                Attempting automatic initialization to prevent errors."""
                )
            )
            PyGlassEnvironment.initializeFromInternalPath(initPath[0])

        if not cls.upgradeDatabase(databaseUrl):
            cls.logger.write(
                StringUtils.dedent(
                    """
                [WARNING]: No alembic support detected. Migration support disabled."""
                )
            )

        items = []
        for module in moduleList:
            if module.startswith("__init__.py") or module.find("_") == -1:
                continue

            parts = module.rsplit(".", 1)
            parts[0] = parts[0].rsplit(os.sep, 1)[-1]
            if not parts[-1].startswith(StringUtils.toStr2("py")) or parts[0] in items:
                continue
            items.append(parts[0])

            m = None
            n = None
            r = None
            c = None
            try:
                n = module.rsplit(".", 1)[0]
                m = initName + "." + n
                r = __import__(m, locals(), globals(), [n])
                c = getattr(r, StringUtils.toText(n))
                out[n] = c
                if not c.__table__.exists(c.ENGINE):
                    c.__table__.create(c.ENGINE, True)
            except Exception as err:
                cls._logger.writeError(
                    [
                        "MODEL INITIALIZATION FAILURE:",
                        "INIT PATH: %s" % initPath,
                        "INIT NAME: %s" % initName,
                        "MODULE IMPORT: %s" % m,
                        "IMPORT CLASS: %s" % n,
                        "IMPORT RESULT: %s" % r,
                        "CLASS RESULT: %s" % c,
                    ],
                    err,
                )

        return out
开发者ID:sernst,项目名称:PyGlass,代码行数:76,代码来源:PyGlassModelUtils.py


注:本文中的pyaid.string.StringUtils.StringUtils.dedent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。