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

Consider an extensible Field type for sheet importers #8

Open
3noch opened this issue Feb 25, 2016 · 0 comments
Open

Consider an extensible Field type for sheet importers #8

3noch opened this issue Feb 25, 2016 · 0 comments

Comments

@3noch
Copy link
Contributor

3noch commented Feb 25, 2016

I've found myself needing to generate documentation for the sheet importer. Since there's a large overlap between the sheet definition and the documentation of each field, it's nice to put everything in one place:

fields = (
    FieldDoc('Column Header', 'column_key', parser, 'Column description', is_required=True),
)

But this seems like scope creep for Tribune itself. Perhaps we could address this by making the Field type extensible. This could be accomplished several ways.

  1. Use make it a super class

Instead of using a namedtuple, turn Field into a class that can be inherited. As long as children classes have the necessary fields of header, key, parser, they can add as much as they want, including documentation metadata.

  1. Allow Field to take an additional metadata field.

Keep Field as a namedtuple but add one more field to be used for anything the end-coder needs:

Field = namedtuple('Field', ['label', 'key', 'parser', 'metadata'])

Ideally we'd make this metadata field optional and default it to None or something. That can be achieved several ways that I won't mention here.

The nice thing about option #2 is that in maintains the immutable nature of tuples and it's still very simple.

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