Skip to content

Commit 4f2bf88

Browse files
committed
Add V4 to pyodata cmd interface
Also imports' paths were updated to correctly reflect project structure.
1 parent b6913a9 commit 4f2bf88

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Support for navigation property in OData v4 - Martin Miksik
1616
- Support for EntitySet in OData v4 - Martin Miksik
1717
- Support for TypeDefinition in OData v4 - Martin Miksik
18+
- Support for TypeDefinition in OData v4 - Martin Miksik
19+
- Add V4 to pyodata cmd interface - Martin Miksik
1820

1921
### Changed
2022
- Implementation and naming schema of `from_etree` - Martin Miksik

bin/pyodata

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import sys
44
from argparse import ArgumentParser
55

66
import pyodata
7-
from pyodata.v2.model import PolicyFatal, PolicyWarning, PolicyIgnore, ParserError, Config
7+
from pyodata.policies import PolicyFatal, PolicyWarning, PolicyIgnore, ParserError
8+
from pyodata.config import Config
9+
10+
from pyodata.v2 import ODataV2
11+
from pyodata.v4 import ODataV4
812

913
import requests
1014

@@ -42,7 +46,10 @@ def print_out_metadata_info(args, client):
4246
print(f' + {prop.name}({prop.typ.name})')
4347

4448
for prop in es.entity_type.nav_proprties:
45-
print(f' + {prop.name}({prop.to_role.entity_type_name})')
49+
if client.schema.config.odata_version == ODataV2:
50+
print(f' + {prop.name}({prop.to_role.entity_type_name})')
51+
else:
52+
print(f' + {prop.name}({prop.partner.name})')
4653

4754
for fs in client.schema.function_imports:
4855
print(f'{fs.http_method} {fs.name}')
@@ -90,6 +97,7 @@ def _parse_args(argv):
9097
help='Specify metadata parser default error handler')
9198
parser.add_argument('--custom-error-policy', action='append', type=str,
9299
help='Specify metadata parser custom error handlers in the form: TARGET=POLICY')
100+
parser.add_argument('--version', default=2, choices=[2, 4], type=int)
93101

94102
parser.set_defaults(func=print_out_metadata_info)
95103

@@ -145,10 +153,16 @@ def _main(argv):
145153

146154
def get_config():
147155
if config is None:
148-
return Config()
156+
version = ODataV4
157+
if args.version == 2:
158+
version = ODataV2
159+
160+
return Config(odata_version=version)
149161

150162
return config
151163

164+
config = get_config()
165+
152166
if args.default_error_policy:
153167
config = get_config()
154168
config.set_default_error_policy(ERROR_POLICIES[args.default_error_policy]())

0 commit comments

Comments
 (0)