From 1e63d523e6583977f9437e61fe709da572096f23 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Fri, 23 Sep 2011 11:18:46 +0200 Subject: [PATCH] modify setup.py and manifest template to relocate normalizer xml definition in a more suitable path. Fix missing install of i18n directory. Modify doc2RST to take an already configured gettext as argument. --- MANIFEST.in | 1 + logsparser/normalizer.py | 18 +++++++++++------- setup.py | 6 ++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 4477b3a..ff84aa7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ include LICENSE INSTALL README.rst recursive-include tests *.py recursive-include normalizers *.xml *.template *.dtd +recursive-include logsparser/i18n *.po *.mo diff --git a/logsparser/normalizer.py b/logsparser/normalizer.py index bbf6d90..8cdb75d 100644 --- a/logsparser/normalizer.py +++ b/logsparser/normalizer.py @@ -29,18 +29,12 @@ import re import csv -import gettext import warnings import math from lxml.etree import parse, tostring from datetime import datetime # pyflakes:ignore -try: - _ = gettext.translation('normalizer', 'i18n').ugettext -except: - _ = lambda x: x #pyflakes:ignore - # the following symbols and modules are allowed for use in callbacks. SAFE_SYMBOLS = ["list", "dict", "tuple", "set", "long", "float", "object", "bool", "callable", "True", "False", "dir", @@ -639,9 +633,14 @@ def get_languages(self): return self.description.keys() # Documentation generator -def doc2RST(description, lang = 'fr'): +def doc2RST(description, gettext = None): """ Returns a RestructuredText documentation from a parser description. + @param description: the long description of the parser. + @param gettext: is the gettext method to use. + You must configure gettext to use the domain 'normalizer' and + select a language. + eg. gettext.translation('normalizer', 'i18n', ['fr_FR']).ugettext """ def escape(text): @@ -650,6 +649,11 @@ def escape(text): text.replace(c, "\\" + c) return text + if not gettext: + _ = lambda x: x + else: + _ = gettext + template = _("""%(title)s **Written by** diff --git a/setup.py b/setup.py index 87b7a16..d992870 100644 --- a/setup.py +++ b/setup.py @@ -33,10 +33,11 @@ def read(fname): data = glob.glob('normalizers/*.xml') data.extend(glob.glob('normalizers/*.template')) data.extend(glob.glob('normalizers/*.dtd')) +fr_trans = glob.glob('logsparser/i18n/fr_FR/LC_MESSAGES/normalizer.*') setup( name = "pylogsparser", - version = "0.1", + version = "0.3", author = "Wallix", author_email = "opensource@wallix.org", description = ("A log parser library packaged with a set of ready to use parsers (DHCPd, Squid, Apache, ...)"), @@ -45,7 +46,8 @@ def read(fname): url = "http://www.wallix.org/pylogsparser-project/", package_dir={'logsparser.tests':'tests'}, packages=['logsparser', 'logsparser.tests'], - data_files=[('share/normalizers', data)], + data_files=[('share/logsparser/normalizers', data), + ('share/logsparser/i18n/fr_FR/LC_MESSAGES/', fr_trans),], requires=['lxml', 'pytz'], long_description=read('README.rst'), # http://pypi.python.org/pypi?:action=list_classifiers