Skip to main content
`Ctrl`+`K`

# get_pkg_data_filenames

astropy.utils.data.get_pkg_data_filenames(datadir, package=None, pattern='*')

  Returns the path of all of the data files in a given directory that match a given glob pattern.

  Parameters:
    datadir `python:str`

      Name/location of the desired data files. One of the following:

      > - The name of a directory included in the source distribution. The path is relative to the module calling this function. For example, if calling from `astropy.pkname`, use `'data'` to get the files in `astropy/pkgname/data`.

      > - Remote URLs are not currently supported.

    package `python:str`, optional

      If specified, look for a file relative to the given package, rather than the default of looking relative to the calling module’s package.

    pattern `python:str`, optional

      A UNIX-style filename glob pattern to match files. See the `glob` module in the standard library for more information. By default, matches all files.

  Returns:
    filenames python:iterator of `python:str`

      Paths on the local filesystem in datadir matching pattern.

  Examples

  This will retrieve the contents of the data file for the `astropy.wcs` tests:

      >>> from astropy.utils.data import get_pkg_data_filenames
      >>> for fn in get_pkg_data_filenames('data/maps', 'astropy.wcs.tests',
      ...                                  '*.hdr'):
      ...     with open(fn) as f:
      ...         fcontents = f.read()
      ...