diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ed8ebf583f771da9150c35db3955987b7d757904 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/src/ebook/extract_book_code.py b/src/ebook/extract_book_code.py index f65d725b934205a7d40402d594758161f84d6d25..93573dfcfdb2aa588a1581bbfa564062bc329abd 100644 --- a/src/ebook/extract_book_code.py +++ b/src/ebook/extract_book_code.py @@ -16,8 +16,6 @@ def extract_code(): "全程软件测试(第3版)": "825acb73c85c4c4bb9632afe858bc097", } for book_idx, book_name in enumerate(book_mapping.keys()): - if book_name == 'Python编程无师自通': - continue book_dir_name = book_name book_dir = os.path.join('data', book_dir_name) if not os.path.exists(book_dir): @@ -70,7 +68,7 @@ def extract_code(): if section.find(r'/') != -1: section = section.replace('/', '') section_dir = os.path.join(chapter_dir, section) - print(section_dir) + # print(section_dir) if not os.path.exists(section_dir): os.mkdir(section_dir) section_dir_list.append(section_dir) @@ -80,8 +78,8 @@ def extract_code(): else: html_save_path = os.path.join( section_dir_list[idx - 1], 'text.html') - with open(html_save_path, 'w', encoding='utf-8') as f: - f.write(section_content) + # with open(html_save_path, 'w', encoding='utf-8') as f: + # f.write(section_content) code_list = re.findall(r'(.*?)', section_content, re.S) @@ -104,6 +102,7 @@ def extract_code(): section_dir_list[idx - 1], 'code_{}.java'.format(count)) + print(code_save_dir) print(res_str) with open(code_save_dir, 'w', encoding='utf-8') as f: f.write(res_str)