%prog correctX folder tag

    Run ALLPATHS correction on a folder of paired reads and apply tag.
501554
def correctX(args):
    
    p = OptionParser(correctX.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    folder, tag = args
    tag = tag.split(",")
    for p, pf in iter_project(folder):
        correct_pairs(p, pf, tag)
452263
def _match_tags(repex_tags, path_tags):
    
    if 'any' in repex_tags or (not repex_tags and not path_tags):
        return True
    elif set(repex_tags) & set(path_tags):
        return True
    return False
566135
def __write_edit_tmpl(tag_key, tag_list):
    '''
    
    '''
    edit_file = os.path.join(OUT_DIR, 'edit', 'edit_' + tag_key.split('_')[1] + '.html')
    edit_widget_arr = []
    for sig in tag_list:
        html_sig = '_'.join(['html', sig])
        # var_html = eval('html_vars.' + html_sig)
        var_html = HTML_DICS[html_sig]

        if var_html['type'] in INPUT_ARR:
            tmpl = func_gen_html.gen_input_edit(var_html)
        elif var_html['type'] == 'select':
            tmpl = func_gen_html.gen_select_edit(var_html)
        elif var_html['type'] == 'radio':
            tmpl = func_gen_html.gen_radio_edit(var_html)
        elif var_html['type'] == 'checkbox':
            tmpl = func_gen_html.gen_checkbox_edit(var_html)
        elif var_html['type'] == 'file':
            tmpl = func_gen_html.gen_file_edit(var_html)
        else:
            tmpl = ''
        edit_widget_arr.append(tmpl)
    with open(edit_file, 'w') as fileout2:
        outstr = minify(
            TPL_EDIT.replace(
                'xxxxxx',
                ''.join(edit_widget_arr)
            ).replace(
                'yyyyyy',
                tag_key.split('_')[1][:2]
            ).replace(
                'kkkk',
                KIND_DICS['kind_' + tag_key.split('_')[-1]]
            )
        )
        fileout2.write(outstr)
708408
def tag(self, path, name):
    '''
      
    '''

    if not path[len(path) - 1] == '/':
      path += '/'

    config = self.get_config()
    folder = self.find_folder({
      'path' : path
    }, config)

    if not folder:
      raise custom_errors.FileNotInConfig(path)

    old_name = folder['label']
    folder['label'] = name
    
    dir_config = self.adapter.get_dir_config(path)
    dir_config['label'] = name
    self.adapter.set_dir_config(dir_config)

    self.set_config(config)
    # self.restart

    return old_name
999781
def run_tag_processor(self, tag_proc_name):
        '''
        '''
        tag_processor = self.tag_procs[tag_proc_name]

        for tag in tag_processor.find(self.soup):
            self.process_tag(tag_proc_name, tag)
1214321
def find_output_with_tag(self, tag):
        
        # Enforce upper case
        tag = tag.upper()
        return FileList([i for i in self if tag in i.tags])
366501
function extractFilePaths(content, targetPath, opt, tagsRegExp) {
	const files = [];

	const tagMatches = content.match(tagsRegExp.start);
	if (tagMatches) {
		tagMatches.forEach(function (tagMatch) {
			const fileUrl = tagsRegExp.startex.exec(tagMatch)[1];
			const filePath = setFullPath(targetPath, opt.prefix + fileUrl);
			try {
				const fileContent = stripBomBuf(fs.readFileSync(filePath));
				files.push({
					file: new File({
						path: filePath,
						cwd: __dirname,
						base: path.resolve(__dirname, 'expected', path.dirname(filePath)),
						contents: fileContent
					}),
					tags: getRegExpTags(opt, fileUrl)
				});
			} catch (e) {
				if (opt.ignoreError) {
					log(colors.red(filePath + ' not found.'));
				} else {
					throw error(filePath + ' not found.');
				}
			}
			// reset the regex
			tagsRegExp.startex.lastIndex = 0;
		});
	}
	return files;
}
1257738
def find_clean_dirs(self):
        """"""

        for folder in glob.glob(self.glob_pattern):
            if re.match(self.re_pattern, folder):
                yield folder
        for folder in glob.glob(self.orig_glob_pattern):
            if re.match(self.orig_re_pattern, folder):
                yield folder
113265
def view_all_tags(ctx, param, value):
    
    # To make sure this function executed only when the flag was called
    if not value or ctx.resilient_parsing:
        return
    avail_tags = dict()
    print("\nMultiQC Available module tag groups:\n")
    for mod_dict in filter(lambda mod:isinstance(mod, dict), config.module_order):
        mod_key, mod_val = list(mod_dict.items())[0]
        tags = list(mod_val.get('module_tag', []))
        for t in tags:
            if t not in avail_tags:
                avail_tags[t] = []
            avail_tags[t].append(mod_key)
    for t in sorted(avail_tags.keys(), key=lambda s: s.lower()):
        print (" - {}:".format(t))
        for ttgs in avail_tags[t]:
            print ("   - {}".format(ttgs))
    ctx.exit()
5311
def apply_fixes(args, tmpdir):
  """"""
  invocation = [args.clang_apply_replacements_binary]
  if args.format:
    invocation.append('-format')
  if args.style:
    invocation.append('-style=' + args.style)
  invocation.append(tmpdir)
  subprocess.call(invocation)
702469
def _os_walk(directory, recurse=True, **kwargs):
    
    if recurse:
        for root, dirs, files in os.walk(directory, **kwargs):
            yield root, dirs, files
    else:
        files = []
        for filename in os.listdir(directory):
            if os.path.isfile(os.path.join(directory, filename)):
                files.append(filename)
        yield directory, [], files
1313585
function _loop(dir) {
            /* eventually try every python file */
            var pdir = fs.readdirSync(dir);

            pdir.forEach(function(v, i) {
              var stat = fs.statSync(dir + '/' + v);
              if (stat.isFile()) {
                // only process Makefiles and .mk targets.
                if (v !== 'Makefile' && path.extname(v) !== '.mk') {
                  return;
                }

                _log('patching ' + v);

                /* patch the file */
                var py = fs.readFileSync(dir + '/' + v, {
                  encoding: 'utf8',
                });
                py = py.replace(/([a-z]|\/)*python(\w|)/gm, isPy); // this is definently needed
                fs.writeFileSync(dir + '/' + v, py, {
                  encoding: 'utf8',
                }); // write to file
              } else if (stat.isDirectory()) {
                // must be dir?
                // skip tests because we don't need them here
                if (v !== 'test') {
                  _loop(dir + '/' + v);
                }
              }
            });
          }
399420
def find_hg_tag(path):
    """"""
    tags = {}
    try:
        client = subprocess.Popen(
            ["hg", "cat", "-r", "tip", ".hgtags"], stdout=subprocess.PIPE, cwd=path
        )
        for line in client.communicate()[0].splitlines():
            line = line.strip()
            if not line:
                continue
            hash, tag = line.split()
            tags[hash] = tag
    except OSError:
        return

    client = subprocess.Popen(
        ["hg", "parent", "--template", "#node#"], stdout=subprocess.PIPE, cwd=path
    )

    tip = client.communicate()[0].strip()
    tag = tags.get(tip)
    if tag is not None:
        return tag
    return tip
118802
def main() -> None:
    
    parser = ArgumentParser(
        formatter_class=RawDescriptionHelpFormatter,
        description="""
Tool to scan rescued Microsoft Office OpenXML files (produced by the
find_recovered_openxml.py tool in this kit; q.v.) and detect bad (corrupted)
ones.
        """
    )
    parser.add_argument(
        "filename", nargs="*",
        help="File(s) to check. You can also specify directores if you use "
             "--recursive"
    )
    parser.add_argument(
        "--filenames_from_stdin", "-x", action="store_true",
        help="Take filenames from stdin instead, one line per filename "
             "(useful for chained grep)."
    )
    parser.add_argument(
        "--recursive", action="store_true",
        help="Allow search to descend recursively into any directories "
             "encountered."
    )
    parser.add_argument(
        "--skip_files", nargs="*", default=[],
        help="File pattern(s) to skip. You can specify wildcards like '*.txt' "
             "(but you will have to enclose that pattern in quotes under "
             "UNIX-like operating systems). The basename of each file will be "
             "tested against these filenames/patterns. Consider including "
             "Scalpel's 'audit.txt'."
    )
    parser.add_argument(
        "--good", action="store_true",
        help="List good files, not bad"
    )
    parser.add_argument(
        "--delete_if_bad", action="store_true",
        help="If a file is found to be bad, delete it. DANGEROUS."
    )
    parser.add_argument(
        "--run_repeatedly", type=int,
        help="Run the tool repeatedly with a pause of <run_repeatedly> "
             "seconds between runs. (For this to work well with the move/"
             "delete options, you should specify one or more DIRECTORIES in "
             "the 'filename' arguments, not files, and you will need the "
             "--recursive option.)"
    )
    parser.add_argument(
        "--nprocesses", type=int, default=multiprocessing.cpu_count(),
        help="Specify the number of processes to run in parallel."
    )
    parser.add_argument(
        "--verbose", action="store_true",
        help="Verbose output"
    )
    args = parser.parse_args()
    main_only_quicksetup_rootlogger(
        level=logging.DEBUG if args.verbose else logging.INFO,
        with_process_id=True
    )
    if bool(args.filenames_from_stdin) == bool(args.filename):
        raise ValueError("Specify --filenames_from_stdin or filenames on the "
                         "command line, but not both")
    if args.filenames_from_stdin and args.run_repeatedly:
        raise ValueError("Can't use both --filenames_from_stdin and "
                         "--run_repeatedly")

    # Repeated scanning loop
    while True:
        log.debug("Starting scan.")
        log.debug("- Scanning files/directories {!r}{}",
                  args.filename,
                  " recursively" if args.recursive else "")
        log.debug("- Skipping files matching {!r}", args.skip_files)
        log.debug("- Using {} simultaneous processes", args.nprocesses)
        log.debug("- Reporting {} filenames", "good" if args.good else "bad")
        if args.delete_if_bad:
            log.warning("- Deleting bad OpenXML files.")

        # Iterate through files
        pool = multiprocessing.Pool(processes=args.nprocesses)

        if args.filenames_from_stdin:
            generator = gen_from_stdin()
        else:
            generator = gen_filenames(starting_filenames=args.filename,
                                      recursive=args.recursive)

        for filename in generator:
            src_basename = os.path.basename(filename)
            if any(fnmatch.fnmatch(src_basename, pattern)
                   for pattern in args.skip_files):
                log.debug("Skipping file as ordered: " + filename)
                continue
            exists, locked = exists_locked(filename)
            if locked or not exists:
                log.debug("Skipping currently inaccessible file: " + filename)
                continue
            kwargs = {
                'filename': filename,
                'print_good': args.good,
                'delete_if_bad': args.delete_if_bad,
            }
            # log.critical("start")
            pool.apply_async(process_openxml_file, [], kwargs)
            # result = pool.apply_async(process_file, [], kwargs)
            # result.get()  # will re-raise any child exceptions
            # ... but it waits for the process to complete! That's no help.
            # log.critical("next")
            # ... https://stackoverflow.com/questions/22094852/how-to-catch-exceptions-in-workers-in-multiprocessing  # noqa
        pool.close()
        pool.join()

        log.debug("Finished scan.")
        if args.run_repeatedly is None:
            break
        log.info("Sleeping for {} s...", args.run_repeatedly)
        sleep(args.run_repeatedly)
1360353
def program(self, prog, offset = 0):
		
		for addr, word in enumerate(prog):
			self.program_word(offset + addr, word)
1340948
def match_path(entry, opts):
    """"""
    if entry.name in ALWAYS_OMIT:
        return False
    # TODO: currently we use fnmatch syntax and match against names.
    # We also might allow glob syntax and match against the whole relative path instead
    # path = entry.get_rel_path()
    path = entry.name
    ok = True
    match = opts.get("match")
    exclude = opts.get("exclude")
    if entry.is_file() and match:
        assert type(match) is list
        ok = False
        for pat in match:
            if fnmatch.fnmatch(path, pat):
                ok = True
                break
    if ok and exclude:
        assert type(exclude) is list
        for pat in exclude:
            if fnmatch.fnmatch(path, pat):
                ok = False
                break
    # write("match", ok, entry)
    return ok
413217
def runpath(path, argv, filename=None, threads=True, verbose=False):
    
    _run(threads, verbose, 'runpath', filename, path, argv)