Explorar el Código

update cdplib

tsteuer hace 5 años
padre
commit
a0759818cf
Se han modificado 1 ficheros con 22 adiciones y 29 borrados
  1. 22 29
      cdplib/db_migration/ParseJsonSchema.py

+ 22 - 29
cdplib/db_migration/ParseJsonSchema.py

@@ -338,7 +338,7 @@ class ParseJsonSchema(ParseDbSchema):
             "Parameter 'schema' must be a dictionary type"
             
         base_dir_url = Path(os.path.join(os.getcwd(), "mongo_schema")).as_uri() + '/'
-        schema = jsonref.loads(str(schema).replace("'", "\""),base_uri=base_dir_url)
+        schema = jsonref.loads(str(schema).replace("'", "\""), base_uri=base_dir_url)
         schema = deepcopy(schema)
         schema.pop('definitions', None)
         return schema
@@ -378,14 +378,12 @@ class ParseJsonSchema(ParseDbSchema):
 
         return schema
            
-        return schema
-    
    
     def _analyze_schema(self, schema: dict, definitions_flag: bool = False) -> dict:
 
 
         for key in schema:
-            if key == 'definitions':
+            if key == '$ref':
                 definitions_flag = True
                 return definitions_flag
 
@@ -403,29 +401,24 @@ if __name__ == "__main__":
 
     # Only for testing
 
-    schema_path = os.path.join(".", "mongo_schema", "schema_wheelsets.json")
-    
-    parse_obj = ParseJsonSchema(schema_paths=schema_path)
-    
+    schema_path = os.path.join(".", "mongo_schema", "schema_components.json")
     
-    test=parse_obj.read_schema_and_parse_for_mongodb(schema_path)
-    
-#    if os.path.isfile(schema_path):
-#
-#        parse_obj = ParseJsonSchema(schema_paths=schema_path)
-#
-#        fields = parse_obj.get_fields()
-#
-#        required_fileds = parse_obj.get_required_fields()
-#
-#        patterns = parse_obj.get_patterns()
-#
-#        mongo_types = parse_obj.get_mongo_types()
-#
-#        python_types_except_dates = parse_obj.get_python_types()
-#
-#        datetime_fields = parse_obj.get_datetime_fields()
-#
-#        allowed_values = parse_obj.get_allowed_values()
-#
-#        descriptions = parse_obj.get_field_descriptions()
+    if os.path.isfile(schema_path):
+
+        parse_obj = ParseJsonSchema(schema_paths=schema_path)
+
+        fields = parse_obj.get_fields()
+
+        required_fileds = parse_obj.get_required_fields()
+
+        patterns = parse_obj.get_patterns()
+
+        mongo_types = parse_obj.get_mongo_types()
+
+        python_types_except_dates = parse_obj.get_python_types()
+
+        datetime_fields = parse_obj.get_datetime_fields()
+
+        allowed_values = parse_obj.get_allowed_values()
+
+        descriptions = parse_obj.get_field_descriptions()