X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Futils.py;h=20646a1420dad41f9f0de84374b43404a5fb006a;hb=c4629bd3b12d44dd568240735f8cc546475170a3;hp=00f6f2d200947692cfe64da9636f928ef39d5329;hpb=bf669b95be698c7ca0e1f43577e27aa355d11228;p=osm%2FRO.git diff --git a/osm_ro/utils.py b/osm_ro/utils.py index 00f6f2d2..20646a14 100644 --- a/osm_ro/utils.py +++ b/osm_ro/utils.py @@ -62,7 +62,7 @@ def format_in(http_response, schema): #print "Input data: ", str(client_data) return True, client_data except js_e.ValidationError as exc: - print "validate_in error, jsonschema exception ", exc.message, "at", exc.path + print("validate_in error, jsonschema exception ", exc.message, "at", exc.path) return False, ("validate_in error, jsonschema exception ", exc.message, "at", exc.path) def remove_extra_items(data, schema): @@ -75,8 +75,8 @@ def remove_extra_items(data, schema): #TODO deal with patternProperties if 'properties' not in schema: return None - for k in data.keys(): - if k not in schema['properties'].keys(): + for k in list(data.keys()): + if k not in list(schema['properties'].keys()): del data[k] deleted.append(k) else: @@ -102,7 +102,7 @@ def convert_bandwidth(data, reverse=False): None ''' if type(data) is dict: - for k in data.keys(): + for k in list(data.keys()): if type(data[k]) is dict or type(data[k]) is tuple or type(data[k]) is list: convert_bandwidth(data[k], reverse) if "bandwidth" in data: @@ -119,7 +119,7 @@ def convert_bandwidth(data, reverse=False): if value % 1000 == 0: data["bandwidth"]=str(value/1000) + " Gbps" else: data["bandwidth"]=str(value) + " Mbps" except: - print "convert_bandwidth exception for type", type(data["bandwidth"]), " data", data["bandwidth"] + print("convert_bandwidth exception for type", type(data["bandwidth"]), " data", data["bandwidth"]) return if type(data) is tuple or type(data) is list: for k in data: @@ -133,7 +133,7 @@ def convert_datetime2str(var): It enters recursively in the dict var finding this kind of variables ''' if type(var) is dict: - for k,v in var.items(): + for k,v in list(var.items()): if type(v) is datetime.datetime: var[k]= v.strftime('%Y-%m-%dT%H:%M:%S') elif type(v) is dict or type(v) is list or type(v) is tuple: @@ -153,7 +153,7 @@ def convert_str2boolean(data, items): None ''' if type(data) is dict: - for k in data.keys(): + for k in list(data.keys()): if type(data[k]) is dict or type(data[k]) is tuple or type(data[k]) is list: convert_str2boolean(data[k], items) if k in items: