From 6eb30b09566a53ef510532f2a1705d7fc22985a8 Mon Sep 17 00:00:00 2001 From: Tony Anderson Date: Mon, 22 Jun 2009 14:04:24 +0000 Subject: initial commit --- (limited to 'checkrenyi.py') diff --git a/checkrenyi.py b/checkrenyi.py new file mode 100755 index 0000000..162cfcb --- /dev/null +++ b/checkrenyi.py @@ -0,0 +1,50 @@ +#! /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') -- cgit v0.9.1