-
Notifications
You must be signed in to change notification settings - Fork 181
Fixes #50 - materialize the properties for completion #52
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
Changes from all commits
5d9d5e3
e221c8a
dc013bc
7118327
5d758a9
8b22012
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,12 +41,6 @@ def apply_metadata(self, metadata_record): | |
| def from_xml(cls, xmldata): | ||
| return cls(xmldata) | ||
|
|
||
| def __getattr__(self, item): | ||
| private_name = '_{}'.format(item) | ||
| if item in _ATTRIBUTES or item in _METADATA_ATTRIBUTES: | ||
| return getattr(self, private_name) | ||
| raise AttributeError(item) | ||
|
|
||
| def _apply_attribute(self, xmldata, attrib, default_func): | ||
| if hasattr(self, '_read_{}'.format(attrib)): | ||
| value = getattr(self, '_read_{}'.format(attrib))(xmldata) | ||
|
|
@@ -71,6 +65,62 @@ def name(self): | |
|
|
||
| return self.id | ||
|
|
||
| @property | ||
| def id(self): | ||
| """ Name of the field as specified in the file, usually surrounded by [ ] """ | ||
| return self._id | ||
|
|
||
| @property | ||
| def caption(self): | ||
| """ Name of the field as displayed in Tableau unless an aliases is defined """ | ||
| return self._caption | ||
|
|
||
| @property | ||
| def alias(self): | ||
| """ Name of the field as displayed in Tableau if the default name isn't wanted """ | ||
| return self._alias | ||
|
|
||
| @property | ||
| def datatype(self): | ||
| """ Type of the field within Tableau (string, integer, etc) """ | ||
| return self._datatype | ||
|
|
||
| @property | ||
| def role(self): | ||
| """ Dimension or Measure """ | ||
| return self._role | ||
|
|
||
| @property | ||
| def is_quantitative(self): | ||
| """ A dependent value, usually a measure of something | ||
|
|
||
| e.g. Profit, Gross Sales """ | ||
| return self._type == 'quantitative' | ||
|
|
||
| @property | ||
| def is_ordinal(self): | ||
| """ Is this field a categorical field that has a specific order | ||
|
|
||
| e.g. How do you feel? 1 - awful, 2 - ok, 3 - fantastic """ | ||
| return self._type == 'ordinal' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I know which types are 'ordinal' vs 'nominal' -- can you add a docstring to these three?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, I'll have to determine how to word it to make it obvious. The best example I can think of is a date series, they define an order, but I'll dig through docs to see how it's explained |
||
|
|
||
| @property | ||
| def is_nominal(self): | ||
| """ Is this field a categorical field that does not have a specific order | ||
|
|
||
| e.g. What color is your hair? """ | ||
| return self._type == 'nominal' | ||
|
|
||
| @property | ||
| def calculation(self): | ||
| """ If this field is a calculated field, this will be the formula """ | ||
| return self._calculation | ||
|
|
||
| @property | ||
| def default_aggregation(self): | ||
| """ The default type of aggregation on the field (e.g Sum, Avg)""" | ||
| return self._aggregation | ||
|
|
||
| ###################################### | ||
| # Special Case handling methods for reading the values from the XML | ||
| ###################################### | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach, it will allow for some really clean filtering
[f for f in fields if f.is_quantitative]