Skip to content

Commit 091c38f

Browse files
committed
wip
1 parent dfcffe0 commit 091c38f

7 files changed

+37
-37
lines changed

pyodata/model/build_functions.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import copy
55
import logging
66

7-
import pyodata.config as pyodata
7+
import pyodata.config as conf
88
import pyodata.policies as policies
99
import pyodata.exceptions as exceptions
1010
import pyodata.model.elements as elements
@@ -18,7 +18,7 @@ def modlog():
1818
return logging.getLogger("callbacks")
1919

2020

21-
def build_struct_type_property(config: pyodata.Config, entity_type_property_node):
21+
def build_struct_type_property(config: conf.Config, entity_type_property_node):
2222
return elements.StructTypeProperty(
2323
entity_type_property_node.get('Name'),
2424
elements.Types.parse_type_name(entity_type_property_node.get('Type')),
@@ -42,7 +42,7 @@ def build_struct_type_property(config: pyodata.Config, entity_type_property_node
4242

4343

4444
# pylint: disable=protected-access
45-
def build_struct_type(config: pyodata.Config, type_node, typ, schema=None):
45+
def build_struct_type(config: conf.Config, type_node, typ, schema=None):
4646
name = type_node.get('Name')
4747
base_type = type_node.get('BaseType')
4848

@@ -80,7 +80,7 @@ def build_struct_type(config: pyodata.Config, type_node, typ, schema=None):
8080
return stype
8181

8282

83-
def build_complex_type(config: pyodata.Config, type_node, schema=None):
83+
def build_complex_type(config: conf.Config, type_node, schema=None):
8484
try:
8585
return elements.build_element(elements.StructType, config, type_node=type_node, typ=elements.ComplexType,
8686
schema=schema)
@@ -90,7 +90,7 @@ def build_complex_type(config: pyodata.Config, type_node, schema=None):
9090

9191

9292
# pylint: disable=protected-access
93-
def build_entity_type(config: pyodata.Config, type_node, schema=None):
93+
def build_entity_type(config: conf.Config, type_node, schema=None):
9494
try:
9595
etype = elements.build_element(elements.StructType, config, type_node=type_node, typ=elements.EntityType,
9696
schema=schema)
@@ -113,7 +113,7 @@ def build_entity_type(config: pyodata.Config, type_node, schema=None):
113113

114114

115115
# pylint: disable=protected-access, too-many-locals
116-
def build_enum_type(config: pyodata.Config, type_node, namespace):
116+
def build_enum_type(config: conf.Config, type_node, namespace):
117117
try:
118118
ename = type_node.get('Name')
119119
is_flags = type_node.get('IsFlags')
@@ -263,7 +263,7 @@ def build_value_helper_parameter(config, value_help_parameter_node):
263263

264264

265265
# pylint: disable=too-many-locals
266-
def build_function_import(config: pyodata.Config, function_import_node):
266+
def build_function_import(config: conf.Config, function_import_node):
267267
name = function_import_node.get('Name')
268268
entity_set = function_import_node.get('EntitySet')
269269
http_method = elements.metadata_attribute_get(function_import_node, 'HttpMethod')

pyodata/model/builder.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io
44
from lxml import etree
55

6-
import pyodata.config as pyodata
6+
import pyodata.config as conf
77
import pyodata.exceptions as exceptions
88
import pyodata.model.elements as elements
99
import pyodata.v2 as odata_v2
@@ -44,12 +44,12 @@ def __init__(self, xml, config=None):
4444
self._xml = xml
4545

4646
if config is None:
47-
config = pyodata.Config(odata_v2.ODataV2)
47+
config = conf.Config(odata_v2.ODataV2)
4848
self._config = config
4949

5050
# pylint: disable=missing-docstring
5151
@property
52-
def config(self) -> pyodata.Config:
52+
def config(self) -> conf.Config:
5353
return self._config
5454

5555
def build(self):
@@ -103,7 +103,7 @@ def build(self):
103103
return elements.build_element(elements.Schema, self._config, schema_nodes=edm_schemas)
104104

105105
@staticmethod
106-
def get_aliases(edmx, config: pyodata.Config):
106+
def get_aliases(edmx, config: conf.Config):
107107
"""Get all aliases"""
108108

109109
# aliases = collections.defaultdict(set)
@@ -121,7 +121,7 @@ def get_aliases(edmx, config: pyodata.Config):
121121
return aliases
122122

123123
@staticmethod
124-
def update_alias(aliases, config: pyodata.Config):
124+
def update_alias(aliases, config: conf.Config):
125125
"""Update config with aliases"""
126126
config.aliases = aliases
127127
helper_direction_keys = list(config.sap_value_helper_directions.keys())
@@ -139,7 +139,7 @@ def schema_from_xml(metadata_xml, namespaces=None):
139139

140140
meta = MetadataBuilder(
141141
metadata_xml,
142-
config=pyodata.Config(
142+
config=conf.Config(
143143
odata_v2.ODataV2,
144144
xml_namespaces=namespaces,
145145
))

pyodata/model/elements.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Union
1010

1111

12-
import pyodata.config as pyodata
12+
import pyodata.config as conf
1313
import pyodata.policies as policies
1414
import pyodata.exceptions as exceptions
1515
import pyodata.model.type_traits as base_traits
@@ -23,7 +23,7 @@ def modlog():
2323
return logging.getLogger("Elements")
2424

2525

26-
def build_element(element_name: Union[str, type], config: pyodata.Config, **kwargs):
26+
def build_element(element_name: Union[str, type], config: conf.Config, **kwargs):
2727
"""
2828
This function is responsible for resolving which implementation is to be called for parsing EDM element. It's a
2929
primitive implementation of dynamic dispatch, thus there exist table where all supported elements are assigned
@@ -52,7 +52,7 @@ def build_element(element_name: Union[str, type], config: pyodata.Config, **kwar
5252
raise exceptions.PyODataParserError(f'{element_name} is unsupported in {config.odata_version.__name__}')
5353

5454

55-
def build_annotation(term: str, config: pyodata.Config, **kwargs):
55+
def build_annotation(term: str, config: conf.Config, **kwargs):
5656
"""
5757
Similarly to build_element this function purpoas is to resolve build function for annotations. There are two
5858
main differences:
@@ -143,7 +143,7 @@ class Types:
143143
"""
144144

145145
@staticmethod
146-
def register_type(typ: 'Typ', config: pyodata.Config):
146+
def register_type(typ: 'Typ', config: conf.Config):
147147
"""Add new type to the ODATA version type repository as well as its collection variant"""
148148

149149
o_version = config.odata_version
@@ -159,7 +159,7 @@ def register_type(typ: 'Typ', config: pyodata.Config):
159159
o_version.Types[collection_name] = collection_typ
160160

161161
@staticmethod
162-
def from_name(name, config: pyodata.Config) -> 'Typ':
162+
def from_name(name, config: conf.Config) -> 'Typ':
163163
o_version = config.odata_version
164164

165165
# build types hierarchy on first use (lazy creation)
@@ -426,7 +426,7 @@ def __getitem__(self, key):
426426
except KeyError:
427427
raise KeyError('There is no Schema Namespace {}'.format(key))
428428

429-
def __init__(self, config: pyodata.Config):
429+
def __init__(self, config: conf.Config):
430430
super(Schema, self).__init__()
431431

432432
self._decls = Schema.Declarations()

pyodata/v2/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
from typing import List
55

6-
import pyodata.config as pyodata
6+
import pyodata.config as conf
77

88
import pyodata.model.type_traits as base_traits
99
import pyodata.v2.type_traits as v2_traits
@@ -20,7 +20,7 @@ def modlog():
2020
return logging.getLogger("v2")
2121

2222

23-
class ODataV2(pyodata.ODATAVersion):
23+
class ODataV2(conf.ODATAVersion):
2424
""" Definition of OData V2 """
2525

2626
@staticmethod

pyodata/v2/build_functions.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import logging
88
from typing import List
99

10-
import pyodata.config as pyodata
10+
import pyodata.config as conf
1111
import pyodata.exceptions as exceptions
1212
import pyodata.policies as policies
1313

@@ -23,7 +23,7 @@ def modlog():
2323
# pylint: disable=protected-access,too-many-locals, too-many-branches,too-many-statements
2424
# While building schema it is necessary to set few attributes which in the rest of the application should remain
2525
# constant. As for now, splitting build_schema into sub-functions would not add any benefits.
26-
def build_schema(config: pyodata.Config, schema_nodes):
26+
def build_schema(config: conf.Config, schema_nodes):
2727
schema = v2_elements.Schema(config)
2828

2929
# Parse Schema nodes by parts to get over the problem of not-yet known
@@ -205,12 +205,12 @@ def build_schema(config: pyodata.Config, schema_nodes):
205205
return schema
206206

207207

208-
def build_navigation_type_property(config: pyodata.Config, node):
208+
def build_navigation_type_property(config: conf.Config, node):
209209
return v2_elements.NavigationTypeProperty(
210210
node.get('Name'), node.get('FromRole'), node.get('ToRole'), elements.Identifier.parse(node.get('Relationship')))
211211

212212

213-
def build_end_role(config: pyodata.Config, end_role_node):
213+
def build_end_role(config: conf.Config, end_role_node):
214214
entity_type_info = elements.Types.parse_type_name(end_role_node.get('Type'))
215215
multiplicity = end_role_node.get('Multiplicity')
216216
role = end_role_node.get('Role')
@@ -219,7 +219,7 @@ def build_end_role(config: pyodata.Config, end_role_node):
219219

220220

221221
# pylint: disable=protected-access
222-
def build_association(config: pyodata.Config, association_node):
222+
def build_association(config: conf.Config, association_node):
223223
name = association_node.get('Name')
224224
association = v2_elements.Association(name)
225225

@@ -247,14 +247,14 @@ def build_association(config: pyodata.Config, association_node):
247247
return association
248248

249249

250-
def build_association_set_end_role(config: pyodata.Config, end_node):
250+
def build_association_set_end_role(config: conf.Config, end_node):
251251
role = end_node.get('Role')
252252
entity_set = end_node.get('EntitySet')
253253

254254
return v2_elements.AssociationSetEndRole(role, entity_set)
255255

256256

257-
def build_association_set(config: pyodata.Config, association_set_node):
257+
def build_association_set(config: conf.Config, association_set_node):
258258
end_roles: List[v2_elements.AssociationSetEndRole] = []
259259
name = association_set_node.get('Name')
260260
association = elements.Identifier.parse(association_set_node.get('Association'))
@@ -269,7 +269,7 @@ def build_association_set(config: pyodata.Config, association_set_node):
269269
return v2_elements.AssociationSet(name, association.name, association.namespace, end_roles)
270270

271271

272-
def build_referential_constraint(config: pyodata.Config, referential_constraint_node):
272+
def build_referential_constraint(config: conf.Config, referential_constraint_node):
273273
principal = referential_constraint_node.xpath('edm:Principal', namespaces=config.namespaces)
274274
if len(principal) != 1:
275275
raise RuntimeError('Referential constraint must contain exactly one principal element')

pyodata/v4/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import List
44

5-
import pyodata.config as pyodata
5+
import pyodata.config as conf
66

77
import pyodata.model.elements as base_elements
88
import pyodata.v4.elements as v4_elements
@@ -14,7 +14,7 @@
1414
import pyodata.v4.build_functions as v4_build_functions
1515

1616

17-
class ODataV4(pyodata.ODATAVersion):
17+
class ODataV4(conf.ODATAVersion):
1818
""" Definition of OData V4 """
1919

2020
@staticmethod

pyodata/v4/build_functions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import itertools
77
import copy
88

9-
import pyodata.config as pyodata
9+
import pyodata.config as conf
1010
import pyodata.exceptions as exceptions
1111
import pyodata.policies as policies
1212

@@ -17,7 +17,7 @@
1717
# pylint: disable=protected-access,too-many-locals,too-many-branches,too-many-statements
1818
# While building schema it is necessary to set few attributes which in the rest of the application should remain
1919
# constant. As for now, splitting build_schema into sub-functions would not add any benefits.
20-
def build_schema(config: pyodata.Config, schema_nodes):
20+
def build_schema(config: conf.Config, schema_nodes):
2121
schema = elements.Schema(config)
2222

2323
# Parse Schema nodes by parts to get over the problem of not-yet known
@@ -125,7 +125,7 @@ def build_schema(config: pyodata.Config, schema_nodes):
125125
return schema
126126

127127

128-
def build_navigation_type_property(config: pyodata.Config, node):
128+
def build_navigation_type_property(config: conf.Config, node):
129129
partner = elements.Types.parse_type_name(node.get('Partner')) if node.get('Partner') else None
130130
ref_cons = []
131131

@@ -141,16 +141,16 @@ def build_navigation_type_property(config: pyodata.Config, node):
141141
ref_cons)
142142

143143

144-
def build_navigation_property_binding(config: pyodata.Config, node, et_info):
144+
def build_navigation_property_binding(config: conf.Config, node, et_info):
145145
return v4_elements.NavigationPropertyBinding(v4_elements.to_path_info(node.get('Path'), et_info),
146146
node.get('Target'))
147147

148148

149-
def build_unit_annotation(config: pyodata.Config, target: elements.Typ, annotation_node):
149+
def build_unit_annotation(config: conf.Config, target: elements.Typ, annotation_node):
150150
target.annotation = v4_elements.Unit(f'self.{target.name}', annotation_node.get('String'))
151151

152152

153-
def build_type_definition(config: pyodata.Config, node):
153+
def build_type_definition(config: conf.Config, node):
154154
typ = copy.deepcopy(elements.Types.from_name(node.get('UnderlyingType'), config))
155155
typ.name = node.get('Name')
156156

0 commit comments

Comments
 (0)