<s> from __future__ import unicode_literals <EOL> from django . db import models , migrations <EOL> import json , os <EOL> dir = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> def populate_cogatlas ( apps , schema_editor ) : <EOL> CognitiveAtlasTask = apps . get_model ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> CognitiveAtlasContrast = apps . get_model ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> json_content = open ( os . path . join ( dir , "<STR_LIT>" ) ) . read ( ) <EOL> json_content = json_content . decode ( "<STR_LIT:utf-8>" ) . replace ( '<STR_LIT:\t>' , '<STR_LIT>' ) <EOL> data = json . loads ( json_content ) <EOL> for item in data : <EOL> task = CognitiveAtlasTask ( name = item [ "<STR_LIT:name>" ] , cog_atlas_id = item [ "<STR_LIT:id>" ] ) <EOL> task . save ( ) <EOL> for contrast in item [ "<STR_LIT>" ] : <EOL> contrast = CognitiveAtlasContrast ( name = contrast [ "<STR_LIT>" ] , cog_atlas_id = contrast [ "<STR_LIT>" ] , task = task ) <EOL> contrast . save ( ) <EOL> class Migration ( migrations . Migration ) : <EOL> dependencies = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> operations = [ <EOL> migrations . RunPython ( populate_cogatlas ) , <EOL> ] </s>
