11# Import modules
2+ import json
3+ import ast
24from flask_restx import Namespace , Resource
35from . import request_parser
46from . import representations
911import VariantValidator
1012vval = VariantValidator .Validator ()
1113
14+
15+ def ordereddict_to_dict (value ):
16+ for k , v in value .items ():
17+ if isinstance (v , dict ):
18+ value [k ] = ordereddict_to_dict (v )
19+ return dict (value )
20+
21+
1222"""
1323Create a parser object locally
1424"""
@@ -69,6 +79,11 @@ def get(self, genome_build, variant_description, transcript_model, select_transc
6979 content = VariantFormatter .simpleVariantFormatter .format (variant_description , genome_build , transcript_model ,
7080 select_transcripts , checkonly , liftover )
7181
82+ to_dict = ordereddict_to_dict (content )
83+ content = str (to_dict )
84+ content = content .replace ("'" , '"' )
85+ content = ast .literal_eval (content )
86+
7287 # Collect Arguments
7388 args = parser .parse_args ()
7489
@@ -78,7 +93,7 @@ def get(self, genome_build, variant_description, transcript_model, select_transc
7893 return representations .application_json (content , 200 , None )
7994 # example: http://127.0.0.1:5000.....?content-type=application/xml
8095 elif args ['content-type' ] == 'application/xml' :
81- return representations .xml (content , 200 , None )
96+ return representations .xml (str ( content ) , 200 , None )
8297 else :
8398 # Return the api default output
8499 return content
0 commit comments