Commit f7a90344 authored by Julien Pivotto's avatar Julien Pivotto

Tests pass!

Signed-off-by: Julien Pivotto's avatarJulien Pivotto <roidelapluie@inuits.eu>
parent 1e641834
......@@ -11,11 +11,12 @@ Options:
import os
from docopt import docopt
from translate.storage import factory
import subprocess
import logging
logging.basicConfig(level=logging.DEBUG)
class Tox:
class Pox:
def __init__(self, directory):
self.directory = directory
......@@ -24,21 +25,53 @@ class Tox:
return 0
def walk_into_dirs(self):
for dirpath, _, filenames in os.walk(self.directory):
os.chdir(self.directory)
for dirpath, _, filenames in os.walk('.'):
if 'locale.pot' in filenames:
logging.debug('Pot in %s' % dirpath)
pofiles = self.get_po_files(filenames)
filenames = self.extract_files_from_pot(dirpath)
translated_filenames = self.extract_files_from_pot(dirpath)
logging.debug('Filenames files: %s' % filenames)
logging.debug('Po files: %s' % pofiles)
for pofile in pofiles:
for filename in filenames:
pofile_obj = factory.getobject(os.path.join(dirpath, pofile))
self.is_pofile_translated_for_file()
for unit in pofile_x.unit_iter():
self.is_
print unit.sourcecomments
for pofilename in pofiles:
logging.info('Analyzing %s' % pofilename)
pofile = factory.getobject(os.path.join(dirpath, pofilename))
for filename in translated_filenames:
logging.info('Analyzing with %s' % filename)
if self.is_pofile_translated_for_file(pofile, filename):
lang = pofilename.split('.')[1]
newname = '%s.%s.xhtml' % (filename.split('.')[0], lang)
command = ['po2html',
'-t',
filename,
os.path.join(dirpath, pofilename),
newname]
logging.info('Running %s' % ' '.join(command))
subprocess.call(command)
def is_pofile_translated_for_file(self, pofile, filename):
result = False
for unit in pofile.unit_iter():
logging.debug("Unit %s (type: %s)" % (unit, type(unit)))
for source in unit.sourcecomments:
logging.debug("Source %s" % source)
logging.debug("is blank? %s" % unit.isblank())
logging.debug("is translated? %s" % unit.istranslated())
logging.debug("is fuzzy? %s" % unit.isfuzzy())
path = source[3:].split('+')[0]
logging.debug('Comparing %s and %s' % (path, filename))
if filename == path:
if unit.isblank():
logging.debug('Blank!')
return False
if unit.isfuzzy():
logging.debug('Fuzzy!')
return False
if not unit.istranslated():
logging.debug('Not Translated!')
return False
result = True
return result
def extract_files_from_pot(self, dirpath):
filenames = set()
......@@ -66,8 +99,8 @@ class Tox:
def main():
arguments = docopt(__doc__, version='0.1')
srcdir=arguments['<sourcedir>']
exit(Tox(srcdir).run())
srcdir = arguments['<sourcedir>']
exit(Pox(srcdir).run())
if __name__ == '__main__':
......
......@@ -13,7 +13,8 @@ do
echo
tmpdir="$(mktemp -d)"
cp -rv $i/input/ "$tmpdir"
./tox.py "$tmpdir/input"
./pox.py "$tmpdir/input"
echo "Comparing $tmpdir/input and $i/output"
if diff -r "$tmpdir/input" "$i/output"
then
echo -e "Test $(basename $i) \e[1;32mSUCCESS\e[0m" | tee -a "$results"
......
......@@ -2,25 +2,25 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"POT-Creation-Date: 2016-07-18 20:59+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
#: extra/index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
#: extra/index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
#: extra/index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
......@@ -2,25 +2,25 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"POT-Creation-Date: 2016-07-18 20:59+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: Dutch\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
#: extra/index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr ""
#: index.en.xhtml+html.body.p:6
#: extra/index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
#: extra/index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
......@@ -2,25 +2,25 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"POT-Creation-Date: 2016-07-18 20:59+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
#: extra/index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
#: extra/index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
#: extra/index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
......@@ -2,25 +2,25 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"POT-Creation-Date: 2016-07-18 20:59+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: Dutch\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
#: extra/index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr ""
#: index.en.xhtml+html.body.p:6
#: extra/index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
#: extra/index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment