Create accepted stands tree
authorPieter De Praetere <pieter.de.praetere@helptux.be>
Sun, 3 Jan 2021 14:49:54 +0000 (15:49 +0100)
committerPieter De Praetere <pieter.de.praetere@helptux.be>
Sun, 3 Jan 2021 14:49:54 +0000 (15:49 +0100)
scripts/create_skeleton_for_accepted_stands.py
scripts/pull_code_for_accepted_stands.py [deleted file]

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..62ba07c31f77702c1d8d98af254a13960f7038b3 100644 (file)
@@ -0,0 +1,76 @@
+import requests
+from os import mkdir
+from os.path import exists, isfile, isdir
+
+
+def fetch():
+    result = requests.get('http://stands.fosdem.org/submission/api/accepted')
+    result.raise_for_status()
+    return result.json()
+
+
+def create_skeleton(stand_o):
+    path = '../content/stands/{0}'.format(stand_o['submission']['project']['name'].lower())
+    static_path = '../static/stands/{0}'.format(stand_o['submission']['project']['name'].lower())
+    if not exists(path):
+        mkdir(path)
+    if not exists(static_path):
+        mkdir(static_path)
+    _index = """---
+title: {0}
+themes:
+ - {1}
+website: {2}
+logo: stands/{3}/logo.png
+description: |
+    {4}
+
+showcase: |
+    {5}
+
+new_this_year: |
+    {6}
+
+layout: stand
+---
+Welcome to the {0} stand!
+""".format(
+    stand_o['submission']['project']['name'],
+    stand_o['submission']['project']['theme']['theme'],
+    stand_o['submission']['project']['website'],
+    stand_o['submission']['project']['name'].lower(),
+    stand_o['submission']['project']['description'],
+    stand_o['submission']['digital_edition']['showcase'],
+    stand_o['submission']['digital_edition']['new_this_year']
+)
+    if not exists('{0}/_index.md'.format(path)):
+        with open('{0}/_index.md'.format(path), 'w') as fh:
+            fh.write(_index)
+
+
+def main():
+    print('Fetching list of accepted stands ... ', end=None)
+    try:
+        accepted_stands = fetch()
+    except Exception as e:
+        print('[FAILED]')
+        print('\t\t {0}'.format(e))
+        return(10)
+    else:
+        print('[OK]')
+    for stand in accepted_stands:
+        print('Creating skeleton for {0} ... '.format(stand['submission']['project']['name']), end=None)
+        try:
+            create_skeleton(stand)
+        except Exception as e:
+            print('[FAILED]')
+            print('\t\t {0}'.format(e))
+        else:
+            print('[OK]')
+    return 0
+
+
+
+if __name__ == '__main__':
+    exit(main())
+
diff --git a/scripts/pull_code_for_accepted_stands.py b/scripts/pull_code_for_accepted_stands.py
deleted file mode 100644 (file)
index e69de29..0000000