pypyr.steps.glob permalink

get all matching existing paths from glob permalink

Resolve a glob and get all the paths that exist on the filesystem for the input glob.

Any given path can point to a file or a directory.

The glob context key must exist in input context:

- name: pypyr.steps.glob
  in:
    glob: ./**/*.py # single glob

If you want to resolve multiple globs simultaneously and combine the results, you can pass a list instead. You can freely mix literal paths and globs.

- name: pypyr.steps.glob
  in:
    glob:
      - ./file1 # literal relative path
      - ./dirname # also finds dirs
      - ./**/{arbkey}* # glob with a string formatting expression

After glob completes, the globOut context key is available. This contains the results of the glob operation.

globOut: # list of strings. Paths of all files found.
    ['file1', 'dir1', 'blah/arb']

You can use globOut as the list to enumerate in a foreach decorator step, to run a step for each file found. In this example you run a pipeline on every file found by the glob.

- name: pypyr.steps.glob
  in:
   glob: ./get-files/**/*
- name: pypyr.steps.pype
  foreach: '{globOut}'
  in:
    pype:
      name: pipeline-does-something-with-single-file

All inputs support substitutions. This means you can specify another context item to be an individual path, or part of a path, or the entire path list.

See a worked example for glob.

see also

last updated on .