本文整理汇总了Python中java.lang.String.substring方法的典型用法代码示例。如果您正苦于以下问题:Python String.substring方法的具体用法?Python String.substring怎么用?Python String.substring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.String
的用法示例。
在下文中一共展示了String.substring方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getDistributors
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
def getDistributors(self,oshv,sqlServerId):
#is there is a chance that we have more than one distributor?
rs = self.connection.doCall(Queries.SERVER_DIST_CALL)
distributor = None
databaseName = None
while rs.next():
name = rs.getString('distributor')
if(name is None):
rs.close()
return None
databaseName = rs.getString('distribution database')
max = int(rs.getInt('max distrib retention'))
min = int(rs.getInt('min distrib retention'))
history = int(rs.getInt('history retention'))
cleanup = String(rs.getString('history cleanup agent'))
idx = cleanup.indexOf('Agent history clean up:')
if(idx>=0):
cleanup=cleanup.substring(len("Agent history clean up:"))
distributor = ObjectStateHolder('sqlserverdistributor')
sqlServer = self.createSqlServer(name,oshv,sqlServerId)
distributor.setContainer(sqlServer)
distributor.setAttribute(Queries.DATA_NAME,name)
distributor.setIntegerAttribute('maxTxRetention',max)
distributor.setIntegerAttribute('minTxRetention',min)
distributor.setIntegerAttribute('historyRetention',history)
distributor.setAttribute('cleanupAgentProfile',cleanup)
oshv.add(sqlServer)
oshv.add(distributor)
database = self.getDatabase(sqlServer,databaseName)
oshv.add(database)
oshv.add(modeling.createLinkOSH('use',distributor,database))
rs.close()
if(distributor!=None):
logger.debug('we got a distributor')
return [distributor,databaseName]
示例2: sortResultsByCode
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
def sortResultsByCode(self):
tempMap = HashMap()
for result in self.__results:
uri = String(self.getValue(result, "dc_identifier"))
lastIndex = uri.lastIndexOf('/') + 1
code = uri.substring(lastIndex)
tempMap.put(code, result)
self.resultsByCode = TreeMap(tempMap)
示例3: loadXmlFile
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
def loadXmlFile(self, path, container = None, fileContent = None):
'str, osh, str -> Document'
saxBuilder = SAXBuilder()
globalSettings = GeneralSettingsConfigFile.getInstance()
#loadExternalDTD = globalSettings.getPropertyBooleanValue('loadExternalDTD', 1)
loadExternalDTD = 1
saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", loadExternalDTD)
logger.debug("loadXmlFile, loadExternalDTD: ", loadExternalDTD, ", path: ", path )
if loadExternalDTD :
saxBuilder.setEntityResolver( XMLExternalEntityResolver( self.fileMonitor, str(path), self.shellUtils ) )
saxBuilder.setFeature("http://xml.org/sax/features/use-entity-resolver2", 1)
doc = None
try:
fileContent = fileContent or self.fileMonitor.getFileContent(path)
if fileContent:
try:
strContent = String(fileContent)
strContent = String(strContent.substring(0, strContent.lastIndexOf('>') + 1))
doc = saxBuilder.build(ByteArrayInputStream(strContent.getBytes()))
if container is not None:
cfOSH = self.createCF(container, path, fileContent)
if cfOSH is not None:
self.OSHVResult.add(cfOSH)
except:
logger.debugException('Failed to load xml file:', path)
excMsg = traceback.format_exc()
logger.debug( excMsg )
except:
logger.debugException('Failed to get content of file:', path)
excMsg = traceback.format_exc()
logger.debug( excMsg )
return doc
示例4: getPath
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
def getPath(path):
ss = String(path)
if(ss.indexOf("\\")==-1):
# return ss
return path # changed by Daniel La - HP Case 4644803487
return ss.substring(0,ss.lastIndexOf("\\"))
示例5: loadProperties
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
def loadProperties(cfg_file, extra_props):
props = Properties()
iterated_props = Properties()
inherited_props = Properties()
data_linage = Properties()
redback_reg = redback.load_redback_registry()
site_home = redback_reg.getProperty('site.home')
global_properties = redback_reg.getProperty('global.properties')
if global_properties:
if site_home:
baseFile=getBaseFile(global_properties, site_home)
if baseFile=='':
log.error('Global properties file does not exist: ' + global_properties)
log.info('Suggested Fix: Update the global.properties property within redback.properties to the correct file path')
sys.exit()
global_properties=baseFile
log.info('Loading global configuration from file: ' + global_properties)
addPropertiesFromFile(props, global_properties, site_home)
if cfg_file:
addPropertiesFromFile(props, cfg_file, site_home)
if extra_props:
props.putAll(extra_props)
# resolve property level inheritance and iterations
log.debug('Attempting to resolve property level inheritance')
enum = props.keys()
while enum.hasMoreElements():
key = enum.nextElement()
value = props.getProperty(key)
# Check for property level inheritance
if re.search(r"\.base$", key) is not None:
prop_to_inherit = value
prop_to_extend = key[:-5]
log.debug('Inheriting the properties from the ' + prop_to_inherit + ' section in to the section ' + prop_to_extend)
# Iterate the properties again looking for a match on properties to inherit
enum_inner = props.keys()
while enum_inner.hasMoreElements():
key_inner = enum_inner.nextElement()
value_inner = props.getProperty(key_inner)
log.debug('Checking key_inner [' + key_inner + '] matches ' + prop_to_inherit)
if String.startsWith(String(key_inner),String(prop_to_inherit)):
new_property = prop_to_extend + String.substring(key_inner, len(prop_to_inherit))
# Don't override the property if it has already been defined earlier
if props.getProperty(new_property) is None:
log.debug('Setting inherited property ' + new_property + ' to value ' + value_inner)
inherited_props.setProperty(new_property, value_inner)
addDataLinage(key,cfg_file,value_inner)
# Remove the key that defines the base, just keeps us consistant with the template behaviours
log.debug("About to remove key " + key)
props.remove(key)
props.putAll(inherited_props)
log.debug('Attempting to resolve iterations')
enum = props.keys()
while enum.hasMoreElements():
key = enum.nextElement()
value = props.getProperty(key)
# Check for property set iterations
if re.search(r"\.iterate$", key) is not None:
iteration_key = key
iteration_set = eval(value)
prop_to_iterate = key[:-9]
log.debug('Iterating the properties from the ' + prop_to_iterate + ' section')
# Iterate the properties again looking for a match on properties to iterate
enum_inner = props.keys()
while enum_inner.hasMoreElements():
key_inner = enum_inner.nextElement()
value_inner = props.getProperty(key_inner)
# if the string is part of the set but not the actual iterator then we will check it
if String.startsWith(String(key_inner),String(prop_to_iterate)) and key_inner != iteration_key:
log.debug('Checking if the key [' + key_inner + '] or value = ' + value_inner + ' contains an iterator ')
contains_iterator = 0
iterated_key = String(key_inner)
iterated_value = String(value_inner)
if String.indexOf(String(key_inner),"%") > -1:
log.debug(key_inner + ' contains an iterator, replacing it')
contains_iterator = 1
if String.indexOf(String(value_inner),"%") > -1:
log.debug(value_inner + ' contains an iterator, replacing it')
contains_iterator = 1
for i in iteration_set:
iterated_key = String.replaceAll(String(key_inner),"\%",str(i))
iterated_value = String.replaceAll(String(value_inner),"\%",str(i))
# Don't override the property if it has already been defined earlier
if props.getProperty(iterated_key) is None:
log.debug('Setting iterated property ' + iterated_key + ' to value ' + iterated_value)
iterated_props.setProperty(iterated_key, iterated_value)
addDataLinage(key,cfg_file,iterated_value)
# Remove the key that gets iterated, just keeps us consistant with the template behaviours
#.........这里部分代码省略.........
示例6: cl
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
from subprocess import call, Popen, PIPE
import re
from java.lang import String
def cl(cmd):
call(cmd, shell=True)
pattern = re.compile(r"([^:]*):([0-9]+):([0-9]+):(.*)$")
name = String(sourceFile.getName())
shName = name.substring(0, name.lastIndexOf(".vhd"))
parent = sourceFile.getParent()
os.chdir(parent)
cl("rm -rf work")
cl("mkdir work")
process = Popen(["ghdl", "-i", "--work=work", "--workdir=work", str(name)], stdout=PIPE)
marker_clean(sourceFileFullPath)
process = Popen(["ghdl", "-m", "--ieee=synopsys", "-fexplicit", "--workdir=work", "-Pwork", str(shName)], stderr=PIPE, stdout=PIPE)
out = process.stdout.read()
err = process.stderr.read()
for line in re.split("\n+", out):
if line:
printf(line)
for line in re.split("\n+", err):
示例7: getPath
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
def getPath(path):
ss = String(path)
if(ss.indexOf("\\")==-1):
return path
return ss.substring(0,ss.lastIndexOf("\\"))
示例8: getFileFromPath
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import substring [as 别名]
def getFileFromPath(path):
ss = String(path)
if(ss.indexOf("\\")==-1):
return path
return ss.substring(ss.lastIndexOf("\\")+1)