| import json |
|
|
| from Constants import Constants |
| from EnumParkingStatus import EnumParkingStatus |
|
|
| class JSonEditor: |
| def __init__(self, jsonPath): |
| self.jsonPath = jsonPath |
| with open(jsonPath, 'r') as file: |
| self.json = json.load(file) |
|
|
| def check_structure(self): |
| for key in self.json.keys(): |
| print(key) |
|
|
| def remove_keys_json(self, list_remove): |
| for str in list_remove: |
| print("Removing: ", str) |
| del self.json[str] |
|
|
| def save_json(self, filename): |
| with open(filename, 'w') as file: |
| json.dump(self.json, file) |
|
|
| def generate_lightweight_segmentation(self): |
| pass |
| |
|
|
| def update_tags(self): |
| climates = self.json["climates"] |
| for cl in climates: |
| if(cl["id"] == 5): |
| cl["name"] = "no_rain " |
| try: |
| del self.json["parkingSpots"] |
| except: |
| pass |
|
|
| def consolidateValInfoJson(self): |
| annotations = self.json[Constants.JSON_ANNOTATIONS_KEY] |
| for annot in annotations: |
| if (annot[Constants.JSON_LINK_CATEG_KEY] == Constants.JSON_PARKING_SPACE_KEY): |
| status = int(annot[Constants.JSON_PARKING_STATUS_ID_KEY]) |
| if(status == EnumParkingStatus.EMPTY_NEED_VAL.value): |
| annot[Constants.JSON_PARKING_STATUS_ID_KEY] = EnumParkingStatus.EMPTY.value |
| elif(status == EnumParkingStatus.OCCUPIED_NEED_VAL.value): |
| annot[Constants.JSON_PARKING_STATUS_ID_KEY] = EnumParkingStatus.OCCUPIED.value |
|
|
| |
|
|
| |
| |
| |
|
|
| |
| |
| |
|
|
| |
| |
|
|
| def generate_final_json(self): |
| self.update_tags() |
| |