def addKDStories(nids):
	readStories()
	
	
	fields = []
	
	anote=mw.col.getNote(nids[0])
	#get the fields of the first note
	for (i, f) in anote.items():
		fields.append(i)
	
	#get input/output fields from user
	expField = addinfofuncts.getKeyFromList("Select field to read from", "Read relevant kanji/expression from:", fields)
	if (expField is None):
		return
	
	compoundMeaning = addinfofuncts.getKeyFromList("Select field to write to", "Write compound information to:", fields)
	if (compoundMeaning is None):
		return 
	
	Mnemonic = addinfofuncts.getKeyFromList("Select field to write to", "Write Mnemonic to:", fields)
	if (Mnemonic is None):
		return 
	
	EngMeaning = addinfofuncts.getKeyFromList("Select field to write to", "Write English meanings to:", fields)
	if (EngMeaning  is None):
		return 
	
	mw.checkpoint("Add KD Stories")
	mw.progress.start()
	#For each seleccted card
	for nid in nids:
		note = mw.col.getNote(nid)
		srcTxt = mw.col.media.strip(note[expField])
		if not srcTxt.strip():
			continue
		
		#Add the data to the dst field
		
		kanjizz = extractKanji(note[expField])
		if kanjiIndex.get(kanjizz):
			if kanjiIndex[kanjizz]['compound']:
				note[compoundMeaning] = kanjiIndex[kanjizz]['compound'].decode('utf8')
			else:
				note[compoundMeaning] = ""
				
				
			if kanjiIndex[kanjizz]['eng2meaning']:
				note[Mnemonic] = kanjiIndex[kanjizz]['eng2meaning'].decode('utf8')
			else:
				note[Mnemonic] = ""
				
				
			if kanjiIndex[kanjizz]['engmeaning']:
				note[EngMeaning] = kanjiIndex[kanjizz]['engmeaning'].decode('utf8')
			else:
				note[EngMeaning] = ""
			note.flush()
	mw.progress.finish()
	mw.reset()
예제 #2
0
def addExtraStories(nids):
    readStories()

    fields = []

    anote = mw.col.getNote(nids[0])
    #get the fields of the first note
    for (i, f) in anote.items():
        fields.append(i)

    #get input/output fields from user
    expField = addinfofuncts.getKeyFromList(
        "Select field to read from", "Read relevant kanji/expression from:",
        fields)
    if (expField is None):
        return

    #get input/output fields from user
    story1DstField = addinfofuncts.getKeyFromList("Select field to write to",
                                                  "Write extra story to:",
                                                  fields)
    if (story1DstField is None):
        return

        #get input/output fields from user
    story2DstField = addinfofuncts.getKeyFromList(
        "Select field to write to", "Write other extra story to:", fields)
    if (story2DstField is None):
        return

    mw.checkpoint("Add Extra Stories")
    mw.progress.start()
    #For each seleccted card
    for nid in nids:
        note = mw.col.getNote(nid)
        src = expField
        srcTxt = mw.col.media.strip(note[src])
        if not srcTxt.strip():
            continue
        #Add the data to the dst field

        kanjizz = extractKanji(note[src])
        if kanjizz not in kanjiIndex:
            continue
        if kanjiIndex[kanjizz]:
            if kanjiIndex[kanjizz]['story1']:
                note[story1DstField] = kanjiIndex[kanjizz]['story1'].decode(
                    'utf8')
            else:
                note[story1DstField] = ""
            if kanjiIndex[kanjizz]['story2']:
                note[story2DstField] = kanjiIndex[kanjizz]['story2'].decode(
                    'utf8')
            else:
                note[story2DstField] = ""
        note.flush()
    mw.progress.finish()
    mw.reset()
예제 #3
0
def addExtraStories(nids):
    readStories()
    
    
    fields = []
    
    anote=mw.col.getNote(nids[0])
    #get the fields of the first note
    for (i, f) in anote.items():
        fields.append(i)
    
    #get input/output fields from user
    expField = addinfofuncts.getKeyFromList("Select field to read from", "Read relevant kanji/expression from:", fields)
    if (expField is None):
        return
    
    #get input/output fields from user
    story1DstField = addinfofuncts.getKeyFromList("Select field to write to", "Write extra story to:", fields)
    if (story1DstField is None):
        return
    
        #get input/output fields from user
    story2DstField = addinfofuncts.getKeyFromList("Select field to write to", "Write other extra story to:", fields)
    if (story2DstField is None):
        return
    
    mw.checkpoint("Add Extra Stories")
    mw.progress.start()
    #For each seleccted card
    for nid in nids:
        note = mw.col.getNote(nid)
        src = expField
        srcTxt = mw.col.media.strip(note[src])
        if not srcTxt.strip():
            continue
        #Add the data to the dst field
        
        kanjizz = extractKanji(note[src])
        if kanjizz not in kanjiIndex:
            continue
        if kanjiIndex[kanjizz]:
            if kanjiIndex[kanjizz]['story1']:
                note[story1DstField] = kanjiIndex[kanjizz]['story1'].decode('utf8')
            else:
                note[story1DstField] = ""
            if kanjiIndex[kanjizz]['story2']:
                note[story2DstField] = kanjiIndex[kanjizz]['story2'].decode('utf8')
            else:
                note[story2DstField] = ""
        note.flush()
    mw.progress.finish()
    mw.reset()
예제 #4
0
def addJPVocab(nids):

    vocabIndex.clear()
    readVocabfile()

    fields = []

    anote = mw.col.getNote(nids[0])
    #get the fields of the first note
    for (i, f) in anote.items():
        fields.append(i)

    #get input/output fields from user
    src = addinfofuncts.getKeyFromList("Select field to read from",
                                       "Read relevant kanji/expression from:",
                                       fields)
    if (src is None):
        return

        #get input/output fields from user
    dst = addinfofuncts.getKeyFromList("Select field to write to",
                                       "Write JLPT vocabulary to:", fields)
    if (dst is None):
        return

    mw.checkpoint("Add JPVocab")
    mw.progress.start()
    #For each seleccted card
    for nid in nids:
        note = mw.col.getNote(nid)
        srcTxt = mw.col.media.strip(note[src])
        if not srcTxt.strip():
            continue
        #Add the data to the dst field
        note[dst] = lookupVocab(srcTxt)
        #if (note[dst] == ""):
        #	note[dst] = note['Story']
        note.flush()
    mw.progress.finish()
    mw.reset()
예제 #5
0
def addJPVocab(nids):

    vocabIndex.clear()
    readVocabfile()

    fields = []

    anote = mw.col.getNote(nids[0])
    # get the fields of the first note
    for (i, f) in anote.items():
        fields.append(i)

        # get input/output fields from user
    src = addinfofuncts.getKeyFromList("Select field to read from", "Read relevant kanji/expression from:", fields)
    if src is None:
        return

        # get input/output fields from user
    dst = addinfofuncts.getKeyFromList("Select field to write to", "Write JLPT vocabulary to:", fields)
    if dst is None:
        return

    mw.checkpoint("Add JPVocab")
    mw.progress.start()
    # For each seleccted card
    for nid in nids:
        note = mw.col.getNote(nid)
        srcTxt = mw.col.media.strip(note[src])
        if not srcTxt.strip():
            continue
            # Add the data to the dst field
        note[dst] = lookupVocab(srcTxt)
        # if (note[dst] == ""):
        # 	note[dst] = note['Story']
        note.flush()
    mw.progress.finish()
    mw.reset()