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


Python StringUtils.getRandomString方法代码示例

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


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

示例1: cleanFilename

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
 def cleanFilename(cls, filename):
     if not filename:
         return StringUtils.getRandomString(12)
     out = StringUtils.slugify(filename)
     if not out:
         return StringUtils.getRandomString(12)
     return out
开发者ID:sernst,项目名称:PyAid,代码行数:9,代码来源:FileUtils.py

示例2: _makePlot

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
    def _makePlot(self, label, data, color ='b', isLog =False, histRange =None):
        """_makePlot doc..."""

        pl = self.plot
        self.owner.createFigure('makePlot')

        pl.hist(
            data, 31,
            range=histRange,
            log=isLog,
            facecolor=color,
            alpha=0.75)
        pl.title('%s Distribution%s' % (label, ' (log)' if isLog else ''))
        pl.xlabel('Fractional Deviation')
        pl.ylabel('Frequency')
        pl.grid(True)

        axis = pl.gca()
        xlims = axis.get_xlim()
        pl.xlim((max(histRange[0], xlims[0]), min(histRange[1], xlims[1])))

        path = self.getTempPath(
            '%s.pdf' % StringUtils.getRandomString(16), isFile=True)
        self.owner.saveFigure('makePlot', path)
        return path
开发者ID:sernst,项目名称:Cadence,代码行数:27,代码来源:StrideLengthStage.py

示例3: __init__

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
 def __init__(self):
     """Creates a new instance of UniqueObject."""
     self._INSTANCE_INDEX += 1
     self._instanceUid = TimeUtils.getUidTimecode(
         prefix=self.__class__.__name__,
         suffix=StringUtils.toUnicode(
             self._INSTANCE_INDEX) + '-' + StringUtils.getRandomString(8) )
开发者ID:sernst,项目名称:PyAid,代码行数:9,代码来源:UniqueObject.py

示例4: __init__

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
 def __init__(self, parent=None, **kwargs):
     """Creates a new instance of VisibilityElement."""
     super(VisibilityElement, self).__init__(parent=parent)
     self._instanceUid = TimeUtils.getUidTimecode(
         prefix=self.__class__.__name__, suffix=StringUtils.getRandomString(8)
     )
     self._visibility = VisibilityManager(target=self)
开发者ID:sernst,项目名称:PyGlass,代码行数:9,代码来源:VisibilityElement.py

示例5: saveFigure

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
    def saveFigure(self, key, path =None, close =True, **kwargs):
        """ Saves the specified figure to a file at teh specified path.

            key :: String
                The key for the figure to be saved. If no such key exists, the method will return
                false.

            path :: String :: None
                The absolute file location to where the figure should be saved. If no path is
                specified the file will be saved as a pdf in this Analyzer's temporary folder.

            close :: Boolean :: True
                If true, the figure will be closed upon successful completion of the save process.

            [kwargs]
                Data to be passed directly to the PyPlot Figure.savefig() method, which can be
                used to further customize how the figure is saved. """

        if not plt or key not in self._plotFigures:
            return False

        if not path:
            path = self.getTempPath('%s-%s.pdf' % (
                key, TimeUtils.getUidTimecode(suffix=StringUtils.getRandomString(16))), isFile=True)

        figure = self._plotFigures[key]

        if 'orientation' not in kwargs:
            kwargs['orientation'] = 'landscape'

        figure.savefig(path, **kwargs)
        if close:
            self.closeFigure(key)
        return path
开发者ID:sernst,项目名称:Cadence,代码行数:36,代码来源:AnalyzerBase.py

示例6: getTempFilePath

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
    def getTempFilePath(self, name =None, extension =None, *args):
        """ Used to create a temporary file path within this instance's temporary folder.
            Any file on this path will be automatically removed at the end of the analysis
            process.

            [name] :: String :: None
                The desired file name for the desired file within the temporary directory. If no
                name is specified, a name will be created automatically using the current time
                (microsecond) and a 16 digit random code for a very low probability of collisions.

            [extension] :: String :: None
                Specifies the extension to add to this file. The file name is not altered if no
                extension is specified.

            [*args] :: [String] :: []
                A list of relative folder prefixes in which the file should reside. For example,
                if you wish to have a file 'bar' in a folder 'foo' then you would specify 'foo' as
                the single arg to get a file located at 'foo/bar' within the temporary file. No
                directory prefixes will be created within this method. """

        if not name:
            name = TimeUtils.getUidTimecode(suffix=StringUtils.getRandomString(16))
        if extension:
            extension = '.' + extension.strip('.')
            if not name.endswith(extension):
                name += extension

        args = list(args) + [name]
        return FileUtils.makeFilePath(self.tempPath, *args)
开发者ID:sernst,项目名称:Cadence,代码行数:31,代码来源:AnalyzerBase.py

示例7: _addCRSFToken

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
 def _addCRSFToken(self, tokenName =None):
     name  = tokenName if tokenName else ZigguratDisplayView.DEFAULT_CSRF_TOKEN_NAME
     value = StringUtils.getRandomString(16)
     self._request.response.set_cookie(name, value, overwrite=True)
     self._request.response.set_cookie(
         name + '-secure',
         value,
         secure=True,
         httponly=True,
         overwrite=True)
开发者ID:sernst,项目名称:Ziggurat,代码行数:12,代码来源:ZigguratDisplayView.py

示例8: createUniqueId

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
 def createUniqueId(cls, prefix = u''):
     """ Creates a universally unique identifier string based on current
         time, active application instance state, and a randomized hash
     """
     cls._UID_INDEX += 1
     return '%s%s-%s-%s' % (
         prefix,
         TimeUtils.getNowTimecode(cls.BASE_UNIX_TIME),
         Base64.to64(cls._UID_INDEX),
         StringUtils.getRandomString(12))
开发者ID:sernst,项目名称:Cadence,代码行数:12,代码来源:CadenceEnvironment.py

示例9: __init__

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
    def __init__(self, source, **kwargs):

        self.footerDom  = u''
        self.page       = ArgsUtils.get('page', None, kwargs)
        self.site       = ArgsUtils.get('site', None, kwargs)

        self.filePath = ArgsUtils.get('path', None, kwargs)
        self.filename = ArgsUtils.get(
            'filename',
            os.path.basename(self.filePath) if self.filePath else None,
            kwargs)

        debugData = ArgsUtils.extract('debugData', None, kwargs)
        blocks    = {
            'root':[
                MarkupTextBlockUtils.createMarkupCommentDef(BlockDefinition.BLOCKED),
                MarkupTextBlockUtils.createMarkupOpenDef('quote'),
                MarkupTextBlockUtils.createMarkupCloseDef(BlockDefinition.BLOCKED) ],
            'quote':[
                BlockDefinition.createQuoteDef(BlockDefinition.BLOCKED),
                BlockDefinition.createLiteralDef(BlockDefinition.BLOCKED) ]}

        self._renderErrors = []
        self._tagIndex     = -1

        super(MarkupProcessor, self).__init__(
            source,
            ArgsUtils.extract('debug', False, kwargs),
            blocks,
            debugData,
            stripSource=False,
            **kwargs)

        self.logger.trace       = True
        self._result            = None
        self._anchors           = []
        self._tags              = []
        self._id                = StringUtils.getRandomString(8)
        self._css               = []
        self._js                = []
        self._radioArrays       = dict()
        self._patterns          = dict()
        self._groups            = dict()
        self._metadata          = ArgsUtils.getAsDict('metadata', kwargs)
        self._libraryIDs        = []
        self._autoTitle         = u''
        self._autoDescription   = u''
        self._allowModelCaching = False

        self.privateView = False
开发者ID:sernst,项目名称:StaticFlow,代码行数:52,代码来源:MarkupProcessor.py

示例10: _process

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
    def _process(
            self, label, widthKey, lengthKey, trackDeviations,
            absoluteOnly =False
    ):
        """_process doc..."""
        pl  = self.plot
        ws  = []
        ls  = []
        w2D = []
        l2D = []

        for entry in self.entries:
            if widthKey in entry:
                ws.append(entry[widthKey])
                if lengthKey in entry:
                    w2D.append(entry[widthKey])

            if lengthKey in entry:
                ls.append(entry[lengthKey])
                if widthKey in entry:
                    l2D.append(entry[lengthKey])

        plotList = [
            ('widths', ws, 'Width', 'b'),
            ('lengths', ls, 'Length', 'r')]

        wRes = NumericUtils.getMeanAndDeviation(ws)
        self.logger.write('Width %ss' % wRes.label)
        lRes = NumericUtils.getMeanAndDeviation(ls)
        self.logger.write('Length %ss' % lRes.label)

        for data in plotList:
            if not absoluteOnly:
                d = data[1]
                self._paths.append(
                    self._makePlot(
                        label, d, data,
                        histRange=(-1.0, 1.0)))
                self._paths.append(
                    self._makePlot(
                        label, d, data,
                        isLog=True,
                        histRange=(-1.0, 1.0)))

            # noinspection PyUnresolvedReferences
            d = np.absolute(np.array(data[1]))
            self._paths.append(
                self._makePlot(
                    'Absolute ' + label, d, data,
                    histRange=(0.0, 1.0)))
            self._paths.append(
                self._makePlot(
                    'Absolute ' + label, d, data,
                    isLog=True,
                    histRange=(0.0, 1.0)))

        self.owner.createFigure('twoD')
        pl.hist2d(w2D, l2D, bins=20, range=([-1, 1], [-1, 1]))
        pl.title('2D %s Distribution' % label)
        pl.xlabel('Width %s' % label)
        pl.ylabel('Length %s' % label)
        pl.xlim(-1.0, 1.0)
        pl.ylim(-1.0, 1.0)
        path = self.getTempPath(
            '%s.pdf' % StringUtils.getRandomString(16),
            isFile=True)
        self.owner.saveFigure('twoD', path)
        self._paths.append(path)

        csv = CsvWriter()
        csv.path = self.getPath(
            '%s-Deviations.csv' % label.replace(' ', '-'),
            isFile=True)
        csv.addFields(
            ('uid', 'UID'),
            ('fingerprint', 'Fingerprint'),
            ('wSigma', 'Width Deviation'),
            ('lSigma', 'Length Deviation') )

        count = 0
        for entry in self.entries:
            widthDevSigma  = NumericUtils.roundToOrder(
                abs(entry.get(widthKey, 0.0)/wRes.uncertainty), -2)
            lengthDevSigma = NumericUtils.roundToOrder(
                abs(entry.get(lengthKey, 0.0)/lRes.uncertainty), -1)
            if widthDevSigma > 2.0 or lengthDevSigma > 2.0:
                count += 1
                track = entry['track']
                data = dict(
                    wSigma=widthDevSigma,
                    lSigma=lengthDevSigma)

                if trackDeviations is not None:
                    trackDeviations[track.uid] = data

                csv.createRow(
                    uid=track.uid,
                    fingerprint=track.fingerprint,
                    **data)

#.........这里部分代码省略.........
开发者ID:sernst,项目名称:Cadence,代码行数:103,代码来源:LengthWidthStage.py

示例11: __init__

# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import getRandomString [as 别名]
    def __init__(self, **kwargs):
        """Creates a new instance of PyGlassWindow."""
        parent                  = ArgsUtils.extract('parent', None, kwargs)
        self._application       = ArgsUtils.extract('pyGlassApp', None, kwargs)
        self._qApplication      = ArgsUtils.extract('qApp', None, kwargs)
        self._isMainWindow      = ArgsUtils.extract('isMainWindow', bool(parent is None), kwargs)
        self._mainWindow        = ArgsUtils.extract('mainWindow', None, kwargs)
        self._appWrappingWidget = None
        self._centerWidget      = None
        self._hasShown          = False
        self._isHighDpi         = OsUtils.isHighDpiScaledScreen()
        self._settings          = ConfigsDict()

        self._appLevelWidgets              = dict()
        self._appLevelWidgetDisplayHistory = []

        self._keyboardCallback = ArgsUtils.extract('keyboardCallback', None, kwargs)

        if not self._mainWindow:
            if self._isMainWindow:
                self._mainWindow = self
            elif self._application:
                self._mainWindow = self._application.mainWindow

        self._dependentWindows = []
        self._currentWidget    = None

        QtGui.QMainWindow.__init__(self, parent, ArgsUtils.extract('flags', 0, kwargs))

        self._instanceUid = TimeUtils.getUidTimecode(
            prefix=self.__class__.__name__,
            suffix=StringUtils.getRandomString(8))

        self._styleSheet = kwargs.get('styleSheet', None)
        if self._styleSheet:
            self.setStyleSheet(self.styleSheetPath)

        if self._keyboardCallback is not None:
            self.setFocusPolicy(QtCore.Qt.StrongFocus)

        if self._isMainWindow:
            self._log                 = Logger(self, printOut=True)
            self._config              = ApplicationConfig(self)
            self._commonConfig        = ApplicationConfig(self, common=True)
            self._resourceFolderParts = PyGlassGuiUtils.getResourceFolderParts(self)

            icon = PyGlassGuiUtils.createIcon(
                kwargs.get('iconsPath', self.getAppResourcePath('icons', isDir=True)) )
            if icon:
                self.setWindowIcon(icon)

        elif self._mainWindow:
            icon = self._mainWindow.windowIcon()
            if icon:
                self.setWindowIcon(icon)

        self._appWrappingWidget = VisibilityElement(self)
        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self._appWrappingWidget.setLayout(layout)

        self._contentWrappingWidget = self.addApplicationLevelWidget('main')
        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self._contentWrappingWidget.setLayout(layout)

        # Loads the ui file if it exists
        externalCentralParent = None
        hasWindowFile = kwargs.get('mainWindowFile', False)
        if hasWindowFile == self:
            UiFileLoader.loadWidgetFile(self)
            externalCentralParent = getattr(self, 'windowContainer')
            if externalCentralParent:
                externalLayout = externalCentralParent.layout()
                if not externalLayout:
                    externalLayout = QtGui.QVBoxLayout()
                    externalLayout.setContentsMargins(0, 0, 0, 0)
                    externalLayout.setSpacing(0)
                    externalCentralParent.setLayout(externalLayout)

        if externalCentralParent:
            self._appWrappingWidget.setParent(externalCentralParent)
            externalLayout.addWidget(self._appWrappingWidget)
        else:
            self.setCentralWidget(self._appWrappingWidget)

        # Sets a non-standard central widget
        centralWidgetName = kwargs.get('centralWidgetName')
        if centralWidgetName and hasattr(self, centralWidgetName):
            self._centerWidget = getattr(self, centralWidgetName)
        elif hasWindowFile and not hasWindowFile == self:
            if not self._centerWidget:
                self._createCentralWidget()
            UiFileLoader.loadWidgetFile(self, target=self._centerWidget)
        elif not hasWindowFile:
            self._centerWidget = None

        if not self._centerWidget and kwargs.get('defaultCenterWidget', True):
#.........这里部分代码省略.........
开发者ID:sernst,项目名称:PyGlass,代码行数:103,代码来源:PyGlassWindow.py

示例12: range

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

import nimble

conn = nimble.getConnection()

result = conn.ping()
print 'PING:', result.echo(True, True)

result = conn.echo('This is a test')
print 'ECHO:', result.echo(True, True)

for i in range(100):
    largeMessage = StringUtils.getRandomString(64000)
    result = conn.echo(largeMessage)
    print 'LARGE ECHO[#%s]:' % i, result.echo(True, True)

print 'Operation complete'
开发者ID:Gorfaal,项目名称:Nimble,代码行数:20,代码来源:test_ping.py


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