[gsoc-admin] config: Add fetching of main data



commit 976263e7b3ffdd3f2b690bde31cff29d14a19d5a
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date:   Wed Aug 12 12:20:57 2015 +0200

    config: Add fetching of main data

 email/config.py |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/email/config.py b/email/config.py
index e99168a..89679b2 100644
--- a/email/config.py
+++ b/email/config.py
@@ -1,6 +1,34 @@
 #!/usr/bin/env python3
 
 import configparser
+import datetime
+
+
+def apply_substitutions(uri):
+    now = datetime.datetime.now()
+    substitutions = {
+        'year': now.year,
+        'month': now.month,
+        'day': now.day,
+        'hour': now.hour,
+        'minute': now.minute}
+    return uri.format(substitutions)
+
+
+def get_main_data_from_section(section):
+    """
+    This one will search for 'url' or 'path' settings, eventually supply data
+    to them and get the data wanted.
+    """
+    assert ('url' in section) != ('path' in section)
+    if 'url' in section:
+        source = apply_substitutions(section['url'])
+
+        raise NotImplementedError
+    else:
+        source = apply_substitutions(section['path'])
+        with open(source) as file:
+            return file.read()
 
 
 class EventConfig:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]