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


Python Properties.list方法代码示例

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


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

示例1: len

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import list [as 别名]
from pyjavaproperties import Properties
import sys
import os

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print "Usage: python prop_util.py <path to runtime.properties> <mydomain replacement>"
        sys.exit(1)
    runtime_filepath = sys.argv[1]
    print "Updating %s" % runtime_filepath
    p = Properties()
    p.load(open(runtime_filepath))
    print "****Properties before****"
    p.list()
    #Add/replace environment variables that begin with v_
    for key, value in [(key[2:], os.environ[key]) for key in os.environ if key.startswith("v_")]:
        print "Adding key %s: %s" % (key, value)
        p[key] = value
    #Replace mydomain in any values
    newdomain = sys.argv[2]
    for key, value in [(key, value) for (key, value) in p.iteritems() if "mydomain.edu" in value]:
        new_value = value.replace("mydomain.edu", newdomain)
        print "Changing key %s from %s to %s" % (key, value, new_value)
        p[key] = new_value
    #Set DB values based on docker-provided environment variables
    p['VitroConnection.DataSource.url'] = "http://db:8111/v1/graphs/sparql"
    p['VitroConnection.DataSource.username'] = 'admin'
    p['VitroConnection.DataSource.password'] = 'admin'
    print "****Properties after****"
    p.list()
    p.store(open(runtime_filepath,'w'))
开发者ID:patrickmcelwee,项目名称:vivo-marklogic-docker,代码行数:33,代码来源:prop_util.py

示例2: main

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import list [as 别名]
def main():
    
    properties = Properties()
    properties.load(open("/home/khepry/home/distributions/PyDataGenerator/PyDataGenerator.properties"))
    properties.list()

    maxRows = 100
    maxXlsRows = 10000
    
    globalPath = '/home/khepry/home/distributions/PyDataGenerator/temp/'
    targetName = 'dataGenerator.csv'

    maxRows = int(properties.getProperty('maxRows', maxRows))
    maxXlsRows = int(properties.getProperty('maxXlsRows', maxXlsRows))

    globalPath = properties.getProperty('globalPath', globalPath)
    targetName = properties.getProperty('targetName', targetName)
    
    print("-- operating system --")
    print(platform.system())
    
    print("-- processing messages --")
    
    if platform.system() == 'Windows':
        xlsPgmPath = '"/Program Files/Microsoft Office 15/root/office15/EXCEL.EXE"'
        txtPgmPath = '"/Program Files (x86)/Notepad++/notepad++.exe"'
    else:
        xlsPgmPath = "libreoffice"
        txtPgmPath = "gedit"
    
    tgtFileFullPath = os.path.abspath(globalPath + targetName)
    tgtFile = open(tgtFileFullPath, 'w', newline='')

    bgnTime = tyme.time()

    rows = 0
    
    try:
        writer = csv.writer(tgtFile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)

        for i in range(0, maxRows):
            rows += 1
            
            record = Record()
            record.addField("UUID4", "UUID4").random()
            record.addField("Alpha", "Alpha").random(20, 25)
            record.addField("AlphaNumeric", "AlphaNumeric").random()
            record.addField("Numeric", "Numeric").random()
            record.addField("String", "String").random()
            record.addField("Range", "Range").random(12, 24)
            record.addField("Date", "Date").random(date(1980,1,1), date(2000,12,31))
            record.addField("DateTime", "DateTime").random(date(1980,1,1), date(2000,12,31))
            record.addField("AgeInYears","Numeric").years(date.today(), record.getField("Date").value)
            record.addField("AgeInMonths","Numeric").months(date.today(), record.getField("Date").value)
            record.addField("AgeInDays","Numeric").days(date.today(), record.getField("Date").value)
                
            if (i == 0):
                writer.writerow([key for key in record.fields.keys()])
            writer.writerow([field.text for field in record.fields.values()])
            
    finally:
        tgtFile.close()


    endTime = tyme.time()

    elapsedTime = endTime - bgnTime

    print("{:,}".format(rows) + ' records processed in ' + "{:,.4f}".format(elapsedTime) + ' seconds at ' + "{:,.4f}".format(rows / elapsedTime) + ' rows/second.')

    if (platform.system() == 'Windows'):
        if (rows < maxXlsRows):
            subprocess.call(xlsPgmPath + ' "' + tgtFileFullPath + '"')
        else:
            subprocess.call(txtPgmPath + ' "' + tgtFileFullPath + '"')
    else:
        if (rows < maxXlsRows):
            subprocess.call([xlsPgmPath, tgtFileFullPath])
        else:
            subprocess.call([txtPgmPath, tgtFileFullPath])
开发者ID:Frackalyzer,项目名称:PyDataGenerator,代码行数:82,代码来源:DataGenerator.py


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