diff options
Diffstat (limited to 'checkphrase.py')
-rwxr-xr-x | checkphrase.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/checkphrase.py b/checkphrase.py new file mode 100755 index 0000000..ef10b3f --- /dev/null +++ b/checkphrase.py @@ -0,0 +1,39 @@ +#! /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') |