Commit ef2f0195 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

#342668: mboximport option to skip signature

--HG--
branch : stable
parent 1c69ccc93fb4
......@@ -34,6 +34,11 @@ class MBOXImportCommand(Command):
'default': False,
'help': 'ask confirmation to continue after an error.',
}),
("skip-sign",
{'short': 's', 'action' : 'store_true',
'default': False,
'help': 'skip email signature.',
}),
)
def run(self, args):
......@@ -42,7 +47,8 @@ class MBOXImportCommand(Command):
cnx = config_connect(appid, self.config)
cnx.load_appobjects(cubes=None, subpath=('entities',))
importer = MBOXImporter(cnx, verbose=True,
interactive=self.config.interactive)
interactive=self.config.interactive,
skipsign=self.config.skip_sign)
# set autocommit, add an option to control that if needed
importer.autocommit_mode()
try:
......
......@@ -36,14 +36,14 @@ def combinaison(list):
class MBOXImporter(object):
"""import content of a Unix mailbox into cubicweb as Email (and related) objects"""
def __init__(self, cnx,
verbose=False, interactive=False):
def __init__(self, cnx, verbose=False, interactive=False, skipsign=False):
self.cnx = cnx
self.schema = cnx.get_schema()
self.req = cnx.request()
self.execute = self.req.execute
self._verbose = verbose
self._interactive = interactive
self._skipsign = skipsign
self.created = {}
self.skipped = []
self.error = []
......@@ -166,6 +166,8 @@ class MBOXImporter(object):
if main == 'text':
encoding = u'UTF-8'
elif contenttype == 'application/pgp-signature':
if self._skipsign:
return
encoding = u'ascii'
if isinstance(data, str):
data = unicode(data, encoding)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment