本文整理汇总了Python中properties.Properties.keySet方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.keySet方法的具体用法?Python Properties.keySet怎么用?Python Properties.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类properties.Properties
的用法示例。
在下文中一共展示了Properties.keySet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import keySet [as 别名]
def main() :
"""
This is a simple script used to parse a .properties file
and recurslively examine a body of code to identify properties
which are no longer referenced.
Usage :
>> python dead-properties-finder.py propFile searchRootDir
Where propFile is the properties file
and searchRootDir is the root directory of the body of code to search through
If a property is not found in the code base, the name of the property is
printed to stdout
Note : If the body of code you are searching contains the properties file you
are parsing, it won't work! That file will contain all properties which are
being searched for and thus the script will not flag any properties as unreferenced.
It may be best to remove ALL properties files from the project temporarily
before running the script to ensure there are no false negatives.
Also, the class used to parse the properties file assumes property value pairs
are "=" delimited. Using ":" may be accepted by other properties parsers, but
the properties file class used by this script currently only accepts "="
"""
propFile = sys.argv[1]
searchRoot = sys.argv[2]
props = Properties(propFile)
for prop in props.keySet() :
retCode = os.system("grep -rq %s %s" % (prop, searchRoot))
if retCode > 0 :
print prop