function Package

function Package

txt2xls.function.create_file_function(body)[source]

Create function from specified python script file.

The python script file has to have __call__(data)__ function.

Parameters:body (string) – A filename of the python script
Returns:A function
Return type:function
txt2xls.function.create_lambda_function(body)[source]

Create lambda function with partial code.

The partial code (body) will be put inside of lambda expression as:

lambda *args, **kwargs: <BODY>
Parameters:body (string) – A body part of lambda expression
Returns:A lambda function
Return type:function
txt2xls.function.create_regex_function(body)[source]

Create function from regex pattern.

It is used for creating a function for classification.

Parameters:body (string) – A regex pattern
Returns:A function which will return string for classification
Return type:function
txt2xls.function.parse_function(function, default_type='lambda')[source]

Parse function expression which start from function type (e.g. ‘lambda:’)

The function expression has to be start from ‘lambda:’, ‘file:’, ‘regex:’, or ‘builtin:’ (shortcut alias of ‘file:’ type for builtin functions). If no function type is specified, the function will be treated as default_type.

Parameters:
  • function (string) – A function expression
  • default_type (string) – A default function expression type
Returns:

A function

Return type:

function

Raises:

AttributeError – Raise when unknown function type has been specified.