本文整理汇总了Python中pyaid.string.StringUtils.StringUtils.isStringType方法的典型用法代码示例。如果您正苦于以下问题:Python StringUtils.isStringType方法的具体用法?Python StringUtils.isStringType怎么用?Python StringUtils.isStringType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.string.StringUtils.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isStringType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def set(self, key, value, defaultValue =None):
if not key:
return False
if value is None or value == defaultValue:
self.remove(key)
return True
if not StringUtils.isStringType(key) and len(key) == 1:
key = key[0]
if StringUtils.isStringType(key):
addKey = self._formatKey(key)
source = self._data
else:
addKey = self._formatKey(key[-1])
source = self._data
temp = self._data
for k in key[:-1]:
temp = self._getFrom(temp, k)
if temp == self.null:
temp = dict()
source[self._formatKey(k)] = temp
source = temp
source[addKey] = value
return True
示例2: __init__
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def __init__(self, capType, addExp=None, addReplace="", removeExp=None, removeReplace=""):
"""Creates a new instance of ClassTemplate."""
self._addPattern = re.compile(addExp) if StringUtils.isStringType(addExp) else addExp
self._removePattern = re.compile(removeExp) if StringUtils.isStringType(removeExp) else removeExp
self._addReplace = addReplace
self._removeReplace = removeReplace
self._capType = capType
示例3: addKeysFromLists
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def addKeysFromLists(self, **kwargs):
self._clearCache()
x = ArgsUtils.get('times', None, kwargs)
if not x:
return
y = ArgsUtils.get('values', None, kwargs)
if not y:
return
tans = ArgsUtils.get('tangents', None, kwargs)
inTans = ArgsUtils.get('inTangents', tans, kwargs)
outTans = ArgsUtils.get('outTangents', tans, kwargs)
if not inTans:
inTans = 'lin'
if not outTans:
outTans = 'lin'
for i in range(0,len(x)):
self._keys.append(DataChannelKey(
time=x[i],
value=y[i],
inTangent=inTans if StringUtils.isStringType(inTans) else inTans[i],
outTangent=outTans if StringUtils.isStringType(outTans) else outTans[i] ))
示例4: _executeCommand
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def _executeCommand(cls, payload):
cmd = payload['command']
if cmd is None or (StringUtils.isStringType(cmd) and not cmd in globals()):
return NimbleResponseData(
kind=DataKindEnum.COMMAND,
response=NimbleResponseData.FAILED_RESPONSE,
error=DataErrorEnum.INVALID_COMMAND )
if StringUtils.isStringType(cmd):
targetObject = globals().get(cmd)
else:
if isinstance(cmd, dict):
module = str(cmd['module'])
target = str(cmd['target'])
method = str(cmd['method']) if 'method' in cmd else None
else:
target = str(cmd[0])
module = str(cmd[1]) if len(cmd) > 0 else None
method = str(cmd[2]) if len(cmd) > 1 else None
try:
res = __import__(module, globals(), locals(), [target])
Target = getattr(res, target)
if method:
m = getattr(Target, method)
if m is None:
raise Exception(
'%s not found on %s. Unable to execute command.' % \
(str(method), str(target) ))
except Exception as err:
return NimbleResponseData(
kind=DataKindEnum.COMMAND,
response=NimbleResponseData.FAILED_RESPONSE,
error=cls._getDetailedError(
'Failed to import remote command module', err) )
if method:
targetObject = getattr(Target, method)
if inspect.ismethod(targetObject) and targetObject.__self__ is None:
targetObject = getattr(cls._instantiateClass(Target, cmd), method)
elif inspect.isclass(Target):
targetObject = cls._instantiateClass(Target, cmd)
else:
targetObject = Target
try:
result = targetObject(
*payload['args'],
**DictUtils.cleanDictKeys(payload['kwargs']) )
return cls.createReply(DataKindEnum.COMMAND, result)
except Exception as err:
return NimbleResponseData(
kind=DataKindEnum.COMMAND,
response=NimbleResponseData.FAILED_RESPONSE,
error=cls._getDetailedError('Failed to execute command', err) )
示例5: __init__
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def __init__(self, parent =None, **kwargs):
"""Creates a new instance of PyGlassWidget."""
PyGlassElement.__init__(self, parent, **kwargs)
if kwargs.get('verbose', False):
print('CREATING: %s | PARENTED TO: %s' % (self, parent))
self.setStyleSheet(self.owner.styleSheetPath)
self._displayCount = 0
self._widgetClasses = kwargs.get('widgets', dict())
self._widgetParent = None
self._currentWidget = None
self._widgets = dict()
self._widgetFlags = kwargs.get('widgetFlags')
self._widgetID = kwargs.get('widgetID')
self._lastChildWidgetID = None
self._lastPeerWidgetID = None
widgetFile = kwargs.get('widgetFile', True)
if widgetFile:
parts = self.RESOURCE_WIDGET_FILE
if parts:
if StringUtils.isStringType(parts):
parts = parts.split('/')[-1:]
elif parts:
parts = parts[-1:]
self._widgetData = UiFileLoader.loadWidgetFile(self, names=parts)
else:
self._widgetData = None
name = kwargs.get('containerWidgetName')
self._containerWidget = getattr(self, name) if name and hasattr(self, name) else None
示例6: __init__
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def __init__(self, name=None, **kwargs):
"""Initializes settings."""
self._buffer = []
self._meta = dict()
self._fileCount = kwargs.get('fileCount', 10)
self._zeroTime = kwargs.get('zeroTime', self._ZERO_TIME)
self._reportPath = kwargs.get('path', self._REPORT_PATH)
self._time = datetime.datetime.utcnow()
self._timeCode = Reporter.getTimecodeFromDatetime(self._time, self._zeroTime)
if StringUtils.isStringType(name) and len(name) > 0:
self._name = name
elif hasattr(name, '__class__'):
try:
self._name = name.__class__.__name__
except Exception:
self._name = 'UnknownObject'
elif hasattr(name, '__name__'):
try:
self._name = name.__name__
except Exception:
self._name = 'UnknownClass'
else:
self._name = 'General'
self._meta['_vw'] = self._name
示例7: addFields
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def addFields(self, *args):
""" Tuples containing key, name pairs"""
for arg in args:
if StringUtils.isStringType(arg):
self.addField(arg, arg)
else:
self.addField(arg[0], arg[1])
示例8: openLocalWebUrl
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def openLocalWebUrl(self, url):
"""Doc..."""
if StringUtils.isStringType(url):
url = url.split('/')
url = self.mainWindow.getRootResourcePath('web', *url)
self.load(QtCore.QUrl('file:///' + url))
示例9: __call__
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def __call__(self):
super(ZigguratDataView, self).__call__()
if isinstance(self._response, Response) or StringUtils.isStringType(self._response):
return self._response
DictUtils.cleanBytesToText(self._response, inPlace=True)
return render_to_response('json', self._response, self._request)
示例10: get
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def get(name, defaultValue =None, kwargs =None, args =None, index =None, allowNone =True):
if args and not index is None and (index < 0 or index < len(args)):
out = args[index]
if not allowNone and args[index] is None:
return defaultValue
return out
try:
if StringUtils.isStringType(name):
if name in kwargs:
out = kwargs[name]
if not allowNone and out is None:
return defaultValue
return out
else:
for n in name:
if n in kwargs:
out = kwargs[n]
if not allowNone and out is None:
return defaultValue
return out
except Exception as err:
pass
return defaultValue
示例11: _setEnvValue
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def _setEnvValue(cls, key, value):
settings = cls._getEnvValue(None) if cls._ENV_SETTINGS is None else cls._ENV_SETTINGS
if settings is None:
settings = dict()
cls._ENV_SETTINGS = settings
if StringUtils.isStringType(key):
key = [key]
src = settings
for k in key[:-1]:
src = src[k]
src[key[-1]] = value
envPath = cls.getRootLocalResourcePath(cls._GLOBAL_SETTINGS_FILE, isFile=True)
envDir = os.path.dirname(envPath)
if not os.path.exists(envDir):
os.makedirs(envDir)
f = open(envPath, 'w+')
try:
f.write(JSON.asString(cls._ENV_SETTINGS))
except Exception:
print('ERROR: Unable to write environmental settings file at: ' + envPath)
return False
finally:
f.close()
return True
示例12: load
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def load(self, data):
""" Loads the data into the CadenceData instance, parsing if necessary beforehand.
@@@param load:string,dict
Either a string or dictionary representation of valid Cadence Interchange Data
formatted data to be loaded.
@@@return bool
True if successful, False if the load process failed because of invalid data.
"""
if not data:
return False
if StringUtils.isStringType(data):
try:
data = json.loads(data)
except Exception as err:
print("FAILED: Loading Cadence data from JSON string.", err)
return False
if CadenceData._NAME_KEY in data:
self._name = data.get(CadenceData._NAME_KEY)
if CadenceData._CONFIGS_KEY in data:
self._configs = ConfigReader.fromDict(data.get(CadenceData._CONFIGS_KEY))
if CadenceData._CHANNELS_KEY in data:
for c in data.get(CadenceData._CHANNELS_KEY, dict()):
self._channels.append(DataChannel.fromDict(c))
return True
示例13: _configParserToDict
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def _configParserToDict(self, parser):
out = dict()
for section in parser.sections():
s = dict()
for opt in parser.options(section):
value = str(parser.get(section, opt))
test = value.lower()
if test.startswith('"') and test.endswith('"'):
value = value[1:-1]
elif value.startswith(ConfigReader._VECTOR_PREFIX):
value = Vector3D.fromConfig(value[len(ConfigReader._VECTOR_PREFIX):-1])
elif value.startswith(ConfigReader._JSON_PREFIX):
value = json.loads(value[len(ConfigReader._JSON_PREFIX):])
elif StringUtils.isStringType(value) and (value in ['None', 'none', '']):
value = None
elif test in ['on', 'true', 'yes']:
value = True
elif test in ['off', 'false', 'no']:
value = False
elif ConfigReader._NUMERIC_REGEX.match(test):
try:
value = float(value) if test.find('.') else int(value)
except Exception:
pass
s[opt] = value
out[section] = s
return out
示例14: _handleResponseReady
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def _handleResponseReady(self, request, response):
"""Event handler for the response object being ready for use."""
if self._cacheControlPublic:
response.cache_control = "public"
# -------------------------------------------------------------------------------------------
# Cache Expiration: Set the caching values according to the _expires property
rep = self._explicitResponse
if rep is None or (isinstance(rep, ViewResponse) and rep.allowCaching):
response.cache_control.max_age = self.expires if not self.expires is None else 0
else:
response.cache_control.max_age = 0
# -------------------------------------------------------------------------------------------
# Cache Validators
if self._etag is not None:
response.etag = StringUtils.toUnicode(self._etag)
if self._lastModified is not None:
response.last_modified = self._lastModified
# If required encode the response headers as strings to prevent unicode errors. This is
# necessary for certain WSGI server applications, e.g. flup.
if self.ziggurat.strEncodeEnviron:
for n, v in DictUtils.iter(response.headers):
if StringUtils.isStringType(v):
response.headers[n] = StringUtils.toStr2(v)
# Clean up per-thread sessions.
ConcreteModelsMeta.cleanupSessions()
示例15: _handleImportSitemaps
# 需要导入模块: from pyaid.string.StringUtils import StringUtils [as 别名]
# 或者: from pyaid.string.StringUtils.StringUtils import isStringType [as 别名]
def _handleImportSitemaps(self):
self.mainWindow.showLoading(
self,
u'Browsing for Sitemap File',
u'Choose the Sitemap CSV file to import into the database')
path = PyGlassBasicDialogManager.browseForFileOpen(
parent=self,
caption=u'Select CSV File to Import',
defaultPath=self.mainWindow.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH) )
self.mainWindow.hideLoading(self)
if not path or not StringUtils.isStringType(path):
self.mainWindow.toggleInteractivity(True)
return
# Store directory location as the last active directory
self.mainWindow.appConfig.set(
UserConfigEnum.LAST_BROWSE_PATH, FileUtils.getDirectoryOf(path) )
self.mainWindow.showStatus(
self,
u'Importing Sitemaps',
u'Reading sitemap information into database')
SitemapImporterRemoteThread(
parent=self,
path=path
).execute(
callback=self._sitemapImportComplete,
logCallback=self._handleImportStatusUpdate)