blob: 162cfcb80c765d2e601ea76568cd44b8989450bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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')
|