mirror of
https://kkgithub.com/chinese-poetry/chinese-poetry.git
synced 2026-04-13 00:47:18 +00:00
修改为中文目录
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
.pyenv
|
||||||
BIN
__pycache__/test_poetry.cpython-311-pytest-7.3.1.pyc
Normal file
BIN
__pycache__/test_poetry.cpython-311-pytest-7.3.1.pyc
Normal file
Binary file not shown.
@@ -5,46 +5,43 @@ import sys
|
|||||||
import traceback
|
import traceback
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
namespace = locals()
|
||||||
|
|
||||||
|
|
||||||
def check_json(f, _dir):
|
def check_json(f, _dir):
|
||||||
|
filepath = os.path.join(_dir, f)
|
||||||
|
|
||||||
|
if os.path.isdir(filepath):
|
||||||
|
[check_json(f, filepath) for f in os.listdir(filepath)]
|
||||||
|
|
||||||
if not f.endswith('.json'):
|
if not f.endswith('.json'):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
filepath = os.path.join(_dir, f)
|
|
||||||
with open(filepath) as file:
|
with open(filepath) as file:
|
||||||
try:
|
try:
|
||||||
_ = json.loads(file.read())
|
_ = json.loads(file.read())
|
||||||
sys.stdout.write(f"{filepath} 校验成功")
|
sys.stdout.write(f"{filepath} 校验成功")
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception as e:
|
||||||
sys.stderr.write(traceback.format_exc())
|
sys.stderr.write(traceback.format_exc())
|
||||||
assert False, f"{filepath} 校验失败"
|
print(dir(e))
|
||||||
|
assert False, f"{filepath} 校验失败, {e}"
|
||||||
|
|
||||||
|
|
||||||
def __check_path__(path):
|
def check_path(path):
|
||||||
"""校验 指定目录 中的 json 文件"""
|
"""校验 指定目录 中的 json 文件"""
|
||||||
[ check_json(f, path) for f in os.listdir(path) ]
|
[check_json(f, path) for f in os.listdir(path)]
|
||||||
|
|
||||||
|
|
||||||
test_shi = functools.partial(__check_path__, './json')
|
def is_book_directory(book):
|
||||||
|
if not os.path.isdir(book):
|
||||||
|
return False
|
||||||
|
|
||||||
test_ci = functools.partial(__check_path__, './ci')
|
for i in book:
|
||||||
|
if i > u'\u4e00' and i < u'\u9fff':
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
test_shijing = functools.partial(__check_path__, './shijing')
|
|
||||||
|
|
||||||
test_lunyu = functools.partial(__check_path__, './lunyu')
|
|
||||||
|
|
||||||
test_huajianji = functools.partial(__check_path__, u'./wudai/huajianji/')
|
|
||||||
|
|
||||||
test_nantang2 = functools.partial(__check_path__, u'./wudai/nantang/')
|
|
||||||
|
|
||||||
test_youmengying = functools.partial(__check_path__, u'./youmengying/')
|
|
||||||
|
|
||||||
test_sishuwujing = functools.partial(__check_path__, u'./sishuwujing/')
|
|
||||||
|
|
||||||
test_yuanqu = functools.partial(__check_path__, u'./yuanqu/')
|
|
||||||
|
|
||||||
test_mengxue = functools.partial(__check_path__, u'./mengxue')
|
|
||||||
|
|
||||||
caocaoshiji = functools.partial(__check_path__, u'./caocaoshiji')
|
|
||||||
|
|
||||||
|
for path in [i for i in os.listdir('.') if is_book_directory(i)]:
|
||||||
|
namespace[f'test_{path}'] = functools.partial(check_path, f'{path}')
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user