-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore/abstract choices method (#355)
* abstracting choices() method into base class * refactored 'email' typo * created Choices class for choices() method inheritance * abstract choices method from all classes, not just file events * moved Choices class to sdk.queries.__init__.py * moved Choices into choices.py * modified Choices docstr to read 'values' not 'names' * rename get_attribute_keys to get_attribute_values
- Loading branch information
1 parent
3e28450
commit 96a186a
Showing
14 changed files
with
56 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from py42.util import get_attribute_values_from_class | ||
|
||
|
||
class Choices: | ||
"""Helper class to provide the choices() method to a class.""" | ||
|
||
@classmethod | ||
def choices(cls): | ||
"""Returns attribute values for the given class. | ||
Returns: | ||
(list): A list containing the attribute values of the given class. | ||
""" | ||
return get_attribute_values_from_class(cls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
from py42.util import get_attribute_keys_from_class | ||
from py42.choices import Choices | ||
|
||
|
||
class SortDirection: | ||
class SortDirection(Choices): | ||
"""Code42 request `sort_direction` constants for sorting returned lists in responses.""" | ||
|
||
DESC = "DESC" | ||
ASC = "ASC" | ||
|
||
@staticmethod | ||
def choices(): | ||
return get_attribute_keys_from_class(SortDirection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.