Commit b2622e4a authored by mouadh's avatar mouadh

config file dash

parent 5d7e68cc
...@@ -4,7 +4,7 @@ import os ...@@ -4,7 +4,7 @@ import os
from lxml import etree from lxml import etree
from .models import Cube, Dimension, Facts, Table from .models import Cube, Dimension, Facts, Table, Dashboard
class ConfigParser: class ConfigParser:
...@@ -294,6 +294,24 @@ class ConfigParser: ...@@ -294,6 +294,24 @@ class ConfigParser:
except: except:
raise ('Bad configuration in the configuration file') raise ('Bad configuration in the configuration file')
def construct_cubes(self, client_type='excel'):
"""
Construct cube (with it dimensions) and facts from the config file.
:param client_type: excel | web
:return: list of Cubes instance
"""
if self.config_file_exist(client_type):
if client_type == 'excel':
return self._construct_cubes_excel()
elif client_type == 'web':
return self._construct_cubes_web()
else:
raise ("Config file don't exist")
def _construct_cubes_web(self): def _construct_cubes_web(self):
# try: # try:
...@@ -338,18 +356,22 @@ class ConfigParser: ...@@ -338,18 +356,22 @@ class ConfigParser:
# except: # except:
# raise ('Bad configuration in the configuration file') # raise ('Bad configuration in the configuration file')
def construct_cubes(self, client_type='excel'): def construct_web_dashboard(self):
"""
Construct cube (with it dimensions) and facts from the config file.
:param client_type: excel | web
:return: list of Cubes instance
"""
if self.config_file_exist(client_type): # try:
if client_type == 'excel': with open(os.path.join(self.cube_path,
return self._construct_cubes_excel() self.web_config_file_name)) as config_file:
elif client_type == 'web':
return self._construct_cubes_web()
else: parser = etree.XMLParser()
raise ("Config file don't exist") tree = etree.parse(config_file, parser)
return [
Dashboard(
pie_charts=dashboard.find('PieCharts').text.split(','),
bar_chats=dashboard.find('BarCharts').text.split(',')
) for dashboard in tree.xpath('/cubes/cube/Dashboards/Dashboard')
]
# except:
# raise ('Bad configuration in the configuration file')
...@@ -69,3 +69,20 @@ class Table: ...@@ -69,3 +69,20 @@ class Table:
def __str__(self): def __str__(self):
return str(self.__dict__) return str(self.__dict__)
class Dashboard:
"""Column class used to encapsulate config file attributes for web client."""
def __init__(self, **kwargs):
"""
:param kwargs: {
table_name : 'something',
old_column_name : 'something',
new_column_name : 'something'
}
"""
self.__dict__.update(kwargs)
def __str__(self):
return str(self.__dict__)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment