读取main下的所有入口文件名，遇到子目录则在构建目录里创建相应的子目录
965509
function readMainFiles(path, files) {
		fs.readdirSync(path).forEach(function (filename) {
			var file = path+'/'+filename,
				file_ext = filename.slice(filename.lastIndexOf('.') + 1);
			if (file_ext==='css' || file_ext==='scss') {
				files.push(file.slice(path_main_len)); //把“main/”也去掉
			} else if (filename[0]!=='.' && fs.statSync(file).isDirectory()) {
				//排除.svn，.github之类的文件夹
				readMainFiles(file, files);
				//在构建目录的main和min里创建对应的目录
				file = file.slice(path_main_len)+'/';
				util.mkdir(path_main, file);
				util.mkdir(path_min, file);
				version_file || util.mkdir(path_tag, file);
			}
		});
	}
560825
function getProgramDir(programFile) {
    const info = programFile.query_info('standard::', Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
    if (info.get_is_symlink()) {
      const symlinkFile = programFile.get_parent().resolve_relative_path(info.get_symlink_target());
      return symlinkFile.get_parent();
    } else {
      return programFile.get_parent();
    }
  }
1046165
def main():
    
    src_dir = sys.argv[1]
    os.chdir(src_dir)
    config = get_config(src_dir)
    cmd = 'python -c "import f5;print(f5.__version__)"'
    version = \
        subprocess.check_output([cmd], shell=True).strip()
    tmp_dist = "/var/deb_dist"
    project = config['project']
    tmp_dist = "/var/deb_dist"
    os_version = "1404"
    deb_dir = "%s/deb_dist" % config['dist_dir']
    print("Building %s debian packages..." % project)
    shutil.copyfile("%s/stdeb.cfg" % (deb_dir), "./stdeb.cfg")
    shutil.copytree(deb_dir, tmp_dist)
    cmd = 'python setup.py --command-packages=stdeb.command sdist_dsc ' + \
        '--dist-dir=%s' % tmp_dist
    print(subprocess.check_output([cmd], shell=True))
    os.chdir("%s/%s-%s" % (tmp_dist, project, version))
    cmd = 'dpkg-buildpackage -rfakeroot -uc -us'.split()
    subprocess.check_output(cmd)  # args will not show up in ps...
    os.chdir(src_dir)
    pkg = "python-%s_%s-1" % (project, version)
    os_pkg = pkg + "_%s_all.deb" % os_version
    pkg = pkg + "_all.deb"
    shutil.copyfile("%s/%s" % (tmp_dist, pkg), "%s/%s" % (deb_dir, os_pkg))
    cmd = "python %s/add_pkg_name.py deb_pkg %s/%s" % \
        (config['scripts'], deb_dir, os_pkg)
1216845
def main() -> None:
    
    parser = ArgumentParser(
        description="Remove duplicate files"
    )
    parser.add_argument(
        "directory", nargs="+",
        help="Files and/or directories to check and remove duplicates from."
    )
    parser.add_argument(
        "--recursive", action="store_true",
        help="Recurse through any directories found"
    )
    parser.add_argument(
        "--dummy_run", action="store_true",
        help="Dummy run only; don't actually delete anything"
    )
    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,"
             "you should specify one or more DIRECTORIES in "
             "the 'filename' arguments, not files, and you will need the "
             "--recursive option.)"
    )
    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)

    while True:
        deduplicate(args.directory,
                    recursive=args.recursive,
                    dummy_run=args.dummy_run)
        if args.run_repeatedly is None:
            break
        log.info("Sleeping for {} s...", args.run_repeatedly)
        sleep(args.run_repeatedly)
258210
function _main() {
  const {guides: acGuidePaths, images: acGuideImagesPaths, examples: acExamplePaths} = getPathsFromAioContent();
  const {guides: coGuidePaths, images: coGuideImagesPaths, examples: coExamplePaths} = getPathsFromCodeowners();

  const guidesDiff = arrayDiff(acGuidePaths, coGuidePaths);
  const imagesDiff = arrayDiff(acGuideImagesPaths, coGuideImagesPaths);
  const examplesDiff = arrayDiff(acExamplePaths, coExamplePaths);
  const hasDiff = !!(guidesDiff.diffCount || imagesDiff.diffCount || examplesDiff.diffCount);

  if (hasDiff) {
    const expectedGuidesSrc = path.relative(PROJECT_ROOT_DIR, AIO_GUIDES_DIR);
    const expectedImagesSrc = path.relative(PROJECT_ROOT_DIR, AIO_GUIDE_IMAGES_DIR);
    const expectedExamplesSrc = path.relative(PROJECT_ROOT_DIR, AIO_GUIDE_EXAMPLES_DIR);
    const actualSrc = path.relative(PROJECT_ROOT_DIR, CODEOWNERS_PATH);

    reportDiff(guidesDiff, expectedGuidesSrc, actualSrc);
    reportDiff(imagesDiff, expectedImagesSrc, actualSrc);
    reportDiff(examplesDiff, expectedExamplesSrc, actualSrc);
  }

  process.exit(hasDiff ? 1 : 0);
}
1027199
function findMainFiles(name, component, meta) {
			grunt.verbose.writeln();
			grunt.verbose.writeln('Finding main file for ' + name + '...');
			var mainFiles = ensureArray(component);

			// Main file explicitly defined in bower_concat options
			if (mains[name]) {
				var componentDir = meta && meta.canonicalDir || path.join(bowerDir, bower.config.directory, name);
				var manualMainFiles = ensureArray(mains[name]);
				manualMainFiles = _.map(manualMainFiles, joinPathWith(componentDir));
				grunt.verbose.writeln('Main file was specified in bower_concat options: ' + manualMainFiles);
				return manualMainFiles;
			}

			// Bower knows main JS file?
			mainFiles = _.map(mainFiles, joinPathWith(bowerDir));
			var mainJSFiles = _.filter(mainFiles, function(file) { return isFileExtension(file, '.js'); });
			var mainCSSFiles = _.filter(mainFiles, function(file) { return isFileExtension(file, '.css'); });
			var mainSCSSFiles = _.filter(mainFiles, function(file) { return isFileExtension(file, '.scss'); });
			var allMainFiles = mainJSFiles.concat(mainCSSFiles.concat(mainSCSSFiles));

			if (allMainFiles.length) {
				grunt.verbose.writeln('Main file was specified in bower.json: ' + allMainFiles);
				return allMainFiles;
			}

			// Try to find main JS, CSS, SCSS files
			var jsFiles = expandForAll(component, joinPathWith(bowerDir, '*.js'));
			var cssFiles = expandForAll(component, joinPathWith(bowerDir, '*.css'));
			var scssFiles = expandForAll(component, joinPathWith(bowerDir, '*.scss'));

			// Skip Gruntfiles
			jsFiles = _.filter(jsFiles, function(filepath) {
				return !/(Gruntfile\.js)|(grunt\.js)$/.test(filepath);
			});

			var mainJsFiles = [];
			if (jsFiles.length === 1) {
				// Only one JS file: no doubt it’s main file
				grunt.verbose.writeln('Considering the only JS file in a component’s folder ' +
					 'as a main file: ' + jsFiles
						);
				mainJsFiles = jsFiles;
			}
			else {
				// More than one JS file: try to guess
				var bestFile = guessBestFile(name, jsFiles);
				if (bestFile) {
					grunt.verbose.writeln('Guessing the best JS file in a component’s folder: ' + [bestFile]);
					mainJsFiles = [bestFile];
				}
				else {
					grunt.verbose.writeln('Main JS file not found');
				}
			}
			return mainJsFiles.concat(cssFiles);
		}
797630
def findall(self):
        
        from stat import S_ISREG, S_ISDIR, S_ISLNK

        self.allfiles = allfiles = []
        root = self.base
        stack = [root]
        pop = stack.pop
        push = stack.append

        while stack:
            root = pop()
            names = os.listdir(root)

            for name in names:
                fullname = os.path.join(root, name)

                # Avoid excess stat calls -- just one will do, thank you!
                stat = os.stat(fullname)
                mode = stat.st_mode
                if S_ISREG(mode):
                    allfiles.append(fsdecode(fullname))
                elif S_ISDIR(mode) and not S_ISLNK(mode):
                    push(fullname)
719401
def start(self):
        
        dwn_count = 1
        self._directory_prefix()
        for dwn in self.url:
            # get file name from url and fix passing char '+'
            self.file_name = dwn.split("/")[-1].replace("%2B", "+")

            if dwn.startswith("file:///"):
                source_dir = dwn[7:-7].replace(slack_ver(), "")
                self._make_tarfile(self.file_name, source_dir)

            self._check_certificate()
            print("\n[{0}/{1}][ {2}Download{3} ] --> {4}\n".format(
                dwn_count, len(self.url), self.meta.color["GREEN"],
                self.meta.color["ENDC"],
                self.file_name))
            if self.downder in ["wget"]:
                subprocess.call("{0} {1} {2}{3} {4}".format(
                                self.downder, self.downder_options,
                                self.dir_prefix, self.path, dwn),
                                shell=True)
            if self.downder in ["aria2c"]:
                subprocess.call("{0} {1} {2}{3} {4}".format(
                                self.downder, self.downder_options,
                                self.dir_prefix, self.path[:-1], dwn),
                                shell=True)
            elif self.downder in ["curl", "http"]:
                subprocess.call("{0} {1} {2}{3} {4}".format(
                                self.downder, self.downder_options,
                                self.path, self.file_name, dwn), shell=True)
            self._check_if_downloaded()
            dwn_count += 1
263726
def main():
    
    try:
        # Get the `src` directory's absolute path
        src_path = os.path.dirname(
            # `aoiklivereload` directory's absolute path
            os.path.dirname(
                # `demo` directory's absolute path
                os.path.dirname(
                    # This file's absolute path
                    os.path.abspath(__file__)
                )
            )
        )

        # If the `src` directory path is not in `sys.path`
        if src_path not in sys.path:
            # Add to `sys.path`.
            #
            # This aims to save user setting PYTHONPATH when running this demo.
            #
            sys.path.append(src_path)

        # Import reloader class
        from aoiklivereload import LiveReloader

        # Create reloader
        reloader = LiveReloader()

        # Start watcher thread
        reloader.start_watcher_thread()

        # Server host
        server_host = '0.0.0.0'

        # Server port
        server_port = 8000

        # Get message
        msg = '# ----- Run server -----\nHost: {}\nPort: {}'.format(
            server_host, server_port
        )

        # Print message
        print(msg)

        # Create Flask app
        flask_app = flask.Flask(__name__)

        # Create request handler
        @flask_app.route('/')
        def hello_handler():  # pylint: disable=unused-variable
            """
            Request handler.

            :return:
                Response body.
            """
            # Return response body
            return 'hello'

        # Run server
        flask_app.run(
            host=server_host,
            port=server_port,
            # Disable Flask's reloader
            debug=False,
        )

    # If have `KeyboardInterrupt`
    except KeyboardInterrupt:
        # Not treat as error
        pass
197192
def main(directories):
    ''''''
    msg = 'Checking module "{}" from directory "{}" for coding errors.'
    api_checker = ApiChecker()
    resource_checker = ResourceChecker()
    errors = []
    modules = []
    for loader, mname, _ in pkgutil.walk_packages(directories):
        sys.path.append(os.path.abspath(loader.path))
        log.info(msg.format(mname, loader.path))
        modules.append(mname)
        import_module(mname)
    for api in Api:
        if api.__module__.split('.')[-1] not in modules:
            continue
        log.debug('Anlysing Api class: {}'.format(api.__name__))
        errors.extend(api_checker(api))
    for res in Resource:
        if res.__module__.split('.')[-1] not in modules:
            continue
        log.debug('Anlysing Resource class: {}'.format(res.__name__))
        errors.extend(resource_checker(res))
    else:
        log.info('All modules tested, no problem detected.')
    return errors
1064326
def main(self):
        
        self.secret_finder()
        self.parse_access_token()
        self.get_session_token()
        self.parse_session_token()
        self.get_route()
        self.download_profile()
        self.find_loci()
        self.download_loci()
238165
def get_main_title(self, path_name, request_name):
        '''
        
        '''
        main_title = '.. http:{}:: {}'.format(request_name, path_name)
        self.write(main_title)
        self.write('')
315478
def get_distribution_names(self):
        
        result = set()
        for root, dirs, files in os.walk(self.base_dir):
            for fn in files:
                if self.should_include(fn, root):
                    fn = os.path.join(root, fn)
                    url = urlunparse(('file', '',
                                      pathname2url(os.path.abspath(fn)),
                                      '', '', ''))
                    info = self.convert_url_to_download_info(url, None)
                    if info:
                        result.add(info['name'])
            if not self.recursive:
                break
        return result
1297771
def main():
    """"""
    parser = get_parser()
    args = parser.parse_args()

    # set up variables
    ARCHIVE = args.archive_path
    archive = (not args.no_archive)
    os.environ['F2FORMAT_VERSION'] = args.python
    os.environ['F2FORMAT_ENCODING'] = args.encoding

    def find(root):
        """Recursively find all files under root."""
        flst = list()
        temp = os.listdir(root)
        for file in temp:
            path = os.path.join(root, file)
            if os.path.isdir(path):
                flst.extend(find(path))
            elif os.path.isfile(path):
                flst.append(path)
            elif os.path.islink(path):  # exclude symbolic links
                continue
        yield from flst

    def rename(path):
        stem, ext = os.path.splitext(path)
        name = '%s-%s%s' % (stem, uuid.uuid4(), ext)
        return os.path.join(ARCHIVE, name)

    # make archive directory
    if archive:
        os.makedirs(ARCHIVE, exist_ok=True)

    # fetch file list
    filelist = list()
    for path in sys.argv[1:]:
        if os.path.isfile(path):
            if archive:
                dest = rename(path)
                os.makedirs(os.path.dirname(dest), exist_ok=True)
                shutil.copy(path, dest)
            filelist.append(path)
        if os.path.isdir(path):
            if archive:
                shutil.copytree(path, rename(path))
            filelist.extend(find(path))

    # check if file is Python source code
    def ispy(file): return (os.path.isfile(file) and (os.path.splitext(file)[1] in ('.py', '.pyw')))
    filelist = sorted(filter(ispy, filelist))

    # if no file supplied
    if len(filelist) == 0:
        parser.error('argument PATH: no valid source file found')

    # process files
    if mp is None  or CPU_CNT <= 1:
        [f2format(filename) for filename in filelist]
    else:
        mp.Pool(processes=CPU_CNT).map(f2format, filelist)
848728
def postprocess(self):
        
        # Add suffix to all sub_dir/{items}
        for path in self.neb_dirs:
            for f in VASP_NEB_OUTPUT_SUB_FILES:
                f = os.path.join(path, f)
                if os.path.exists(f):
                    if self.final and self.suffix != "":
                        shutil.move(f, "{}{}".format(f, self.suffix))
                    elif self.suffix != "":
                        shutil.copy(f, "{}{}".format(f, self.suffix))

        # Add suffix to all output files
        for f in VASP_NEB_OUTPUT_FILES + [self.output_file]:
            if os.path.exists(f):
                if self.final and self.suffix != "":
                    shutil.move(f, "{}{}".format(f, self.suffix))
                elif self.suffix != "":
                    shutil.copy(f, "{}{}".format(f, self.suffix))
643385
def main():
    """"""
    if len(sys.argv) < 3:
        print('Usage: <project-name> <filetype> <list-of-path to traverse>')
        print('\tfiletype can be python/cpp/all')
        exit(-1)
    _HELPER.project_name = sys.argv[1]
    file_type = sys.argv[2]
    allow_type = []
    if file_type == 'python' or file_type == 'all':
        allow_type += [x for x in PYTHON_SUFFIX]
    if file_type == 'cpp' or file_type == 'all':
        allow_type += [x for x in CXX_SUFFIX]
    allow_type = set(allow_type)
    if os.name != 'nt':
        sys.stderr = codecs.StreamReaderWriter(sys.stderr,
                                               codecs.getreader('utf8'),
                                               codecs.getwriter('utf8'),
                                               'replace')
    for path in sys.argv[3:]:
        if os.path.isfile(path):
            process(path, allow_type)
        else:
            for root, dirs, files in os.walk(path):
                for name in files:
                    process(os.path.join(root, name), allow_type)

    nerr = _HELPER.print_summary(sys.stderr)
    sys.exit(nerr > 0)
316315
def ipynb_file_name(params):
    
    global notebook_dir
    p = notebook_dir + [param.replace('/', '') for param in params if param is not None]
    return path.join(*p)