cmd handler for manipulating manifests
330749
def cmd_fw_manifest(self, args):
        ''''''
        if len(args) == 0:
            print(self.fw_manifest_usage())
            return
        rest = args[1:]
        if args[0] == "download":
            return self.manifest_download()
        if args[0] == "list":
            return self.cmd_fw_manifest_list()
        if args[0] == "load":
            return self.cmd_fw_manifest_load()
        if args[0] == "purge":
            return self.cmd_fw_manifest_purge()
        if args[0] == "help":
            return self.cmd_fw_manifest_help()
        else:
            print("fw: Unknown manifest option (%s)" % args[0])
            print(fw_manifest_usage())
238196
def handle_cmd(self, cmd):
        """"""
        cmd = cmd.strip()
        segments = []
        for s in cmd.split():
            # remove bash-like comments
            if s.startswith('#'):
                break
            # TODO implement escape sequences (also for \#)
            segments.append(s)
        args = []
        if not len(segments):
            return
        # process more specific commands first
        while segments:
            cur_cmd = "_".join(segments)
            if cur_cmd in self._cmd_methods:
                argc = self._cmd_argc[cur_cmd]
                if argc is not None and len(args) != argc:
                    msg('command {0} expects {1} argument(s), got {2}',
                        " ".join(segments), argc, len(args))
                    return
                self._cmd_methods[cur_cmd](args)
                return
            args.insert(0, segments.pop())
        # invalid command
        prefix = '_'.join(args) + '_'
        matches = filter(
            lambda cmd: cmd.startswith(prefix), self._cmd_methods.keys())
        candidates = set([])
        for m in matches:
            if len(m) <= len(prefix):
                continue
            m = m[len(prefix):]
            if '_' in m:
                m = m[:m.index('_')]
            candidates.add(m)
        if len(candidates):
            msg('command "{0}" needs more arguments:', ' '.join(args))
            for c in candidates:
                msg('    {0}', c)
        else:
            msg('command "{0}" invalid; type ' +
                'help or use <TAB> for a list of commands',
                ' '.join(args))
893065
def reload_manifest(self, manifest):
        
        self._logger.debug("Reloading manifest for {}.".format(manifest.get("name", "Unnamed Plugin")))
        self._manifests.remove(manifest)
        self.load_manifest(manifest["path"])
        self._logger.debug("Manifest reloaded.")
1344129
def controlprompt_cmd(self, cmd):
        """"""
        data = tags.string_tag('cmbe', cmd) + tags.uint8_tag('cmcc', 0)
        return self.daap.post(_CTRL_PROMPT_CMD, data=data)
1342292
def for(module_path, manifest)
      Puppet::Node::Environment.create(:anonymous,
                                       module_path.split(File::PATH_SEPARATOR),
                                       manifest)
    end
436142
private static void completeManifest(Manifest manifest, URL url) {

    String path = url.getPath();
    int start = 0;
    int end = path.length();
    if (path.endsWith(JAR_SUFFIX)) {
      // 4 for ".jar"
      end = end - JAR_SUFFIX.length() + 4;
      start = path.lastIndexOf('/', end) + 1;
    }
    String source = path.substring(start, end);
    manifest.getMainAttributes().put(MANIFEST_SOURCE, source);
  }
465340
public function command(ConsoleCommandEvent $event)
    {
        /** @var ManifestCommand $command */
        $command = $event->getCommand();

        if (!in_array($command->getName(), $this->getSupportedCommands())) {
            return;
        }

        $command->setChain($this->chain);

        if ($command instanceof RunCommand) {
            $command->setEventDispatcher($this->dispatcher);
        }
    }
1329059
protected void traverseManifest(Manifest manifest, TraversalState state) {
    Attributes	atts;
    String	cp;
    String[]	parts;

    if (manifest == null)
      return;

    atts = manifest.getMainAttributes();
    cp   = atts.getValue("Class-Path");
    if (cp == null)
      return;
    
    parts = cp.split(" ");
    for (String part: parts) {
      if (part.trim().length() == 0)
	return;
      if (part.toLowerCase().endsWith(".jar") || !part.equals("."))
        traverseClasspathPart(part, state);
    }
  }
605082
def do_cli(function_identifier,  # pylint: disable=too-many-locals
           template,
           base_dir,
           build_dir,
           clean,
           use_container,
           manifest_path,
           docker_network,
           skip_pull_image,
           parameter_overrides,
           mode):
    

    LOG.debug("'build' command is called")

    if use_container:
        LOG.info("Starting Build inside a container")

    with BuildContext(function_identifier,
                      template,
                      base_dir,
                      build_dir,
                      clean=clean,
                      manifest_path=manifest_path,
                      use_container=use_container,
                      parameter_overrides=parameter_overrides,
                      docker_network=docker_network,
                      skip_pull_image=skip_pull_image,
                      mode=mode) as ctx:
        try:
            builder = ApplicationBuilder(ctx.functions_to_build,
                                         ctx.build_dir,
                                         ctx.base_dir,
                                         manifest_path_override=ctx.manifest_path_override,
                                         container_manager=ctx.container_manager,
                                         mode=ctx.mode)
        except FunctionNotFound as ex:
            raise UserException(str(ex))

        try:
            artifacts = builder.build()
            modified_template = builder.update_template(ctx.template_dict,
                                                        ctx.original_template_path,
                                                        artifacts)

            move_template(ctx.original_template_path,
                          ctx.output_template_path,
                          modified_template)

            click.secho("\nBuild Succeeded", fg="green")

            msg = gen_success_msg(os.path.relpath(ctx.build_dir),
                                  os.path.relpath(ctx.output_template_path),
                                  os.path.abspath(ctx.build_dir) == os.path.abspath(DEFAULT_BUILD_DIR))

            click.secho(msg, fg="yellow")

        except (UnsupportedRuntimeException, BuildError, UnsupportedBuilderLibraryVersionError,
                ContainerBuildNotSupported) as ex:
            click.secho("\nBuild Failed", fg="red")
            raise UserException(str(ex))
389439
function (manifest) {
  return {
    startPage: manifest.startPage,
    srcDirectory: manifest.srcDirectory,
    name: manifest.name,
    exposeExperimentalAPIs: true
  }
}
691479
function completionHandler(currentInput, currentArgv) {
    commandExecuted = true
    const {scripts} = getPSConfig(currentArgv) || {}
    if (scripts) {
      return getCompletionScripts(scripts, currentInput)
    }
    return []
  }
913076
def cli(ctx, cmd):
    """"""

    exit_code = util.call(cmd)
    ctx.exit(exit_code)
45128
def cmd_fw(self, args):
        ''''''
        if len(args) == 0:
            print(self.usage())
            return
        rest = args[1:]
        if args[0] == "manifest":
            self.cmd_fw_manifest(rest)
        elif args[0] == "list":
            self.cmd_fw_list(rest)
        elif args[0] == "download":
            self.cmd_fw_download(rest)
        elif args[0] in ["help","usage"]:
            self.cmd_fw_help(rest)
        else:
            print(self.usage())
1072775
def embedManifestExeCheck(target, source, env):
    """"""
    if env.get('WINDOWS_EMBED_MANIFEST', 0):
        manifestSrc = target[0].get_abspath() + '.manifest'
        if os.path.exists(manifestSrc):
            ret = (embedManifestExeAction) ([target[0]],None,env)
            if ret:
                raise SCons.Errors.UserError("Unable to embed manifest into %s" % (target[0]))
            return ret
        else:
            print('(embed: no %s.manifest found; not embedding.)'%str(target[0]))
    return 0
758984
function Manifest(output, path) {

    this._output = output;
    this._path = path;

    var buffer = FS.readFileSync(path, {"encoding": "utf8"});
    var json = JSON.parse(buffer);

    // App version is [major.][minor.]micro
    // Major and minor need to be < 100, micro < 1000
    if (json.xwalk_app_version &&
        json.xwalk_app_version.match("^([0-9]+\.){0,2}[0-9]+$")) {

        var valid = true;
        var numbers = json.xwalk_app_version.split(".");
        for (var i = 0; i < numbers.length; i++) {
            if (i == numbers.length - 1 &&
                numbers[i] >= 1000) {
                // Last component, up to 3 digits
                output.warning("App version part '" + numbers[i] + "' must be < 1000");
                valid = false;
                break;
            } else if (i < numbers.length - 1 &&
                       numbers[i] >= 100) {
                // First 2 components, up to 2 digits
                output.warning("App version part '" + numbers[i] + "' must be < 100");
                valid = false;
                break;
            }
        }

        if (valid) {
            this._appVersion = json.xwalk_app_version;
        }
    }

    if (!this._appVersion) {
        output.error("Invalid app version '" + json.xwalk_app_version + "' in the manifest");
        throw new Error("Invalid app version '" + json.xwalk_app_version + "' in the manifest");
    }

    // Splash background colour
    this._backgroundColor = "#ffffff";
    if (json.background_color) {
        var color = ParseColor(json.background_color);
        if (color && color.hex) {
            this._backgroundColor = color.hex;
        } else {
            output.warning("Failed to parse background_color " + json.background_color);
        }
    }

    // Name
    if (json.name &&
        typeof json.name === "string") {
        this._name = json.name;
    }

    if (!this._name) {
        output.warning("Invalid or missing field 'name' in manifest.json");
    }

    // Short name
    if (json.short_name &&
        typeof json.short_name === "string") {
        this._shortName= json.short_name;
    }

    var values;

    // Display
    this._display = "standalone";
    if (json.display) {

        values = ["fullscreen", "standalone", "minimal-ui", "browser"];

        if (values.indexOf(json.display) > -1) {
            // supported mode
            this._display = json.display;
        } else {
            output.warning("Unsupported value '" + json.display + "' for 'display' in manifest.json");
        }
    }

    // Orientation
    this._orientation = "any";
    if (json.orientation) {

        values = [ "any",
                   "natural",
                   "landscape",
                   "portrait",
                   "portrait-primary",
                   "portrait-secondary",
                   "landscape-primary",
                   "landscape-secondary" ];

        if (values.indexOf(json.orientation) > -1) {
            // supported mode
            this._orientation = json.orientation;
        } else {
            output.warning("Unsupported value '" + json.orientation + "' for 'orientation' in manifest.json");
        }
    }

    // Start URL
    // TODO check value
    if (json.start_url &&
        typeof json.start_url === "string") {
        this._startUrl = json.start_url;
    }

    // Icons
    this._icons = [];
    if (json.icons) {
        // TODO validate
        this._icons = json.icons;
    }

    // Command line params
    this._commandLine = null;
    if (json.xwalk_command_line) {
        if (typeof json.xwalk_command_line === "string") {
            this._commandLine = json.xwalk_command_line;
        } else {
            output.warning("Invalid command line '" + json.xwalk_command_line + "'");
        }
    }

    // Package ID
    if (json.xwalk_package_id &&
        CommandParser.validatePackageId(json.xwalk_package_id, this._output)) {
        this._packageId = json.xwalk_package_id;
    } else {
        throw new Error("manifest.json: Invalid package ID '" + json.xwalk_package_id + "'");
    }

    // Extensions
    this._extensions = [];
    if (json.xwalk_extensions) {
        if (json.xwalk_extensions instanceof Array) {
            json.xwalk_extensions.forEach(function (path) {
                var absPath = Path.resolve(Path.dirname(this._path), path);
                absPath = Path.normalize(absPath);
                if (ShellJS.test("-e", absPath)) {
                    this._extensions.push(absPath);
                } else {
                    output.warning("Skipping extension because dir not found: " + absPath);
                }
            }.bind(this));
        } else {
            output.warning("Invalid extensions " + json.xwalk_extensions);
        }
    }
    // Absolute path of Extension Hooks.
    // This info is needed to skip them when generating MSI.
    this._extensionHooks = [];
    this._extensions.forEach(function(extension, i){
      var path = Path.join(extension, "XWalkExtensionHooks.js");
      if (ShellJS.test("-f", path)) {
        this._extensionHooks.push(path);
      }
    }.bind(this));

    // Target platforms
    if (json.xwalk_target_platforms &&
        json.xwalk_target_platforms instanceof Array) {
        this._targetPlatforms = json.xwalk_target_platforms;
    }

    if (!this._targetPlatforms) {
        output.error("Missing or invalid target platforms in the manifest");
        output.error("Try adding");
        output.error('    "xwalk_target_platforms": [ "android" ]');
        output.error("or similar for platform of choice.");
    }

    // Android animatable view
    this._androidAnimatableView = false;
    if (json.xwalk_android_animatable_view) {

        // Recognise boolean or string true.
        if (typeof json.xwalk_android_animatable_view === "boolean" ||
        json.xwalk_android_animatable_view === "true") {
            this._androidAnimatableView = true;
        }
    }

    // Android "keep screen on"
    this._androidKeepScreenOn = false;
    if (json.xwalk_android_keep_screen_on) {

        // Recognise boolean or string true.
        if (typeof json.xwalk_android_keep_screen_on === "boolean" ||
        json.xwalk_android_keep_screen_on === "true") {
            this._androidKeepScreenOn = true;
        }
    }

    // Android permissions
    this._androidPermissions = Manifest.ANDROID_DEFAULT_PERMISSIONS.concat([]); // clone array
    if (json.xwalk_android_permissions) {
        if (json.xwalk_android_permissions instanceof Array) {
            // Merge permissions to the default ones.
            json.xwalk_android_permissions.forEach(function (permission) {
                if (this._androidPermissions.indexOf(permission) < 0) {
                    this._androidPermissions.push(permission);
                }
            }.bind(this));
        } else {
            output.warning("Invalid android permissions '" + json.xwalk_android_permissions + "'");
        }
    }

    // Android webp
    this._androidWebp = false;
    if (json.xwalk_android_webp) {

        if (typeof json.xwalk_android_webp === "string") {
            // TODO better check
            this._androidWebp = json.xwalk_android_webp;
        } else {
            output.warning("Invalid webp parameters '" + json.xwalk_android_webp + "'");
        }
    }

    // Windows update ID
    // Optional field, only check if present.
    this._windowsUpdateId = null;
    if (json.xwalk_windows_update_id) {

        var parts = json.xwalk_windows_update_id.split("-");
        if (parts.length === 5 &&
            parts[0].length === 8 && parts[0].match("^[0-9]*$") &&
            parts[1].length === 4 && parts[1].match("^[0-9]*$") &&
            parts[2].length === 4 && parts[2].match("^[0-9]*$") &&
            parts[3].length === 4 && parts[3].match("^[0-9]*$") &&
            parts[4].length === 12 && parts[4].match("^[0-9]*$")) {

            this._windowsUpdateId = json.xwalk_windows_update_id;

        } else {

            output.error("Invalid Windows Update ID + '" + json.xwalk_windows_update_id + "'");
        }
    }

    // Windows vendor field
    // Optional field, only check if present.
    this._windowsVendor = null;
    if (json.xwalk_windows_vendor) {
        if (typeof json.xwalk_windows_vendor === "string") {
            this._windowsVendor = json.xwalk_windows_vendor;
        } else {
            output.error("Windows target: Invalid vendor field + '" + json.xwalk_windows_vendor + "'");
        }
    }
}
1067276
function injectAddons(manifestUrls) {
  var addons = {};
  for (var n = 0; n < manifestUrls.length; n++) {
    // Fetch Manifest JSON.
    var url = manifestUrls[n];
    var json = getUrl(url);
    if (!json) {
      log('Unable to fetch manifest JSON: ' + url);
      continue;
    }
    json = JSON.parse(json);
    addons[url] = json;

    // If it has a tracing node, inject scripts.
    var tracingInfo = json['tracing'];
    if (tracingInfo && tracingInfo['scripts']) {
      var tracingScripts = tracingInfo['scripts'];
      for (var m = 0; m < tracingScripts.length; m++) {
        var scriptUrl = resolveUrl(url, tracingScripts[m]);
        if (!injectScriptFile(scriptUrl)) {
          log('Error loading addon ' + url + ':');
          log('Tracing script file not found: ' + scriptUrl);
        }
      }
    }
  }
  return addons;
}
635951
def _get_script_args(cls, type_, name, header, script_text):
        
        if type_ == 'gui':
            launcher_type = 'gui'
            ext = '-script.pyw'
            old = ['.pyw']
        else:
            launcher_type = 'cli'
            ext = '-script.py'
            old = ['.py', '.pyc', '.pyo']
        hdr = cls._adjust_header(type_, header)
        blockers = [name + x for x in old]
        yield (name + ext, hdr + script_text, 't', blockers)
        yield (
            name + '.exe', get_win_launcher(launcher_type),
            'b'  # write in binary mode
        )
        if not is_64bit():
            # install a manifest for the launcher to prevent Windows
            # from detecting it as an installer (which it will for
            #  launchers like easy_install.exe). Consider only
            #  adding a manifest for launchers detected as installers.
            #  See Distribute #143 for details.
            m_name = name + '.exe.manifest'
            yield (m_name, load_launcher_manifest(name), 't')