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


Python Properties.load方法代码示例

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


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

示例1: _testParsePropertiesInput

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
 def _testParsePropertiesInput(self, stream):
   properties = Properties()
   properties.load(stream)
   self.assertEquals(23, len(properties.items()))
   self.assertEquals('Value00', properties['Key00'])
   self.assertEquals('Value01', properties['Key01'])
   self.assertEquals('Value02', properties['Key02'])
   self.assertEquals('Value03', properties['Key03'])
   self.assertEquals('Value04', properties['Key04'])
   self.assertEquals('Value05a, Value05b, Value05c', properties['Key05'])
   self.assertEquals('Value06a, Value06b, Value06c', properties['Key06'])
   self.assertEquals('Value07b', properties['Key07'])
   self.assertEquals(
       'Value08a, Value08b, Value08c, Value08d, Value08e, Value08f',
       properties['Key08'])
   self.assertEquals(
       'Value09a, Value09b, Value09c, Value09d, Value09e, Value09f',
       properties['Key09'])
   self.assertEquals('Value10', properties['Key10'])
   self.assertEquals('', properties['Key11'])
   self.assertEquals('Value12a, Value12b, Value12c', properties['Key12'])
   self.assertEquals('Value13 With Spaces', properties['Key13'])
   self.assertEquals('Value14 With Spaces', properties['Key14'])
   self.assertEquals('Value15 With Spaces', properties['Key15'])
   self.assertEquals('Value16', properties['Key16 With Spaces'])
   self.assertEquals('Value17', properties['Key17 With Spaces'])
   self.assertEquals('Value18 # Not a comment.', properties['Key18'])
   self.assertEquals('Value19 ! Not a comment.', properties['Key19'])
   self.assertEquals('Value20', properties['Key20=WithEquals'])
   self.assertEquals('Value21', properties['Key21:WithColon'])
   self.assertEquals('Value22', properties['Key22'])
开发者ID:Finntack,项目名称:pyjavaproperties,代码行数:33,代码来源:pyjavaproperties_test.py

示例2: load_configuration

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
 def load_configuration(self):
     p = Properties()
     p.load(open(CONFIGURATION_PROPERTIES))
     self.producers_point = p['producers.point']
     # FIXME: auto acquire the name according to the machine's ip
     self.cluster_name = socket.gethostname().split('-')[0]
     self.ip = get_public_ip()
开发者ID:spyrosg,项目名称:VISION-Cloud-Monitoring,代码行数:9,代码来源:vismo_dispatch.py

示例3: parse

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = JitsiProperties.path
        p = Properties()
        p.load(open(os.path.join(settingsdir, JitsiProperties.propertiesfile)))
        keydict = dict()
        for item in p.items():
            propkey = item[0]
            name = ""
            if re.match("net\.java\.sip\.communicator\.impl\.protocol\.jabber\.acc[0-9]+\.ACCOUNT_UID", propkey):
                name = JitsiProperties._parse_account_uid(item[1])
                if name in keydict:
                    key = keydict[name]
                else:
                    key = dict()
                    key["name"] = name
                    key["protocol"] = "prpl-jabber"
                    keydict[name] = key

                propkey_base = "net.java.sip.communicator.plugin.otr." + re.sub("[^a-zA-Z0-9_]", "_", item[1])
                private_key = p.getProperty(propkey_base + "_privateKey").strip()
                public_key = p.getProperty(propkey_base + "_publicKey").strip()
                numdict = util.ParsePkcs8(private_key)
                key["x"] = numdict["x"]
                numdict = util.ParseX509(public_key)
                for num in ("y", "g", "p", "q"):
                    key[num] = numdict[num]
                key["fingerprint"] = util.fingerprint((key["y"], key["g"], key["p"], key["q"]))
                verifiedkey = (
                    "net.java.sip.communicator.plugin.otr."
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_publicKey_verified"
                )
                if p.getProperty(verifiedkey).strip() == "true":
                    key["verification"] = "verified"
            elif re.match("net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey_verified", propkey):
                name, protocol = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
                if name != None:
                    if name not in keydict:
                        key = dict()
                        key["name"] = name
                        keydict[name] = key
                    if protocol and "protocol" not in keydict[name]:
                        keydict[name]["protocol"] = protocol
                    keydict[name]["verification"] = "verified"
            # if the protocol name is included in the property name, its a local account with private key
            elif re.match("net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey", propkey) and not re.match(
                "net\.java\.sip\.communicator\.plugin\.otr\.(Jabber_|Google_Talk_)", propkey
            ):
                name, ignored = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
                if name not in keydict:
                    key = dict()
                    key["name"] = name
                    key["protocol"] = "prpl-jabber"
                    keydict[name] = key
                numdict = util.ParseX509(item[1])
                for num in ("y", "g", "p", "q"):
                    key[num] = numdict[num]
                key["fingerprint"] = util.fingerprint((key["y"], key["g"], key["p"], key["q"]))
        return keydict
开发者ID:rostendorf,项目名称:otrfileconverter,代码行数:62,代码来源:jitsi.py

示例4: getFilename

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
def getFilename():
    p = Properties();
    p.load(open('../../build.number.properties'));
    minor = p['build.minor'];
    major = p['build.major'];
    point = p['build.point'];
    filename = 'core_' + major + minor + point 
    return filename
开发者ID:Azurami,项目名称:wagic,代码行数:10,代码来源:createResourceZip.py

示例5: write

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print 'Adium WARNING: "' + loadfile + '" does not exist! Reading from:'
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print '\t"' + loadfile + '"'

        propkey_base = 'net.java.sip.communicator.plugin.otr.'
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.iteritems():
            if 'verification' in key and key['verification'] != '':
                verifiedkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_publicKey_verified')
                p[verifiedkey] = 'true'
            if 'y' in key:
                pubkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if 'x' in key:
                suffix2 = ''
                if '@' in key['name']:
                    suffix = re.sub('[^a-zA-Z0-9_]', '_', key['name'].split('@')[1])
                    if 'facebook' in key['name'].split('@')[1]:
                        protocolAcc = 'Facebook_'
                    elif 'gmail' in key['name'].split('@')[1]:
                        protocolAcc = 'Google_Talk_'
                        suffix2 = 'talk_google_com'
                    else:
                        protocolAcc = 'Jabber_'
                elif '@' not in key['name']:
                    if 'icq' in key['protocol']:
                        protocolAcc = 'ICQ_'
                        suffix = 'icq_com'
                    elif 'yahoo' in key['protocol']:
                        protocolAcc = 'Yahoo__'
                        suffix = 'yahoo_com'
                # Writing
                pubkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_' + suffix + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                           + '_' + suffix + '_privateKey')
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
		   
                if suffix2 != '':
                    pubkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                              + '_' + suffix2 + '_publicKey')
                    p.setProperty(pubkey, util.ExportDsaX509(key))
                    privkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_' + suffix2 + '_privateKey')
                    p.setProperty(privkey, util.ExportDsaPkcs8(key))	
		   		
        p.store(open(savefile, 'w'))
开发者ID:gitter-badger,项目名称:keysync,代码行数:60,代码来源:jitsi.py

示例6: parse

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = JitsiProperties.path
        p = Properties()
        p.load(open(os.path.join(settingsdir, JitsiProperties.propertiesfile)))
        keydict = dict()
        for item in p.items():
            propkey = item[0]
            name = ''
            if re.match('net\.java\.sip\.communicator\.impl\.protocol\.jabber\.acc[0-9]+\.ACCOUNT_UID', propkey):
                name = JitsiProperties._parse_account_uid(item[1])
                if name in keydict:
                    key = keydict[name]
                else:
                    key = dict()
                    key['name'] = name
                    key['protocol'] = 'prpl-jabber'
                    keydict[name] = key

                propkey_base = ('net.java.sip.communicator.plugin.otr.'
                                + re.sub('[^a-zA-Z0-9_]', '_', item[1]))
                private_key = p.getProperty(propkey_base + '_privateKey').strip()
                public_key = p.getProperty(propkey_base + '_publicKey').strip()
                numdict = util.ParsePkcs8(private_key)
                key['x'] = numdict['x']
                numdict = util.ParseX509(public_key)
                for num in ('y', 'g', 'p', 'q'):
                    key[num] = numdict[num]
                key['fingerprint'] = util.fingerprint((key['y'], key['g'], key['p'], key['q']))
                verifiedkey = ('net.java.sip.communicator.plugin.otr.'
                               + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_publicKey_verified')
                if p.getProperty(verifiedkey).strip() == 'true':
                    key['verification'] = 'verified'
            elif (re.match('net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey_verified', propkey)):
                name, protocol = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
                if name != None:
                    if name not in keydict:
                        key = dict()
                        key['name'] = name
                        keydict[name] = key
                    if protocol and 'protocol' not in keydict[name]:
                        keydict[name]['protocol'] = protocol
                    keydict[name]['verification'] = 'verified'
            # if the protocol name is included in the property name, its a local account with private key
            elif (re.match('net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey', propkey) and not
                  re.match('net\.java\.sip\.communicator\.plugin\.otr\.(Jabber_|Google_Talk_)', propkey)):
                name, ignored = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
                if name not in keydict:
                    key = dict()
                    key['name'] = name
                    key['protocol'] = 'prpl-jabber'
                    keydict[name] = key
                numdict = util.ParseX509(item[1])
                for num in ('y', 'g', 'p', 'q'):
                    key[num] = numdict[num]
                key['fingerprint'] = util.fingerprint((key['y'], key['g'], key['p'], key['q']))
        return keydict
开发者ID:the-solipsist,项目名称:keysync,代码行数:60,代码来源:jitsi.py

示例7: suffixFilename

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
def suffixFilename(filename, build):
    p = Properties();
    p.load(open('projects/mtg/build.number.properties'));
    minor = p['build.minor'];
    major = p['build.major'];
    point = p['build.point'];
    name, extension = os.path.splitext(filename)
    filename = name + '-' + major + minor + point + '-' + build + extension
    return filename
开发者ID:bjornsnoen,项目名称:wagic,代码行数:11,代码来源:upload-binaries.py

示例8: get_dependency_projects

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
def get_dependency_projects():
    if os.path.exists(project_filename):
        with open(project_filename) as fsock:
            properties = Properties()
            properties.load(fsock)

            project  = re.compile(r'android.library.reference.\d+')
            return (value for key, value in properties.items() if project.match(key))
    else:
        return []
开发者ID:HuangWenhuan0,项目名称:email-build,代码行数:12,代码来源:util.py

示例9: load

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
def load(filename=DEFAULT_CONFIG_FILENAME):
    p = Properties()
    if os.path.isfile(filename):
        p.load(open('stock.properties'))

    if not p['listed.pricePath'].strip():
        p['listed.pricePath'] = DEFAULT_LISTED_PRICE_PATH
    if not p['listed.instPath'].strip():
        p['listed.instPath'] = DEFAULT_LISTED_INST_PATH
    
    if not p['listed.lastDownload'].strip():
        p['listed.lastDownload'] = DEFAULT_START_DATE
    if p['listed.isDownload'].strip() != 'false':
        p['listed.isDownload'] = 'true'
    
    if not p['listed.lastUpdateDb'].strip():
        p['listed.lastUpdateDb'] = DEFAULT_START_DATE
    if p['listed.isUpdateDb'].strip() != 'false':
        p['listed.isUpdateDb'] = 'true'
    
    if not p['listed.lastUpdateIdx'].strip():
        p['listed.lastUpdateIdx'] = DEFAULT_START_DATE
    if p['listed.isUpdateIdx'].strip() != 'false':
        p['listed.isUpdateIdx'] = 'true'

    if not p['otc.pricePath'].strip():
        p['otc.pricePath'] = DEFAULT_OTC_PRICE_PATH
    if not p['otc.instPath'].strip():
        p['otc.instPath'] = DEFAULT_OTC_INST_PATH
        
    if not p['otc.lastDownload'].strip():
        p['otc.lastDownload'] = DEFAULT_START_DATE
    if p['otc.isDownload'].strip() != 'false':
        p['otc.isDownload'] = 'true'
    
    if not p['otc.lastUpdateDb'].strip():
        p['otc.lastUpdateDb'] = DEFAULT_START_DATE
    if p['otc.isUpdateDb'].strip() !='false':
        p['otc.isUpdateDb'] = 'true'
    
    if not p['otc.lastUpdateIdx'].strip():
        p['otc.lastUpdateIdx'] = DEFAULT_START_DATE
    if p['otc.isUpdateIdx'].strip() !='false':
        p['otc.isUpdateIdx'] = 'true'

    if not p['db.server'].strip():
        p['db.server'] = 'SERVER_NAME'
    if not p['db.username'].strip():
        p['db.username'] = 'USERNAME'
    if not p['db.password'].strip():
        p['db.password'] = 'PASSWORD'
    if not p['db.database'].strip():
        p['db.database'] = 'DATABASE_NAME'

    return p
开发者ID:angusan,项目名称:twstock,代码行数:57,代码来源:stockconfig.py

示例10: parse_property_file

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
def parse_property_file(filename):
    """
    parse java properties file
    :param filename: the path of the properties file
    :return: dictionary loaded from the file
    """
    if not os.path.isfile(filename):
        raise RuntimeError("No file found for parameter at {0}".format(filename))
    p = Properties()
    p.load(open(filename))
    return p
开发者ID:DavidjohnBlodgett,项目名称:on-tools,代码行数:13,代码来源:common.py

示例11: Config

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
class Config(object):
    def __init__(self, filepath):
        self.filepath = filepath
        self.config = Properties()
        with open(filepath) as file:
            self.config.load(file)

    def get_property(self, key):
        return self.config[key]

    def has_property(self, key):
        return key in self.config.propertyNames()
开发者ID:vijithreddy,项目名称:Navigator-SDK,代码行数:14,代码来源:gen_reports.py

示例12: __generate_workload_config

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
 def __generate_workload_config(self, extraneous_config):
     # Read base workload properties into a dict if we haven't already
     if self.__base_workload_props is None:
         props = Properties()
         with open(self.workload_path) as wf:
             props.load(wf)
         self.__base_workload_props = props.getPropertyDict()
     if extraneous_config is None:
         extraneous_config = {}
     # Merge base workload properties with extraneous options
     workload_config = dict(self.__base_workload_props)
     workload_config.update(extraneous_config)
     # Merge and return the workload config dict
     return workload_config
开发者ID:tomzhang,项目名称:YCSB-runner,代码行数:16,代码来源:dbsystem.py

示例13: __init__

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
    def __init__(self,*args):
        unittest.TestCase.__init__(self, *args)
        index = int(__file__.rfind("/"))
        basedir = __file__[0:index]

        p = Properties()
        p.load(open(basedir + '/gnip_account.properties'))
        p.load(open(basedir + '/test.properties'))
        self.gnip = Gnip(p['gnip.username'], p['gnip.password'], p['gnip.server'])
        self.testpublisher = p['gnip.test.publisher']
        self.testpublisherscope = p['gnip.test.publisher.scope']
        self.success = Result('Success')
        self.filterXml = None
        self.rules = None
        self.filterName = None
        self.filterFullData = None
开发者ID:jvaleski,项目名称:gnip-python,代码行数:18,代码来源:gnip_test.py

示例14: write

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print 'Adium WARNING: "' + loadfile + '" does not exist! Reading from:'
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print '\t"' + loadfile + '"'

        propkey_base = "net.java.sip.communicator.plugin.otr."
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.iteritems():
            if "verification" in key and key["verification"] != "":
                verifiedkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey_verified"
                p[verifiedkey] = "true"
            if "y" in key:
                pubkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey"
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if "x" in key and "@" in key["name"]:
                pubkey = (
                    propkey_base
                    + "Jabber_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"].split("@")[1])
                    + "_publicKey"
                )
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (
                    propkey_base
                    + "Jabber_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"].split("@")[1])
                    + "_privateKey"
                )
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
        p.store(open(savefile, "w"))
开发者ID:rostendorf,项目名称:otrfileconverter,代码行数:43,代码来源:jitsi.py

示例15: __init__

# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import load [as 别名]
    def __init__(self, username, password, gnip_server=None, properties_file=None):
        """Initialize the class.

        @type username string
        @param username Your Gnip account username
        @type password string
        @param password Your Gnip account password
        @type gnip_server string
        @param gnip_server The Gnip server to connect to

        Initializes a Gnip class by setting up authentication
        information, used to log into the Gnip service.

        """

        p = Properties()
        if properties_file is not None:
            p.load(open(properties_file))
        else:
            index = int(__file__.rfind("/"))
            basedir = __file__[0:index]
            p.load(open(basedir + '/gnip.properties'))
        
        # Determine base Gnip URL
        if (gnip_server is None):
            self.base_url = p['gnip.server']
        else:
            self.base_url = gnip_server
        
        self.tunnel_over_post = bool(p['gnip.tunnel.over.post=false'])

        # Configure authentication
        self.client = httplib2.Http(timeout = int(p['gnip.http.timeout']))
        self.client.add_credentials(username, password)

        self.headers = {}
        self.headers['Accept'] = 'gzip, application/xml'
        self.headers['User-Agent'] = 'Gnip-Client-Python/2.1.0'
        self.headers['Content-Encoding'] = 'gzip'
        self.headers['Content-Type'] = 'application/xml'
开发者ID:michaelmontano,项目名称:gnip-python,代码行数:42,代码来源:__init__.py


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