Skip to content

Regex

RegexAssets

Bases: Backend

Takes a regex glob and yields a dictionary for each matching path.

Method name: regex

Example configuration

.. code-block:: yaml

  • method: regex inputs: input_term: '/path/glob/*.json'

noqa: W605

Source code in extraction_methods/plugins/assets/backends/regex.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class RegexAssets(Backend):
    """
    Takes a regex glob and yields a dictionary for each matching path.

    **Method name:** ``regex``

    Example configuration:
        .. code-block:: yaml

        - method: regex
          inputs:
            input_term: '/path/glob/*.json'

    # noqa: W605
    """

    input_class = RegexAssetsInput

    @update_input
    def run(self, body: dict[str, Any]) -> Iterator[dict[str, Any]]:

        for path in glob.iglob(self.input.input_term):
            yield {
                "href": path,
            }

RegexAssetsInput

Bases: Input

Model for Regex Assets Backend Input.

Parameters:

Name Type Description Default
input_term str

term for method to run on.

'$uri'
Source code in extraction_methods/plugins/assets/backends/regex.py
22
23
24
25
26
27
28
29
30
class RegexAssetsInput(Input):
    """
    Model for Regex Assets Backend Input.
    """

    input_term: str = Field(
        default="$uri",
        description="term for method to run on.",
    )