Creates a file containing the current module graph in JSON serialization.
328759
@GwtIncompatible("Unnecessary")
  private void outputModuleGraphJson() throws IOException {
    if (config.outputModuleDependencies != null &&
        config.outputModuleDependencies.length() != 0) {
      try (Writer out = fileNameToOutputWriter2(config.outputModuleDependencies)) {
        printModuleGraphJsonTo(out);
      }
    }
  }
572204
def convert_json_object(obographdoc, **args):
    
    digraph = networkx.MultiDiGraph()
    xref_graph = networkx.MultiGraph()
    logical_definitions = []
    property_chain_axioms = []
    context = obographdoc.get('@context',{})
    logging.info("CONTEXT: {}".format(context))
    mapper = OboJsonMapper(digraph=digraph, context=context)
    ogs = obographdoc['graphs']
    base_og = ogs[0]
    for og in ogs:
        # TODO: refactor this
        mapper.add_obograph_digraph(og, xref_graph=xref_graph,
                                    logical_definitions=logical_definitions,
                                    property_chain_axioms=property_chain_axioms, **args)

    return {
        'id': base_og.get('id'),
        'meta': base_og.get('meta'),
        'graph': mapper.digraph,
        'xref_graph': xref_graph,
        'graphdoc': obographdoc,
        'logical_definitions': logical_definitions,
        'property_chain_axioms': property_chain_axioms
        }
1252377
function createApiRefApiJson(oChainObject) {
		if (returnOutputFiles) {
			// If requested, return data instead of writing to FS (required by UI5 Tooling/UI5 Builder)
			return JSON.stringify(oChainObject.parsedData);
		}
		let sOutputDir = path.dirname(oChainObject.outputFile);

		// Create dir if it does not exist
		if (!fs.existsSync(sOutputDir)) {
			fs.mkdirSync(sOutputDir);
		}

		// Write result to file
		fs.writeFileSync(oChainObject.outputFile, JSON.stringify(oChainObject.parsedData) /* Transform back to string */, 'utf8');
	}
598274
def add_graph_copy(self, graph, tags=None):
    """"""
    with graph.as_default():
      # Remove default attrs so that Modules created by a tensorflow version
      # with ops that have new attrs that are left to their default values can
      # still be loaded by older versions unware of those attributes.
      meta_graph = tf_v1.train.export_meta_graph(strip_default_attrs=True)
      _export_tags(meta_graph, tags)
      _export_signatures(meta_graph)
      _export_module_attachments(meta_graph)
    self._proto.meta_graphs.extend([meta_graph])
443823
def render_output_json(self, graph_data, output_file=None):
        """"""
        if output_file:
            with open(output_file, 'wt') as json_output_f:
                json.dump(graph_data, json_output_f)
        else:
            self.stdout.write(json.dumps(graph_data))
561611
private function create_json() {
		$packages = $this->list_directory( $this->packages_dir );
		$arr      = array();

		foreach ( $packages as $package ) {
			foreach ( $this->translations as $translation ) {
				if ( false !== stripos( $package, $translation ) ) {
					$locale                       = ltrim( strrchr( $translation, '-' ), '-' );
					$arr[ $locale ]['slug']       = stristr( $translation, strrchr( $translation, '-' ), true );
					$arr[ $locale ]['language']   = $locale;
					$arr[ $locale ]['updated']    = $this->get_po_revision( $translation . '.po' );
					$arr[ $locale ]['package']    = '/packages/' . $package;
					$arr[ $locale ]['autoupdate'] = '1';
				}
			}
		}

		file_put_contents( $this->root_dir . '/language-pack.json', json_encode( $arr ) );
		printf( "\n<br>" . 'language-pack.json created.' . "\n<br>" );
	}
663363
function ModuleGraph(moduleData) {
  var self = this;
  var modules = {};
  var moduleNameList = [];
  moduleData.forEach(function(info) {
    var m = new Module(info);
    modules[info.name] = m;
    moduleNameList.push(info.name);
  });

  /**
   * Get a list of all module names.
   * @return {Array.<string>} List of module names.
   */
  this.getAllModules = function() {
    return moduleNameList;
  };

  /**
   * Get transitive dependencies for a given module
   * @param {string} name Name of the module.
   * @return {Array.<string>} List of module names.
   */
  this.getTransitiveDependencies = function(name) {
    var m = getModule(name);
    return m.transitiveDeps || [];
  };

  function getModule(name) {
    var m = modules[name];
    if (!m) {
      throw new self.NotFoundException(name);
    }
    return m;
  }

  /**
   * Error object used when a requested module cannot be found.
   * @constructor
   */
  this.NotFoundException = function(name) {
    var msg = 'Unknown module: ' + name;
    this.name = name;
    this.message = msg;
    Error.call(this, msg);
  };
  this.NotFoundException.prototype = new Error();
  this.NotFoundException.prototype.statusCode = 404;

  /**
   * Gets the requested module names and their transitive deps minus the
   * transitive deps (and the) of the optional excluded names.
   * @param {Array.<string>} moduleNames List of module names.
   * @apram {Array.<string>} opt_excludeNames List of module names to exclude.
   * @return {Array.<string>} List of module names.
   */
  this.getModules = function(moduleNames, opt_excludeNames) {
    var list = [];
    var seen = {};
    var exclude = {};

    if (opt_excludeNames) {
      opt_excludeNames.forEach(function(name) {
        exclude[name] = true;
        var m = getModule(name);
        m.transitiveDeps.forEach(function(name) {
          exclude[name] = true;
        });
      });
    }

    function addModule(name) {
      if (!seen[name] && !exclude[name]) {
        seen[name] = true;
        list.push(name)
      }
    }
    moduleNames.forEach(function(name) {
      var m = getModule(name);
      m.transitiveDeps.forEach(addModule);
      addModule(m.name);
    });
    return list;
  };
}
1077482
def as_dict(self):
        

        d = {"@module": self.__class__.__module__,
             "@class": self.__class__.__name__,
             "molecule": self.molecule.as_dict(),
             "graphs": json_graph.adjacency_data(self.graph)}

        return d
1203335
function loadPrettyGraphSONSync(graph, filename) {
        var jsonText = fs.readFileSync(filename, { encoding: 'utf8' });
        var jsonObjArray = JSON.parse(jsonText);
        var jsonTextArray = _.map(jsonObjArray, JSON.stringify);
        var uglyText = jsonTextArray.join('\n');
        var StringInputStream = Tinkerpop.autoImport('StringInputStream');
        var stream = StringInputStream.from(uglyText);
        var builder = Tinkerpop.GraphSONReader.build();
        var mapper = _newGraphSONMapperSync();
        builder.mapper(mapper);
        var reader = builder.create();
        reader.readGraph(stream, graph);
        return graph;
    }
501582
def json_to_file(data, filename, pretty=False):
    ''''''
    kwargs = dict(indent=4) if pretty else {}
    dirname = os.path.dirname(filename)
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    dump = json.dumps(api.__schema__, **kwargs)
    with open(filename, 'wb') as f:
        f.write(dump.encode('utf-8'))
1242785
def serialize(graph: BELGraph, csv, sif, gsea, graphml, json, bel):
    """"""
    if csv:
        log.info('Outputting CSV to %s', csv)
        to_csv(graph, csv)

    if sif:
        log.info('Outputting SIF to %s', sif)
        to_sif(graph, sif)

    if graphml:
        log.info('Outputting GraphML to %s', graphml)
        to_graphml(graph, graphml)

    if gsea:
        log.info('Outputting GRP to %s', gsea)
        to_gsea(graph, gsea)

    if json:
        log.info('Outputting JSON to %s', json)
        to_json_file(graph, json)

    if bel:
        log.info('Outputting BEL to %s', bel)
        to_bel(graph, bel)
120595
def _SGraphFromJsonTree(json_str):
    
    g = json.loads(json_str)
    vertices = [_Vertex(x['id'],
                dict([(str(k), v) for k, v in _six.iteritems(x) if k != 'id']))
                                                      for x in g['vertices']]
    edges = [_Edge(x['src'], x['dst'],
             dict([(str(k), v) for k, v in _six.iteritems(x) if k != 'src' and k != 'dst']))
                                                      for x in g['edges']]
    sg = _SGraph().add_vertices(vertices)
    if len(edges) > 0:
        sg = sg.add_edges(edges)
    return sg
40465
function createPackageJson(plugin_path) {
    var pluginInfo = new PluginInfo(plugin_path);

    var defaults = {
        id:pluginInfo.id,
        version:pluginInfo.version,
        description:pluginInfo.description,
        license:pluginInfo.license,
        keywords:pluginInfo.getKeywordsAndPlatforms(),
        repository:pluginInfo.repo,
        bugs:pluginInfo.issue,
        engines:pluginInfo.getEngines(),
        platforms: pluginInfo.getPlatformsArray()
    };

    fs.writeFile(path.join(__dirname,'defaults.json'), JSON.stringify(defaults), 'utf8', function (err) {
        if (err) throw err;
        events.emit('verbose', 'defaults.json created from plugin.xml');
        var initFile = require.resolve('./init-defaults');
        var dir = process.cwd();

        init(dir, initFile, {}, function (err, data) {
            if(err) throw err;
            events.emit('verbose', 'Package.json successfully created');
        });
    });
    return Q();
}
18454
def to_graph(self):
        """"""
        def json_node(graph, element, prefix):
            if not element:
                return None
            node_id = '|'.join(prefix)
            if isinstance(element, list):
                graph.add_node(node_id, label='')
                # Enumerate children and add nodes and connect to anchor node
                for i, sub_element in enumerate(element):
                    sub_id = json_node(graph, sub_element, prefix + ['%s' % i])
                    if sub_id:
                        graph.add_edge(node_id, sub_id, label='')
            elif isinstance(element, dict):
                graph.add_node(node_id, label='')
                # Add node recursively for each element
                # Connect to this node with edge label according to key
                for k, v in element.items():
                    if k == 'id':
                        continue
                    elif k == 'name':
                        graph.node[node_id]['label'] = v
                        continue
                    elif k == 'type':
                        graph.node[node_id]['label'] = v
                        continue

                    sub_id = json_node(graph, v, prefix + ['%s' % k])
                    if sub_id:
                        graph.add_edge(node_id, sub_id, label=('%s' % k))
            else:
                if isinstance(element, basestring) and \
                   element.startswith('http'):
                    element = element.split('/')[-1]
                graph.add_node(node_id, label=('%s' % str(element)))
            return node_id
        jd = self.to_json()
        graph = networkx.DiGraph()
        json_node(graph, jd, ['%s' % self.uuid])
        return graph
360040
function createDependencyGraph(pool, moduleNames, indegreeOnly) {
	const graph = Object.create(null);

	const promises = moduleNames.map( (moduleName) => {
		return pool.getModuleInfo(moduleName).
			then( (module) => {
				let node = graph[moduleName];
				if ( node == null ) {
					node = new GraphNode(moduleName, indegreeOnly);
					graph[moduleName] = node;
				}
				const p = module.dependencies.map( function(dep) {
					if ( module.isConditionalDependency(dep) ) {
						return;
					}
					return pool.getModuleInfo(dep).then( (depModule) => {
						if ( moduleNames.indexOf(dep) >= 0 ) {
							let depNode = graph[dep];
							if ( depNode == null ) {
								depNode = new GraphNode(dep, indegreeOnly);
								graph[dep] = depNode;
							}
							node.outgoing.push(depNode);
							if ( indegreeOnly ) {
								depNode.indegree++;
							} else {
								depNode.incoming.push(node);
							}
						}
					}, (erro) => null);
				});
				return Promise.all(p);
			}, (err) => {
				log.error("module %s not found in pool", moduleName);
			});
	});

	return Promise.all(promises).then(function() {
		// if ( trace.isTrace() ) trace.trace("initial module dependency graph: %s", dumpGraph(graph, moduleNames));
		return graph;
	});
}
318737
function createGraph(modules, circular, config, options) {
	const g = graphviz.digraph('G');
	const nodes = {};
	const cyclicModules = circular.reduce((a, b) => a.concat(b), []);

	if (config.graphVizPath) {
		g.setGraphVizPath(config.graphVizPath);
	}

	Object.keys(modules).forEach((id) => {
		nodes[id] = nodes[id] || g.addNode(id);

		if (!modules[id].length) {
			setNodeColor(nodes[id], config.noDependencyColor);
		} else if (cyclicModules.indexOf(id) >= 0) {
			setNodeColor(nodes[id], config.cyclicNodeColor);
		}

		modules[id].forEach((depId) => {
			nodes[depId] = nodes[depId] || g.addNode(depId);

			if (!modules[depId]) {
				setNodeColor(nodes[depId], config.noDependencyColor);
			}

			g.addEdge(nodes[id], nodes[depId]);
		});
	});

	return new Promise((resolve, reject) => {
		g.output(options, resolve, (code, out, err) => {
			reject(new Error(err));
		});
	});
}
616738
function saveGraphSONSync(graph, filename) {
        var FileOutputStream = Tinkerpop.autoImport('FileOutputStream');
        var stream = new FileOutputStream(filename);
        var builder = Tinkerpop.GraphSONWriter.build();
        var mapper = _newGraphSONMapperSync();
        builder.mapper(mapper);
        var writer = builder.create();
        writer.writeGraph(stream, graph);
        return graph;
    }