本文整理汇总了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)