Skip to content

File system

FileSystemConf

Bases: BaseModel

File system config.

Parameters:

Name Type Description Default
path str

Root path to begin walk.

required
kwargs dict

os walk kwargs.

{}
Source code in stac_generator/plugins/inputs/file_system.py
21
22
23
24
25
26
27
28
29
30
class FileSystemConf(BaseModel):
    """File system config."""

    path: str = Field(
        description="Root path to begin walk.",
    )
    kwargs: dict = Field(
        default={},
        description="os walk kwargs.",
    )

FileSystemInput

Bases: Input

Performs an os.walk to provide a stream of messages for procesing.

Plugin name: file_system

Example Configuration

.. code-block:: yaml

name: file_system conf: path: test_directory

Source code in stac_generator/plugins/inputs/file_system.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
58
59
60
61
class FileSystemInput(Input):
    """
    Performs an os.walk to provide a stream of messages for procesing.

    **Plugin name:** ``file_system``

    Example Configuration:
      .. code-block:: yaml

        name: file_system
        conf:
          path: test_directory
    """

    config_class = FileSystemConf

    def run(self):
        total_files = 0
        start = datetime.now()
        for root, _, files in tqdm(os.walk(self.conf.path, **self.conf.kwargs)):
            for file in files:
                filename = os.path.abspath(os.path.join(root, file))
                logger.debug("Input processing: %s", filename)

                yield {"uri": filename}
                total_files += 1

        end = datetime.now()
        print(f"Processed {total_files} files from {self.conf.path} in {end-start}")