Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser context #22

Open
yakovistomin opened this issue May 12, 2020 · 0 comments
Open

Parser context #22

yakovistomin opened this issue May 12, 2020 · 0 comments

Comments

@yakovistomin
Copy link
Collaborator

Добавить возможность передавать в парсер контекст.
Контекст должен быть доступен в любой момент при обработке данных, а также прокидываться колонки и обработчики

class MyProcessor(IntegerProcessor):
    def process_value(value, context):
        value = super().process_value(value, context)
        value += context.get(“i”, 10):
        return value

class MyParser(BaseXLSXParser):
    columns = [
        Column(“column1”, processor=MyProcessor())
    ]

    def clean_column_column1(self, value):
        value += self.context.get(“j”, 2)
        return value

context = {“i”: 10, “j”: 20}

parser = MyParser(filr_path, context=context)
        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant