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


Python Policy.read_json_reform_text方法代码示例

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


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

示例1: test_reforms

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import read_json_reform_text [as 别名]
def test_reforms(reforms_path):  # pylint: disable=redefined-outer-name
    """
    Check that each JSON reform file can be converted into a reform dictionary,
    which can then be passed to the Policy.implement_reform() method.
    While doing this, construct a set of Policy parameters (other than those
    ending in '_cpi') included in the JSON reform files.
    """
    params_set = set()
    for jrf in glob.glob(reforms_path):
        # read contents of jrf (JSON reform filename)
        with open(jrf) as jrfile:
            jrf_text = jrfile.read()
        # check that jrf_text can be implemented as a Policy reform
        jrf_dict = Policy.read_json_reform_text(jrf_text)
        policy = Policy()
        policy.implement_reform(jrf_dict)
        # identify policy parameters included in jrf after removing //-comments
        json_without_comments = re.sub('//.*', ' ', jrf_text)
        json_dict = json.loads(json_without_comments)
        for param in json_dict.keys():
            if param.endswith('_cpi'):
                continue
            params_set.add(param)
开发者ID:kerkphil,项目名称:Tax-Calculator,代码行数:25,代码来源:test_reforms.py


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