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


Python Properties.keySet方法代码示例

本文整理汇总了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
开发者ID:steventclarke,项目名称:dead-properties-finder,代码行数:35,代码来源:dead-property-finder.py


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