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


Python StringUtils.toText方法代码示例

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


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

示例1: shortFingerprint

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
 def shortFingerprint(self):
     return ''.join([
         'L' if getattr(self, TrackPropEnum.LEFT.name, False) else 'R',
         'P' if getattr(self, TrackPropEnum.PES.name, False) else 'M',
         StringUtils.toText(
             getattr(self, TrackPropEnum.NUMBER.name, '0'))
             .replace('-', 'N') ])
开发者ID:sernst,项目名称:Cadence,代码行数:9,代码来源:TracksTrackDefault.py

示例2: appendStatus

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
    def appendStatus(self, target, message, formatAsHtml =True):
        w = self.getApplicationLevelWidget('status')
        if not w.isShowing or w.target != target:
            return

        message = StringUtils.toText(message).replace('\r', '')
        if formatAsHtml:
            parts = []
            for p in message.strip().split('\n'):
                parts.append(p.replace('\t', '    '))
            message = '<br/>'.join(parts)
        else:
            message = '<div>%s</div>' % message

        w.append(message)
        self.refreshGui()
开发者ID:sernst,项目名称:Cadence,代码行数:18,代码来源:CadenceMainWindow.py

示例3: fingerprint

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
 def fingerprint(self):
     """ String created from the uniquely identifying track properties. """
     TPE = TrackPropEnum
     return '-'.join([
         StringUtils.toText(getattr(self, TPE.SITE.name, '')),
         StringUtils.toText(getattr(self, TPE.LEVEL.name, '')),
         StringUtils.toText(getattr(self, TPE.YEAR.name, '')),
         StringUtils.toText(getattr(self, TPE.SECTOR.name, '')),
         StringUtils.toText(getattr(self, TPE.TRACKWAY_TYPE.name, '')),
         StringUtils.toText(getattr(self, TPE.TRACKWAY_NUMBER.name, '0')),
         'L' if getattr(self, TPE.LEFT.name, False) else 'R',
         'P' if getattr(self, TPE.PES.name, False) else 'M',
         StringUtils.toText(
             getattr(self, TPE.NUMBER.name, '0'))
             .replace('-', 'N') ])
开发者ID:sernst,项目名称:Cadence,代码行数:17,代码来源:TracksTrackDefault.py

示例4: traceLogMessage

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
    def traceLogMessage(cls, logMessage, callbacks =None, callbackTarget =None):

        log = logMessage['log']
        if 'stack' in logMessage:
            log += logMessage['stack']
        out = cls.asAscii(log)
        print(StringUtils.toText(out))

        try:
            for cb in callbacks:
                try:
                    cb(callbackTarget, out)
                except Exception:
                    pass
        except Exception:
            pass

        return out
开发者ID:sernst,项目名称:PyAid,代码行数:20,代码来源:Logger.py

示例5: trackwayFingerprint

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
    def trackwayFingerprint(self):
        TPE = TrackPropEnum
        out = '-'.join([
            StringUtils.toText(getattr(self, TPE.SITE.name, '')),
            StringUtils.toText(getattr(self, TPE.LEVEL.name, '')),
            StringUtils.toText(getattr(self, TPE.YEAR.name, '')),
            StringUtils.toText(getattr(self, TPE.SECTOR.name, '')),
            StringUtils.toText(getattr(self, TPE.TRACKWAY_TYPE.name, '')),
            StringUtils.toText(getattr(self, TPE.TRACKWAY_NUMBER.name, '0')) ])

        if out == 'TCH-1000-2014-12-S-13BIS':
            # Fix a naming ambiguity from the catalog
            out = 'TCH-1000-2006-12-S-13'
        return out
开发者ID:sernst,项目名称:Cadence,代码行数:16,代码来源:TracksTrackDefault.py

示例6: save

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
    def save(self):
        """save doc..."""
        if self.removeIfSavedEmpty and not self.rows:
            self.remove()
            return

        index = 0
        names = self.fieldNames
        if self.autoIndexFieldName:
            names.insert(0, self.autoIndexFieldName)

        fieldNames = []
        for name in names:
            if StringUtils.isTextType(name):
                name = name.encode('latin-1')
            fieldNames.append(name)

        try:
            if sys.version < '3':
                args = dict(mode='w')
            else:
                args = dict(mode='w', encoding='utf-8')
            with open(self.path, **args) as f:
                writer = csv.DictWriter(f, fieldnames=names, dialect=csv.excel)
                writer.writeheader()
                for row in self.rows:
                    result = dict()

                    if self.autoIndexFieldName:
                        index += 1
                        result[self.autoIndexFieldName] = index

                    for key, name in self._fields.items():
                        value = row.get(key, '')
                        if StringUtils.isBinaryType(value):
                            value = StringUtils.toText(value)
                        result[name] = value
                    writer.writerow(result)
            return True
        except Exception as err:
            raise
            return False
开发者ID:sernst,项目名称:PyAid,代码行数:44,代码来源:CsvWriter.py

示例7: _refreshDatabaseDisplay

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
    def _refreshDatabaseDisplay(self):
        w = self.revisionsListWidget
        w.clear()

        if self.databasesListWidget.count() == 0:
            w.setEnabled(False)
            self.createRevisionBtn.setEnabled(False)
            self.initializeBtn.setEnabled(False)
            return
        else:
            w.setEnabled(True)
            self.createRevisionBtn.setEnabled(True)
            self.initializeBtn.setEnabled(True)

        revisions = AlembicUtils.getRevisionList(
            databaseUrl=self.currentDatabaseUrl,
            resourcesPath=self.currentAppResourcesPath)

        for rev in revisions:
            name = StringUtils.toText(rev.revision) + (' (HEAD)' if rev.is_head else '')
            DataListWidgetItem(name, w, data=rev)
开发者ID:sernst,项目名称:PyGlassAlembic,代码行数:23,代码来源:AlembicMainWidget.py

示例8: _handleAddDatabase

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

示例9: removeTrack

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
    sys.exit(1)

tracksModel = Tracks_Track.MASTER
tracksSession = tracksModel.createSession()

analysisModel = Analysis_Track.MASTER
analysisSession = analysisModel.createSession()

data = pd.read_csv(CSV_FILE)

def removeTrack(track):
    analysisTrack = track.getAnalysisPair(analysisSession)
    if analysisTrack:
        analysisSession.delete(analysisTrack)

    tracksSession.delete(track)

for index, row in data.iterrows():
    uid = StringUtils.toText(row.UID)
    tracks = Tracks_Track.removeTracksByUid(uid, tracksSession, analysisSession)
    for track in tracks:
        print('[REMOVED]: %s (%s)' % (track.fingerprint, track.uid))

tracksSession.commit()
analysisSession.commit()

print('Removal Operation Complete')



开发者ID:sernst,项目名称:Cadence,代码行数:29,代码来源:trackRemover.py

示例10: Tracks_Track

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
model = Tracks_Track.MASTER
session = model.createSession()

try:
    for index, row in data.iterrows():
        # For each row in the source spreadsheet file, create a new track if no such track exists

        if row.site == 'FAKE':
            # Skip tracks marked with the site name FAKE as they represent file structure
            # formatting examples and not real tracks
            continue

        t = Tracks_Track()
        t.custom = True

        t.site = StringUtils.toText(row.site)
        t.sector = StringUtils.toText(row.sector)
        t.level = StringUtils.toText(row.level)
        t.trackwayNumber = StringUtils.toText(row.trackwayNumber)
        t.name = StringUtils.toText(row.trackwayName)

        t.trackwayType = 'S'
        t.year = '2014'
        t.index = -1

        existing = t.findExistingTracks(session=session)
        if existing:
            # Do not create a track if the fingerprint for the new track matches one already found
            # in the database
            print('[WARNING]: Track "%s" already exists. Skipping this entry.')
            continue
开发者ID:sernst,项目名称:Cadence,代码行数:33,代码来源:trackCreator.py

示例11: fromSpreadsheetEntry

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]

#.........这里部分代码省略.........
            t.trackwayType   = result.groupdict()['type'].upper().strip()
            t.trackwayNumber = result.groupdict()['number'].upper().strip()
        except Exception:
            self._writeError({
                'message':'Invalid trackway value: %s' % test,
                'data':csvRowData,
                'result':result,
                'match':result.groupdict() if result else 'N/A',
                'index':csvIndex })
            return False

        #-------------------------------------------------------------------------------------------
        # NAME
        #       Parse the name value into left, pes, and number attributes
        try:
            t.name = csvRowData.get(TrackCsvColumnEnum.TRACK_NAME.name).strip()
        except Exception:
            self._writeError({
                'message':'Missing track name',
                'data':csvRowData,
                'index':csvIndex })
            return False

        #-------------------------------------------------------------------------------------------
        # YEAR
        try:
            year = csvRowData.get(TrackCsvColumnEnum.MEASURED_DATE.name)

            if not year:
                year = '2014'
            else:

                try:
                    y = StringUtils.toText(year).split(';')[-1].strip().replace(
                        '/', '_').replace(
                        ' ', '').replace(
                        '-', '_').split('_')[-1]
                    year = int(re.compile('[^0-9]+').sub('', y))
                except Exception:
                    year = 2014

                if year > 2999:
                    # When multiple year entries combine into a single large number
                    year = int(StringUtils.toUnicode(year)[-4:])
                elif year < 2000:
                    # When two digit years (e.g. 09) are used instead of four digit years
                    year += 2000

                year = StringUtils.toUnicode(year)

            t.year = year
        except Exception:
            self._writeError({
                'message':'Missing cast date',
                'data':csvRowData,
                'index':csvIndex })
            return False

        #-------------------------------------------------------------------------------------------
        # FIND EXISTING
        #       Use data set above to attempt to load the track database entry
        fingerprint = t.fingerprint

        for uid, fp in DictUtils.iter(self.remainingTracks):
            # Remove the fingerprint from the list of fingerprints found in the database, which at
            # the end will leave only those fingerprints that exist in the database but were not
开发者ID:sernst,项目名称:Cadence,代码行数:70,代码来源:TrackCsvImporter.py

示例12: __unicode__

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
 def __unicode__(self):
     """__unicode__ doc..."""
     return StringUtils.toText(self.__str__())
开发者ID:sernst,项目名称:PyGlass,代码行数:5,代码来源:PyGlassModelsDefault.py

示例13: list

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
# TRACK QUERY
query = session.query(trackModel)
if INDEXES:
    query = query.filter(trackModel.i.in_(INDEXES))

if UID_BEGINS:
    # OR together the UID_BEGINS using the startswith query modifier for each entry
    query = query.filter(sqla.or_(*[trackModel.uid.startswith(start) for start in UID_BEGINS]))

if UIDS is None:
    UIDS = []

if CSV_FILE:
    # Loads all of the CSV files
    df = pd.read_csv(CSV_FILE)
    UIDS.extend([StringUtils.toText(item) for item in list(df.UID)])

if UIDS:
    query = query.filter(trackModel.uid.in_(UIDS))

tracks = query.all()

if UIDS:
    ordered = []
    missing = []
    for uid_entry in UIDS:
        not_found = True
        for track in tracks:
            if track.uid == uid_entry:
                ordered.append(track)
                not_found = False
开发者ID:sernst,项目名称:Cadence,代码行数:33,代码来源:TrackPrinter.py

示例14: modelsInit

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [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

示例15: prettyPrint

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import toText [as 别名]
 def prettyPrint(self):
     return StringUtils.toText(NumericUtils.roundToSigFigs(self.degrees, 3))
开发者ID:sernst,项目名称:PyAid,代码行数:4,代码来源:Angle.py


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