From 0f93b2ed5ec4fc94cd1d6e28183b119e93a88c66 Mon Sep 17 00:00:00 2001 From: ospalh Date: Wed, 17 Oct 2012 17:42:22 +0200 Subject: [PATCH] New round of clean-up: use flake8 --- Kanji stroke colour.py | 23 +++++++-------- Lean browser qa.py | 4 +-- Local CSS.py | 6 ++-- Nachschlagen.py | 3 +- One-sided cards.py | 2 +- Play with mpgNN.py | 8 ++++-- Play with sox.py | 1 + Play with vlc.py | 9 +++--- Quick replay.py | 19 ++++++------- Show colored stroke order diagram.py | 6 ++-- Small_add_cards.py | 3 +- dehashilator/__init__.py | 2 +- dehashilator/dehashilator.py | 13 ++++----- dehashilator/exists.py | 1 - dehashilator/kana_kanji.py | 2 +- dehashilator/progress.py | 2 +- dehashilator/romaji.py | 8 ++---- downloadaudio/blacklist.py | 4 +-- downloadaudio/conflanguage.py | 7 ++--- downloadaudio/download.py | 36 +++++++++++------------- downloadaudio/exists.py | 1 - downloadaudio/google_tts.py | 6 ++-- downloadaudio/japanesepod.py | 9 ++---- downloadaudio/language.py | 2 -- downloadaudio/process_audio.py | 9 +++--- downloadaudio/review_gui.py | 42 ++++++++++++++-------------- downloadaudio/update_gui.py | 14 ++++++---- 27 files changed, 115 insertions(+), 127 deletions(-) diff --git a/Kanji stroke colour.py b/Kanji stroke colour.py index bb6ab4b27..be5789bb1 100644 --- a/Kanji stroke colour.py +++ b/Kanji stroke colour.py @@ -4,7 +4,6 @@ # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import os -import sys from anki import hooks from aqt import mw @@ -37,8 +36,8 @@ def get_file_name(txt, colors='indexed'): """ Return the file name to a kanji svg. """ - fname = os.path.join(mw.addonManager.addonsFolder(),\ - strokeorder_basename + colors, txt + '.svg') + fname = os.path.join(mw.addonManager.addonsFolder(), + strokeorder_basename + colors, txt + '.svg') if os.path.exists(fname): return fname return u'' @@ -46,7 +45,7 @@ def get_file_name(txt, colors='indexed'): def kanji_stroke_color(txt, *args): """ - Replace the kanji with the SVG of the stroke order diagram. + Replace kanji with SVG For each han character in txt, try check if there is an svg to display and replace txt with this svg image. @@ -69,7 +68,7 @@ def kanji_stroke_color(txt, *args): def kanji_stroke_color_spectrum(txt, *args): """ - Replace the kanji with the SVG of the stroke order diagram. + Replace kanji with SVG For each han character in txt, try check if there is an svg to display and replace txt with this svg image. @@ -91,7 +90,7 @@ def kanji_stroke_color_spectrum(txt, *args): def kanji_stroke_color_contrast(txt, *args): """ - Replace the kanji with the SVG of the stroke order diagram. + Replace kanji with SVG For each han character in txt, try check if there is an svg to display and replace txt with this svg image. @@ -113,7 +112,7 @@ def kanji_stroke_color_contrast(txt, *args): def first_kanji_stroke_color(txt, *args): """ - Replace txt with the SVG of the stroke order diagram of the first character. + Replace txt with the SVG for the first character. This version uses files from the default position. Typically using the indexed color scheme. @@ -129,7 +128,7 @@ def first_kanji_stroke_color(txt, *args): def first_kanji_stroke_color_spectrum(txt, *args): """ - Replace txt with the SVG of the stroke order diagram of the first character. + Replace txt with SVG for the first character. This version uses files from the "spectrum" directory. """ @@ -144,7 +143,7 @@ def first_kanji_stroke_color_spectrum(txt, *args): def first_kanji_stroke_color_contrast(txt, *args): """ - Replace txt with the SVG of the stroke order diagram of the first character. + Replace txt with SVG for the the first character. This version uses files from the "contrast" directory. """ @@ -161,5 +160,7 @@ def first_kanji_stroke_color_contrast(txt, *args): hooks.addHook('fmod_kanjiColorContrast', kanji_stroke_color_contrast) hooks.addHook('fmod_kanjiColorSpectrum', kanji_stroke_color_spectrum) hooks.addHook('fmod_firstKanjiColor', first_kanji_stroke_color) -hooks.addHook('fmod_firstKanjiColorContrast', first_kanji_stroke_color_contrast) -hooks.addHook('fmod_firstKanjiColorSpectrum', first_kanji_stroke_color_spectrum) +hooks.addHook('fmod_firstKanjiColorContrast', + first_kanji_stroke_color_contrast) +hooks.addHook('fmod_firstKanjiColorSpectrum', + first_kanji_stroke_color_spectrum) diff --git a/Lean browser qa.py b/Lean browser qa.py index 3f64ff966..f99b4c729 100644 --- a/Lean browser qa.py +++ b/Lean browser qa.py @@ -16,8 +16,8 @@ def reduce_format_qa(self, text): soup = BeautifulSoup(text) - for hide in soup.findAll(True, - {'class': re.compile('\\b' + hide_class_name + '\\b')}): + for hide in soup.findAll(True, {'class': re.compile( + '\\b' + hide_class_name + '\\b')}): hide.extract() return old_format_qa(self, unicode(soup)) diff --git a/Local CSS.py b/Local CSS.py index af7014858..224cc690f 100644 --- a/Local CSS.py +++ b/Local CSS.py @@ -8,10 +8,10 @@ import os import re -from anki.cards import Card -from anki.consts import * +from anki.cards import Card +from anki.consts import MODEL_STD from anki import hooks -from aqt import utils, mw +from aqt import mw """ Load local CSS and add it to the cards. diff --git a/Nachschlagen.py b/Nachschlagen.py index b66d4d98e..83267d0d4 100644 --- a/Nachschlagen.py +++ b/Nachschlagen.py @@ -10,9 +10,8 @@ # Original author: Damien Elmes import urllib -import re from aqt import mw -from aqt.qt import * +from aqt.qt import QDesktopServices, QUrl, QMenu, QAction, SIGNAL from aqt.utils import showInfo from aqt.webview import QWebPage diff --git a/One-sided cards.py b/One-sided cards.py index f4504b013..44bd58a5d 100644 --- a/One-sided cards.py +++ b/One-sided cards.py @@ -6,7 +6,7 @@ from aqt import mw -from anki.consts import * +from anki.consts import MODEL_STD from anki.hooks import addHook __version__ = "1.0.1" diff --git a/Play with mpgNN.py b/Play with mpgNN.py index 5fe12e7f1..aee0ee024 100644 --- a/Play with mpgNN.py +++ b/Play with mpgNN.py @@ -13,6 +13,7 @@ from anki import sound from anki.hooks import addHook +from aqt import utils __version__ = "1.0.1" @@ -64,9 +65,10 @@ def playSomeSoundsWithMpg(path): os.remove(tname) else: try: - subprocess.Popen([mpgBaseName, "-q", "-b 4m", "--stereo", path], - shell=False, stdin=None, stdout=None, - stderr=None, close_fds=True) + subprocess.Popen( + [mpgBaseName, "-q", "-b 4m", "--stereo", path], + shell=False, stdin=None, stdout=None, stderr=None, + close_fds=True) except OSError: # On Macs, we get ‘Interruppted system call’s. Just # ignore, like anki’s sound module does. diff --git a/Play with sox.py b/Play with sox.py index 763de1349..a71c8cf43 100644 --- a/Play with sox.py +++ b/Play with sox.py @@ -13,6 +13,7 @@ from anki import sound from anki.hooks import addHook +from aqt import utils ## Just play flac, ogg, vorbis with sox: fileFormatsToSox = ['.ogg', '.flac', '.vorbis'] diff --git a/Play with vlc.py b/Play with vlc.py index 9ca033867..80e49a773 100644 --- a/Play with vlc.py +++ b/Play with vlc.py @@ -10,7 +10,6 @@ import re import subprocess import sys -import tempfile from anki.sound import playFromText, play from aqt import utils, reviewer @@ -85,12 +84,12 @@ def find_vlc(): global command_list if command_list: if sys.platform.startswith("win32"): - mp3_command_list[0] += '.exe' + command_list[0] += '.exe' if not which(command_list[0]): # Complain, - utils.showWarning(u'Replay with vlc add-on: Could not find {} '\ - 'in path. Please download and install it.' - .format(command_list[0])) + warn_string = u'Replay with vlc add-on: Could not find {} ' \ + + u'in path. Please download and install it.' + utils.showWarning(warn_string.format(command_list[0])) # and clear the list command_list = None diff --git a/Quick replay.py b/Quick replay.py index 9199ce451..851ce3db6 100644 --- a/Quick replay.py +++ b/Quick replay.py @@ -10,7 +10,6 @@ import re import subprocess import sys -import tempfile from anki.sound import playFromText, play from aqt import utils, reviewer @@ -41,9 +40,9 @@ def patched_play_from_text(text): return # The same for ogg and flac if play_command_list: - play_files = [pf for pf in matches \ - for ending in play_endings_list \ - if pf.lower().endswith(ending)] + play_files = [pf for pf in matches + for ending in play_endings_list + if pf.lower().endswith(ending)] if len(play_files) == len(matches): play_with_play(play_files) return @@ -112,9 +111,9 @@ def fix_commands(): mp3_command_list[0] += '.exe' if not which(mp3_command_list[0]): # Complain, - utils.showWarning(u'Quick replay add-on: Could not find {} '\ - 'in path. Please download and install it.' - .format(mp3_command_list[0])) + warn_string = u'Quick replay add-on: Could not find {} '\ + + u'in path. Please download and install it.' + utils.showWarning(warn_string.format(mp3_command_list[0])) # and clear the list mp3_command_list = None if play_command_list: @@ -122,9 +121,9 @@ def fix_commands(): play_command_list[0] += '.exe' if not which(play_command_list[0]): # Complain, - utils.showWarning(u'Quick replay add-on:: Could not find {} '\ - 'in path. Please download and install it.' - .format(play_command_list[0])) + warn_string = u'Quick replay add-on:: Could not find {} ' \ + + u'in path. Please download and install it.' + utils.showWarning(warn_string .format(play_command_list[0])) # and clear the list play_command_list = None diff --git a/Show colored stroke order diagram.py b/Show colored stroke order diagram.py index fce114124..cc3c51e46 100644 --- a/Show colored stroke order diagram.py +++ b/Show colored stroke order diagram.py @@ -14,9 +14,9 @@ # * Attribution. You must attribute the work by stating your use of KanjiVG in # your own copyright header and linking to KanjiVG's website # (http://kanjivg.tagaini.net) -# * Share Alike. If you alter, transform, or build upon this work, you may -# distribute the resulting work only under the same or similar license to this -# one. +# * Share Alike. If you alter, transform, or build upon this work, you +# may distribute the resulting work only under the same or similar +# license to this one. # # See http://creativecommons.org/licenses/by-sa/3.0/ for more details. # This file has been generated on 2012-04-01, using the latest KanjiVG data diff --git a/Small_add_cards.py b/Small_add_cards.py index 230a9e6a5..6b8b9a9ba 100644 --- a/Small_add_cards.py +++ b/Small_add_cards.py @@ -8,7 +8,8 @@ from anki.hooks import wrap from aqt.addcards import AddCards -from aqt.qt import * +from aqt.qt import QDialogButtonBox, QWidgetItem, SIGNAL +from aqt.lang import _ __version__ = '1.0.1' diff --git a/dehashilator/__init__.py b/dehashilator/__init__.py index 05cc479e8..682e69eba 100644 --- a/dehashilator/__init__.py +++ b/dehashilator/__init__.py @@ -18,7 +18,7 @@ from dehashilator import test_and_dehashilate from progress import progress from exists import exists_lc -from romaji import * +from romaji import roma, html, kana __version__ = '1.0.0b5' __all__ = ['test_and_dehashilate', 'progress', 'roma', 'html', 'kana', diff --git a/dehashilator/dehashilator.py b/dehashilator/dehashilator.py index e57be79ad..d514b1871 100644 --- a/dehashilator/dehashilator.py +++ b/dehashilator/dehashilator.py @@ -12,7 +12,6 @@ import os import re -import shutil import romaji import kana_kanji @@ -20,9 +19,9 @@ from progress import progress from aqt import mw -from aqt.qt import * from aqt.utils import showInfo, showText, askUser -from anki.utils import ids2str, stripHTML +from anki.utils import stripHTML +from aqt.lang import _ name_source_fields = ['SequenceMarker', 'Reading', 'Expression', 'Kanji'] @@ -123,7 +122,7 @@ def find_field(note, old_base): # is the one with the file. (Almost reasonable. One-side cards to # just listen to something and decide without further info if you # recoginze that.) - raise ValueError(u'No data for new name found') + raise ValueError(_(u'No data for new name found')) def free_media_name(base, end): @@ -251,8 +250,8 @@ def dehashilate(): try: os.rename(src, dst) except OSError: - print 'src: ', src - print 'dst: ', dst + print u'Problem movivg {0} → {1}\n'.format(src, dst) + bad_mv_text += u'{0} → {1}\n'.format(src, dst) else: new_names_dict[old_name] = new_name n[name] = value.replace(old_name, new_name) @@ -275,4 +274,4 @@ def dehashilate(): # mw.col.updateFieldCache([re_dict[nids] for re_dict in rename_exec_list]) mw.reset() if bad_mv_text: - showText('These files weren’t renamed:\n' + test_string) + showText(_(u'These files weren’t renamed:\n') + bad_mv_text) diff --git a/dehashilator/exists.py b/dehashilator/exists.py index b69f9e5a0..fc9a5d2c5 100644 --- a/dehashilator/exists.py +++ b/dehashilator/exists.py @@ -5,7 +5,6 @@ # import os -import sys from anki.utils import isWin, isMac diff --git a/dehashilator/kana_kanji.py b/dehashilator/kana_kanji.py index 9c6a604f4..5fd639b7e 100644 --- a/dehashilator/kana_kanji.py +++ b/dehashilator/kana_kanji.py @@ -36,5 +36,5 @@ def kanji(txt, *args): def kana(txt, *args): """Return the kana of a standard kakasi reading.""" if too_old: - return re.sub(r, no_sound(r'\g'), txt) + return re.sub(split_pat, no_sound(r'\g'), txt) return re.sub(split_pat, no_sound(r'\g'), txt, flags=re.UNICODE) diff --git a/dehashilator/progress.py b/dehashilator/progress.py index 6574ff823..b2607f8c2 100644 --- a/dehashilator/progress.py +++ b/dehashilator/progress.py @@ -12,7 +12,7 @@ instead of iterator. That’s pretty much it. ''' -from aqt.qt import * +from aqt.qt import QProgressDialog, QCoreApplication def progress(data, *args): diff --git a/dehashilator/romaji.py b/dehashilator/romaji.py index aa9df7871..1a179fe9a 100755 --- a/dehashilator/romaji.py +++ b/dehashilator/romaji.py @@ -41,10 +41,8 @@ import random -import unicodedata -from unicodedata import * +import unicodedata import re -from re import * _roma = {} _kana = {} @@ -101,7 +99,7 @@ def _setup(): for point in range(0x3040, 0x30FF): char = unichr(point) for pattern in [regular, chiisai]: - match = pattern.match(name(char, '')) + match = pattern.match(unicodedata.name(char, '')) if match: syllable = match.group(3) for fix in _irregular: @@ -220,7 +218,7 @@ def gyou(g, family=None, kanaify=False, rare=False): roman = _gyou[g] if not rare: roman = [x for x in roman if not x in - set(['wi', 'WI', 'we', 'WE'])] + set(['wi', 'WI', 'we', 'WE'])] if kanaify: return tuple([kana(x) for x in roman]) return tuple(roman) diff --git a/downloadaudio/blacklist.py b/downloadaudio/blacklist.py index 8128ad41e..f63d8cd41 100644 --- a/downloadaudio/blacklist.py +++ b/downloadaudio/blacklist.py @@ -39,8 +39,8 @@ def get_hash(file_name): load_hashes() retrieved_hash = hashlib.sha256(file(file_name, 'r').read()) if retrieved_hash.hexdigest() in blacklist_hashes: - raise ValueError('Retrieved file is in blacklist. ' +\ - '(No pronunciation found.)') + raise ValueError('Retrieved file is in blacklist. ' + + '(No pronunciation found.)') return retrieved_hash diff --git a/downloadaudio/conflanguage.py b/downloadaudio/conflanguage.py index 28f14eeeb..ba4b8ed3a 100644 --- a/downloadaudio/conflanguage.py +++ b/downloadaudio/conflanguage.py @@ -4,12 +4,11 @@ # Copyright © 2012 Roland Sieker, # License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html -from aqt import mw -from aqt.reviewer import Reviewer from aqt.deckconf import DeckConf from aqt.forms import dconf -from anki.hooks import addHook, wrap -from aqt.qt import * +from anki.hooks import wrap +from aqt.qt import QHBoxLayout, QLabel, QLineEdit +from aqt.lang import _ from language import default_audio_language_code, al_code_code diff --git a/downloadaudio/download.py b/downloadaudio/download.py index 33ec7527c..9ef99476c 100644 --- a/downloadaudio/download.py +++ b/downloadaudio/download.py @@ -8,14 +8,10 @@ import os from aqt import mw from aqt.utils import tooltip -from aqt.qt import * - -#from anki.cards import Card -#from anki.notes import Note -from anki.hooks import addHook +from aqt.qt import QAction, QIcon, SIGNAL from google_tts import get_word_from_google -from japanesepod import get_word_from_jpod +from japanesepod import get_word_from_jpod from review_gui import store_or_blacklist from update_gui import update_data from language import get_language_code @@ -33,8 +29,10 @@ name suggests, these are only Japanese words. The pronunciations that are there are rather high-quality, though. -Google TTS: Get pronunciations from the Google Text-To-Speech service. These are - robot voices, so be a bit suspicous about them. + +Google TTS: Get pronunciations from the Google Text-To-Speech + service. These are robot voices, so be a bit suspicous + about them. There are three ways to download: Current card, current note and manual. @@ -327,25 +325,25 @@ def download_on(): mw.note_download_action = QAction(mw) mw.note_download_action.setText(u"Note audio") mw.note_download_action.setIcon(QIcon(os.path.join(icons_dir, - 'download_note_audio.png'))) -mw.note_download_action.setToolTip("Download audio for all audio fields " + \ - "of this note.") + 'download_note_audio.png'))) +mw.note_download_action.setToolTip( + "Download audio for all audio fields of this note.") mw.connect(mw.note_download_action, SIGNAL("triggered()"), download_for_note) mw.side_download_action = QAction(mw) mw.side_download_action.setText(u"Side audio") -mw.side_download_action.setIcon(QIcon(os.path.join(icons_dir, - 'download_side_audio.png'))) -mw.side_download_action.setToolTip("Download audio for audio fields " + \ - "currently visible.") +mw.side_download_action.setIcon( + QIcon(os.path.join(icons_dir, 'download_side_audio.png'))) +mw.side_download_action.setToolTip( + "Download audio for audio fields currently visible.") mw.connect(mw.side_download_action, SIGNAL("triggered()"), download_for_side) mw.manual_download_action = QAction(mw) mw.manual_download_action.setText(u"Manual audio") -mw.manual_download_action.setIcon(QIcon(os.path.join(icons_dir, - 'download_audio_manual.png'))) -mw.manual_download_action.setToolTip("Download audio, " + \ - "editing the information first.") +mw.manual_download_action.setIcon( + QIcon(os.path.join(icons_dir, 'download_audio_manual.png'))) +mw.manual_download_action.setToolTip( + "Download audio, editing the information first.") mw.connect(mw.manual_download_action, SIGNAL("triggered()"), download_manual) diff --git a/downloadaudio/exists.py b/downloadaudio/exists.py index 0ed4de690..b960a3726 100644 --- a/downloadaudio/exists.py +++ b/downloadaudio/exists.py @@ -6,7 +6,6 @@ import os import re -import sys from aqt import mw from anki.utils import isWin, isMac, stripHTML diff --git a/downloadaudio/google_tts.py b/downloadaudio/google_tts.py index 9d9ea6cfb..62f943392 100644 --- a/downloadaudio/google_tts.py +++ b/downloadaudio/google_tts.py @@ -15,12 +15,10 @@ import urllib2 import os -from aqt import mw from process_audio import process_audio, unmunge_to_mediafile from blacklist import get_hash -from exists import free_media_name - +from language import default_audio_language_code download_file_extension = u'.mp3' @@ -65,7 +63,7 @@ def get_word_from_google(source, language=None): def build_query_url(source, language=None): qdict = {} if not language: - language = default_language + language = default_audio_language_code qdict['tl'] = language.encode('utf-8') qdict['q'] = source.encode('utf-8') return url_gtts + urllib.urlencode(qdict) diff --git a/downloadaudio/japanesepod.py b/downloadaudio/japanesepod.py index 7df7cb13a..f020c95d6 100644 --- a/downloadaudio/japanesepod.py +++ b/downloadaudio/japanesepod.py @@ -16,18 +16,13 @@ import urllib2 import os -from aqt import mw - from process_audio import process_audio, unmunge_to_mediafile from blacklist import get_hash -from exists import free_media_name - download_file_extension = u'.mp3' - -url_jdict = 'http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?' -# url_jdict='http://assets.languagepod101.com/dictionary/japanese/audioogg.php?' +url_jdict = \ + 'http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?' # Code diff --git a/downloadaudio/language.py b/downloadaudio/language.py index 3a88b4f49..95a50b8e7 100644 --- a/downloadaudio/language.py +++ b/downloadaudio/language.py @@ -5,9 +5,7 @@ # License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html import re -import os from aqt import mw -from anki.cards import Card ## Set the two-letter language code for the language you are learning diff --git a/downloadaudio/process_audio.py b/downloadaudio/process_audio.py index bb43345f7..d89474ac8 100644 --- a/downloadaudio/process_audio.py +++ b/downloadaudio/process_audio.py @@ -90,15 +90,16 @@ def process_audio(temp_file_name, base_name, suffix, sox_signal.set_param(channels=2) sox_out_file = pysox.CSoxStream(temp_out_file_name, 'w', sox_signal) sox_chain = pysox.CEffectsChain(sox_in_file, sox_out_file) - sox_chain.add_effect(pysox.CEffect( - 'silence', [b'1', b'0', '{}%'.format(silence_percent)])) + sox_chain.add_effect( + pysox.CEffect('silence', [b'1', b'0', '{}%'.format(silence_percent)])) # Trick: to automatically remove silence at the end, reverse, # remove at the front and reverse. sox_chain.add_effect(pysox.CEffect('reverse', [])) if not silence_end_percent: silence_end_percent = silence_percent - sox_chain.add_effect(pysox.CEffect( - 'silence', [b'1', b'0', '{}%'.format(silence_end_percent)])) + sox_chain.add_effect( + pysox.CEffect('silence', + [b'1', b'0', '{}%'.format(silence_end_percent)])) sox_chain.add_effect(pysox.CEffect('reverse', [])) sox_chain.add_effect(pysox.CEffect('gain', [b'-n'])) if 1 == in_channels: diff --git a/downloadaudio/review_gui.py b/downloadaudio/review_gui.py index 1e2e1ad96..20991511c 100644 --- a/downloadaudio/review_gui.py +++ b/downloadaudio/review_gui.py @@ -25,7 +25,8 @@ from blacklist import add_black_hash -from aqt.qt import * +from aqt.qt import QGridLayout, QLabel, QDialog, QDialogButtonBox, \ + QPushButton, QIcon, SIGNAL, SLOT, QButtonGroup icons_dir = os.path.join(mw.pm.addonFolder(), 'downloadaudio', 'icons') @@ -72,31 +73,30 @@ def __init__(self, note, files_list): self.list = files_list super(ReviewFiles, self).__init__() # Cut-and-pasted self.buttons_groups = [] - self.text_help = u"Text used to retrieve audio.
" + \ - u"(Mouse over the texts below to see further information." + self.text_help = u"""Text used to retrieve audio.
+(Mouse over the texts below to see further information.""" self.play_help = u"Play the retrieved file." - self.play_old_help = u"

Play the current content of the audio field." + \ - u" No button means the field is empty. " + \ - u"Hovering over the button shows the current field contetn as text." + self.play_old_help = u"""

Play the current content of the + audio field. No button means the field is empty. Hovering over the + button shows the current field contetn as text.""" self.play_old_empty_line_help = u"The target field is empty." - self.add_help_text_long = u"Add the sound to the card.
" + \ - u"This is the normal thing to select for a good download. " + \ - u"(But you may want to select only one file in this column.)" + self.add_help_text_long = u"""Add the sound to the +card.
This is the normal thing to select for a good download. (But +you may want to select only one file in this column.)""" self.add_help_text_short = u"Add this sound to the card" - self.keep_help_text_long = u"Keep the file.
" + \ - u"Keep this file in the media collection folder, but don’t add " + \ - u"it to the card. (This means the file will show up as an " + \ - u"unused medium and may be deleted during the unused media check." + self.keep_help_text_long = u"""Keep the file.
Keep this +file in the media collection folder, but don’t add it to the +card. (This means the file will show up as an unused medium and may be +deleted during the unused media check.""" self.keep_help_text_short = u"Keep this file" - self.delete_help_text_long = u"Delete the file.
" + \ - u"This is the normal thing to do with a file you don’t like." + self.delete_help_text_long = u"""Delete the file.
+This is the normal thing to do with a file you don’t like.""" self.delete_help_text_short = u"Delete this file" - self.blacklist_help_text_long = u"Blacklist the file.
" + \ - u"Add an idetifier for this file to a blacklist. When this " + \ - u"file is downloaded again, it will be silently dropped. This " + \ - u"behaviour is useful for Japanesepod downloads. " + \ - u"When your downloaded file tells you that they they are sorry, " +\ - u"will add this soon &c., click on this." + self.blacklist_help_text_long = u"""Blacklist the file.
+Add an idetifier for this file to a blacklist. When this file is +downloaded again, it will be silently dropped. This behaviour is +useful for Japanesepod downloads. When your downloaded file tells you +that they they are sorry, will add this soon &c., click on this.""" self.blacklist_help_text_short = u"Blacklist this file" self.initUI() diff --git a/downloadaudio/update_gui.py b/downloadaudio/update_gui.py index 1caf57bcd..c3c15c3ad 100644 --- a/downloadaudio/update_gui.py +++ b/downloadaudio/update_gui.py @@ -4,8 +4,8 @@ # Copyright © 2012 Roland Sieker, # License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html -from aqt.qt import * -from aqt import mw +from aqt.qt import QGridLayout, QLabel, QLineEdit, QDialog,\ + QIcon, QHBoxLayout, QVBoxLayout, SLOT, QDialogButtonBox, SIGNAL from language import default_audio_language_code """ @@ -20,9 +20,10 @@ def update_data(general_fields, japanese_fields, language_code): if not review_fields.exec_(): raise RuntimeError('User cancel') for num, (source, dest, old_text) in enumerate(general_fields): - general_fields[num] = (source, dest, - review_fields.general_text_lineedits[num].text()) - for num, (source, dest, old_kanji, old_kana) in enumerate(japanese_fields): + general_fields[num] = ( + source, dest, review_fields.general_text_lineedits[num].text()) + for num, (source, dest, old_kanji, old_kana) \ + in enumerate(japanese_fields): japanese_fields[num] = (source, dest, review_fields.kanji_lineedits[num].text(), review_fields.kana_lineedits[num].text()) @@ -104,7 +105,8 @@ def create_japanese_rows(self, layout): jpod_head_label = QLabel( u'Requests send to Japanesepod, split into kanji and kana:') jf_layout.addWidget(jpod_head_label, 0, 0, 1, 3) - for num, (source, dest, kanji, kana) in enumerate(self.japanese_fields): + for num, (source, dest, kanji, kana)\ + in enumerate(self.japanese_fields): label = QLabel(u'{0}:'.format(source)) label.setToolTip(u'Source of the request text') jf_layout.addWidget(label, num + 1, 0)