Skip to content

Commit

Permalink
Fix bug where install didn't have template files
Browse files Browse the repository at this point in the history
  • Loading branch information
autoelk committed Sep 30, 2023
1 parent 41ef6d1 commit ce5f113
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Asynchronously scrape the ArchChinese dictionary to generate [Anki](https://apps
# Installation

pip install ankichinese
playwright install

# Usage

Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ install_requires =
genanki
tqdm
requests
ankipandas

[options.package_data]
* = *.html, *.css, *.ttf

[options.packages.find]
where = src
Expand Down
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 9 additions & 5 deletions src/AnkiChinese/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ def gen_csv(results, output_name):
df.to_csv(output_name + ".csv", index=False, sep="\t")


def get_full_path(relative_path):
return os.path.join(os.path.dirname(__file__), relative_path)


def gen_model():
front_html = open("card_template/front.html", "r")
front_html = open(get_full_path("card_template/front.html"), "r")
front = front_html.read()
front_html.close()
back_html = open("card_template/back.html", "r")
back_html = open(get_full_path("card_template/back.html"), "r")
back = back_html.read()
back_html.close()
styles_css = open("card_template/styles.css", "r")
styles_css = open(get_full_path("card_template/styles.css"), "r")
styles = styles_css.read()
styles_css.close()

Expand All @@ -30,7 +34,7 @@ def gen_model():
{"name": "Definition"},
{"name": "Pinyin"},
{"name": "Pinyin 2"},
{"name": "Words"},
{"name": "Examples"},
{"name": "Formation"},
{"name": "HSK"},
{"name": "Audio"},
Expand Down Expand Up @@ -79,7 +83,7 @@ def gen_anki(results, output_name):

package = genanki.Package(deck)
add_audio(package, "ankichinese_audio")
package.media_files.append("card_template/_CNstrokeorder.ttf")
package.media_files.append(get_full_path("card_template/_CNstrokeorder.ttf"))
package.write_to_file(output_name + ".apkg")


Expand Down
4 changes: 4 additions & 0 deletions src/AnkiChinese/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import sys
import os.path

sys.path.insert(1, os.path.dirname(__file__))
import scraper
import export

Expand Down

0 comments on commit ce5f113

Please sign in to comment.