From 359b3bf9bc4eb8d8a58e6f31805fdd06eed3d8cf Mon Sep 17 00:00:00 2001
From: Sebastian Lobinger <sebastian.lobinger@fu-berlin.de>
Date: Thu, 1 Jun 2017 09:20:52 +0200
Subject: [PATCH] update basic structure for exampleApp - correct some
 misstakes

no use of dict get method in create_hub to force exceptions on creation
process
---
 ExampleApp/__init__.py        | 13 ++++++-------
 ExampleApp/config/config.yaml |  9 ++++-----
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/ExampleApp/__init__.py b/ExampleApp/__init__.py
index 40b19cf..4e6336a 100644
--- a/ExampleApp/__init__.py
+++ b/ExampleApp/__init__.py
@@ -1,20 +1,19 @@
-#from .sams_classes import SAMSHub
 import yaml, os, glob
 from sams_classes import SAMSHub, SAMSApp
+from flask import Flask
 
 def create_hub():
   with open('ExampleApp/config/config.yaml', 'r') as f:
     hubConf = yaml.load(f.read())
-  hub = SAMSHub(name='main', config=hubConf.get('ExampleApp',
-    { 'default_language': 'en', 'main_app': 'Main'}))
+  hub = SAMSHub(name= __name__, config=hubConf['exampleApp'])
   hub.flaskApp.config.update(hubConf.get('flask', {}))
-  for appName in hubConf.get('apps', []):
-    with open('ExampleApp/' + appName + '/manifest.yaml') as f:
+  for appName in hubConf['apps']:
+    with open(appName.replace('.', '/') + '/manifest.yaml') as f:
       manifest = yaml.load(f.read())
     langDict = {'en': {}}
-    for yaml_file in search_yaml_files('ExampleApp' + '/' + appName + '/lang/'):
+    for yaml_file in search_yaml_files(appName.replace('.', '/') + '/lang/'):
       with open(yaml_file) as f:
-        singleLang = yaml.load(f.read)
+        singleLang = yaml.load(f.read())
       langDict.update(
         {os.path.splitext(os.path.basename(yaml_file))[0]: singleLang})
     hub.addApp(SAMSApp(name = appName, manifest = manifest, langDict = langDict))
diff --git a/ExampleApp/config/config.yaml b/ExampleApp/config/config.yaml
index d234576..c1d153d 100644
--- a/ExampleApp/config/config.yaml
+++ b/ExampleApp/config/config.yaml
@@ -1,9 +1,8 @@
 flask:
   DEBUG: true
   jinja2_strict_undefined: true
-samsHUB:
+exampleApp:
   default_language: de
-  apps:
-    - ExampleApp.Main
-    - ExampleApp.Extra
-  main_app: ExampleApp.Main
\ No newline at end of file
+  main_app: 'ExampleApp.Main'
+apps:
+  - 'ExampleApp.Main'
\ No newline at end of file
-- 
GitLab