Skip to content

Types

Collector

Bases: ABC

Collector define an abstraction with methods needed to handle metadata collection process. Subclasses should implement the iter method to collect metadata from various data inputs. Use this class to create collector subtypes.

Usage:

class File(Collector):

    def __iter__(self):
        # read our file and yield the content
        with open('dummy.json') as file:
            for data in json.load(file):
                yield JSON(data)
Source code in nucleus/sdk/harvest/types.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Collector(ABC):
    """Collector define an abstraction with methods needed to handle metadata collection process.
    Subclasses should implement the __iter__ method to collect metadata from various data inputs.
    Use this class to create collector subtypes.

    Usage:

        class File(Collector):

            def __iter__(self):
                # read our file and yield the content
                with open('dummy.json') as file:
                    for data in json.load(file):
                        yield JSON(data)

    """

    @abstractmethod
    def __iter__(self) -> Iterator[JSON]:
        """Collect metadata from any kind of data input and return an iterator.

        :return: The iterable JSON with data to process.
        """
        ...

__iter__() abstractmethod

Collect metadata from any kind of data input and return an iterator.

Returns:

Type Description
Iterator[JSON]

The iterable JSON with data to process.

Source code in nucleus/sdk/harvest/types.py
26
27
28
29
30
31
32
@abstractmethod
def __iter__(self) -> Iterator[JSON]:
    """Collect metadata from any kind of data input and return an iterator.

    :return: The iterable JSON with data to process.
    """
    ...