1#!/usr/bin/env python 2# Copyright (c) 2012 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6 7from grit.gather import interface 8 9 10class JsonLoader(interface.GathererBase): 11 '''A simple gatherer that loads and parses a JSON file.''' 12 13 def Parse(self): 14 '''Reads and parses the text of self._json_text into the data structure in 15 self._data. 16 ''' 17 self._json_text = self._LoadInputFile() 18 self._data = None 19 20 globs = {} 21 exec('data = ' + self._json_text, globs) 22 self._data = globs['data'] 23 24 def GetData(self): 25 '''Returns the parsed JSON data.''' 26 return self._data 27