aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile21
-rw-r--r--control30
-rw-r--r--debian-build-log.txt198
-rw-r--r--mail2news.py2
-rw-r--r--pyg-build.tar.gzbin208139 -> 0 bytes
-rw-r--r--setup.py94
-rw-r--r--test/__init__.py0
-rwxr-xr-xtest/test_wlp.py108
-rw-r--r--wlp/README.notes16
-rwxr-xr-xwlp_test31
11 files changed, 190 insertions, 313 deletions
diff --git a/.gitignore b/.gitignore
index e38c13b..c9290d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
-build/*
+build/
wlp/commands.tab.*
wlp/lex.yy.c
+*.pyc
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 3605412..0000000
--- a/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-WLPDIR=wlp
-
-CSRCDIR=$(WLPDIR)/C
-MODULEDIR=$(WLPDIR)/module
-BINDIR=$(WLPDIR)
-
-bin:
- $(MAKE) -C $(WLPDIR)
-
-install:
- install pygm2n pygn2m $(DESTDIR)/usr/bin
- install *.py $(DESTDIR)/usr/lib/pyg
- install *.so $(DESTDIR)/usr/lib/pyg
-
-check:
- # pygm2n -TVn local.news.group < examples/mail
- echo "Not Implemented!"
-
-clean:
- $(MAKE) -C $(WLPDIR) clean
- rm -f *.pyc *.so
diff --git a/control b/control
deleted file mode 100644
index 40c52a5..0000000
--- a/control
+++ /dev/null
@@ -1,30 +0,0 @@
-Source: pyg
-Section: news
-Priority: optional
-Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
-XSBC-Original-Maintainer: Cosimo Alfarano <kalfa@debian.org>
-Standards-Version: 3.9.3
-Build-Depends: debhelper (>= 3.0), python-dev (>= 2.6.6-3~), flex, bison
-
-Package: pyg
-Architecture: any
-Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends}
-Suggests: news-transport-system , mail-transport-agent, procmail | maildrop | sensible-mda
-Description: Python Mail <-> News Gateway
- Python Gateway Script from news to mail and vice versa.
- .
- It is intended to be a full SMTP/NNTP rfc compliant gateway
- with whitelist manager.
- .
- You will probably have to install a mail-transport-agent and/or
- news-transport-system package to manage SMTP/NNTP traffic.
- .
- MTA is needed for mail2news service, since mail have to be
- processed on a box where pyg is installed. You can use a remote
- smtpserver for news2mail.
- .
- News system is useful but not needed, since you can send articles to a
- remote SMTP server (ie: moderated NG) where is installed pyg, otherwise you
- will need it.
- .
- It refers to rfc 822 (mail) and 850 (news).
diff --git a/debian-build-log.txt b/debian-build-log.txt
deleted file mode 100644
index 3ef45df..0000000
--- a/debian-build-log.txt
+++ /dev/null
@@ -1,198 +0,0 @@
-dh_testdir
-/usr/bin/make bin #CFLAGS="-O2 -g -Wall"
-make[1]: Entering directory `/home/matej/build/pyg/pyg-0.9.7'
-/usr/bin/make -C wlp
-make[2]: Entering directory `/home/matej/build/pyg/pyg-0.9.7/wlp'
-/usr/bin/make -C module -f Makefile.pre.in boot
-make[3]: Entering directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-rm -f *.o *~
-rm -f *.a tags TAGS config.c Makefile.pre python sedscript
-rm -f *.so *.sl so_locations
-VERSION=`python -c "import sys; print sys.version[:3]"`; \
- installdir=`python -c "import sys; print sys.prefix"`; \
- exec_installdir=`python -c "import sys; print sys.exec_prefix"`; \
- /usr/bin/make -f ./Makefile.pre.in VPATH=. srcdir=. \
- VERSION=$VERSION \
- installdir=$installdir \
- exec_installdir=$exec_installdir \
- Makefile
-make[4]: Entering directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-sed -n \
- -e '1s/.*/1i\\/p' \
- -e '2s%.*%# Generated automatically from Makefile.pre.in by sedscript.%p' \
- -e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \
- -e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
- -e '/^CXX=/s/^CXX=[ ]*\(.*\)/s%@CXX[@]%\1%/p' \
- -e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \
- -e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \
- -e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
- -e '/^LDLAST=/s/^LDLAST=[ ]*\(.*\)/s%@LDLAST[@]%\1%/p' \
- -e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
- -e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
- -e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
- -e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
- -e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
- -e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
- -e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
- -e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
- -e '/^BLDSHARED=/s/^BLDSHARED=[ ]*\(.*\)/s%@BLDSHARED[@]%\1%/p' \
- -e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
- -e '/^SGI_ABI=/s/^SGI_ABI=[ ]*\(.*\)/s%@SGI_ABI[@]%\1%/p' \
- -e '/^LINKFORSHARED=/s/^LINKFORSHARED=[ ]*\(.*\)/s%@LINKFORSHARED[@]%\1%/p' \
- -e '/^prefix=/s/^prefix=\(.*\)/s%^prefix=.*%prefix=\1%/p' \
- -e '/^exec_prefix=/s/^exec_prefix=\(.*\)/s%^exec_prefix=.*%exec_prefix=\1%/p' \
- /usr/lib/python2.7/config/Makefile >sedscript
-echo "/^installdir=/s%=.*%= /usr%" >>sedscript
-echo "/^exec_installdir=/s%=.*%=/usr%" >>sedscript
-echo "/^srcdir=/s%=.*%= .%" >>sedscript
-echo "/^VPATH=/s%=.*%= .%" >>sedscript
-echo "/^LINKPATH=/s%=.*%= %" >>sedscript
-echo "/^BASELIB=/s%=.*%= %" >>sedscript
-echo "/^BASESETUP=/s%=.*%= %" >>sedscript
-if grep 's%@DEFS' sedscript >/dev/null 2>&1; then \
- :; \
- else \
- echo "s%@DEFS[@]%%" >>sedscript; \
- fi
-sed -f sedscript ./Makefile.pre.in >Makefile.pre
-cp ./Setup.in Setup
-/usr/lib/python2.7/config/makesetup \
- -m Makefile.pre -c /usr/lib/python2.7/config/config.c.in Setup -n /usr/lib/python2.7/config/Setup.config /usr/lib/python2.7/config/Setup.local /usr/lib/python2.7/config/Setup
-/usr/bin/make -f Makefile do-it-again
-make[5]: Entering directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-/usr/lib/python2.7/config/makesetup \
- -m Makefile.pre -c /usr/lib/python2.7/config/config.c.in Setup -n /usr/lib/python2.7/config/Setup.config /usr/lib/python2.7/config/Setup.local /usr/lib/python2.7/config/Setup
-make[5]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-make[4]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-make[3]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-/usr/bin/make -C C archive
-make[3]: Entering directory `/home/matej/build/pyg/pyg-0.9.7/wlp/C'
-gcc -fPIC -Wall -ansi -c structs.c -o structs.o
-bison -d -d commands.y -b commands
-gcc -fPIC -c commands.tab.c -o commands.tab.o
-commands.y: In function ‘yyparse’:
-commands.y:49:4: warning: incompatible implicit declaration of built-in function ‘strncpy’ [enabled by default]
-commands.y:49:42: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
-commands.y:56:4: warning: incompatible implicit declaration of built-in function ‘strncpy’ [enabled by default]
-commands.y:56:41: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
-commands.y:63:4: warning: incompatible implicit declaration of built-in function ‘strncpy’ [enabled by default]
-commands.y:63:42: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
-commands.y: In function ‘found’:
-commands.y:91:2: warning: incompatible implicit declaration of built-in function ‘strncpy’ [enabled by default]
-commands.y:91:28: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
-flex commands.l
-gcc -fPIC -c lex.yy.c -o lex.yy.o
-ar -rs ./wlp.a structs.o commands.tab.o lex.yy.o \
- /usr/lib/libfl.a
-ar: creating ./wlp.a
-make[3]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7/wlp/C'
-/usr/bin/make -C module
-make[3]: Entering directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-gcc -pthread -fPIC -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/usr/include/python2.7 -I/usr/include/python2.7 -c ../C/wlp.c -o ./wlp.o
-../C/wlp.c: In function ‘wlp_setfilebyname’:
-../C/wlp.c:40:2: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
-../C/wlp.c: In function ‘wlp_mkdict’:
-../C/wlp.c:93:3: warning: implicit declaration of function ‘parse’ [-Wimplicit-function-declaration]
-../C/wlp.c: At top level:
-../C/wlp.c:181:6: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
-../C/wlp.c:154:18: warning: ‘node2dict2’ defined but not used [-Wunused-function]
-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions ./wlp.o ../C/wlp.a -o ./wlp.so
-make[3]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7/wlp/module'
-chmod 0644 module/*.so
-mv module/*.so ..
-make[2]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7/wlp'
-make[1]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7'
-touch build-stamp
-dh_testdir
-dh_testroot
-dh_clean -k
-dh_clean: dh_clean -k is deprecated; use dh_prep instead
-dh_clean: No compatibility level specified in debian/compat
-dh_clean: This package will soon FTBFS; time to fix it!
-dh_clean: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_installdirs
-dh_installdirs: No compatibility level specified in debian/compat
-dh_installdirs: This package will soon FTBFS; time to fix it!
-dh_installdirs: Compatibility levels before 5 are deprecated (level 4 in use)
-/usr/bin/make install DESTDIR=/home/matej/build/pyg/pyg-0.9.7/debian/pyg
-make[1]: Entering directory `/home/matej/build/pyg/pyg-0.9.7'
-install pygm2n pygn2m /home/matej/build/pyg/pyg-0.9.7/debian/pyg/usr/bin
-install *.py /home/matej/build/pyg/pyg-0.9.7/debian/pyg/usr/lib/pyg
-install *.so /home/matej/build/pyg/pyg-0.9.7/debian/pyg/usr/lib/pyg
-make[1]: Leaving directory `/home/matej/build/pyg/pyg-0.9.7'
-dh_testdir
-dh_testroot
-dh_testdir
-dh_testroot
-dh_installdirs
-dh_installdirs: No compatibility level specified in debian/compat
-dh_installdirs: This package will soon FTBFS; time to fix it!
-dh_installdirs: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_installchangelogs
-dh_installchangelogs: No compatibility level specified in debian/compat
-dh_installchangelogs: This package will soon FTBFS; time to fix it!
-dh_installchangelogs: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_installdocs
-dh_installdocs: No compatibility level specified in debian/compat
-dh_installdocs: This package will soon FTBFS; time to fix it!
-dh_installdocs: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_installmanpages
-dh_installmanpages: This program is deprecated, switch to dh_installman.
-dh_installmanpages: No compatibility level specified in debian/compat
-dh_installmanpages: This package will soon FTBFS; time to fix it!
-dh_installmanpages: Compatibility levels before 5 are deprecated (level 4 in use)
-# these are class modules, they don't need manpages,
-# undocumented link means I'm planning to document them.
-#dh_undocumented whitelist.py.3 news2mail.py.3 mail2news.py.3 pyginfo.py.3
-dh_installexamples
-dh_installexamples: No compatibility level specified in debian/compat
-dh_installexamples: This package will soon FTBFS; time to fix it!
-dh_installexamples: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_fixperms
-dh_fixperms: No compatibility level specified in debian/compat
-dh_fixperms: This package will soon FTBFS; time to fix it!
-dh_fixperms: Compatibility levels before 5 are deprecated (level 4 in use)
-# dh_fixperms doesn't fix perms in /usr/lib subdirs
-chmod 0644 /home/matej/build/pyg/pyg-0.9.7/debian/pyg/usr/lib/pyg/*.py
-# make sure pyg executables have right permission
-chmod 0755 /home/matej/build/pyg/pyg-0.9.7/debian/pyg/usr/bin/pygn2m
-chmod 0755 /home/matej/build/pyg/pyg-0.9.7/debian/pyg/usr/bin/pygm2n
-# dh_fixperms doesn't fix perms in /usr/share/doc subdirs
-find /home/matej/build/pyg/pyg-0.9.7/debian/pyg/usr/share/doc/pyg -type d -exec chmod 0755 {} \;
-dh_pysupport
-dh_pysupport: This program is deprecated, you should use dh_python2 instead. Migration guide: http://deb.li/dhs2p
-dh_pysupport: No compatibility level specified in debian/compat
-dh_pysupport: This package will soon FTBFS; time to fix it!
-dh_pysupport: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_strip
-dh_strip: No compatibility level specified in debian/compat
-dh_strip: This package will soon FTBFS; time to fix it!
-dh_strip: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_compress
-dh_compress: No compatibility level specified in debian/compat
-dh_compress: This package will soon FTBFS; time to fix it!
-dh_compress: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_installdeb
-dh_installdeb: No compatibility level specified in debian/compat
-dh_installdeb: This package will soon FTBFS; time to fix it!
-dh_installdeb: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_shlibdeps
-dh_shlibdeps: No compatibility level specified in debian/compat
-dh_shlibdeps: This package will soon FTBFS; time to fix it!
-dh_shlibdeps: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_gencontrol
-dh_gencontrol: No compatibility level specified in debian/compat
-dh_gencontrol: This package will soon FTBFS; time to fix it!
-dh_gencontrol: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_md5sums
-dh_md5sums: No compatibility level specified in debian/compat
-dh_md5sums: This package will soon FTBFS; time to fix it!
-dh_md5sums: Compatibility levels before 5 are deprecated (level 4 in use)
-dh_builddeb
-dh_builddeb: No compatibility level specified in debian/compat
-dh_builddeb: This package will soon FTBFS; time to fix it!
-dh_builddeb: Compatibility levels before 5 are deprecated (level 4 in use)
-dpkg-deb: vytvářím balík „pyg“ v „../pyg_0.9.7_amd64.deb“.
-dh_builddeb: No compatibility level specified in debian/compat
-dh_builddeb: This package will soon FTBFS; time to fix it!
-dh_builddeb: Compatibility levels before 5 are deprecated (level 4 in use)
diff --git a/mail2news.py b/mail2news.py
index 697de0b..d340432 100644
--- a/mail2news.py
+++ b/mail2news.py
@@ -46,7 +46,7 @@ class mail2news:
def readfile(self):
for line in sys.stdin.readlines():
- sef.email.append(line)
+ self.email.append(line)
if(len(self.email) == 1 and self.email[0][0] == '/'):
file = self.email[0][:-1]
diff --git a/pyg-build.tar.gz b/pyg-build.tar.gz
deleted file mode 100644
index 2d4772e..0000000
--- a/pyg-build.tar.gz
+++ /dev/null
Binary files differ
diff --git a/setup.py b/setup.py
index 2d4e9ba..33c9261 100644
--- a/setup.py
+++ b/setup.py
@@ -1,18 +1,45 @@
#!/usr/bin/python
-
-from setuptools import setup
-from distutils.core import Extension
+import unittest
+import sys
+from distutils.core import setup, Extension, Command
from distutils.command.build_ext import build_ext
from subprocess import check_call
+
+class RunTests(Command):
+ """New setup.py command to run all tests for the package.
+ """
+ description = "run all tests for the package"
+
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ tests = unittest.TestLoader().discover('.')
+ runner = unittest.TextTestRunner()
+ results = runner.run(tests)
+ sys.exit(not results.wasSuccessful())
+
+
class Build_WLP_ext(build_ext):
def run(self):
- self.make_file('wlp/command.y', 'wlp/y.tab.c', check_call,
- ([['yacc', '-d', '-o', 'wlp/commands.tab.c', 'wlp/commands.y']]),
- 'Generating lexer')
- self.make_file('wlp/commands.l', 'wlp/lex.yy.c', check_call,
- ([['lex', '-o', 'wlp/lex.yy.c', 'wlp/commands.l']]),
- 'Generating parser')
+ self.make_file(
+ 'wlp/commands.y', 'wlp/commands.tab.c', check_call,
+ # Yes, the following line contains list-in-list-in-tuple, and
+ # that's how it should be.
+ # otherwise, subsequent calls down the stack unwind the list and
+ # check_call won't get it.
+ ([['yacc', '-d', '-o', 'wlp/commands.tab.c', 'wlp/commands.y']]),
+ 'Generating lexer')
+ self.make_file(
+ 'wlp/commands.l', 'wlp/lex.yy.c', check_call,
+ ([['lex', '-o', 'wlp/lex.yy.c', 'wlp/commands.l']]),
+ 'Generating parser')
build_ext.run(self)
# see https://github.com/Turbo87/py-xcsoar/blob/master/setup.py
@@ -22,11 +49,48 @@ wlp_module = Extension('wlp',
'wlp/commands.tab.c',
'wlp/lex.yy.c'])
-install_requirements = ['']
+setup(name='pyg',
+ version='0.9.9', # the current Debian version is 0.9.8
+ author="Cosimo Alfarano",
+ author_email="kalfa@debian.org", # FIXME I am an contributor?
+ description='Python Mail <-> News Gateway',
+ long_description='''
+ Python Gateway Script from news to mail and vice versa.
+
+ It is intended to be a full SMTP/NNTP rfc compliant gateway
+ with whitelist manager.
+
+ You will probably have to install a mail-transport-agent and/or
+ news-transport-system package to manage SMTP/NNTP traffic.
+
+ MTA is needed for mail2news service, since mail have to be
+ processed on a box where pyg is installed. You can use a remote
+ smtpserver for news2mail.
+
+ News system is useful but not needed, since you can send articles to a
+ remote SMTP server (ie: moderated NG) where is installed pyg, otherwise you
+ will need it.
-setup(name='PackageName',
- version='1.0',
- description='This is a demo package',
- cmdclass={'build_ext': Build_WLP_ext},
+ It refers to rfc 822 (mail) and 850 (news).
+ ''',
+ py_modules=['mail2news', 'news2mail', 'pyginfo', 'setup', 'whitelist'],
ext_modules=[wlp_module],
- install_requires=install_requirements)
+ scripts=['pygm2n', 'pygn2m'],
+ cmdclass={'build_ext': Build_WLP_ext,
+ 'test': RunTests},
+ # TODO package actually requires lex and yacc port, but not sure
+ # how to say it here
+ requires=[],
+ license="GPLv2",
+ keywords=["nntp", "email", "gateway"],
+ classifiers=[
+ 'Development Status :: 3 - Alpha',
+ 'Programming Language :: Python :: 2.7',
+ 'Natural Language :: English',
+ 'Topic :: Office/Business :: Financial :: Accounting',
+ 'Topic :: Utilities',
+ 'Environment :: Console',
+ 'Operating System :: OS Independent',
+ 'License :: OSI Approved :: GNU Affero General Public License v3'
+ ]
+ )
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/__init__.py
diff --git a/test/test_wlp.py b/test/test_wlp.py
new file mode 100755
index 0000000..dcb2b78
--- /dev/null
+++ b/test/test_wlp.py
@@ -0,0 +1,108 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import unittest
+import sysconfig
+import sys
+import os
+import os.path
+import subprocess
+import re
+
+
+def distutils_dir_name(dname):
+ """Returns the name of a distutils build directory"""
+ f = "{dirname}.{platform}-{version[0]}.{version[1]}"
+ return f.format(dirname=dname,
+ platform=sysconfig.get_platform(),
+ version=sys.version_info)
+wlp_lib_path = os.path.join('build', distutils_dir_name('lib'))
+sys.path.insert(0, wlp_lib_path)
+
+
+import wlp
+
+
+class TestWLP(unittest.TestCase):
+ def test_wlp_parser(self):
+ wlp.setfilebyname('examples/whitelist.example')
+ wl_dict = wlp.mkdict()
+ expected_dict = {'alfarano@students.cs.unibo.it': {
+ 'From:': 'Cosimo Alfarano',
+ 'X-Firstname:': 'Cosimo'
+ },
+ 'kame@innocent.com': {
+ 'From:': 'kame@inwind.it',
+ 'Reply-to': 'me',
+ 'Reply-to:': 'KA',
+ 'Sender:': 'Kalfa'}
+ }
+ self.assertEqual(wl_dict, expected_dict)
+
+
+class TestM2N(unittest.TestCase):
+ def test_m2n(self):
+ expected_output = """Newsgroups: pyg.test
+From: Pyg <pyg@localhost.com>
+To: this header probably broke RFC, but is frequent.
+Subject: test
+Date: Sun, 1 Feb 2002 16:40:40 +0200
+Message-Id: <20001001164040.Aa8326@localhost>
+Content-Type: text/plain; charset=us-ascii
+Mime-Version: 1.0
+Return-Path: <pyg@localhost>
+User-Agent: Mutt/1.2.5i
+X-Gateway: pyg The Python Gateway - Mail to News
+"""
+ with open('examples/mail') as in_mail:
+ pid = subprocess.Popen(['./pygm2n', '-TV', '-n', 'pyg.test'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+ out, err = pid.communicate(in_mail.read())
+ self.assertEqual(out, expected_output)
+
+
+class TestN2M(unittest.TestCase):
+ def test_n2m(self):
+ expected_output = """Received: from GATEWAY by mitmanek.ceplovi.cz with pyg
+ for <test@example.com> ; Mon Dec 15 17:13:30 2014 (CEST)
+From: kame@inwind.it (PYG)
+To: test@example.com
+Subject: pyg's article test
+Date: 10 Jun 2000 23:20:47 +0200
+Organization: Debian GNU/Linux
+Reply-To: pyg@localhost
+Content-Type: text/plain; charset=US-ASCII
+Mime-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Trace: pyg.server.tld 960672047 927 192.168.1.2 (10 Jun 2000 21:20:47 GMT)
+X-Newsgroups: local.moderated
+X-Gateway: pyg The Python Gateway Script: news2mail mail2news gateway
+X-NNTP-Posting-Host: pyg.server.tld
+Resent-From: sender@example.com
+Resent-Sender: sender@example.com
+"""
+ env = os.environ
+ env['PYTHONPATH'] = wlp_lib_path
+
+ with open('examples/articletest.accepted') as in_mail:
+ pid = subprocess.Popen(['./pygn2m', '-TVt', 'test@example.com',
+ '-s', 'sender@example.com', '-d',
+ '-w', 'examples/whitelist.example'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE, env=env)
+ in_message = in_mail.read().replace('pyg@pyg.server.tld',
+ 'kame@inwind.it')
+ out, err = pid.communicate(in_message)
+ out = re.sub(r'^Message-Id:.*$', '', out)
+ # Not sure how to compare two email mesages (with different
+ # times, etc.) so for now just to make sure the script doesn’t
+ # blow up and gives some output
+ # otherwise it would be
+ # self.assertEqual(out, expected_output)
+ self.assertEqual(pid.returncode, 0)
+ self.assertGreater(len(out), 0)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/wlp/README.notes b/wlp/README.notes
deleted file mode 100644
index d522092..0000000
--- a/wlp/README.notes
+++ /dev/null
@@ -1,16 +0,0 @@
-wlp module from
-
-import wlp
-wlf = open('/home/matej/projekty/pyg/examples/whitelist.example')
-f = wlp.setfilebyfd(wlf)
-# or wlp.setfilebyname('/home/matej/projekty/pyg/examples/whitelist.example')
-wlp.mkdict()
-
-In [9]: wlp.mkdict()
-Out[9]:
-{'alfarano@students.cs.unibo.it': {'From:': 'Cosimo Alfarano',
- 'X-Firstname:': 'Cosimo'},
- 'kame@innocent.com': {'From:': 'kame@inwind.it',
- 'Reply-to': 'me',
- 'Reply-to:': 'KA',
- 'Sender:': 'Kalfa'}}
diff --git a/wlp_test b/wlp_test
deleted file mode 100755
index 5ccea1c..0000000
--- a/wlp_test
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-
-# Script to test if wlp.so works. It should parse confile without errors.
-
-import sys
-import wlp
-
-if(len(sys.argv) == 1):
- wlp.setfilebyname('./pyg.wl')
-else:
- wlp.setfilebyname(sys.argv[1])
-
-# dict is a { ownername : {variable: value}} dictionary of dictionaries
-dict = wlp.mkdict()
-
-try:
- print 'owner: option = value'
-
- for owner in dict.keys():
- options = dict[owner]
- for option in options.keys():
- print '%s: %s = %s' % (owner,option,options[option])
-except (Exception), message:
- print message
-
-
-for k in dict.keys():
- if(dict[k]['From:'] == 'Cosimo Alfarano'):
- print '%s has %s' % (k,dict[k]['From:'])
-
-sys.exit(0)