| 89 | |
| 90 | |
| 91 | def check_compatible_str(old_api_spec_str, new_api_spec_str): |
| 92 | patArgSpec = re.compile( |
| 93 | r'args=(.*), varargs=.*defaults=(None|\((.*)\)), kwonlyargs=.*' |
| 94 | ) |
| 95 | mo_o = patArgSpec.search(old_api_spec_str) |
| 96 | mo_n = patArgSpec.search(new_api_spec_str) |
| 97 | if not (mo_o and mo_n): |
| 98 | # error |
| 99 | logger.warning("old_api_spec_str: %s", old_api_spec_str) |
| 100 | logger.warning("new_api_spec_str: %s", new_api_spec_str) |
| 101 | return False |
| 102 | |
| 103 | args_o = eval(mo_o.group(1)) |
| 104 | args_n = eval(mo_n.group(1)) |
| 105 | defaults_o = mo_o.group(2) if mo_o.group(3) is None else mo_o.group(3) |
| 106 | defaults_n = mo_n.group(2) if mo_n.group(3) is None else mo_n.group(3) |
| 107 | defaults_o = defaults_o.split(', ') if defaults_o else [] |
| 108 | defaults_n = defaults_n.split(', ') if defaults_n else [] |
| 109 | return _check_compatible(args_o, args_n, defaults_o, defaults_n) |
| 110 | |
| 111 | |
| 112 | def read_argspec_from_file(specfile): |