27 def try_get_json(path: Path):
28 for coding in ["utf-8", "gbk"]:
29 try:
30 return json.loads(path.read_text(encoding=coding))
31 except Exception:
32 continue
33 return {}
34
35
125 elif path.is_dir():
126 # 移除 .git
127 if path.name == ".git":
128 if platform.system() == "darwin":
129 from subprocess import call
130 call(['rm', '-rf', path.as_posix()])
131 elif platform.system() == "Windows":
132 os.system(f'rd/s/q "{path.as_posix()}"')
126 # 移除 .git
127 if path.name == ".git":
128 if platform.system() == "darwin":
129 from subprocess import call
130 call(['rm', '-rf', path.as_posix()])
131 elif platform.system() == "Windows":
132 os.system(f'rd/s/q "{path.as_posix()}"')
133 return
126 # 移除 .git
127 if path.name == ".git":
128 if platform.system() == "darwin":
129 from subprocess import call
130 call(['rm', '-rf', path.as_posix()])
131 elif platform.system() == "Windows":
132 os.system(f'rd/s/q "{path.as_posix()}"')
133 return
128 if platform.system() == "darwin":
129 from subprocess import call
130 call(['rm', '-rf', path.as_posix()])
131 elif platform.system() == "Windows":
132 os.system(f'rd/s/q "{path.as_posix()}"')
133 return
134 for child in path.iterdir():
135 rmtree(child)