本文整理汇总了Python中java.lang.String.format方法的典型用法代码示例。如果您正苦于以下问题:Python String.format方法的具体用法?Python String.format怎么用?Python String.format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.String
的用法示例。
在下文中一共展示了String.format方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_object_varargs
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def test_object_varargs(self):
"array.array objects can be used in the varargs position, with primitive boxing"
a = array("i", range(5, 10))
self.assertEqual(
"arg 0=5, arg 1=6, arg 2=7, arg 3=8, arg 4=9",
JString.format("arg 0=%d, arg 1=%d, arg 2=%d, arg 3=%d, arg 4=%d", [5, 6, 7, 8, 9]),
)
示例2: __createNew
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def __createNew(self):
self.vc("log").debug("Creating a new package...")
packageType, jsonConfigFile = self.__getPackageTypeAndJsonConfigFile()
self.vc("log").debug("packageType = '{}'", packageType)
self.vc("log").debug("jsonConfigFile = '{}'", jsonConfigFile)
manifestHash = "%s.tfpackage" % uuid.uuid4()
# store the manifest file for harvesting
packageDir = FascinatorHome.getPathFile("packages")
packageDir.mkdirs()
manifestFile = File(packageDir, manifestHash)
outStream = FileOutputStream(manifestFile)
outWriter = OutputStreamWriter(outStream, "UTF-8")
self.vc("sessionState").set("package/active", None)
manifest = self.__getActiveManifest()
manifest.setType(packageType)
metaList = list(self.vc("formData").getValues("metaList"))
jsonObj = manifest.getJsonObject()
for metaName in metaList:
value = self.vc("formData").get(metaName)
jsonObj.put(metaName, value)
if self.vc("formData").getValues("sequencesMetaList") != None:
sequenceService = ApplicationContextProvider.getApplicationContext().getBean("sequenceService")
sequencesMetaList = list(self.vc("formData").getValues("sequencesMetaList"))
for sequenceInfo in sequencesMetaList:
sequenceInfoJson = JsonSimple(sequenceInfo)
sequenceIndex = sequenceService.getSequence(sequenceInfoJson.getString(None,"sequenceName"))
jsonObj.put(sequenceInfoJson.getString(None,"metadataName"), String.format(sequenceInfoJson.getString(None,"stringFormat"),sequenceIndex))
self.vc("log").debug("json object created is: %r" % jsonObj)
outWriter.write(manifest.toString(True))
outWriter.close()
# adding ability to set access plugin
accessPlugin = self.vc("formData").get("access_plugin", "derby")
if accessPlugin is not None:
self.vc("page").authentication.set_access_plugin(accessPlugin)
try:
# harvest the package as an object
username = self.vc("sessionState").get("username")
if username is None:
username = "guest" # necessary?
harvester = None
# set up config files, creating if necessary
workflowsDir = FascinatorHome.getPathFile("harvest/workflows")
configFile = self.__getFile(workflowsDir, jsonConfigFile)
self.__getFile(workflowsDir, "packaging-rules.py")
# run the harvest client with our packaging workflow config
harvester = HarvestClient(configFile, manifestFile, username)
harvester.start()
manifestId = harvester.getUploadOid()
harvester.shutdown()
except Exception, ex:
error = "Packager workflow failed: %s" % str(ex)
self.vc("log").error(error, ex)
if harvester is not None:
harvester.shutdown()
return '{ "status": "failed" }'
示例3: notifyExternalRelationship
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def notifyExternalRelationship(self, relationship,pid,system,identifier):
try:
url = self.systemConfig.getString(None, "curation","external-system-urls","notify-curation",system)
self.writer.println(url+ "&relationship=isCollectedBy&curatedPid="+pid+"&identifier="+relationship.get("identifier")+"&system="+self.systemConfig.getString(None,"system")+"&sourceIdentifier="+identifier)
client = BasicHttpClient(url+ "&relationship=isCollectedBy&curatedPid="+pid+"&identifier="+relationship.get("identifier")+"&system="+self.systemConfig.getString(None,"system")+"&sourceIdentifier="+identifier)
get = GetMethod(url+ "&relationship=isCollectedBy&curatedPid="+pid+"&identifier="+relationship.get("identifier")+"&system="+self.systemConfig.getString(None,"system")+"&sourceIdentifier="+identifier)
client.executeMethod(get)
status = get.getStatusCode()
if status != 200:
text = get.getStatusText()
self.log.error(String.format("Error accessing ReDBox: %s %s",status, text));
return None;
except Exception, ex:
return None;
示例4: drawLines
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def drawLines(imp, points=None):
if points and (len(points)%2 == 0):
# points is numeric list of even length
pRoi = PointRoi(points[0::2], points[1::2], len(points)/2)
pRoi.setShowLabels(True)
pRoi.setSize(3)
imp.setRoi(pRoi)
roi = imp.getRoi()
pp = roi.getFloatPolygon()
# print "Added", pp.npoints
if pp.npoints <= 1:
# don't draw if only one point
return
xys = []
for i in xrange(pp.npoints):
xys.append([pp.xpoints[i], pp.ypoints[i]])
ol = Overlay()
x0 = xys[0][0]
y0 = xys[0][1]
cal = imp.getCalibration()
for i in xrange(1, pp.npoints):
xi = xys[i][0]
yi = xys[i][1]
# prepare text label
d = math.sqrt((xi - x0)**2 + (yi - y0)**2) * cal.pixelWidth
dText = String.format("%.2f ", d) + cal.getUnits()
textOffset = 30
xt = xi
yt = yi
# if xi > x0:
# xt += textOffset
if xi < x0:
xt -= textOffset
# if yi > y0:
# yt += textOffset
if yi < y0:
yt -= textOffset
dTextRoi = TextRoi(xt, yt, dText)
ol.add(dTextRoi)
lineRoi = Line(x0, y0, xi, yi)
lineRoi.setStrokeWidth(1)
lineRoi.setStrokeColor(Color(255,255,0))
ol.add(lineRoi)
imp.setOverlay(ol)
imp.updateAndDraw()
示例5: notifyExternalRelationship
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def notifyExternalRelationship(self,relationship,pid,system,identifier):
try:
url = self.systemConfig.getString(None, "curation","external-system-urls","notify-curation",system)
url = "http://localhost:9001/default/api/notifyCuration.script?apiKey=1412412412241"
completeUrl = url+ "&relationship=isCollectorOf&curatedPid="+pid+"&identifier="+relationship.get("identifier")+"&system="+self.systemConfig.getString("redbox","system")+"&sourceIdentifier="+identifier
self.writer.println("the completeUrl: "+ completeUrl)
client = BasicHttpClient(completeUrl)
get = GetMethod(completeUrl)
client.executeMethod(get)
status = get.getStatusCode()
if status != 200:
text = get.getStatusText()
self.log.error(String.format("Error accessing Mint",status, text));
return None;
except Exception, ex:
return None;
示例6: queryJobStatus
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def queryJobStatus(self, curationJob):
relations = ArrayList()
get = None
try:
url = self.systemConfig.getString(None, "curation","curation-manager-url")
client = BasicHttpClient(url + "/job/"+ curationJob.getCurationJobId())
get = GetMethod(url+ "/job/"+ curationJob.getCurationJobId())
client.executeMethod(get)
status = get.getStatusCode()
if status != 200:
text = get.getStatusText()
self.log.error(String.format("Error accessing Curation Manager, status code '%d' returned with message: %s",status, text));
return None;
except Exception, ex:
return None;
示例7: getRequiredClaims
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def getRequiredClaims(self, context): # context is reference of org.gluu.oxauth.uma.authorization.UmaAuthorizationContext
json = """[
{
"issuer" : [ "%1$s" ],
"name" : "country",
"claim_token_format" : [ "http://openid.net/specs/openid-connect-core-1_0.html#IDToken" ],
"claim_type" : "string",
"friendly_name" : "country"
},
{
"issuer" : [ "%1$s" ],
"name" : "city",
"claim_token_format" : [ "http://openid.net/specs/openid-connect-core-1_0.html#IDToken" ],
"claim_type" : "string",
"friendly_name" : "city"
}
]"""
context.addRedirectUserParam("customUserParam1", "value1") # pass some custom parameters to need_info uri. It can be removed if you don't need custom parameters.
return ClaimDefinitionBuilder.build(String.format(json, context.getIssuer()))
示例8: created
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def created(who,what):
if (not (File(what)).exists()):
(Logger.getLogger(VLAB.LOGGER_NAME)).info(JString.format ("Error: \"%s\" failed to generate \"%s\"", [who, what]))
示例9: dependsOn
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def dependsOn(who,what):
if (not (File(what)).exists()):
(Logger.getLogger(VLAB.LOGGER_NAME)).info(JString.format ("Error: \"%s\" expected \"%s\" to exist", [who, what]))
示例10: getFormattedScannableValue
# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import format [as 别名]
def getFormattedScannableValue(scannable, value):
return String.format(scannable.outputFormat[0], [ value ])