You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ponymail.apache.org by GitBox <gi...@apache.org> on 2018/05/23 11:07:25 UTC

[GitHub] dimidd closed pull request #448: edit-list: handle config consistently

dimidd closed pull request #448: edit-list: handle config consistently
URL: https://github.com/apache/incubator-ponymail/pull/448
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/tools/edit-list.py b/tools/edit-list.py
index 1f38137..b3dcde6 100755
--- a/tools/edit-list.py
+++ b/tools/edit-list.py
@@ -27,6 +27,7 @@
 
 """
 
+import os
 import sys
 import time
 import configparser
@@ -41,8 +42,9 @@
 
 
 # Fetch config
+path = os.path.dirname(os.path.realpath(__file__))
 config = configparser.RawConfigParser()
-config.read('ponymail.cfg')
+config.read("%s/ponymail.cfg" % path)
 
 dbname = config.get("elasticsearch", "dbname")
 ssl = config.get("elasticsearch", "ssl", fallback="false").lower() == 'true'
diff --git a/tools/pony_config.py b/tools/pony_config.py
new file mode 100644
index 0000000..5bf8195
--- /dev/null
+++ b/tools/pony_config.py
@@ -0,0 +1,21 @@
+import configparser
+import os
+
+"""
+A module for consistently locating ponymail config files.
+"""
+
+FILENAME = "ponymail.cfg"
+
+
+def fetch_config():
+    """Fetch the config file from the CWD,
+    if it doesn't exist check the tools dir.
+    """
+    file_dir = os.path.dirname(os.path.realpath(__file__))
+    config = configparser.RawConfigParser()
+    if os.path.isfile("./%s" % FILENAME):
+        config.read("./%s" % FILENAME)
+    else:
+        config.read("%s/%s" % (file_dir, FILENAME))
+    return config


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services