Skip to content

Commit 7166a75

Browse files
authored
Replace old liff functions with new ones and keep backward compatibility (#486)
* NO-ISSUE Revert "chore(deps): update dependency black to v23.7.0 (#483)" This reverts commit 4f5bf2b. * NO-ISSUE apply latest liff-operation-id * NO-ISSUE test * NO-ISSUE Modify script * NO-ISSUE Update line-openapi * NO-ISSUE Keep old functions by calling new functions for backward compatibility * NO-ISSUE Add comment
1 parent 69f937b commit 7166a75

File tree

6 files changed

+354
-246
lines changed

6 files changed

+354
-246
lines changed

generate-code.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ def run_command(command):
55
output = subprocess.check_output(command, shell=True)
66
return output.decode('utf-8').strip()
77

8+
9+
def rewrite_liff_function_name_backward_compats():
10+
for fname in ['liff.py', 'async_liff.py']:
11+
with open(f'linebot/v3/liff/api/{fname}', 'a') as fp:
12+
fp.write("\n\n")
13+
for (orig, cur) in [('liff_v1_apps_get', 'get_all_liff_apps'),
14+
('liff_v1_apps_get_with_http_info', 'get_all_liff_apps_with_http_info'),
15+
('liff_v1_apps_post', 'add_liff_app'),
16+
('liff_v1_apps_post_with_http_info', 'add_liff_app_with_http_info'),
17+
('liff_v1_apps_liff_id_put', 'update_liff_app'),
18+
('liff_v1_apps_liff_id_put_with_http_info', 'update_liff_app_with_http_info'),
19+
('liff_v1_apps_liff_id_delete', 'delete_liff_app'),
20+
('liff_v1_apps_liff_id_delete_with_http_info', 'delete_liff_app_with_http_info')]:
21+
fp.write(f"\n")
22+
fp.write(f" def {orig}(self, *args, **kwargs):\n")
23+
fp.write(f" import warnings\n")
24+
fp.write(f" warnings.warn('{orig} was deprecated. use {cur} instead.', DeprecationWarning)\n")
25+
fp.write(f" return self.{cur}(*args, **kwargs)\n")
26+
827
def main():
928

1029
os.chdir("generator")
@@ -68,5 +87,10 @@ def main():
6887
'''
6988
run_command(command)
7089

90+
91+
## TODO(v4): Delete this workaround in v4. This workaround keeps backward compatibility.
92+
rewrite_liff_function_name_backward_compats()
93+
94+
7195
if __name__ == "__main__":
7296
main()

line-openapi

0 commit comments

Comments
 (0)