Skip to content
This repository has been archived by the owner on May 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from brejoc/master
Browse files Browse the repository at this point in the history
ini style config
  • Loading branch information
RaymiiOrg committed Apr 9, 2013
2 parents 154dbf7 + 556f3ff commit 7ac4b0d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 13 deletions.
9 changes: 9 additions & 0 deletions nopriv.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[nopriv]
imap_server = imap.gmail.com
imap_user = xyz@googlemail.com
imap_password = my_secrept_password
imap_folder = INBOX, Draft, Newletters

#optional
ssl = true
incremental_backup = true
61 changes: 48 additions & 13 deletions nopriv.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,58 @@
import errno
import datetime
import fileinput
import ConfigParser
from quopri import decodestring

###########################
# Do not edit above here #
###########################
# places where the config could be located
config_file_paths = [
'./nopriv.ini',
'./.nopriv.ini',
'~/.config/nopriv.ini',
'/opt/local/etc/nopriv.ini',
'/etc/nopriv.ini'
]

config = ConfigParser.RawConfigParser()
found = False
for conf_file in config_file_paths:
if os.path.isfile(conf_file):
config.read(conf_file)
found = True
break
if found == False:
message = "No config file found. Expected places: %s" % \
("\n".join(config_file_paths), )
raise Exception(message)


IMAPSERVER = config.get('nopriv', 'imap_server')
IMAPLOGIN = config.get('nopriv', 'imap_user')
IMAPPASSWORD = config.get('nopriv', 'imap_password')

IMAPFOLDER = [ folder.strip() for folder in \
config.get('nopriv', 'imap_folder').split(',') \
if folder.strip() != "" ]

yes_flags = ['true', 1, '1', 'True', 'yes', 'y', 'on']

ssl = False
try:
ssl_value = config.get('nopriv', 'ssl')
if ssl_value in yes_flags:
ssl = True
except:
pass

IMAPSERVER = ""
IMAPLOGIN = ""
IMAPPASSWORD = ""
IMAPFOLDER = ["", "", ""]
incremental_backup = False
try:
incremental_value = config.get('nopriv', 'incremental_backup')
if incremental_value in yes_flags:
incremental_backup = True
except:
pass

ssl = True
incremental_backup = True

###########################
# Do not edit below here #
###########################
enable_html = True
CreateMailDir = True
messages_per_overview_page = 50
Expand Down Expand Up @@ -793,4 +828,4 @@ def backup_mails_to_html_from_local_maildir(folder):
print("\n")

if not incremental_backup:
moveMailDir(maildir)
moveMailDir(maildir)

0 comments on commit 7ac4b0d

Please sign in to comment.