Example #1
0
    def initialize(self, ctx):
        """
        Reads CSV data on initialization.
        """

        super(CsvMemoryTable, self).initialize(ctx)

        self._csv_reader = CsvReader()
        self._csv_reader.data = ctx.interpolate(None, self.data)
        ctx.comp.initialize(self._csv_reader)

        for m in self._csv_reader.process(ctx, None):
            self.insert(ctx, m)
Example #2
0
    def initialize(self, ctx):
        """
        Reads CSV data on initialization.
        """

        super().initialize(ctx)

        self._csv_reader = CsvReader()
        self._csv_reader.data = ctx.interpolate(self.data)
        self._csv_reader.strip = True
        ctx.comp.initialize(self._csv_reader)

        for m in self._csv_reader.process(ctx, None):
            self.insert(ctx, m)
Example #3
0
    def initialize(self, ctx):
        """
        Reads CSV data on initialization.
        """

        super(CsvMemoryTable, self).initialize(ctx)

        self._csv_reader = CsvReader()
        self._csv_reader.data = ctx.interpolate(None, self.data)
        ctx.comp.initialize(self._csv_reader)

        for m in self._csv_reader.process(ctx, None):
            self.insert(ctx, m)
Example #4
0
class CSVMemoryTable(MemoryTable):
    """
    This component represents an in-memory table which can be defined in CSV format,
    which is handy to define in-line tables in the configuration files or to quickly read
    a CSV file in memory for lookups.

    The CSV data is processed by a CSVReader.

    Usage:

    """
    def __init__(self, data):
        super().__init__()
        self.data = data
        self._csv_reader = None

    def initialize(self, ctx):
        """
        Reads CSV data on initialization.
        """

        super().initialize(ctx)

        self._csv_reader = CsvReader()
        self._csv_reader.data = ctx.interpolate(self.data)
        self._csv_reader.strip = True
        ctx.comp.initialize(self._csv_reader)

        for m in self._csv_reader.process(ctx, None):
            self.insert(ctx, m)

    def finalize(self, ctx):

        if self._csv_reader:
            ctx.comp.finalize(self._csv_reader)

        super(CSVMemoryTable, self).finalize(ctx)
Example #5
0
class CsvMemoryTable(MemoryTable):
    """
    This component represents an in-memory table which can be defined in CSV format,
    which is handy to define in-line tables in the configuration files or to quickly read
    a CSV file in memory for lookups.

    The CSV data is processed by a CSVReader.

    Usage:

    """

    data = None  # Interpolated at initialization, no message available

    _csv_reader = None


    def initialize(self, ctx):
        """
        Reads CSV data on initialization.
        """

        super(CsvMemoryTable, self).initialize(ctx)

        self._csv_reader = CsvReader()
        self._csv_reader.data = ctx.interpolate(None, self.data)
        ctx.comp.initialize(self._csv_reader)

        for m in self._csv_reader.process(ctx, None):
            self.insert(ctx, m)

    def finalize(self, ctx):

        if self._csv_reader:
            ctx.comp.finalize(self._csv_reader)

        super(CsvMemoryTable, self).finalize(ctx)