@@ -4,7 +4,11 @@ import sys
4
4
from argparse import ArgumentParser
5
5
6
6
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
8
12
9
13
import requests
10
14
@@ -42,7 +46,10 @@ def print_out_metadata_info(args, client):
42
46
print (f' + { prop .name } ({ prop .typ .name } )' )
43
47
44
48
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 } )' )
46
53
47
54
for fs in client .schema .function_imports :
48
55
print (f'{ fs .http_method } { fs .name } ' )
@@ -90,6 +97,7 @@ def _parse_args(argv):
90
97
help = 'Specify metadata parser default error handler' )
91
98
parser .add_argument ('--custom-error-policy' , action = 'append' , type = str ,
92
99
help = 'Specify metadata parser custom error handlers in the form: TARGET=POLICY' )
100
+ parser .add_argument ('--version' , default = 2 , choices = [2 , 4 ], type = int )
93
101
94
102
parser .set_defaults (func = print_out_metadata_info )
95
103
@@ -145,10 +153,16 @@ def _main(argv):
145
153
146
154
def get_config ():
147
155
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 )
149
161
150
162
return config
151
163
164
+ config = get_config ()
165
+
152
166
if args .default_error_policy :
153
167
config = get_config ()
154
168
config .set_default_error_policy (ERROR_POLICIES [args .default_error_policy ]())
0 commit comments