Commit 3dfae2a0 authored by Julien Pivotto's avatar Julien Pivotto

Update filemask

Signed-off-by: Julien Pivotto's avatarJulien Pivotto <roidelapluie@inuits.eu>
parent 1ca8aec1
......@@ -2,8 +2,8 @@
"""lingvoj.py
Usage:
tox.py post-update <sourcedir>
tox.py pre-commit <sourcedir>
tox.py post-update <sourcedir> <template>
tox.py pre-commit <sourcedir> <template>
Options:
sourcedir: Path to the source directory
......@@ -18,8 +18,9 @@ import logging
logging.basicConfig(level=logging.DEBUG, filename='/tmp/pox.log')
class Pox:
def __init__(self, directory):
def __init__(self, directory, filemask):
self.directory = directory
self.filemask = filemask
def precommit(self):
self.walk_into_dirs()
......@@ -31,11 +32,11 @@ class Pox:
def regen_pofiles(self, generate_pot=True):
logging.debug('Regenerating pofiles')
_dirpath = os.path.dirname(os.environ['WL_FILEMASK'])
_dirpath = os.path.dirname(self.filemask)
if _dirpath == '':
_dirpath = '.'
for dirpath, _, filenames in os.walk('.'):
if not dirpath == _dirpath:
if not os.path.relpath('.', dirpath) == os.path.relpath('.', _dirpath):
logging.debug('%s != %s' % (dirpath, _dirpath))
continue
logging.debug('Found potfiles in %s' % dirpath)
......@@ -92,7 +93,13 @@ class Pox:
if generate_pot:
self.regen_pofiles()
_dirpath = os.path.dirname(self.filemask)
if _dirpath == '':
_dirpath = '.'
for dirpath, _, filenames in os.walk('.'):
if not os.path.relpath('.', dirpath) == os.path.relpath('.', _dirpath):
logging.debug('%s != %s' % (dirpath, _dirpath))
continue
if 'locale.pot' in filenames:
logging.debug('Pot in %s' % dirpath)
pofiles = self.get_po_files(filenames)
......@@ -194,10 +201,11 @@ class Pox:
def main():
arguments = docopt(__doc__, version='0.1')
srcdir = arguments['<sourcedir>']
srcdir = arguments['<filemask>']
if arguments['pre-commit']:
exit(Pox(srcdir).precommit())
exit(Pox(srcdir, filemask).precommit())
elif arguments['post-update']:
exit(Pox(srcdir).postupdate())
exit(Pox(srcdir, filemask).postupdate())
if __name__ == '__main__':
......
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