This function expand patterns against the current namespace
    and return a list of filenames
342800
def expand_pattern(pattern: str) -> List[str]:
    ''''''
    ofiles = []
    sz = None
    res = glob_wildcards(pattern, [])
    sz = None
    wildcard = [{}]
    for key in res.keys():
        if key not in env.sos_dict:
            raise ValueError(f'Undefined variable {key} in pattern {pattern}')
        if not isinstance(env.sos_dict[key], str) and isinstance(
                env.sos_dict[key], collections.Sequence):
            if sz is None:
                sz = len(env.sos_dict[key])
                wildcard = [copy.deepcopy(wildcard[0]) for x in range(sz)]
            elif sz != len(env.sos_dict[key]):
                raise ValueError(
                    f'Variables in output pattern should have the same length (other={sz}, len({key})={len(env.sos_dict[key])})'
                )
            for idx, value in enumerate(env.sos_dict[key]):
                wildcard[idx][key] = value
        else:
            for v in wildcard:
                v[key] = env.sos_dict[key]
    #
    for card in wildcard:
        ofiles.append(
            apply_wildcards(
                pattern,
                card,
                fill_missing=False,
                fail_dynamic=False,
                dynamic_fill=None,
                keep_dynamic=False))
    return ofiles
1316041
def get_filenames(self):
        """"""
        # Warning: glob returns a empty list if the directory is unreadable, without raising an Exception
        return list(glob.glob(os.path.join(self.worldfolder,'region','r.*.*.'+self.extension)))
237560
def _TemplateNamesToFiles(self, template_str):
        """"""
        template_list = template_str.split(":")
        template_files = []
        try:
            for tmplt in template_list:
                template_files.append(open(os.path.join(self.template_dir, tmplt), "r"))
        except:  # noqa
            for tmplt in template_files:
                tmplt.close()
            raise

        return template_files
1332620
def _get_available_extensions():
    
    extensions = []

    # from filenames
    parsers_dir = os.path.join(os.path.dirname(__file__))
    glob_filename = os.path.join(parsers_dir, "*" + _FILENAME_SUFFIX + ".py")
    ext_re = re.compile(glob_filename.replace('*', "(?P<ext>\w+)"))
    for filename in glob.glob(glob_filename):
        ext_match = ext_re.match(filename)
        ext = ext_match.groups()[0]
        extensions.append(ext)
        extensions.append('.' + ext)

    # from relevant synonyms (don't use the '' synonym)
    for ext in EXTENSION_SYNONYMS.keys():
        if ext:
            extensions.append(ext)
            extensions.append(ext.replace('.', '', 1))
    extensions.sort()
    return extensions
1033567
def _expand_list(names):
  

  if names is None:
    names = []
  elif isinstance(names, basestring):
    names = [names]

  results = []  # The expanded list.
  items = {}  # Cached contents of buckets; used for matching.
  for name in names:
    bucket, key = datalab.storage._bucket.parse_name(name)
    results_len = len(results)  # If we fail to add any we add name and let caller deal with it.
    if bucket:
      if not key:
        # Just a bucket; add it.
        results.append('gs://%s' % bucket)
      elif datalab.storage.Item(bucket, key).exists():
        results.append('gs://%s/%s' % (bucket, key))
      else:
        # Expand possible key values.
        if bucket not in items and key[:1] == '*':
          # We need the full list; cache a copy for efficiency.
          items[bucket] = [item.metadata.name
                           for item in list(datalab.storage.Bucket(bucket).items())]
        # If we have a cached copy use it
        if bucket in items:
          candidates = items[bucket]
        # else we have no cached copy but can use prefix matching which is more efficient than
        # getting the full contents.
        else:
          # Get the non-wildchar prefix.
          match = re.search('\?|\*|\[', key)
          prefix = key
          if match:
            prefix = key[0:match.start()]

          candidates = [item.metadata.name
                        for item in datalab.storage.Bucket(bucket).items(prefix=prefix)]

        for item in candidates:
          if fnmatch.fnmatch(item, key):
            results.append('gs://%s/%s' % (bucket, item))

    # If we added no matches, add the original name and let caller deal with it.
    if len(results) == results_len:
      results.append(name)

  return results
169224
def _expand_prefixed_files(args):
        
        for arg, _ in enumerate(args):
            if args[arg].startswith('@'):
                try:
                    logger.debug('Attempting to read file %s', args[arg][1:])
                    with open(args[arg][1:], 'r') as f:
                        content = f.read()
                    args[arg] = content
                except IOError:
                    # Leave arg unmodified
                    logger.debug('File Error: Failed to open %s, assume not a file', args[arg][1:])
        return args
519372
def add_view_file_mapping(self, pattern, cls):
        
        if isinstance(pattern, str):
            if not pattern.endswith("*"):
                _, ext = os.path.splitext(pattern)
                self.allowed_extensions.add(ext)
            pattern = re.compile("^" + re.escape(pattern).replace("\\*", ".+") + "$", re.I)
        self.view_class_files_map.append((pattern, cls))
111629
def expand_folder(files):
    """"""
    expfiles = []
    for file in files:
        if os.path.isdir(file):
            for dirpath, dirnames, filenames in os.walk(file):
                for filename in filenames:
                    expfiles.append(os.path.join(dirpath, filename))
        else:
            expfiles.append(file)

    for path in expfiles:
        if not os.path.exists(path):
            sys.stderr.write('%s: No such file or directory\n' % path)

    return expfiles
898639
def _glob(pattern, skip_dirs=False):
    """"""
    # Implicit recursive iff no / in pattern and starts with *
    if "/" not in pattern and pattern.startswith("*"):
        files = glob.glob(f"**/{pattern}", recursive=True)
    else:
        files = glob.glob(pattern, recursive=True)

    # Expand dirs
    all_files = set()
    for file in files:
        if os.path.isdir(file) and not skip_dirs:
            all_files.update(set(f for f in _glob(f"{file}/**/*", skip_dirs=True) if not os.path.isdir(f)))
        else:
            all_files.add(file)

    # Normalize all files
    return {str(Path(f)) for f in all_files}
408150
def glob(self, filename):
        """"""
        if isinstance(filename, six.string_types):
            return [
                # Convert the filenames to string from bytes.
                compat.as_str_any(matching_filename)
                for matching_filename in py_glob.glob(
                    compat.as_bytes(filename))
            ]
        else:
            return [
                # Convert the filenames to string from bytes.
                compat.as_str_any(matching_filename)
                for single_filename in filename
                for matching_filename in py_glob.glob(
                    compat.as_bytes(single_filename))
            ]
225400
def expand_includes(text, path='.'):
    """"""
    def read_and_expand(match):
        filename = match.group('filename')
        filename = join(path, filename)
        text = read(filename)
        return expand_includes(
            text, path=join(path, dirname(filename)))

    return re.sub(r'^\.\. include:: (?P<filename>.*)$',
                  read_and_expand,
                  text,
                  flags=re.MULTILINE)
1100518
function expandFiles(files, basePath) {
    var expandedFiles = [];
    files = files ? _.isArray(files) ? files : [files] : [];

    _.forEach(files, function(fileName) {
        expandedFiles = _.union(
            expandedFiles,
            glob.sync(path.join(basePath, fileName), { dot: true, nodir: true })
        );
    });

    return expandedFiles;
}
751121
def _env_filenames(filenames, env):
    
    env_filenames = []
    for filename in filenames:
        filename_parts = filename.split('.')
        filename_parts.insert(1, env)
        env_filenames.extend([filename, '.'.join(filename_parts)])

    return env_filenames
1177839
function globify (args) {
  let parsed = new ParsedArgs(args);
  let expandGlob = parsed.args[parsed.globIndex];
  let renameOutfile = parsed.args[parsed.outfileIndex];
  let files = expandGlob && expandGlob(parsed.globOptions);

  if (!expandGlob) {
    // No glob patterns were found, so just run browserify as-is
    if (renameOutfile) {
      parsed.args[parsed.outfileIndex] = renameOutfile();
    }
    browserify(parsed.cmd, parsed.args);
  }
  else if (!renameOutfile) {
    // Run browserify with the expanded list of file names
    Array.prototype.splice.apply(parsed.args, [parsed.globIndex, 1].concat(files));
    browserify(parsed.cmd, parsed.args);
  }
  else {
    // Run browserify separately for each file
    files.forEach((file) => {
      let fileArgs = parsed.args.slice();
      fileArgs[parsed.globIndex] = file;
      fileArgs[parsed.outfileIndex] = renameOutfile(file, parsed.baseDir);
      browserify(parsed.cmd, fileArgs);
    });
  }
}
916170
function getFileNames(fileNames = [], componentName) {
  const defaultFileNames = {
    testFileName: `${defaultOptions.testFileName}.${componentName}`,
    componentFileName: componentName,
    styleFileName: componentName,
  }

  const formattedFileNames = Object.keys(fileNames).reduce(
    (acc, curr) => {
      acc[curr] = replaceKeys(fileNames[curr], componentName)
      return acc
    },
    { ...defaultFileNames }
  )

  return formattedFileNames
}
373824
def expandvars(path):
    

    path = path2fsn(path)

    def repl_func(match):
        return environ.get(match.group(1), match.group(0))

    path = re.compile(r"\$(\w+)", flags=re.UNICODE).sub(repl_func, path)
    if os.name == "nt":
        path = re.sub(r"%([^%]+)%", repl_func, path)
    return re.sub(r"\$\{([^\}]+)\}", repl_func, path)
454620
def expand_mapping_target(namespaces, val):
    """"""

    vals = [v.strip() for v in val.split(',')]
    ret = []
    for v in vals:
        inverse = False
        if v.startswith('^'):
            inverse = True
            v = v[1:]
        ret.append((expand_curielike(namespaces, v), inverse))
    return ret