Walks the portlet registry tree
@param {Object} registryJson Portlet Registry Tree
@return {Array<Portlet>} list of portlets
178133
function treeWalker(registryJson) {
  if (registryJson.registry) {
    return treeWalker(registryJson.registry);
  }

  const portlets = registryJson.portlets || [];

  if (registryJson.categories) {
    return portlets
        .concat(registryJson.categories.map(portletRegistryToArray))
        .reduce(flatten, []);
  }
  if (registryJson.subcategories) {
    return portlets
        .concat(registryJson.subcategories.map(portletRegistryToArray))
        .reduce(flatten, []);
  }

  return portlets;
}
659499
function() {

  var globalConfig = getGlobalConfig();
  // Read contents of app registry file.
  return Promise.fromNode(function(cb) {
    fs.readFile(globalConfig.appRegistry, {encoding: 'utf8'}, cb);
  })
  // Parse contents and return app dirs.
  .then(function(data) {
    var json = JSON.parse(data);
    if (json) {
      return json;
    } else {
      return [];
    }
  })
  // Handle no entry error.
  .catch(function(err) {
    if (err.code === 'ENOENT') {
      return [];
    } else {
      throw err;
    }
  });

}
658640
function walk(patterns, cwd) {
	var externals, files, locals;

	if (typeof patterns === 'undefined') {
		return [];
	}

	patterns = (patterns instanceof Array) ? patterns : [patterns];
	cwd = cwd || process.cwd();

	externals = [];
	files = {};
	locals = {};

	each(patterns, function(pattern) {
		var globbed;

		globbed = glob.sync(pattern, {
			cwd: cwd
		});

		globbed.forEach(function(filename) {
			var file;

			file = new File(cwd, filename);
			files[file.path] = file;
		});
	});

	each(_flatten(files), function(file, path) {
		Array.prototype.push.apply(externals, file.external);
		locals[pubname(path, cwd)] = file;
	});

	unique(externals);

	return {
		externals: externals,
		locals: locals
	};
}
123638
function _getRegistryErrMessage(body) {
    if (!body) {
        return null;
    }
    var obj = body;
    if (typeof (obj) === 'string' && obj.length <= MAX_REGISTRY_ERROR_LENGTH) {
        try {
            obj = JSON.parse(obj);
        } catch (ex) {
            // Just return the error as a string.
            return obj;
        }
    }
    if (typeof (obj) !== 'object' || !obj.hasOwnProperty('errors')) {
        return null;
    }
    if (!Array.isArray(obj.errors)) {
        return null;
    }
    // Example obj:
    // {
    //     "errors": [
    //         {
    //             "code": "MANIFEST_INVALID",
    //             "message": "manifest invalid",
    //             "detail": {}
    //         }
    //     ]
    // }
    if (obj.errors.length === 1) {
        return obj.errors[0].message;
    } else {
        return obj.errors.map(function (o) {
            return o.message;
        }).join(', ');
    }
}
766050
function createJsonFileDiscoverProvider(hostsFile) {
    var fs = require('fs');

    return function jsonFileProvider(callback) {
        fs.readFile(hostsFile, function onFileRead(err, data) {
            if (err) {
                callback(err);
                return;
            }

            var hosts;
            try {
                hosts = JSON.parse(data.toString());
            } catch (e) {
                callback(e);
                return;
            }
            callback(null, hosts);
            return;
        });
    };
}
181956
static function packageJson($project_directory, $app_engine_project, $app_engine_service, $package_json_defaults = []) {
        $package_json_location = $project_directory . DIRECTORY_SEPARATOR . "package.json";
        $package_json_content = Files::getJson($package_json_location, []);
        $package_json_content = array_merge([
            "name" => null,
            "project" => null,
            "private" => null,
        ], $package_json_content);
        $project_name = $app_engine_project . '-' . $app_engine_service;
        $package_json_defaults["private"] = true;
        $package_json_content["name"] = $project_name;
        $package_json_content["project"] = $app_engine_project;
        foreach ($package_json_defaults as $key => $val) {
            $package_json_content[$key] = $val;
        }
        if ($app_engine_service == "default") {
            $package_json_content["scripts"]["deploy"] = 'gcloud app deploy app.yaml queue.yaml --project $npm_package_project --promote --quiet';
        } else {
            $package_json_content["scripts"]["deploy"] = 'gcloud app deploy app.yaml --project $npm_package_project --promote --quiet';
        }
        $gaeutil_json = Files::getJson(Conf::getGaeUtilJsonPath($project_directory), []);

        $project_key_name = $gaeutil_json[Secrets::CONF_PROJECT_KEY_NAME];
        $project_key = Secrets::reverseKmsKey($project_key_name);
        $crypt_params = [
            "ciphertext-file" => "config/secrets.cipher",
            "plaintext-file" => "secrets.json",
            "project" => $project_key["project"],
            "location" => $project_key["location"],
            "keyring" => $project_key["keyRing"],
            "key" => $project_key["cryptoKey"]
        ];
        $package_json_content["scripts"]["encrypt"] = self::commandMaker("gcloud kms encrypt", $crypt_params);
        $package_json_content["scripts"]["decrypt"] = self::commandMaker("gcloud kms decrypt", $crypt_params);
        $package_json_content["scripts"]["devserve"] = 'dev_appserver.py --port=5000 . -A $npm_package_project';
        if (Files::putJson($package_json_location, $package_json_content)) {
            Util::cmdline("Updated package.json in $project_name");
        }

    }
1367295
function() {
  // Get list of dirs from app registry.
  return getAppRegistry()
  // Map app dirs to app names.
  .then(inspectDirs)
  .all()
  .tap(function(appRegistryApps) {
    log.debug(format('Apps in registry: %j', appRegistryApps));
  });

}
957666
private Map<String, SortedSet<PortletCategoryBean>> getRegistry43(
            WebRequest request,
            IPerson user,
            PortletCategory rootCategory,
            boolean includeUncategorized,
            Set<IPortletDefinition> favorites) {

        /*
         * This collection of all the portlets in the portal is for the sake of
         * tracking which ones are uncategorized.  They will be added to the
         * output if includeUncategorized=true.
         */
        Set<IPortletDefinition> portletsNotYetCategorized =
                includeUncategorized
                        ? new HashSet<>(portletDefinitionRegistry.getAllPortletDefinitions())
                        : new HashSet<>(); // Not necessary to fetch them if we're not
        // tracking them

        // construct a new channel registry
        Map<String, SortedSet<PortletCategoryBean>> rslt = new TreeMap<>();
        SortedSet<PortletCategoryBean> categories = new TreeSet<>();

        // add the root category and all its children to the registry
        final Locale locale = getUserLocale(user);
        categories.add(
                preparePortletCategoryBean(
                        request, rootCategory, portletsNotYetCategorized, user, locale, favorites));

        if (includeUncategorized) {
            /*
             * uPortal historically has provided for a convention that portlets not in any category
             * may potentially be viewed by users but may not be subscribed to.
             *
             * As of uPortal 4.2, the logic below now takes any portlets the user has BROWSE access to
             * that have not already been identified as belonging to a category and adds them to a category
             * called Uncategorized.
             */

            EntityIdentifier ei = user.getEntityIdentifier();
            IAuthorizationPrincipal ap =
                    AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());

            Set<PortletDefinitionBean> marketplacePortlets = new HashSet<>();
            for (IPortletDefinition portlet : portletsNotYetCategorized) {
                if (authorizationService.canPrincipalBrowse(ap, portlet)) {
                    PortletDefinitionBean pdb =
                            preparePortletDefinitionBean(
                                    request, portlet, locale, favorites.contains(portlet));
                    marketplacePortlets.add(pdb);
                }
            }

            // construct a new channel category bean for this category
            final String uncName = messageSource.getMessage(UNCATEGORIZED, new Object[] {}, locale);
            final String uncDescription =
                    messageSource.getMessage(UNCATEGORIZED_DESC, new Object[] {}, locale);
            PortletCategory pc =
                    new PortletCategory(
                            uncName); // Use of this String for Id matches earlier version of API
            pc.setName(uncName);
            pc.setDescription(uncDescription);
            PortletCategoryBean unc =
                    PortletCategoryBean.fromPortletCategory(pc, null, marketplacePortlets);

            // Add even if no portlets in category
            categories.add(unc);
        }

        rslt.put(CATEGORIES_MAP_KEY, categories);
        return rslt;
    }
270474
def get_registry(registry_prefix)
      response = rest_get('/redfish/v1/Registries/')
      registries = response_handler(response)['Items']
      registry = registries.select { |reg| reg['Schema'].start_with?(registry_prefix) }
      info = []
      registry.each do |reg|
        response = rest_get(reg['Location'][0]['Uri']['extref'])
        registry_store = response_handler(response)
        info.push(registry_store)
      end
      info
    end
802189
function walkAll(nodes){
    var result = undefined
    for (var i=0;i<nodes.length;i++){
      var childNode = nodes[i]
      if (childNode.type === 'EmptyStatement') continue
      result = walk(childNode)
      if (result instanceof ReturnValue){
        return result
      }
    }
    return result
  }
936073
def docker_list(registry_pass):
    # type: (str) -> None
    
    registry = conf.get('docker.registry', None)

    if registry is None:
        log.err("You must define docker.registry conf variable to list images")
        sys.exit(-1)

    registry_user = conf.get('docker.registry_user', None)

    if registry_user is None:
        registry_user = click.prompt("Username")

    rc = client.RegistryClient(registry, registry_user, registry_pass)
    images = {x: rc.list_tags(x) for x in rc.list_images()}

    shell.cprint("<32>Images in <34>{} <32>registry:", registry)
    for image, tags in images.items():
        shell.cprint('  <92>{}', image)
        for tag in tags:
            shell.cprint('      <90>{}:<35>{}', image, tag)
157486
function parseChildrenProperties( root, libs, com, indent ) {
  if (!Array.isArray( root.children )) {
    root.children = [ ];
  }
  root.children.forEach( function( child ) {
    debugger;
    if ( child.type != libs.Tree.TAG ) {
      return;
    }
    libs.compileChildren( child );

    if ( typeof child.attribs === 'undefined' ) {
      child.attribs = {};
    }
    if ( child.attribs.json === null ) {
      parsePropertyJSON( child, libs, com );
    }
    else {
      // By default, this is a list.
      parsePropertyList( child, libs, com, indent + "  " );
    }
  });
}
1154957
function connectionToJson(object) {
        var pointerNames = theCore.getPointerNames(object);
        var src = null;
        var dst = null;
        if (pointerNames.indexOf('source') !== -1) {
            src = theCore.loadPointer(object, 'source');
        }
        if (pointerNames.indexOf('target') !== -1) {
            dst = theCore.loadPointer(object, 'target');
        }
        return TASYNC.call(function (s, d) {
            var jsonObject = initJsonObject(object);
            if (s !== null) {
                if (theCore.getRegistry(s, 'metameta') === 'refport') {
                    var sA = theCore.getParent(s);
                    jsonObject._children.push({
                        _type: 'connpoint',
                        _empty: true,
                        _attr: {
                            role: "src",
                            target: theCore.getRegistry(s, 'id'),
                            refs: theCore.getRegistry(sA, 'id')
                        }
                    });
                } else {
                    jsonObject._children.push({
                        _type: 'connpoint',
                        _empty: true,
                        _attr: {
                            role: "src",
                            target: theCore.getRegistry(s, 'id')
                        }
                    });
                }
            }
            if (d !== null) {
                if (theCore.getRegistry(d, 'metameta') === 'refport') {
                    var dA = theCore.getParent(d);
                    jsonObject._children.push({
                        _type: 'connpoint',
                        _empty: true,
                        _attr: {
                            role: "dst",
                            target: theCore.getRegistry(d, 'id'),
                            refs: theCore.getRegistry(dA, 'id')
                        }
                    });
                } else {
                    jsonObject._children.push({
                        _type: 'connpoint',
                        _empty: true,
                        _attr: {
                            role: "dst",
                            target: theCore.getRegistry(d, 'id')
                        }
                    });
                }
            }
            return jsonObject;
        }, src, dst);
    }
916004
private static RegistryEntry[] filter(String string, String branch, short type) throws RegistryException {
	branch = ListUtil.trim(branch, "\\");
	StringBuffer result = new StringBuffer();
	ArrayList array = new ArrayList();
	String[] arr = string.split("\n");

	for (int i = 0; i < arr.length; i++) {
	    String line = arr[i].trim();
	    int indexDWORD = line.indexOf(RegistryEntry.REGDWORD_TOKEN);
	    int indexSTRING = line.indexOf(RegistryEntry.REGSTR_TOKEN);

	    if ((indexDWORD != -1) || (indexSTRING != -1)) {
		int index = (indexDWORD == -1) ? indexSTRING : indexDWORD;
		int len = (indexDWORD == -1) ? lenSTRING : lenDWORD;
		short _type = (indexDWORD == -1) ? RegistryEntry.TYPE_STRING : RegistryEntry.TYPE_DWORD;

		if (result.length() > 0) result.append("\n");

		String _key = line.substring(0, index).trim();
		String _value = StringUtil.substringEL(line, index + len + 1, "").trim();

		if (_key.equals(NO_NAME)) _key = "";
		if (_type == RegistryEntry.TYPE_DWORD) _value = String.valueOf(ParseNumber.invoke(_value.substring(2), "hex", 0));
		RegistryEntry re = new RegistryEntry(_type, _key, _value);
		if (type == RegistryEntry.TYPE_ANY || type == re.getType()) array.add(re);
		// }
	    }
	    else if (line.indexOf(branch) == 0 && (type == RegistryEntry.TYPE_ANY || type == RegistryEntry.TYPE_KEY)) {
		line = ListUtil.trim(line, "\\");
		if (branch.length() < line.length()) {
		    array.add(new RegistryEntry(RegistryEntry.TYPE_KEY, ListUtil.last(line, "\\", true), ""));
		}
	    }
	}
	return (RegistryEntry[]) array.toArray(new RegistryEntry[array.size()]);
    }
767381
function traverseRevTree(revs, callback) {
  var toVisit = revs.slice();

  var node;
  while ((node = toVisit.pop())) {
    var pos = node.pos;
    var tree = node.ids;
    var branches = tree[2];
    var newCtx =
      callback(branches.length === 0, pos, tree[0], node.ctx, tree[1]);
    for (var i = 0, len = branches.length; i < len; i++) {
      toVisit.push({pos: pos + 1, ids: branches[i], ctx: newCtx});
    }
  }
}
842012
public static String getSupervisorSlotPorts(int memory, int vcores, String instanceName, String supervisorHost, RegistryOperations registryOperations) {
        return join(getSupervisorPorts(memory, vcores, instanceName, supervisorHost, registryOperations), JOYConstants.COMMA, false);
    }
503564
def walk_json(d, func):
    
    if isinstance(d, Mapping):
        return OrderedDict((k, walk_json(v, func)) for k, v in d.items())
    elif isinstance(d, list):
        return [walk_json(v, func) for v in d]
    else:
        return func(d)