Commit 8635deb6 authored by mouadh's avatar mouadh

format

parent 9f3a6365
......@@ -2,6 +2,7 @@
from __future__ import absolute_import, division, print_function
import xmlwitch
import os
from datetime import datetime
from os.path import expanduser
......@@ -158,11 +159,16 @@ class XmlaProviderService(ServiceBase):
if request.Command.Statement == '':
# check if command contains a query
return etree.fromstring("""
xml = xmlwitch.Builder()
# xml.return return reserved of course
xml.root(xmlns="urn:schemas-microsoft-com:xml-analysis:empty")
return """
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:empty"/>
{0}
</return>
""")
""".format(str(xml))
else:
XmlaProviderService.discover_tools.change_catalogue(
request.Properties.PropertyList.Catalog)
......@@ -171,6 +177,28 @@ class XmlaProviderService(ServiceBase):
df = executer.execute_mdx()
xmla_tools = XmlaExecuteTools(executer)
# xml = xmlwitch.Builder()
# with xml.OlapInfo(xmla_tools.generate_cell_info()):
# with xml.CubeInfo:
# with xml.Cube:
# xml.CubeName('Sales')
# xml.LastDataUpdate(datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
# xmlns="http://schemas.microsoft.com/analysisservices/2003/engine")
# xml.LastSchemaUpdate(datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
# xmlns="http://schemas.microsoft.com/analysisservices/2003/engine")
# xml.AxesInfo(xmla_tools.generate_axes_info(df),
# xmla_tools.generate_axes_info_slicer(df))
#
# xml.Axes(xmla_tools.generate_xs0(df),
# xmla_tools.generate_slicer_axis(df))
#
# xml.CellData(xmla_tools.generate_cell_data(df))
return etree.fromstring("""
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:mddataset"
......
......@@ -4,6 +4,10 @@ from __future__ import absolute_import, division, print_function
import uuid
import xmlwitch
import HTMLParser
from lxml import etree
import os
......@@ -52,94 +56,200 @@ class XmlaDiscoverTools():
@staticmethod
def discover_datasources_response():
return etree.fromstring("""
xml = xmlwitch.Builder()
with xml.root(discover_datasources_xsd, xmlns="urn:schemas-microsoft-com:xml-analysis:rowset",
**{'xmlns:EX': 'urn:schemas-microsoft-com:xml-analysis:exception',
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
# "xmlns:EX='urn:schemas-microsoft-com:xml-analysis:exception'"
# "xmlns:xsd='http://www.w3.org/2001/XMLSchema'"
# "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'",
):
with xml.row:
xml.DataSourceName('sales')
xml.DataSourceDescription('sales Sample Data')
xml.URL('http://127.0.0.1:8000/xmla')
xml.DataSourceInfo('-')
xml.ProviderName('olapy')
xml.ProviderType('MDP')
xml.AuthenticationMode('Unauthenticated')
return """
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
xmlns:EX="urn:schemas-microsoft-com:xml-analysis:exception"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
""" + discover_datasources_xsd + """
<row>
<DataSourceName>sales</DataSourceName>
<DataSourceDescription>sales Sample Data</DataSourceDescription>
<URL>http://127.0.0.1:8000/xmla</URL>
<DataSourceInfo>-</DataSourceInfo>
<ProviderName>olapy</ProviderName>
<ProviderType>MDP</ProviderType>
<AuthenticationMode>Unauthenticated</AuthenticationMode>
</row>
</root>
</return>""")
{0}
</return>
""".format(str(xml))
# return etree.fromstring("""
# <return>
# <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
# xmlns:EX="urn:schemas-microsoft-com:xml-analysis:exception"
# xmlns:xsd="http://www.w3.org/2001/XMLSchema"
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
# """ + discover_datasources_xsd + """
# <row>
# <DataSourceName>sales</DataSourceName>
# <DataSourceDescription>sales Sample Data</DataSourceDescription>
# <URL>http://127.0.0.1:8000/xmla</URL>
# <DataSourceInfo>-</DataSourceInfo>
# <ProviderName>olapy</ProviderName>
# <ProviderType>MDP</ProviderType>
# <AuthenticationMode>Unauthenticated</AuthenticationMode>
# </row>
# </root>
# </return>""")
def discover_properties_response(self, request):
def get_props(xsd, PropertyName, PropertyDescription, PropertyType,
PropertyAccessType, IsRequired, Value):
xml = xmlwitch.Builder()
# xml.DataSourceName('sales')
# xml.DataSourceDescription('sales Sample Data')
# xml.URL('http://127.0.0.1:8000/xmla')
# xml.DataSourceInfo('-')
# xml.ProviderName('olapy')
# xml.ProviderType('MDP')
# xml.AuthenticationMode('Unauthenticated')
if PropertyName is not '':
rows = """
<row>
<PropertyName>{0}</PropertyName>
<PropertyDescription>{1}</PropertyDescription>
<PropertyType>{2}</PropertyType>
<PropertyAccessType>{3}</PropertyAccessType>
<IsRequired>{4}</IsRequired>
<Value>{5}</Value>
</row>
""".format(PropertyName, PropertyDescription, PropertyType,
PropertyAccessType, IsRequired, Value)
# return """
# <return>
# <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
# xmlns:xsd="http://www.w3.org/2001/XMLSchema"
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
# {0}
# {1}
# </root>
# </return>
# """.format(xsd, rows))
with xml.root(str(xsd), xmlns="urn:schemas-microsoft-com:xml-analysis:rowset",
**{'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'}):
with xml.row:
xml.PropertyName(PropertyName)
xml.PropertyDescription(PropertyDescription)
xml.PropertyType(PropertyType)
xml.PropertyAccessType(PropertyAccessType)
xml.IsRequired(IsRequired)
xml.Value(Value)
# rows = """
# <row>
# <PropertyName>{0}</PropertyName>
# <PropertyDescription>{1}</PropertyDescription>
# <PropertyType>{2}</PropertyType>
# <PropertyAccessType>{3}</PropertyAccessType>
# <IsRequired>{4}</IsRequired>
# <Value>{5}</Value>
# </row>
# """.format(PropertyName, PropertyDescription, PropertyType,
# PropertyAccessType, IsRequired, Value)
else:
rows = """
<row>
<PropertyName>ServerName</PropertyName>
<PropertyDescription>ServerName</PropertyDescription>
<PropertyType>string</PropertyType>
<PropertyAccessType>Read</PropertyAccessType>
<IsRequired>false</IsRequired>
<Value>{0}</Value>
</row>
<row>
<PropertyName>ProviderVersion</PropertyName>
<PropertyDescription>ProviderVersion</PropertyDescription>
<PropertyType>string</PropertyType>
<PropertyAccessType>Read</PropertyAccessType>
<IsRequired>false</IsRequired>
<Value>0.0.3 25-Nov-2016 07:20:28 GMT</Value>
</row>
<row>
<PropertyName>MdpropMdxSubqueries</PropertyName>
<PropertyDescription>MdpropMdxSubqueries</PropertyDescription>
<PropertyType>int</PropertyType>
<PropertyAccessType>Read</PropertyAccessType>
<IsRequired>false</IsRequired>
<Value>15</Value>
</row>
<row>
<PropertyName>MdpropMdxDrillFunctions</PropertyName>
<PropertyDescription>MdpropMdxDrillFunctions</PropertyDescription>
<PropertyType>int</PropertyType>
<PropertyAccessType>Read</PropertyAccessType>
<IsRequired>false</IsRequired>
<Value>3</Value>
</row>
<row>
<PropertyName>MdpropMdxNamedSets</PropertyName>
<PropertyDescription>MdpropMdxNamedSets</PropertyDescription>
<PropertyType>int</PropertyType>
<PropertyAccessType>Read</PropertyAccessType>
<IsRequired>false</IsRequired>
<Value>15</Value>
</row>
""".format(os.getenv('USERNAME', 'default'))
properties_names_n_description = ['ServerName',
'ProviderVersion',
'MdpropMdxSubqueries',
'MdpropMdxDrillFunctions',
'MdpropMdxNamedSets']
properties_types = ['string',
'string',
'int',
'int',
'int']
values = [os.getenv('USERNAME', 'default'),
'0.0.3 25-Nov-2016 07:20:28 GMT',
'15',
'3',
'15']
with xml.root(str(xsd), xmlns="urn:schemas-microsoft-com:xml-analysis:rowset",
**{'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance'}):
for idx,prop_desc in enumerate(properties_names_n_description):
with xml.row:
xml.PropertyName(prop_desc)
xml.PropertyDescription(prop_desc)
xml.PropertyType(properties_types[idx])
xml.PropertyAccessType('Read')
xml.IsRequired('false')
xml.Value(values[idx])
#
#
# rows = """
# <row>
# <PropertyName>ServerName</PropertyName>
# <PropertyDescription>ServerName</PropertyDescription>
# <PropertyType>string</PropertyType>
# <PropertyAccessType>Read</PropertyAccessType>
# <IsRequired>false</IsRequired>
# <Value>{0}</Value>
# </row>
# <row>
# <PropertyName>ProviderVersion</PropertyName>
# <PropertyDescription>ProviderVersion</PropertyDescription>
# <PropertyType>string</PropertyType>
# <PropertyAccessType>Read</PropertyAccessType>
# <IsRequired>false</IsRequired>
# <Value>0.0.3 25-Nov-2016 07:20:28 GMT</Value>
# </row>
# <row>
# <PropertyName>MdpropMdxSubqueries</PropertyName>
# <PropertyDescription>MdpropMdxSubqueries</PropertyDescription>
# <PropertyType>int</PropertyType>
# <PropertyAccessType>Read</PropertyAccessType>
# <IsRequired>false</IsRequired>
# <Value>15</Value>
# </row>
# <row>
# <PropertyName>MdpropMdxDrillFunctions</PropertyName>
# <PropertyDescription>MdpropMdxDrillFunctions</PropertyDescription>
# <PropertyType>int</PropertyType>
# <PropertyAccessType>Read</PropertyAccessType>
# <IsRequired>false</IsRequired>
# <Value>3</Value>
# </row>
# <row>
# <PropertyName>MdpropMdxNamedSets</PropertyName>
# <PropertyDescription>MdpropMdxNamedSets</PropertyDescription>
# <PropertyType>int</PropertyType>
# <PropertyAccessType>Read</PropertyAccessType>
# <IsRequired>false</IsRequired>
# <Value>15</Value>
# </row>
# """.format(os.getenv('USERNAME', 'default'))
#
# return etree.fromstring("""
# <return>
# <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
# xmlns:xsd="http://www.w3.org/2001/XMLSchema"
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
# {0}
# {1}
# </root>
# </return>
# """.format(xsd, rows))
# escape gt; lt; (from xsd)
html_parser = HTMLParser.HTMLParser()
xml = html_parser.unescape(str(xml))
# return xml
return """
<return>
{0}
</return>
""".format(xml)
return etree.fromstring("""
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
{0}
{1}
</root>
</return>
""".format(xsd, rows))
if request.Restrictions.RestrictionList.PropertyName == 'Catalog':
if request.Properties.PropertyList.Catalog is not None:
......
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