-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathfield_data.py
44 lines (37 loc) · 1.27 KB
/
field_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- mode: python ; coding: utf-8 -*-
#
# Copyright © 2015 Roland Sieker <[email protected]>
#
# License: GNU AGPL, version 3 or later;
# http://www.gnu.org/copyleft/agpl.html
"""
Two classes to store information for the downloader
"""
#
from anki.sound import stripSounds
from anki.template import furigana
from anki.utils import stripHTML
# Apparently some people use a 「・」 between the kana for different
# kanji. Make it easier to switch removing them for the downloads on
# or off
strip_interpunct = False
# Do or do not remove katakana interpuncts 「・」 before sending requests.
class FieldData(object):
def __init__(self, w_field, a_field, word):
self.word_field_name = w_field
self.audio_field_name = a_field
# This is taken from aqt/browser.py.
self.word = word.replace('<br>', ' ')
self.word = self.word.replace('<br />', ' ')
if strip_interpunct:
self.word = self.word.replace('・', '')
# self.word = stripHTML(self.word)
# self.word = stripSounds(self.word)
# Reformat so we have exactly one space between words.
self.word = ' '.join(self.word.split())
@property
def empty(self):
return not self.word
@property
def split(self):
return False