find examples not under lib dir, and move into ``examples``
548284
def move_examples(root, lib_dir):
    """"""
    all_pde = files_multi_pattern(root, INO_PATTERNS)
    lib_pde = files_multi_pattern(lib_dir, INO_PATTERNS)
    stray_pde = all_pde.difference(lib_pde)
    if len(stray_pde) and not len(lib_pde):
        log.debug(
            'examples found outside lib dir, moving them: %s', stray_pde)
        examples = lib_dir / EXAMPLES
        examples.makedirs()
        for x in stray_pde:
            d = examples / x.namebase
            d.makedirs()
            x.move(d)
1017950
def glob_in_parents(dir, patterns, upper_limit=None):
    """"""

    assert(isinstance(dir, str))
    assert(isinstance(patterns, list))

    result = []

    absolute_dir = os.path.join(os.getcwd(), dir)
    absolute_dir = os.path.normpath(absolute_dir)
    while absolute_dir:
        new_dir = os.path.split(absolute_dir)[0]
        if new_dir == absolute_dir:
            break
        result = glob([new_dir], patterns)
        if result:
            break
        absolute_dir = new_dir

    return result
944254
def find_binutils_libs(self, libdir, lib_ext):
        """"""
        bfd_expr = re.compile("(lib(?:bfd)|(?:opcodes))(.*?)\%s" % lib_ext )
        libs = {}
        for root, dirs, files in os.walk(libdir):
            for f in files:
                m = bfd_expr.search(f)
                if m:
                    lib, version = m.groups()
                    fp = os.path.join(root, f)
                    if version in libs:
                        libs[ version ].append( fp )
                    else:
                        libs[ version ] = [fp,]

        # first, search for multiarch files.
        # check if we found more than one version of the multiarch libs.
        multiarch_libs = dict( [(v,_l) for v, _l in libs.items() \
            if v.find("multiarch") != -1 ] )
        if len(multiarch_libs) > 1:
        	print "[W] Multiple binutils versions detected. Trying to build with default..."
            	return multiarch_libs.values()[0]
        if len(multiarch_libs) == 1:
            return multiarch_libs.values()[0]
        # or use the default libs, or .. none
        return libs.get("",[])
49096
def create_examples_all():
    
    remove_examples_all()
    examples_all_dir().mkdir()

    for lib in libraries():
        maindir = examples_all_dir() / lib.upper()[0:1] / lib
#        libraries_dir() /
        maindir.makedirs_p()

        for ex in lib_examples(lib):
            d = lib_example_dir(lib, ex)
            if hasattr(os, 'symlink'):
                d.symlink(maindir / ex)
            else:
                d.copytree(maindir / ex)
591256
def not_files(self):
        """"""

        _args = []

        for arg in self.all:
            if not len(_expand_path(arg)):
                if not os.path.exists(arg):
                    _args.append(arg)

        return ArgsList(_args, no_argv=True)
1031494
def build_sample_paths(sample):
    
    for path_name, path in sample.paths.items():
        print("{}: '{}'".format(path_name, path))
        base, ext = os.path.splitext(path)
        if ext:
            print("Skipping file-like: '[}'".format(path))
        elif not os.path.isdir(base):
            os.makedirs(base)
911279
def example_filename(fn):
    
    fn = os.path.join(data_dir(), fn)
    if not os.path.exists(fn):
        raise ValueError("%s does not exist" % fn)
    return fn
307954
def example_yaml(cls, skip=()):
        
        return cls.example_instance(skip=skip).to_yaml(skip=skip)
1307530
def get_py_files(dir_name: str) -> list:
    """"""
    return flatten([
        x for x in
        [["{0}/{1}".format(path, f) for f in files if f.endswith(".py")]
         for path, _, files in os.walk(dir_name)
         if not path.startswith("./build")] if x
    ])
663155
def _get_files_to_lint(self, external_directories):
        """"""
        all_f = []

        for external_dir in external_directories:
            all_f.extend(_all_files_matching_ext(external_dir, "py"))

        packages = self.distribution.packages or list()
        for package in packages:
            all_f.extend(_all_files_matching_ext(package, "py"))

        py_modules = self.distribution.py_modules or list()
        for filename in py_modules:
            all_f.append(os.path.realpath(filename + ".py"))

        all_f.append(os.path.join(os.getcwd(), "setup.py"))

        # Remove duplicates which may exist due to symlinks or repeated
        # packages found by /setup.py
        all_f = list(set([os.path.realpath(f) for f in all_f]))

        exclusions = [
            "*.egg/*",
            "*.eggs/*"
        ] + self.exclusions
        return sorted([f for f in all_f if not _is_excluded(f, exclusions)])
689799
def find_new(self):
        
        print("\nSearch for .new configuration files:\n")
        for path, dirs, files in os.walk(self.etc):
            del dirs    # delete unsed
            for f in files:
                if f.endswith(".new"):
                    self.news.append(os.path.join(path, f))
        if not self.news:
            print("  No new configuration files\n")
            raise SystemExit()
1043386
def config_examples(dest, user_dir):
    
    examples_path = Path(lightflow.__file__).parents[1] / 'examples'
    if examples_path.exists():
        dest_path = Path(dest).resolve()
        if not user_dir:
            dest_path = dest_path / 'examples'

        if dest_path.exists():
            if not click.confirm('Directory already exists. Overwrite existing files?',
                                 default=True, abort=True):
                return
        else:
            dest_path.mkdir()

        for example_file in examples_path.glob('*.py'):
            shutil.copy(str(example_file), str(dest_path / example_file.name))
        click.echo('Copied examples to {}'.format(str(dest_path)))
    else:
        click.echo('The examples source path does not exist')
1304985
def convert_ipynbs(directory):
    """"""
    # The ipython_examples dir has to be in the same dir as this script
    for root, subfolders, files in os.walk(os.path.abspath(directory)):
        for f in files:
            if ".ipynb_checkpoints" not in root:
                if f.endswith("ipynb"):
                    ipynb_to_rst(root, f)
1160895
def find_files(args):
    '''
    
    '''
    files_or_dirs = args or ['.']
    filenames = []
    for f in files_or_dirs:
        if path.isdir(f):
            filenames.extend(glob.glob(path.join(f, '**', '*_spec.py'), recursive=True))
        elif path.isfile(f):
            filenames.append(f)
        else:
            raise FileNotFoundError('could not spec file {}'.format(repr(f)))
    return filenames
904980
def analyze_lib(lib_dir, cover_filename, *, ignore_existing=False):
  
  work = {}
  stats = collections.OrderedDict(((k, 0) for k in("files", "albums", "missing covers", "errors")))
  with tqdm.tqdm(desc="Analyzing library",
                 unit="dir",
                 postfix=stats) as progress, \
          tqdm_logging.redirect_logging(progress):
    for rootpath, rel_dirpaths, rel_filepaths in os.walk(lib_dir):
      metadata = analyze_dir(stats,
                             rootpath,
                             rel_filepaths,
                             cover_filename,
                             ignore_existing=ignore_existing)
      progress.set_postfix(stats, refresh=False)
      progress.update(1)
      if all(metadata[:-1]):
        work[rootpath] = metadata[:-1]
  return work
958079
function findFilesWithPlaceholders(packageDir) {
  const findCommand = buildPlaceholderFindCommand(packageDir);
  return spawnSync(findCommand.binary, findCommand.args).stdout
    .toString()
    .split(/[\n\r]/)
    .filter(String);
}
1029217
def find_linked_dynamic_libraries():
    
    with TaskContext("Find the required dynamic libraries") as log:
        llvm = get_llvm()
        libs = required_link_libraries()
        resolved = []
        for libname in libs:
            if llvm:
                fullpath = os.path.join(llvm, "lib", libname)
                if os.path.isfile(fullpath):
                    resolved.append(fullpath)
                    log.info("Library `%s` found at %s" % (libname, fullpath))
                    continue
                else:
                    log.info("%s does not exist" % fullpath)
            # Rely on the shell `locate` command to find the dynamic libraries.
            proc = subprocess.Popen(["locate", libname], stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
            stdout, stderr = proc.communicate()
            if proc.returncode == 0:
                results = stdout.decode().strip().split("\n")
                results = [r for r in results if r]
                if results:
                    results.sort(key=len)
                    fullpath = results[0]
                    assert os.path.isfile(fullpath), "Invalid path: %r" % (fullpath,)
                    resolved.append(fullpath)
                    log.info("Library `%s` found at %s" % (libname, fullpath))
                    continue
                else:
                    log.fatal("Cannot locate dynamic library `%s`" % libname)
            else:
                log.fatal("`locate` command returned the following error:\n%s"
                          % stderr.decode())
        return resolved