Skip to content

Add 'squeeze' argument to Parser init, capture_body, to strip any enclosing length-one lists #99

Description

@bskinn

It's common with Parsers as-is to have to do a bunch of ...[0][0] indexing to drill down to the data you want. Adding an option that automatically does ...[0] indexing until a len(l) > 1 list (or a non-list singleton) is obtained would be an attractive way to ease the syntax. Must cope with a final length-zero list...perhaps reduce to None here.

Figure an argument squeeze to capture_body makes sense. Probably not useful on capture_struct. Might also make sense to have squeeze be an argument to Parser initialization, that sets a per-Parser default. capture_body default can be a sentinel, indicating 'defer to Parser setting'.

Figure default should be False, since the squeezing represents a loss of generality/consistency in the output in the event that more or less content is matched than expected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions