You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2020/08/21 23:06:38 UTC
[incubator-ponymail-foal] branch master updated (414703e -> 0ad3325)
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.
from 414703e Local index method no longer exists
new 04aaf6c Simplify
new 0ad3325 Use config plugin
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
tools/archiver.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
[incubator-ponymail-foal] 02/02: Use config plugin
Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 0ad3325dd3b1ce41ce6dff622a6a6f3b698d3d4a
Author: Sebb <se...@apache.org>
AuthorDate: Sat Aug 22 00:06:19 2020 +0100
Use config plugin
---
tools/archiver.py | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/tools/archiver.py b/tools/archiver.py
index 5ca4ebb..39b236f 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -58,30 +58,29 @@ import formatflowed
import netaddr
import yaml
+import plugins.ponymailconfig
import plugins.generators
import plugins.elastic
import elasticsearch
# Fetch config from same dir as archiver.py
-config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ponymail.yaml")
-config = yaml.safe_load(open(config_path))
+config = plugins.ponymailconfig.PonymailConfig()
# Set some vars before we begin
-archiver_generator = config["archiver"].get(
- "generator", "full"
-) # Fall back to full hashing if nothing is set.
+archiver_generator = config.get("archiver", "generator", fallback="full")
+# Fall back to full hashing if nothing is set.
logger = None
# If MailMan is enabled, import and set it up
-if config.get("mailman") and config["mailman"].get("plugin"):
+if config.has_option("mailman", "plugin"):
from mailman.interfaces.archiver import ArchivePolicy, IArchiver
from zope.interface import implementer
logger = logging.getLogger("mailman.archiver")
# Access URL once archived
-aURL = config.get("archiver", {}).get("baseurl")
+aURL = config.get("archiver", "baseurl")
def encode_base64(buff: bytes) -> str:
@@ -219,7 +218,7 @@ class Body:
class Archiver(object): # N.B. Also used by import-mbox.py
"""The general archiver class. Compatible with MailMan3 archiver classes."""
- if config.get("mailman") and config["mailman"].get("plugin"):
+ if config.has_option("mailman", "plugin"):
implementer(IArchiver)
# This is a list of headers which are stored in msg_metadata
@@ -246,7 +245,7 @@ class Archiver(object): # N.B. Also used by import-mbox.py
self.html = parse_html
self.generator = generator
self.dump_dir = dump_dir
- self.cropout = config.get("debug", {}).get("cropout")
+ self.cropout = config.get("debug", "cropout")
if parse_html:
import html2text
[incubator-ponymail-foal] 01/02: Simplify
Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 04aaf6c9cf878386ef79e8f9c47aa520d5fee20a
Author: Sebb <se...@apache.org>
AuthorDate: Fri Aug 21 23:28:27 2020 +0100
Simplify
---
tools/archiver.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/archiver.py b/tools/archiver.py
index 1163cb0..5ca4ebb 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -331,7 +331,7 @@ class Archiver(object): # N.B. Also used by import-mbox.py
lid = lid.replace(self.cropout, "")
def default_empty_string(value):
- return value and str(value) or ""
+ return str(value) if value else ""
msg_metadata = dict([(k, default_empty_string(msg.get(k))) for k in self.keys])
mid = (
@@ -466,6 +466,7 @@ class Archiver(object): # N.B. Also used by import-mbox.py
print("**** Dry run, not saving message to database *****")
return lid, ojson["mid"]
+ # TODO: this belongs in __init__ once that has access to args.dry
if self.dump_dir:
try:
self.elastic = plugins.elastic.Elastic()