<s> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> import json <EOL> import os <EOL> import six <EOL> import yaml <EOL> ALLOWED_EXTS = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> PARSER_FUNCS = { '<STR_LIT>' : json . load , '<STR_LIT>' : yaml . safe_load , '<STR_LIT>' : yaml . safe_load } <EOL> def get_fixtures_base_path ( ) : <EOL> return os . path . dirname ( __file__ ) <EOL> def load_content ( file_path ) : <EOL> """<STR_LIT>""" <EOL> file_name , file_ext = os . path . splitext ( file_path ) <EOL> if file_ext not in ALLOWED_EXTS : <EOL> raise Exception ( '<STR_LIT>' % <EOL> ( file_ext , file_path , ALLOWED_EXTS ) ) <EOL> parser_func = PARSER_FUNCS . get ( file_ext , None ) <EOL> with open ( file_path , '<STR_LIT:r>' ) as fd : <EOL> return parser_func ( fd ) if parser_func else fd . read ( ) <EOL> def load_fixtures ( fixtures_dict = None ) : <EOL> """<STR_LIT>""" <EOL> if fixtures_dict is None : <EOL> fixtures_dict = { } <EOL> all_fixtures = { } <EOL> fixtures_base_path = get_fixtures_base_path ( ) <EOL> for fixture_type , fixtures in six . iteritems ( fixtures_dict ) : <EOL> loaded_fixtures = { } <EOL> for fixture in fixtures : <EOL> fixture_path = fixtures_base_path + '<STR_LIT:/>' + fixture <EOL> fixture_dict = load_content ( fixture_path ) <EOL> loaded_fixtures [ fixture ] = fixture_dict <EOL> all_fixtures [ fixture_type ] = loaded_fixtures <EOL> return all_fixtures </s>
