First bits of renderer code
This commit is contained in:
parent
c53c8a4f16
commit
9a61bf5456
5
parse
5
parse
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import os, argparse, hashlib, email, email.header, email.utils, glob, sqlite3, time
|
import os, argparse, hashlib, email, email.header, email.utils, glob, sqlite3, time
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Parses emails into an SQLite database, and optionally renders static HTML files.')
|
parser = argparse.ArgumentParser(description='Parses emails into an SQLite database and an attachment folder.')
|
||||||
|
|
||||||
parser.add_argument('-p', dest='pattern', action='store', default='*',
|
parser.add_argument('-p', dest='pattern', action='store', default='*',
|
||||||
help='glob pattern (including path) that has to be matched for a file to be parsed')
|
help='glob pattern (including path) that has to be matched for a file to be parsed')
|
||||||
|
@ -13,9 +13,6 @@ parser.add_argument('-d', dest='database', action='store', default='emails.db',
|
||||||
parser.add_argument('-a', dest='attachment_dir', action='store', default='attachments',
|
parser.add_argument('-a', dest='attachment_dir', action='store', default='attachments',
|
||||||
help='path where attachments should be stored (will be created if it does not exist yet)')
|
help='path where attachments should be stored (will be created if it does not exist yet)')
|
||||||
|
|
||||||
parser.add_argument('-r', '--render', dest='render', action='store_true',
|
|
||||||
help='render static HTML files using template files')
|
|
||||||
|
|
||||||
parser.add_argument('-f', '--forced', dest='forced', action='store_true',
|
parser.add_argument('-f', '--forced', dest='forced', action='store_true',
|
||||||
help='force insertion into database, even if entries already exist')
|
help='force insertion into database, even if entries already exist')
|
||||||
|
|
||||||
|
|
23
render
Executable file
23
render
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os, argparse, hashlib, sqlite3, time
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='Renders static HTML pages and indexes from an SQLite database of emails and an attachment folder.')
|
||||||
|
|
||||||
|
parser.add_argument('-d', dest='database', action='store', default='emails.db',
|
||||||
|
help='path of the database that should be used to render the e-mail files')
|
||||||
|
|
||||||
|
parser.add_argument('-a', dest='attachment_dir', action='store', default='attachments',
|
||||||
|
help='path where attachments are stored')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
options = vars(args)
|
||||||
|
|
||||||
|
# Connect to database
|
||||||
|
database = sqlite3.connect(options['database'])
|
||||||
|
cursor = database.cursor()
|
||||||
|
|
||||||
|
cursor.execute("SELECT * FROM emails")
|
||||||
|
email_list = cursor.fetchall()
|
||||||
|
|
||||||
|
print email_list
|
Loading…
Reference in a new issue