Commit d8ead269 authored by Stefane Fermigier's avatar Stefane Fermigier

Format.

parent 2fe0efa9
......@@ -5,8 +5,8 @@ from __future__ import absolute_import, division, print_function
import itertools
import os
import re
from os.path import expanduser
from collections import OrderedDict
from os.path import expanduser
import numpy as np
import pandas as pd
......@@ -730,8 +730,7 @@ class MdxEngine:
self.execute_one_tuple(tupl, start_df,
columns_to_keep.values()))
cols = list(
itertools.chain.from_iterable(columns_to_keep.values()))
cols = list(itertools.chain.from_iterable(columns_to_keep.values()))
# TODO BUG !!! https://github.com/pandas-dev/pandas/issues/15525
# solution 1 .astype(str) ( take a lot of time from execution)
......
......@@ -4,10 +4,11 @@ import os
from lxml import etree
from .models import Cube, Facts, Dimension
from .models import Cube, Dimension, Facts
class ConfigParser:
def __init__(self, cube_path, file_name='cubes-config.xml'):
self.cube_path = cube_path
self.file_name = file_name
......@@ -57,8 +58,7 @@ class ConfigParser:
table_name=xml_facts.find('table_name').text,
keys={
key.text: key.attrib['ref']
for key in xml_facts.findall(
'keys/column_name')
for key in xml_facts.findall('keys/column_name')
},
measures=[
mes.text
......
......@@ -2,6 +2,7 @@ import psycopg2 as pg
class MyDB(object):
def __init__(self,
username='postgres',
password='root',
......
class Facts:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
......@@ -7,6 +8,7 @@ class Facts:
class Dimension:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
......@@ -15,6 +17,7 @@ class Dimension:
class Cube:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
......
......@@ -5,6 +5,7 @@ from spyne.model.fault import Fault
class Tuple(object):
def __init__(self, Hierarchy, UName, Caption, LName, LNum, DisplayInfo,
PARENT_UNIQUE_NAME, HIERARCHY_UNIQUE_NAME, Value):
self.Hierarchy = Hierarchy
......@@ -92,9 +93,7 @@ class Propertielist(ComplexModel):
class Command(ComplexModel):
_type_info = {
'Statement': Unicode,
}
_type_info = {'Statement': Unicode,}
class ExecuteRequest(ComplexModel):
......
......@@ -13,9 +13,8 @@ from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from ..mdx.tools.config_file_parser import ConfigParser
from ..services.models import DiscoverRequest, ExecuteRequest, Session\
# , AuthenticationError
from ..services.models import DiscoverRequest # , AuthenticationError
from ..services.models import ExecuteRequest, Session
from .xmla_discover_tools import XmlaDiscoverTools
from .xmla_execute_tools import XmlaExecuteTools
from .xmla_execute_xsds import execute_xsd
......@@ -45,7 +44,7 @@ class XmlaProviderService(ServiceBase):
_out_header=Session,
_throws=InvalidCredentialsError
# _throws=AuthenticationError
)
)
def Discover(ctx, request):
"""
the first principle function of xmla protocol
......@@ -105,8 +104,7 @@ class XmlaProviderService(ServiceBase):
return discover_tools.discover_mdschema_measures__response(request)
elif request.RequestType == "MDSCHEMA_DIMENSIONS":
return discover_tools.discover_mdschema_dimensions_response(
request)
return discover_tools.discover_mdschema_dimensions_response(request)
elif request.RequestType == "MDSCHEMA_HIERARCHIES":
return discover_tools.discover_mdschema_hierarchies_response(
......@@ -124,8 +122,7 @@ class XmlaProviderService(ServiceBase):
request)
elif request.RequestType == "MDSCHEMA_PROPERTIES":
return discover_tools.discover_mdschema_properties_response(
request)
return discover_tools.discover_mdschema_properties_response(request)
elif request.RequestType == "MDSCHEMA_MEMBERS":
return discover_tools.discover_mdschema_members_response(request)
......
......@@ -7,14 +7,19 @@ import uuid
from lxml import etree
from ..mdx.executor.execute import MdxEngine
from .xmla_discover_xsds import (
dbschema_catalogs_xsd, dbschema_tables_xsd, discover_datasources_xsd,
discover_literals_xsd, discover_preperties_xsd,
discover_schema_rowsets_xsd, mdschema_cubes_xsd, mdschema_dimensions_xsd,
mdschema_hierarchies_xsd, mdschema_kpis_xsd, mdschema_levels_xsd,
mdschema_measures_xsd, mdschema_measuresgroups_dimensions_xsd,
mdschema_measuresgroups_xsd, mdschema_members_xsd,
mdschema_properties_PROPERTIES_xsd, mdschema_sets_xsd)
from .xmla_discover_xsds import (dbschema_catalogs_xsd, dbschema_tables_xsd,
discover_datasources_xsd,
discover_literals_xsd,
discover_preperties_xsd,
discover_schema_rowsets_xsd,
mdschema_cubes_xsd, mdschema_dimensions_xsd,
mdschema_hierarchies_xsd, mdschema_kpis_xsd,
mdschema_levels_xsd, mdschema_measures_xsd,
mdschema_measuresgroups_dimensions_xsd,
mdschema_measuresgroups_xsd,
mdschema_members_xsd,
mdschema_properties_PROPERTIES_xsd,
mdschema_sets_xsd)
# TODO clean
......@@ -73,6 +78,7 @@ class XmlaDiscoverTools():
</return>""")
def discover_properties_response(self, request):
def get_props(xsd, PropertyName, PropertyDescription, PropertyType,
PropertyAccessType, IsRequired, Value):
return etree.fromstring("""
......@@ -114,15 +120,15 @@ class XmlaDiscoverTools():
elif request.Restrictions.RestrictionList.PropertyName == 'MdpropMdxSubqueries':
if 'Unspecified' in request.Properties.PropertyList.Catalog:
return get_props(discover_preperties_xsd,
'MdpropMdxSubqueries', 'MdpropMdxSubqueries',
'int', 'Read', 'false', '15')
return get_props(discover_preperties_xsd, 'MdpropMdxSubqueries',
'MdpropMdxSubqueries', 'int', 'Read', 'false',
'15')
if request.Properties.PropertyList.Catalog is not None:
self.change_catalogue(request.Properties.PropertyList.Catalog)
return get_props(discover_preperties_xsd,
'MdpropMdxSubqueries', 'MdpropMdxSubqueries',
'int', 'Read', 'false', '15')
return get_props(discover_preperties_xsd, 'MdpropMdxSubqueries',
'MdpropMdxSubqueries', 'int', 'Read', 'false',
'15')
elif request.Restrictions.RestrictionList.PropertyName == 'MdpropMdxDrillFunctions':
if 'Unspecified' in request.Properties.PropertyList.Catalog:
......@@ -2268,8 +2274,8 @@ class XmlaDiscoverTools():
# joined -> [Product].[Product].[Company]
last_attribut = ''.join(att for att in separed_tuple[-1]
if att not in '[]').replace(
'&', '&amp;')
if att not in '[]').replace('&',
'&amp;')
return etree.fromstring("""
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"
......@@ -2284,8 +2290,7 @@ class XmlaDiscoverTools():
<LEVEL_UNIQUE_NAME>{2}</LEVEL_UNIQUE_NAME>
<LEVEL_NUMBER>0</LEVEL_NUMBER>
<MEMBER_ORDINAL>0</MEMBER_ORDINAL>
<MEMBER_NAME>""" + last_attribut +
"""</MEMBER_NAME>
<MEMBER_NAME>""" + last_attribut + """</MEMBER_NAME>
<MEMBER_UNIQUE_NAME>{3}</MEMBER_UNIQUE_NAME>
<MEMBER_TYPE>1</MEMBER_TYPE>
<MEMBER_CAPTION>""" + last_attribut +
......@@ -2299,6 +2304,6 @@ class XmlaDiscoverTools():
</row>
</root>
</return>
""".format(self.selected_catalogue, separed_tuple[0],
joined, request.Restrictions.RestrictionList.
MEMBER_UNIQUE_NAME))
""".format(self.selected_catalogue, separed_tuple[
0], joined, request.
Restrictions.RestrictionList.MEMBER_UNIQUE_NAME))
......@@ -302,8 +302,8 @@ class XmlaExecuteTools():
"""
columns_loop = []
if (len(mdx_execution_result['columns_desc']['columns'].keys()) == 0) ^ (
len(mdx_execution_result['columns_desc']['rows'].keys()) == 0):
if (len(mdx_execution_result['columns_desc']['columns'].keys()) == 0
) ^ (len(mdx_execution_result['columns_desc']['rows'].keys()) == 0):
if self.executer.facts in mdx_execution_result['columns_desc'][
'all'].keys():
......@@ -549,12 +549,12 @@ class XmlaExecuteTools():
tuple = ""
# not used dimensions
for dim_diff in list(
set(self.executer.get_all_tables_names(ignore_fact=True)) -
set([
table_name
for table_name in mdx_execution_result['columns_desc'][
'all']
])):
set(self.executer.get_all_tables_names(ignore_fact=True)) - set(
[
table_name
for table_name in mdx_execution_result['columns_desc'][
'all']
])):
tuple += """
<Member Hierarchy="[{0}].[{0}]">
<UName>[{0}].[{0}].[{1}].[{2}]</UName>
......
......@@ -3,8 +3,8 @@ from __future__ import absolute_import, division, print_function
import os
import zipfile
from os.path import expanduser
from pip.download import PipSession
from pip.req import parse_requirements
from setuptools import find_packages, setup
......@@ -12,8 +12,7 @@ from setuptools import find_packages, setup
RUNNING_TOX = 'RUNTING_TOX' in os.environ
session = PipSession()
_install_requires = parse_requirements(
'requirements.txt', session=session)
_install_requires = parse_requirements('requirements.txt', session=session)
install_requires = [str(ir.req) for ir in _install_requires]
setup(
......
......@@ -19,6 +19,7 @@ RUNNING_TOX = 'RUNTING_TOX' in os.environ
class Member(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
......@@ -43,8 +44,7 @@ class WSGIServer:
Copy/pasted from pytest_localserver w/ slight changes.
"""
def __init__(self, host='127.0.0.1', port=8000, application=None,
**kwargs):
def __init__(self, host='127.0.0.1', port=8000, application=None, **kwargs):
self._server = make_server(host, port, application, **kwargs)
self.server_address = self._server.server_address
......
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