Skip to content

Commit

Permalink
modify setup.py and manifest template to relocate normalizer
Browse files Browse the repository at this point in the history
xml definition in a more suitable path.
Fix missing install of i18n directory.
Modify doc2RST to take an already configured gettext as argument.
  • Loading branch information
morucci committed Sep 23, 2011
1 parent e4dbf3a commit 1e63d52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions 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
18 changes: 11 additions & 7 deletions logsparser/normalizer.py
Expand Up @@ -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",
Expand Down Expand Up @@ -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):
Expand All @@ -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**
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -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, ...)"),
Expand All @@ -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
Expand Down

0 comments on commit 1e63d52

Please sign in to comment.