def _create_swagger_attributes( property_names: List[str], neo4j_object: Dict[str, any]) -> List[Attribute]: new_attributes = [] for property_name in property_names: property_value = neo4j_object.get(property_name) # Extract any lists, dicts, and booleans that are stored within strings if type(property_value) is str: if (property_value.startswith('[') and property_value.endswith(']')) or \ (property_value.startswith('{') and property_value.endswith('}')) or \ property_value.lower() == "true" or property_value.lower() == "false": property_value = ast.literal_eval(property_value) if isinstance(property_value, list): property_value.sort() # Alphabetize lists # Create an Attribute for all non-empty values if property_value is not None and property_value != {} and property_value != []: swagger_attribute = Attribute() swagger_attribute.name = property_name swagger_attribute.type = eu.get_attribute_type( swagger_attribute.name) # Figure out whether this is a url and store it appropriately if type(property_value) is str and ( property_value.startswith("http:") or property_value.startswith("https:")): swagger_attribute.url = property_value else: swagger_attribute.value = property_value new_attributes.append(swagger_attribute) return new_attributes
def _create_trapi_attributes( property_names: List[str], neo4j_object: Dict[str, any]) -> List[Attribute]: new_attributes = [] for property_name in property_names: property_value = neo4j_object.get(property_name) if property_value: # Extract any lists, dicts, and booleans that are stored within strings if type(property_value) is str: if (property_value.startswith('[') and property_value.endswith(']')) or \ (property_value.startswith('{') and property_value.endswith('}')) or \ property_value.lower() == "true" or property_value.lower() == "false": property_value = ast.literal_eval(property_value) # Create the actual Attribute object trapi_attribute = Attribute( name=property_name, type=eu.get_attribute_type(property_name), value=property_value) # Also store this value in Attribute.url if it's a URL if type(property_value) is str and ( property_value.startswith("http:") or property_value.startswith("https:")): trapi_attribute.url = property_value new_attributes.append(trapi_attribute) return new_attributes