def _locked_json_write(self, data): """Write a JSON serializable data structure to the multistore. The multistore must be locked when this is called. Args: data: The data to be serialized and written. """ assert self._thread_lock.locked() if self._read_only: return self._file.file_handle().seek(0) simplejson.dump(data, self._file.file_handle(), sort_keys=True, indent=2) self._file.file_handle().truncate()
def main(): for filename in sys.argv[1:]: f = file(filename, "r") dis = simplejson.load(f) f.close() api = dis['name'] version = dis['version'] resources = dis['resources'] for res_name, res_desc in resources.iteritems(): methods = res_desc['methods'] for method_name, method_desc in methods.iteritems(): methods[method_name] = {} path, basename = os.path.split(filename) newfilename = os.path.join(path, "skel-" + basename) f = file(newfilename, "w") simplejson.dump(dis, f, sort_keys=True, indent=2 * ' ') f.close()