Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Anderson <tony_anderson@usa.net>2009-06-22 14:16:54 (GMT)
committer Tony Anderson <tony_anderson@usa.net>2009-06-22 14:16:54 (GMT)
commit697cd95e448b7057007066e908de09bc29f972c6 (patch)
tree0f2a795e9bc7e059e25407c332507ede965576ac
parentecdd5a68c9b6de6e53876d4205a39696c0002013 (diff)
removed the rest of the filesHEADmaster
-rwxr-xr-xConvert.py238
-rwxr-xr-xcheckphrase.py39
-rwxr-xr-xcheckrenyi.py50
-rwxr-xr-ximagequiz_library/Quiz0001.xml131
-rwxr-xr-ximagequiz_library/rld001.xml103
5 files changed, 0 insertions, 561 deletions
diff --git a/Convert.py b/Convert.py
deleted file mode 100755
index fae30f7..0000000
--- a/Convert.py
+++ /dev/null
@@ -1,238 +0,0 @@
-#!/usr/bin/env python
-
-#----------------------------------------------------------------------
-# Convert.py
-# Dave Reed
-# 01/23/2008
-#----------------------------------------------------------------------
-
-import sys, os
-
-try:
- from xml.etree import ElementTree as etree
-except:
- sys.exit()
-
-from GladeWindow import *
-
-#----------------------------------------------------------------------
-
-class Window(GladeWindow):
-
- #----------------------------------------------------------------------
-
- def __init__(self):
-
- ''' '''
-
- self.init()
-
- #----------------------------------------------------------------------
-
- def init(self):
-
- filename = 'Convert.glade'
-
- widget_list = [
- 'window1',
- 'entry1',
- 'entry2',
- ]
-
- handlers = [
- 'on_entry2_activate',
- ]
-
- top_window = 'window1'
- GladeWindow.__init__(self, filename, top_window, widget_list, handlers)
- #----------------------------------------------------------------------
-
- def on_entry2_activate(self, *args):
- output_folder = self.widgets['entry2'].get_text()
- convert_main(output_folder)
-
- def main_window_destroy():
- self.destroy()
-
-#----------------------------------------------------------------------
-class InTree():
-
- def __init__(self, filename):
- self.tree = etree.parse(filename)
- self.xml = self.tree.getroot()
-
- def get(self, node):
- idcard = node.attrib.get("id")
- if not idcard:
- idcard = '0'
- question = node.findtext("front")
- if not question:
- question = ''
- hint = node.findtext('comment')
- if not hint:
- hint = ''
- sound = node.findtext('sound')
- if not sound:
- sound = ''
- answer = node.findtext("back")
- if not answer:
- answer = ''
- more = node.findtext('backexample')
- if not more:
- more = ''
- image = node.findtext('image')
- if not image:
- image = ''
- return (idcard, question, hint, answer, more, sound, image)
-
-#----------------------------------------------------------------------
-class SaveDeck():
- def __init__(self):
- self.xml = etree.Element("quiz")
-
- def put(self, card):
- if len(card) < 7:
- print 'fatal error in put:', len(card)
- sys.exit()
- xmlcard = etree.Element("card")
- xmlcard.set("id",str(card[0]))
- question = etree.SubElement(xmlcard, "question")
- question.text = card[1]
- if len(card[2]) > 0:
- hint = etree.SubElement(question, "hint")
- hint.text = card[2]
- if len(card[5]) > 0:
- sound = etree.SubElement(question, 'sound')
- sound.text = card[5]
- answer = etree.SubElement(xmlcard, "answer")
- answer.text = card[3]
- if len(card[4]) > 0:
- more = etree.SubElement(answer, "more")
- more.text = card[4]
- if len(card[6]) > 0:
- image = etree.SubElement(answer, 'image')
- image.text = card[6]
- self.xml.append(xmlcard)
-
- # in-place prettyprint formatter
-
- def indent(self, elem, level=0):
- i = "\n" + level*" "
- if len(elem):
- if not elem.text or not elem.text.strip():
- elem.text = i + " "
- for elem in elem:
- self.indent(elem, level+1)
- if not elem.tail or not elem.tail.strip():
- elem.tail = i
- else:
- if level and (not elem.tail or not elem.tail.strip()):
- elem.tail = i
-
- def printtree(self, filename, last):
- self.xml.set("last",str(last))
- #prettyprint
- tree = etree.ElementTree(self.xml)
- self.indent(self.xml)
- tree.write(filename, encoding = 'utf-8')
-
-#----------------------------------------------------------------------
-def get_filenames():
- #select decks using file chooser dialog [ user must select in correct order ]
- chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN, \
- buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
- chooser.set_select_multiple(True)
- chooser.set_default_response(gtk.RESPONSE_OK)
- response = chooser.run()
- if response != gtk.RESPONSE_OK:
- sys.exit()
- decks = chooser.get_filenames()
- chooser.destroy()
- return decks
-
-def fix_file(filename, outfilename):
- infile = open(filename)
- s = unicode(infile.read(),'ISO 8859-1')
- infile.close()
- t = s.replace('<?xml version="1.0" ?>','<?xml version="1.0" encoding= "utf-16" ?>')
- s = t
- t = s.replace('utf-16', 'utf-8')
- s = t
- s = t
- t = s.replace('front example', 'frontexample')
- s = t
- s = t
- t = s.replace('back example', 'backexample')
- s = t
- outfile = open(outfilename, 'w')
- outfile.write(t)
- outfile.close
-
-def get_deck(tree):
- deck = []
- for node in tree.xml:
- card = tree.get(node)
- deck.append(card)
- return deck
-
-def get_tree(filename):
- global w
- tree = InTree(filename)
- return tree
-
-def convert_deck(deck):
- cards = []
- for card in deck:
- #card = [id, question, hint, answer, more, sound, image]
- id = str(len(cards))
- #make newcard [id, card[1], card[2], card[3], card[4], card[5], card[6]]
- #sound = card[5]
- #if len(sound) > 0:
- # newcard = [id, card[1], card[2], sound[:-4], card[4], card[5], card[6]]
- #else:
- newcard = [id, card[1], card[2], card[3], card[4], card[5], card[6]]
- #add to cards
- cards.append(newcard)
- return cards
-
-def save_deck(filename, cards):
- #create tree from cards
- out = SaveDeck()
- for card in cards:
- out.put(card)
- #write tree with pretty print
- number = len(cards)
- out.printtree(filename, number)
-
-def path_strip(pathname):
- # get part after last /, if any
- filename = os.path.basename(pathname)
- return filename
-
-
-def convert_main(outfolder):
- global w
- decks = get_filenames()
- for filename in decks:
- w.widgets['entry1'].set_text(path_strip(filename))
- outfilename = './' + outfolder + '/' + path_strip(filename)
- #fix_file(filename, outfilename)
- tree = get_tree(filename)
- deck = get_deck(tree)
- cards = convert_deck(deck)
- save_deck(outfilename, cards)
- sys.exit()
-
-#----------------------------------------------------------------------
-
-def main(argv):
- global w
- w = Window()
- w.show()
- w.widgets['entry2'].grab_focus()
- gtk.main()
-
-#----------------------------------------------------------------------
-
-if __name__ == '__main__':
- main(sys.argv)
diff --git a/checkphrase.py b/checkphrase.py
deleted file mode 100755
index ef10b3f..0000000
--- a/checkphrase.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import sys
-from path import path
-from xmlio import Xmlio
-NEWLINE = '\n'
-
-#open file for output
-outfile = open('errorrptp','w')
-errorcount = 0
-#for each directory in Renyi
-try:
- d = path('/home/tonya/Desktop/ImageQuizPlus.activity/flashcards/russian/Phrases')
- s = path('/home/tonya/Desktop/ImageQuizPlus.activity/flashcards/russian/Phrases/sound')
-except:
- print 'invalid path'
-
-for cat in d.dirs():
- outfile.write(cat + NEWLINE)
- for f in cat.files('*.xml'):
- #write directory name
- deck = Xmlio(f)
- cards = deck.getroot()
- outfile.write(f + ' ' + str(len(cards)) + NEWLINE)
- #if img not in image:
- for card in cards:
- question_node = card.find('question')
- if question_node:
- sound = question_node.findtext('sound')
- if sound:
- sounds = sound.split('/')
- for item in sounds:
- temp = item[:-4] + '.ogg'
- if not path(s/temp).isfile():
- outfile.write(temp + ' not found' + NEWLINE)
- errorcount += 1
-outfile.write(str(errorcount) + ' errors')
-print (errorcount, ' errors')
diff --git a/checkrenyi.py b/checkrenyi.py
deleted file mode 100755
index 162cfcb..0000000
--- a/checkrenyi.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import sys
-from path import path
-from xmlio import Xmlio
-NEWLINE = '\n'
-
-#open file for output
-outfile = open('errorrpt','w')
-errorcount = 0
-#for each directory in Renyi
-try:
- d = path('/home/olpc/Activities/ImageQuizPlus.activity/flashcards/library/russian/renyi')
- i = path('/home/olpc/Activities/ImageQuizPlus.activity/flashcards/library/russian/renyi/image')
- s = path('/home/olpc/Activities/ImageQuizPlus.activity/flashcards/library/russian/renyi/sound')
-except:
- print 'invalid path'
-print d
-print i
-print s
-for cat in d.dirs():
- outfile.write(cat + NEWLINE)
- for f in cat.files('*.xml'):
- #write directory name
- deck = Xmlio(f)
- cards = deck.getroot()
- outfile.write(f + ' ' + str(len(cards)) + NEWLINE)
- #if img not in image:
- for card in cards:
- question_node = card.find('question')
- if question_node:
- sound = question_node.findtext('sound')
- answer_node = card.find('answer')
- if answer_node:
- temp = answer_node.findtext('image')
- if temp:
- image = temp[:-4] + '.png'
- if image and not path(i/image).isfile():
- outfile.write(image + ' not found' + NEWLINE)
- errorcount += 1
- if sound:
- sounds = sound.split('/')
- for item in sounds:
- temp = item[:-4] + '.ogg'
- if not path(s/temp).isfile():
- outfile.write(temp + ' not found' + NEWLINE)
- errorcount += 1
-outfile.write(str(errorcount) + ' errors')
-print (errorcount, ' errors')
diff --git a/imagequiz_library/Quiz0001.xml b/imagequiz_library/Quiz0001.xml
deleted file mode 100755
index 1d5d5c5..0000000
--- a/imagequiz_library/Quiz0001.xml
+++ /dev/null
@@ -1,131 +0,0 @@
-<quiz>
- <card bin="0" count="0" id="1" shown="" think="">
- <question>
- <sound>k2361.ogg</sound>
- <hint />
- </question><answer>
- <image>k2361.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="2" shown="" think="">
- <question>
- <sound>k1809.ogg</sound>
- <hint />
- </question><answer>
- <image>k1809.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="3" shown="" think="">
- <question>
- <sound>k1960.ogg</sound>
- <hint />
- </question><answer>
- <image>k1960.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="4" shown="" think="">
- <question>
- <sound>k0993.ogg</sound>
- <hint />
- </question><answer>
- <image>k0993.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="5" shown="" think="">
- <question>
- <sound>k1030.ogg</sound>
- <hint />
- </question><answer>
- <image>k1030.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="6" shown="" think="">
- <question>
- <sound>k2579.ogg</sound>
- <hint />
- </question><answer>
- <image>k2579.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="7" shown="" think="">
- <question>
- <sound>k0061.ogg</sound>
- <hint />
- </question><answer>
- <image>k0061.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="8" shown="" think="">
- <question>
- <sound>k2532.ogg</sound>
- <hint />
- </question><answer>
- <image>k2532.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="9" shown="" think="">
- <question>
- <sound>k2701.ogg</sound>
- <hint />
- </question><answer>
- <image>k2701.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="10" shown="" think="">
- <question>
- <sound>k2364.ogg</sound>
- <hint />
- </question><answer>
- <image>k2364.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="11" shown="" think="">
- <question>
- <sound>k0177.ogg</sound>
- <hint />
- </question><answer>
- <image>k0177.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="12" shown="" think="">
- <question>
- <sound>k1391.ogg/k1391r.ogg/k1391r1.ogg</sound>
- <hint />
- </question><answer>
- <image>k1391.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="13" shown="" think="">
- <question>
- <sound>k2849.ogg</sound>
- <hint />
- </question><answer>
- <image>k2849.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="14" shown="" think="">
- <question>
- <sound>k2621.ogg</sound>
- <hint />
- </question><answer>
- <image>k2621.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="15" shown="" think="">
- <question>
- <sound>k1267.ogg</sound>
- <hint />
- </question><answer>
- <image>k1267.png</image>
- <more />
- </answer>
- </card><card bin="0" count="0" id="16" shown="" think="">
- <question>
- <sound>k3184.ogg</sound>
- <hint />
- </question><answer>
- <image>k3184.png</image>
- <more />
- </answer>
- </card>
-</quiz>
diff --git a/imagequiz_library/rld001.xml b/imagequiz_library/rld001.xml
deleted file mode 100755
index c15cf24..0000000
--- a/imagequiz_library/rld001.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<quiz last="25">
- <card id="0">
- <question>и<hint>Москва и Петербург</hint>
- </question><answer>and<more />
- </answer>
- </card><card id="1">
- <question>в/во<hint>в Москве/в Москву</hint>
- </question><answer>in/(+pr)/into/to/(+a)<more />
- </answer>
- </card><card id="2">
- <question>не<hint>Он не в Москве</hint>
- </question><answer>not<more />
- </answer>
- </card><card id="3">
- <question>на<hint>на работе/на стол</hint>
- </question><answer>on/at/(+pr)/onto/to/(+a)<more />
- </answer>
- </card><card id="4">
- <question>я/Я<hint>я говорю</hint>
- </question><answer>I<more />
- </answer>
- </card><card id="5">
- <question>он<hint>Он гоборнт</hint>
- </question><answer>he<more />
- </answer>
- </card><card id="6">
- <question>что<hint>Что ето? Я гоборю, что он на работе</hint>
- </question><answer>what/that<more />
- </answer>
- </card><card id="7">
- <question>с/со<hint>Чай с лимоном/со стола</hint>
- </question><answer>with/(+inst)/from/off(+g)<more />
- </answer>
- </card><card id="8">
- <question>это<hint>Это наш клуб; Это верно</hint>
- </question><answer>this/that/it<more />
- </answer>
- </card><card id="9">
- <question>быть/есть<hint>Быть нлн не блыт? / Ест кофе?</hint>
- </question><answer>to be/there is/there are<more />
- </answer>
- </card><card id="10">
- <question>а<hint>Она в Москве, а он в Петербурге</hint>
- </question><answer>and/but/(slight contrast)<more />
- </answer>
- </card><card id="11">
- <question>весь/вся/всё/все<hint>весь стол / вся Москва</hint>
- </question><answer>all<more />
- </answer>
- </card><card id="12">
- <question>они<hint>Они в Москве</hint>
- </question><answer>they<more />
- </answer>
- </card><card id="13">
- <question>она<hint>Она со мной</hint>
- </question><answer>she<more />
- </answer>
- </card><card id="14">
- <question>как<hint>Как он говорйт? как я, как ты</hint>
- </question><answer>how/as/like<more />
- </answer>
- </card><card id="15">
- <question>мы<hint>Мы выли в Петербурге</hint>
- </question><answer>we<more />
- </answer>
- </card><card id="16">
- <question>к/ко<hint>к дому; ко мне</hint>
- </question><answer>towards/to/(+d)<more />
- </answer>
- </card><card id="17">
- <question>у<hint>у окна; у Нвана; у Нвана есть дом</hint>
- </question><answer>by/at/(has)<more />
- </answer>
- </card><card id="18">
- <question>вы<hint>Вы говорнте</hint>
- </question><answer>you/(polite/pl)<more />
- </answer>
- </card><card id="19">
- <question>этот/эта/это/эти<hint>этот стол, эта книга, эти люди</hint>
- </question><answer>this<more />
- </answer>
- </card><card id="20">
- <question>за<hint>платить за водку / за домом</hint>
- </question><answer>beyond/for/(+a)/behind/ (+inst)<more />
- </answer>
- </card><card id="21">
- <question>тот/та/то/те<hint>тот дом; в то время; ...то, что ...</hint>
- </question><answer>that<more />
- </answer>
- </card><card id="22">
- <question>но<hint>Но это не правда</hint>
- </question><answer>but<more />
- </answer>
- </card><card id="23">
- <question>ты<hint>Ты говоришь</hint>
- </question><answer>you/(familiar)<more />
- </answer>
- </card><card id="24">
- <question>по<hint>по уличе; по городу; по плану</hint>
- </question><answer>along/around/according to/(+d)<more />
- </answer>
- </card>
-</quiz> \ No newline at end of file