本文整理汇总了Python中properties.Properties.get方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.get方法的具体用法?Python Properties.get怎么用?Python Properties.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类properties.Properties
的用法示例。
在下文中一共展示了Properties.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: editDebugSettings
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def editDebugSettings(self):
item = self.currentItem()
path = item.data(0, DirectoryRole).toString()
mkPath = os.path.join(path, "mk.cfg")
props = Properties(mkPath)
d = uis.loadDialog("debug_settings")
d.cwdEdit.setText(props.get("DEBUG_CWD"))
d.paramsEdit.setText(props.get("DEBUG_PARAMS"))
d.browseDirButton.clicked.connect(lambda: utils.browseDirectory(d.cwdEdit))
if d.exec_():
props.assign("DEBUG_CWD", d.cwdEdit.text())
props.assign("DEBUG_PARAMS", d.paramsEdit.text())
self.debug = (d.cwdEdit.text(), d.paramsEdit.text())
props.save(mkPath)
示例2: mkProps
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def mkProps(props, dir):
path=os.path.join(dir,'mk.cfg')
if os.path.exists(path):
p=Properties(path)
for name in p.keys():
value=p.get(name)
if value.startswith('\\'):
value=props.get(name)+' '+value[1:]
props.assign(name,value)
return props
示例3: addLibrariesToProject
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def addLibrariesToProject(self, libs):
if self.main:
path = self.mainPath()
mkPath = os.path.join(path, "mk.cfg")
props = Properties(mkPath)
lst = props.get("LINK_LIBS").split(",")
lst = [x for x in lst if len(x) > 0]
for l in libs:
lst.append(l)
props.assign("LINK_LIBS", ",".join(lst))
props.save(mkPath)
self.depsChanged.emit(path)
示例4: editDependencies
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def editDependencies(self):
item = self.currentItem()
path = item.data(0, DirectoryRole).toString()
mkPath = os.path.join(path, "mk.cfg")
props = Properties(mkPath)
libs = re.split("\W+", props.get("LINK_LIBS"))
d = DependenciesDialog(libs)
if d.exec_():
props.assign("LINK_LIBS", ",".join(d.libs))
props.save(mkPath)
self.depsChanged.emit(path)
return True
return False
示例5: runTest
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def runTest(self):
"""Test blank"""
prefString= ""
prefs = Properties(prefString)
prefString = "default.name=Bilbo Baggins\nhomepage.feeds=42,24"
prefs = Properties(prefString)
assert cmp('Bilbo Baggins', prefs.get('default.name')) == 0, 'Error retrieving value from key'
assert cmp('', prefs.get('jeff')) == 0, "Missing keys should default to blank string"
prefs.set('Hulk', 'Hogan')
assert cmp('Hogan', prefs.get('Hulk')) == 0, 'Error retrieving set key/value'
stringValue = prefs.convertToPropertiesFile()
#this last test needs to be fixed, can fail if keys are not brought back in same order
assert cmp(prefString + "\nHulk=Hogan", stringValue) == 0, 'Error converting to properties'
prefString = "jeff=1"
prefs = Properties(prefString)
assert cmp('1', prefs.get('jeff')) == 0
assert cmp('1', prefs.pop('jeff')) == 0
try:
prefs.pop('badkey')
unittest.fail('A KeyError exception should have prevented this')
except KeyError:
pass
assert False == prefs.has_key('jeff')
示例6: scanWorkspace
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def scanWorkspace(self):
self.wsLibs={}
for dir,subdirs,files in os.walk(self.srcDir):
type=""
if isSourceDir(dir,files):
mkPath=os.path.join(dir,'mk.cfg')
if os.path.exists(mkPath):
props=Properties(mkPath)
if props.has("TYPE"):
type=props.get("TYPE")
if type=="":
if findMain(dir):
type="APP"
else:
type="LIB"
if type=="LIB":
dirname=(dir.split('/'))[-1]
self.wsLibs[dirname]=os.path.relpath(dir,self.srcDir)
示例7: generate
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def generate(self,dir,files):
#props=mkProps(Properties(),root)
for d,subs,subfiles in os.walk(dir):
if d!=dir:
for f in subfiles:
files.append(os.path.join(os.path.relpath(d,dir),f))
stack=[]
curdir=dir
while True:
stack.append(curdir)
if curdir==self.root:
break
curdir=os.path.abspath(os.path.join(curdir,'..'))
props=Properties()
self.assignDefaults(props)
while len(stack)>0:
props=mkProps(props,stack[-1])
del stack[-1]
output=os.path.join(dir,"Makefile")
o=open(output,"w")
opt=props.get("OPT_Release")
if len(opt)==0:
opt="-O2"
if opt=="Custom":
opt=""
o.write('INC_STD=-I{}\n'.format(' -I'.join(stdIncludes)))
o.write('OPT_Release={}\n'.format(opt))
o.write('OPT_Debug=-g\n')
o.write('\ndefault: Release\n\n')
self.generateConfig(dir,files,"Release",o,props)
if self.generateConfig(dir,files,"Debug",o,props):
pass
o.write('\nclang_complete:\n')
o.write('\tclang -cc1 -std=c++11 -x c++ $(INC_STD) $(INC_Release) -w -fsyntax-only ')
o.write('-code-completion-macros -v -code-completion-at -:$(LINE):$(COL) -\n\n')
o.close()
示例8: loadMainProjectInfo
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def loadMainProjectInfo(self):
mkPath = os.path.join(self.mainPath(), "mk.cfg")
props = Properties(mkPath)
self.debug = (props.get("DEBUG_CWD"), props.get("DEBUG_PARAMS"))
示例9: generateConfig
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import get [as 别名]
def generateConfig(self,dir,files,cfg,o,props):
'''
Generate rules for a configuration (Debug/Release)
'''
name=os.path.basename(dir)
absdir=os.path.abspath(dir)
pb=Properties(os.path.join(dir,"mk.cfg"))
type=pb.get("TYPE")
if len(type)==0:
if findMain(absdir):
type="APP"
else:
type="LIB"
o.write('TYPE={}\n'.format(type))
libs=re.split(',| ',pb.get("LINK_LIBS"))
libs=filter(bool,libs) # remove empty strings
if len(type)==0:
return False
srcs=filterSources(files)
subdirs=self.findAllSubdirs(srcs)
intr=os.path.join(dir.replace(self.srcDir,self.intrDir),cfg)
verifyDir(intr)
for sd in subdirs:
verifyDir(os.path.join(intr,sd))
outdir=os.path.join(dir.replace(self.srcDir,self.outDir),cfg)
verifyDir(outdir)
#reloutdir=os.path.relpath(outdir,dir)
reloutdir=outdir
#globalInclude=os.path.relpath(self.globalInc,dir)
cfgInclude=''
#o = open(output,'w')
mkProps=Properties()
o.write('CPP_{}=g++\n'.format(cfg))
mkProps.assign('CPP_{}'.format(cfg),'g++')
o.write('INC_{}=-I{} {}\n'.format(cfg,self.globalInc,cfgInclude))
mkProps.assign('INC_{}'.format(cfg),'-I{} {}'.format(self.globalInc,cfgInclude))
cflags='-c $(OPT_{}) $(INC_{}) '.format(cfg,cfg)
cflags=self.addCompileSettings(cflags,props,cfg)
lflags='$(OPT_{}) $(OBJS_{}) '.format(cfg,cfg)
lflags=self.addLinkSettings(lflags,props,cfg)
libdeps={}
for stage in ['local','package']:
for lib in libs:
if lib in packages:
if stage=='package':
cflags=cflags+' `pkg-config --cflags {}` '.format(lib)
lflags=lflags+' `pkg-config --libs {}` '.format(lib)
else:
if lib in self.wsLibs:
if stage=='local':
rel=self.wsLibs.get(lib)
libdir=os.path.join(self.root,'out',rel,cfg)
libDir=os.path.join(self.root,'src',rel)
libProps=Properties(os.path.join(libDir,"mk.cfg"))
wPrefix=''
wSuffix=''
if libProps.get('BUILD_WHOLE_ARCHIVE','False')=='True':
wPrefix=' -Wl,--whole-archive'
wSuffix='-Wl,--no-whole-archive '
lflags=lflags+'{} -L{} -l{} {}'.format(wPrefix,libdir,lib,wSuffix)
libdeps[lib]=libDir
else:
if stage=='package':
lflags=lflags+' -l{} '.format(lib)
o.write('CFLAGS_{}={}\n'.format(cfg,cflags))
o.write('LFLAGS_{}={}\n'.format(cfg,lflags))
objs = arreplace(srcs,'.cpp','.o')
for i in xrange(0,len(objs)):
objs[i]=os.path.join(intr,objs[i])
o.write("OBJS_{}=".format(cfg))
for obj in objs:
o.write("\\\n"+obj)
o.write("\n\n")
liblist=[]
for lib in libdeps:
libname="{}_{}".format(lib,cfg)
liblist.append(libname)
libpath=libdeps.get(lib)
o.write("{}:\n".format(libname))
o.write("\[email protected] --no-print-directory -C {} {}\n\n".format(libpath,cfg))
o.write("clean_{}:\n".format(libname))
o.write("\[email protected] --no-print-directory -C {} clean_{}\n\n".format(libpath,cfg))
cleanlibs=''
if type=='LIB':
outfile='{}/lib{}.a'.format(reloutdir,name)
o.write('{}: $(OBJS_{})\n'.format(outfile,cfg))
o.write('\tar cr {} $(OBJS_{})\n\n'.format(outfile,cfg))
else:
outfile="{}/{}".format(reloutdir,name)
o.write('OUTPUT_PATH_{}={}\n\n'.format(cfg,outfile))
if len(liblist)>0:
cleanlibs='clean_'+' clean_'.join(liblist)
liblist=' '.join(liblist)
#.........这里部分代码省略.........