Execute the passes from a PassConfig instance over a single replaced file.
551192
private void runHotSwap(
      Node originalRoot, Node js, PassConfig passConfig) {
    for (PassFactory passFactory : passConfig.getChecks()) {
      runHotSwapPass(originalRoot, js, passFactory);
    }
  }
1185975
public static void addPostCheckTranspilationPasses(
      List<PassFactory> passes, CompilerOptions options) {
    if (options.needsTranspilationFrom(FeatureSet.ES_NEXT)) {
      passes.add(rewriteCatchWithNoBinding);
    }

    if (options.needsTranspilationFrom(ES2018)) {
      passes.add(rewriteAsyncIteration);
      passes.add(rewriteObjectSpread);
    }

    if (options.needsTranspilationFrom(ES8)) {
      // Trailing commas in parameter lists are flagged as present by the parser,
      // but never actually represented in the AST.
      // The only thing we need to do is mark them as not present in the AST.
      passes.add(
          createFeatureRemovalPass(
              "markTrailingCommasInParameterListsRemoved", Feature.TRAILING_COMMA_IN_PARAM_LIST));
      passes.add(rewriteAsyncFunctions);
    }

    if (options.needsTranspilationFrom(ES7)) {
      passes.add(rewriteExponentialOperator);
    }

    if (options.needsTranspilationFrom(ES6)) {
      // TODO(b/73387406): Move passes here as typechecking & other check passes are updated to cope
      // with the features they transpile and as the passes themselves are updated to propagate type
      // information to the transpiled code.
      // Binary and octal literals are effectively transpiled by the parser.
      // There's no transpilation we can do for the new regexp flags.
      passes.add(
          createFeatureRemovalPass(
              "markEs6FeaturesNotRequiringTranspilationAsRemoved",
              Feature.BINARY_LITERALS,
              Feature.OCTAL_LITERALS,
              Feature.REGEXP_FLAG_U,
              Feature.REGEXP_FLAG_Y));

      passes.add(es6NormalizeShorthandProperties);
      passes.add(es6RewriteClassExtends);
      passes.add(es6ConvertSuper);
      passes.add(es6RenameVariablesInParamLists);
      passes.add(es6SplitVariableDeclarations);
      passes.add(
          getEs6RewriteDestructuring(ObjectDestructuringRewriteMode.REWRITE_ALL_OBJECT_PATTERNS));
      passes.add(es6RewriteArrowFunction);
      passes.add(es6ExtractClasses);
      passes.add(es6RewriteClass);
      passes.add(es6RewriteRestAndSpread);
      passes.add(lateConvertEs6ToEs3);
      passes.add(es6ForOf);
      passes.add(rewriteBlockScopedFunctionDeclaration);
      passes.add(rewriteBlockScopedDeclaration);
      passes.add(rewriteGenerators);
      passes.add(es6ConvertSuperConstructorCalls);
    } else if (options.needsTranspilationOf(Feature.OBJECT_PATTERN_REST)) {
      passes.add(es6RenameVariablesInParamLists);
      passes.add(es6SplitVariableDeclarations);
      passes.add(getEs6RewriteDestructuring(ObjectDestructuringRewriteMode.REWRITE_OBJECT_REST));
    }
  }
148598
def copyFile(input, output, replace=None):
    """"""

    _found = findFile(output)
    if not _found or (_found and replace):
        shutil.copy2(input, output)
1198877
static public InputStream replace(File file, File props) throws IOException, SubstitutionException{
	return replace(file, props, null, false);
    }
232962
def copy_config(config, mutable_config_keys=MUTABLE_CONFIG_KEYS):
    

    cloned_config = copy(config)
    # Apply ``copy`` function to mutable config values
    for key in mutable_config_keys:
        cloned_config[key] = copy(config[key])
    return cloned_config
342530
def do_copy_config(self, line):
        

        def f(p, args):
            try:
                source, target = args
            except:
                print("argument error")
                return
            print(p.copy_config(source, target))

        self._request(line, f)
312320
def from_config(cls, config):
        """"""
        auth_key = None
        password_file = config["authentication.passwordFile"]
        if password_file is not None:
            try:
                auth_key = open(config["authentication.passwordFile"]).read()
                auth_key = re.sub(r"\s", "", auth_key)
            except IOError:
                LOG.error("Could not load password file!")
                sys.exit(1)
        password = config["authentication.password"]
        if password is not None:
            auth_key = password
        connector = Connector(
            mongo_address=config["mainAddress"],
            doc_managers=config["docManagers"],
            oplog_checkpoint=os.path.abspath(config["oplogFile"]),
            collection_dump=config["onlyDump"] or not config["noDump"],
            only_dump=config["onlyDump"],
            batch_size=config["batchSize"],
            continue_on_error=config["continueOnError"],
            auth_username=config["authentication.adminUsername"],
            auth_key=auth_key,
            fields=config["fields"],
            exclude_fields=config["exclude_fields"],
            ns_set=config["namespaces.include"],
            ex_ns_set=config["namespaces.exclude"],
            dest_mapping=config["namespaces.mapping"],
            namespace_options=config["namespaces.namespace_options"],
            gridfs_set=config["namespaces.gridfs"],
            ssl_certfile=config["ssl.sslCertfile"],
            ssl_keyfile=config["ssl.sslKeyfile"],
            ssl_ca_certs=config["ssl.sslCACerts"],
            ssl_cert_reqs=config["ssl.sslCertificatePolicy"],
            tz_aware=config["timezoneAware"],
        )
        return connector
628177
def _apply_replacement(error, found_file, file_lines):
    """"""
    fixed_lines = file_lines
    fixed_lines[error[1].line - 1] = error[1].replacement
    concatenated_fixed_lines = "".join(fixed_lines)

    # Only fix one error at a time
    found_file.seek(0)
    found_file.write(concatenated_fixed_lines)
    found_file.truncate()
33041
def run(path='', code=None, rootdir=CURDIR, options=None):
    
    errors = []
    fileconfig = dict()
    linters = LINTERS
    linters_params = dict()
    lname = 'undefined'
    params = dict()
    path = op.relpath(path, rootdir)

    if options:
        linters = options.linters
        linters_params = options.linters_params
        for mask in options.file_params:
            if mask.match(path):
                fileconfig.update(options.file_params[mask])

        if options.skip and any(p.match(path) for p in options.skip):
            LOGGER.info('Skip checking for path: %s', path)
            return []

    try:
        with CodeContext(code, path) as ctx:
            code = ctx.code
            params = prepare_params(parse_modeline(code), fileconfig, options)
            LOGGER.debug('Checking params: %s', params)

            if params.get('skip'):
                return errors

            for item in params.get('linters') or linters:

                if not isinstance(item, tuple):
                    item = item, LINTERS.get(item)

                lname, linter = item

                if not linter:
                    continue

                lparams = linters_params.get(lname, dict())
                LOGGER.info("Run %s %s", lname, lparams)

                ignore, select = merge_params(params, lparams)

                linter_errors = linter.run(
                    path, code=code, ignore=ignore, select=select, params=lparams)
                if not linter_errors:
                    continue

                errors += filter_errors([
                    Error(filename=path, linter=lname, **er) for er in linter_errors
                ], ignore=ignore, select=select)

    except IOError as e:
        LOGGER.error("IOError %s", e)
        errors.append(Error(text=str(e), filename=path, linter=lname))

    except SyntaxError as e:
        LOGGER.error("SyntaxError %s", e)
        errors.append(
            Error(linter='pylama', lnum=e.lineno, col=e.offset,
                  text='E0100 SyntaxError: {}'.format(e.args[0]),
                  filename=path))

    except Exception as e:  # noqa
        import traceback
        LOGGER.error(traceback.format_exc())

    errors = list(remove_duplicates(errors))

    if code and errors:
        errors = filter_skiplines(code, errors)

    if options and options.sort:
        sort = dict((v, n) for n, v in enumerate(options.sort, 1))

        def key(e):
            return (sort.get(e.type, 999), e.lnum)
    else:
        def key(e):
            return e.lnum

    return sorted(errors, key=key)
433805
def _config_stream(filename):
    
    if filename is None or filename == '-':
        log.info('Reading config from stdin')
        yield sys.stdin
    else:
        with open(filename, mode='rt') as handle:
            log.info('Reading config from %r', filename)
            yield handle
954489
private static CompilerPass runInSerial(
      final Collection<CompilerPass> passes) {
    return new CompilerPass() {
      @Override public void process(Node externs, Node root) {
        for (CompilerPass pass : passes) {
          pass.process(externs, root);
        }
      }
    };
  }
355972
def update_file(self, id, hidden=None, lock_at=None, locked=None, name=None, on_duplicate=None, parent_folder_id=None, unlock_at=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - id
        """ID"""
        path["id"] = id

        # OPTIONAL - name
        """The new display name of the file"""
        if name is not None:
            data["name"] = name

        # OPTIONAL - parent_folder_id
        """The id of the folder to move this file into.
        The new folder must be in the same context as the original parent folder.
        If the file is in a context without folders this does not apply."""
        if parent_folder_id is not None:
            data["parent_folder_id"] = parent_folder_id

        # OPTIONAL - on_duplicate
        """If the file is moved to a folder containing a file with the same name,
        or renamed to a name matching an existing file, the API call will fail
        unless this parameter is supplied.
        
        "overwrite":: Replace the existing file with the same name
        "rename":: Add a qualifier to make the new filename unique"""
        if on_duplicate is not None:
            self._validate_enum(on_duplicate, ["overwrite", "rename"])
            data["on_duplicate"] = on_duplicate

        # OPTIONAL - lock_at
        """The datetime to lock the file at"""
        if lock_at is not None:
            data["lock_at"] = lock_at

        # OPTIONAL - unlock_at
        """The datetime to unlock the file at"""
        if unlock_at is not None:
            data["unlock_at"] = unlock_at

        # OPTIONAL - locked
        """Flag the file as locked"""
        if locked is not None:
            data["locked"] = locked

        # OPTIONAL - hidden
        """Flag the file as hidden"""
        if hidden is not None:
            data["hidden"] = hidden

        self.logger.debug("PUT /api/v1/files/{id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("PUT", "/api/v1/files/{id}".format(**path), data=data, params=params, single_item=True)
382086
def from_cli(cls, opts):
        
        # read configuration file
        logging.info("Reading configuration file")
        if opts.config_overrides is not None:
            overrides = [override.split(":")
                         for override in opts.config_overrides]
        else:
            overrides = None
        if opts.config_delete is not None:
            deletes = [delete.split(":") for delete in opts.config_delete]
        else:
            deletes = None
        return cls(opts.config_files, overrides, deleteTuples=deletes)
816219
def execute_from_file(self, url, file_var):
        '''
        

        '''
        if isinstance(file_var, file):
            f = file_var
        elif isinstance(file_var, str):
            try:
                f = open(file_var)
            except IOError, e:
                raise e
        else:
            raise TypeError("This function only accepts a 'file' type  or file path")

        inputs = json.loads(f.read())
        resp = self.execute(url, inputs)
        return resp
893525
def replace_in_file(filename: str, text_from: str, text_to: str) -> None:
    
    log.info("Amending {}: {} -> {}",
             filename, repr(text_from), repr(text_to))
    with open(filename) as infile:
        contents = infile.read()
    contents = contents.replace(text_from, text_to)
    with open(filename, 'w') as outfile:
        outfile.write(contents)
1011760
def load_config(self, config_source, parameters_source):
        """"""
        with open(config_source) as config_source:
            config_raw = config_source.read()

            parameters = {}
            """Parameteres from file"""
            if os.path.isfile(parameters_source):
                params = self.load_parameters(parameters_source)
                if params is not None:
                    parameters.update(params)

            """Overwrite parameteres with the environment variables"""
            env_params = {}
            env_params.update(os.environ)
            for k, v in env_params.items():
                if is_string(v):
                    env_params[k] = "'" + v + "'"

            parameters.update(env_params)

            """Replace the parameters"""
            final_configuration = config_raw.format(**parameters)
            final_configuration = yaml.safe_load(final_configuration)
            return final_configuration if final_configuration is not None else {}
199959
function(context, descriptor, args, stack) {
		if (context.env.data.isServer)
			return;
		secondPass(args[0], context, descriptor, stack);
	}