summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2012-10-25 10:36:32 +0200
committerAurélien Bompard <aurelien@bompard.org>2012-10-25 10:36:45 +0200
commitdf45c3ed3f6c5e2f15e2aa740c9961f5e462dd55 (patch)
treed67ded7f6fe36fa72823e8a2919f32b58c53bed1
parent72852d0bd2731897833abef47d82547257c95851 (diff)
downloadkittystore-df45c3ed3f6c5e2f15e2aa740c9961f5e462dd55.tar.gz
kittystore-df45c3ed3f6c5e2f15e2aa740c9961f5e462dd55.tar.xz
kittystore-df45c3ed3f6c5e2f15e2aa740c9961f5e462dd55.zip
Rename and package the import script
-rw-r--r--kittystore/import.py (renamed from to_sqldb.py)10
-rw-r--r--setup.py5
2 files changed, 10 insertions, 5 deletions
diff --git a/to_sqldb.py b/kittystore/import.py
index 186c903..af970e4 100644
--- a/to_sqldb.py
+++ b/kittystore/import.py
@@ -1,6 +1,6 @@
-#!/usr/bin/python -tt
-
-# Import the content of a mbox file into SQL
+"""
+Import the content of a mbox file into the database.
+"""
import datetime
import mailbox
@@ -156,8 +156,7 @@ def to_db(mbfile, list_name, store):
print ' %s email added to the database' % cnt
-if __name__ == '__main__':
- #sys.argv.extend(['devel', 'lists/devel-2012-03-March.txt'])
+def main():
if len(sys.argv) < 2 or '-h' in sys.argv or '--help' in sys.argv:
print '''USAGE:
python to_sqldb.py list_name mbox_file [mbox_file]'''
@@ -170,3 +169,4 @@ python to_sqldb.py list_name mbox_file [mbox_file]'''
if os.path.exists(mbfile):
to_db(mbfile, sys.argv[1], store)
print ' %s emails are stored into the database' % store.get_list_size(sys.argv[1])
+
diff --git a/setup.py b/setup.py
index 43521f5..bacfbf1 100644
--- a/setup.py
+++ b/setup.py
@@ -22,4 +22,9 @@ setup(
'python-dateutil < 2.0' # 2.0+ is for Python 3
'mock',
],
+ entry_points={
+ 'console_scripts': [
+ 'kittystore-import = kittystore.import:main',
+ ],
+ },
)