diff options
| author | Abhilash Raj | 2014-09-19 06:59:12 +0530 |
|---|---|---|
| committer | Abhilash Raj | 2014-09-19 06:59:12 +0530 |
| commit | 6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1 (patch) | |
| tree | bf68d953616cd85bc14d3dee866998272fdfb506 /src/mailman/utilities/importer.py | |
| parent | 917c7fab696151743e4765560d55565ec8e8e38e (diff) | |
| download | mailman-6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1.tar.gz mailman-6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1.tar.zst mailman-6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1.zip | |
Diffstat (limited to 'src/mailman/utilities/importer.py')
| -rw-r--r-- | src/mailman/utilities/importer.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py index cf22af24f..9856a8223 100644 --- a/src/mailman/utilities/importer.py +++ b/src/mailman/utilities/importer.py @@ -198,6 +198,14 @@ NAME_MAPPINGS = dict( send_welcome_msg='send_welcome_message', ) +# Datetime Fields that need a type conversion to python datetime +# object for SQLite database. +DATETIME_OBJECTS = [ + 'created_at', + 'digest_last_sent_at', + 'last_post_time', +] + EXCLUDES = set(( 'digest_members', 'members', @@ -217,6 +225,9 @@ def import_config_pck(mlist, config_dict): # Some attributes must not be directly imported. if key in EXCLUDES: continue + # Created at must not be set, it needs a type conversion + if key in DATETIME_OBJECTS: + continue # Some attributes from Mailman 2 were renamed in Mailman 3. key = NAME_MAPPINGS.get(key, key) # Handle the simple case where the key is an attribute of the @@ -238,6 +249,15 @@ def import_config_pck(mlist, config_dict): except (TypeError, KeyError): print('Type conversion error for key "{}": {}'.format( key, value), file=sys.stderr) + for key in DATETIME_OBJECTS: + try: + value = datetime.datetime.utcfromtimestamp(config_dict[key]) + except KeyError: + continue + if key == 'last_post_time': + setattr(mlist, 'last_post_at', value) + continue + setattr(mlist, key, value) # Handle the archiving policy. In MM2.1 there were two boolean options # but only three of the four possible states were valid. Now there's just # an enum. |
