Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Merge 1948288 into 43d0da2
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrich committed Dec 13, 2019
2 parents 43d0da2 + 1948288 commit 877682b
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 4 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,28 @@ prep:

pack:
(cd "$(PROJECT_SHORT)" && zip -r ../$(PROJECT_LONG)-v$(VERSION).zip *)
(cd "$(PROJECT_SHORT)" && zip -r ../package.zip *)
./convert-readme.py

OS := $(shell uname)
ifeq ($(OS),Darwin)
ANKI_PATH = ${HOME}/Library/Application Support/Anki2/addons21/chinese-support-redux
endif
ifeq ($(OS),Linux)
ANKI_PATH = ${HOME}/.local/share/Anki2/addons21/chinese-support-redux
endif


# installs into local anki for testing.
install:
rm -rf package
mkdir package
cp package.zip package
cd package && unzip package.zip
rm package/package.zip
rm -rf "${ANKI_PATH}"
cp -r package "${ANKI_PATH}"

clean:
rm "$(PROJECT_SHORT)/LICENSE.txt"
mv meta.json "$(PROJECT_SHORT)/meta.json"
Expand Down
16 changes: 16 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
coverage = ">=4.5.3"
hypothesis = ">=4.11.6"
pytest-cov = ">=2.6.1"
pytest = ">=4.3.1"
markdown2 = "*"

[requires]
python_version = "3.6"
169 changes: 169 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="https://app.codacy.com/app/luoliyan/chinese-support-redux?utm_source=github.com&utm_medium=referral&utm_content=luoliyan/chinese-support-redux&utm_campaign=Badge_Grade_Dashboard"><img src="https://api.codacy.com/project/badge/Grade/6b99fcb30a2142d899f79c601a6aa291" alt="Codacy Badge" /></a><a href="https://travis-ci.org/luoliyan/chinese-support-redux"><img src="https://travis-ci.org/luoliyan/chinese-support-redux.svg?branch=master" alt="Build Status" /></a> <a href="https://coveralls.io/github/luoliyan/chinese-support-redux?branch=master"><img src="https://coveralls.io/repos/github/luoliyan/chinese-support-redux/badge.svg?branch=master" alt="Coverage Status" /></a>
<a href="https://app.codacy.com/app/luoliyan/chinese-support-redux?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=luoliyan/chinese-support-redux&amp;utm_campaign=Badge_Grade_Dashboard"><img src="https://api.codacy.com/project/badge/Grade/6b99fcb30a2142d899f79c601a6aa291" alt="Codacy Badge" /></a><a href="https://travis-ci.org/luoliyan/chinese-support-redux"><img src="https://travis-ci.org/luoliyan/chinese-support-redux.svg?branch=master" alt="Build Status" /></a> <a href="https://coveralls.io/github/luoliyan/chinese-support-redux?branch=master"><img src="https://coveralls.io/repos/github/luoliyan/chinese-support-redux/badge.svg?branch=master" alt="Coverage Status" /></a>


Chinese Support Redux is a rewrite and port of the <a href="https://github.com/ttempe/chinese-support-addon">original</a> Chinese Support add-on to Anki 2.1. It offers a number of features that streamline the process of creating flashcards for learning Chinese. The current focus of development effort is on improving the stability of the add-on and the accuracy of its output. Once the core functionality is sufficiently robust and reliable, additional features will be considered. While many of the changes will be structural in nature, I would encourage users to update the add-on whenever the version number increases and notify me of any problems. Your feedback is important.
Expand Down Expand Up @@ -45,12 +45,12 @@

Clone the repository:

<code>git clone https://github.com/luoliyan/chinese-support-reduxcd chinese-support-redux</code>
<code>shgit clone https://github.com/luoliyan/chinese-support-reduxcd chinese-support-redux</code>

Ideally, set up a virtual environment to isolate the project:

<code>curl https://pyenv.run | bashpyenv virtualenv 3.6.8 csrpyenv local csr</code>
<code>shcurl https://pyenv.run | bashpyenv virtualenv 3.6.8 csrpyenv local csr</code>

Install dependencies and run the tests:

<code>pip install -r requirements.txtmake test</code>
<code>shpip install -r requirements.txtmake test</code>
55 changes: 55 additions & 0 deletions chinese/fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
fill_sound,
fill_trad,
fill_transcript,
update_fields,
)
from .hanzi import get_hanzi
from .main import config
Expand Down Expand Up @@ -318,6 +319,60 @@ def bulk_fill_classifiers():
)


def bulk_fill_all_missing():
"""
This assumes that at least the hanzi field is present. Everything else
can be built from that. We don't replace fields already present so that
we don't blap def'n that people have put in.
"""
prompt = PROMPT_TEMPLATE.format(
field_names='<i>hanzi</i>',
extra_info=(
'<div>There will be a 5 second delay between each sound request,'
' so this may take a while.</div>'
),
)


fields = config.get_fields(['traditional', 'simplified'])

if not askUser(prompt):
return

d_has_fields = 0
d_success = 0

note_ids = Finder(mw.col).findNotes('deck:current')
mw.progress.start(immediate=True, min=0, max=len(note_ids))

for i, nid in enumerate(note_ids):
note = mw.col.getNote(nid)
copy = dict(note)

# assume all get updated. improves this later
allFields = mw.col.models.fieldNames(note.model())
if not allFields:
assert 2 == 3
update_fields(note, "Hanzi", allFields)
msg = '''
<b>Processing:</b> %(hanzi)s<br>
<b>Updated:</b> %(filled)d''' % {
'hanzi': get_hanzi(copy),
'filled': d_success,
}
mw.progress.update(label=msg, value=i)
note.flush()
#sleep(1)

msg = '''
<b>Update complete!</b> %(hanzi)s<br>
<b>Updated:</b> %(filled)d notes''' % {
'hanzi': get_hanzi(copy),
'filled': d_success,
}
mw.progress.finish()
showInfo(msg)

def bulk_fill_hanzi():
prompt = PROMPT_TEMPLATE.format(field_names='<i>hanzi</i>', extra_info='')

Expand Down
2 changes: 2 additions & 0 deletions chinese/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
bulk_fill_classifiers,
bulk_fill_defs,
bulk_fill_hanzi,
bulk_fill_all_missing,
bulk_fill_transcript,
bulk_fill_silhouette,
bulk_fill_sound,
Expand Down Expand Up @@ -72,6 +73,7 @@ def load_menu():

add_menu('Chinese::Bulk Fill')
add_menu_item('Chinese::Bulk Fill', _('Hanzi'), bulk_fill_hanzi)
add_menu_item('Chinese::Bulk Fill', _('All'), bulk_fill_all_missing)
add_menu_item(
'Chinese::Bulk Fill', _('Transcription'), bulk_fill_transcript
)
Expand Down

0 comments on commit 877682b

Please sign in to comment.