Module acquisition.decorators

Functions

def remove_first_line(func)
def try_unbzip2(func)

Decorate the process() or batch_process() method to unbzip2 (on the fly).

Example

.. code-block:: python

from acquisition import AcquisitionStep
from acquisition.decorators import try_unbzip2

# [...]

class MyStep(AcquisitionStep):

    # [...]

    @try_unbzip2
    def process(self, xaf):
        self.info("xaf is maybe unbzipped")
        # [...]
        return True

If we fail to unbzip the incoming file, nothing is logged and the decorated function is called as usual.

See also unbzip decorator.

def try_ungzip(func)

Decorate the process() or batch_process() method to ungzip (on the fly).

Example

.. code-block:: python

from acquisition import AcquisitionStep
from acquisition.decorators import try_ungzip

# [...]

class MyStep(AcquisitionStep):

    # [...]

    @try_ungzip
    def process(self, xaf):
        self.info("xaf is maybe ungzipped")
        # [...]
        return True

If we fail to ungzip the incoming file, nothing is logged and the decorated function is called as usual.

See also ungzip decorator.

def unbzip2(func)

Decorate the process() or batch_process() method to unbzip2 (on the fly).

Example

.. code-block:: python

from acquisition import AcquisitionStep
from acquisition.decorators import unbzip2

# [...]

class MyStep(AcquisitionStep):

    # [...]

    @unbzip2
    def process(self, xaf):
        self.info("xaf is unbzipped")
        # [...]
        return True

If we fail to unbzip2 the incoming file, a warning is logged and the decorated function is not called at all.

See also try_unbzip2 decorator.

def ungzip(func)

Decorate the process() or batch_process() method to ungzip (on the fly).

Example

.. code-block:: python

from acquisition import AcquisitionStep
from acquisition.decorators import ungzip

# [...]

class MyStep(AcquisitionStep):

    # [...]

    @ungzip
    def process(self, xaf):
        self.info("xaf is ungzipped")
        # [...]
        return True

If we fail to ungzip the incoming file, a warning is logged and the decorated function is not called at all.

See also try_ungzip decorator.

Classes

class Py2Py3Bzip2Wrapper
Expand source code
class Py2Py3Bzip2Wrapper(object):

    @staticmethod
    def open(*args, **kwargs):
        # Because bz2.open does not exist in Python2
        return bz2.BZ2File(*args, **kwargs)

Static methods

def open(*args, **kwargs)