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

plugins: lines: add support for sets of regexes to legacy syntax #408

Closed

Conversation

rmilecki
Copy link
Collaborator

If someone insists on using the old syntax for the "lines" plugin this
change will allow using multiple sets of parsing rules.

Example:
lines:
    - start: Item\s+Discount\s+Price$
    end: \s+Total
    line: (?P<description>.+)\s+(?P<discount>\d+.\d+)\s+(?P<price>\d+\d+)
    - start: Item\s+Price$
    end: \s+Total
    line: (?P<description>.+)\s+(?P<price>\d+\d+)

Rafał Miłecki added 3 commits September 25, 2022 12:09
Sometimes companies use more than 1 format for line-parseable data. They
may e.g. randomly add some extra columns that are used occasionally.

This commit adds "rules" field support to the "lines" parser. It allows
defining multiple sets or regexes ("start", "end", "line" & friends) for
a single field.

Usage of "rules" is optional. Backward compatibility wiht existing
templates is preserved.

Signed-off-by: Rafał Miłecki <[email protected]>
This doesn't really change anything and isn't necessary. It however
allows testing "rules" implementation in the "lines" parser.

Signed-off-by: Rafał Miłecki <[email protected]>
If someone insists on using the old syntax for the "lines" plugin this
change will allow using multiple sets of parsing rules.

Example:
lines:
  - start: Item\s+Discount\s+Price$
    end: \s+Total
    line: (?P<description>.+)\s+(?P<discount>\d+.\d+)\s+(?P<price>\d+\d+)
  - start: Item\s+Price$
    end: \s+Total
    line: (?P<description>.+)\s+(?P<price>\d+\d+)
@rmilecki
Copy link
Collaborator Author

This change depends on the #407

Personally I'd rather against extending the old syntax. That one will always have some limitations and I think we should encourage people to move to the new (parser-based) YAML syntax.

It seems @bosd however prefers the old syntax (see #378 discusson) so I prepared this pull request to discuss / consider.

@rmilecki
Copy link
Collaborator Author

rmilecki commented Feb 3, 2023

This was a draft to show how next rules syntax can be adapted to the old lines syntax. For now #407 got closed, so I'm closing this one too. I'm planning to get back working on rules later.

@rmilecki rmilecki closed this Feb 3, 2023
@rmilecki rmilecki deleted the plugins-lines-multiple-sets branch May 11, 2023 07:50
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

Successfully merging this pull request may close these issues.

1 participant