-
Notifications
You must be signed in to change notification settings - Fork 436
#4 re 8000 name common keywords and reorder properties on item classes #13
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,17 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.3" | ||
- "3.4" | ||
- "3.5" | ||
- "pypy" | ||
# command to install dependencies | ||
install: | ||
- "pip install -e ." | ||
# - "pip install pep8" | ||
# command to run tests | ||
script: | ||
# Tests | ||
- python setup.py test | ||
# pep8 - disabled for now until we can scrub the files to make sure we pass before turning it on | ||
# - pep8 . |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -6,38 +6,27 @@ | |
|
||
class DatasourceItem(object): | ||
def __init__(self, project_id, name=None): | ||
self._connections = None | ||
self._content_url = None | ||
self._created_at = None | ||
self._id = None | ||
self._project_id = None | ||
self._project_name = None | ||
self._tags = set() | ||
self._type = None | ||
self._updated_at = None | ||
self._connections = None | ||
self._project_id = None | ||
self.owner_id = None | ||
self.project_id = project_id | ||
self.name = name | ||
self.owner_id = None | ||
|
||
@property | ||
def project_id(self): | ||
return self._project_id | ||
|
||
@project_id.setter | ||
def project_id(self, value): | ||
if value is None: | ||
error = 'Project ID must be defined.' | ||
raise ValueError(error) | ||
else: | ||
self._project_id = value | ||
|
||
@property | ||
def id(self): | ||
return self._id | ||
# Invoke setter | ||
self.project_id = project_id | ||
|
||
@property | ||
def type(self): | ||
return self._type | ||
def connections(self): | ||
if self._connections is None: | ||
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. This all seems fine, but I'm not sure it's related to the title of the PR? |
||
error = 'Datasource item must be populated with connections first.' | ||
raise UnpopulatedPropertyError(error) | ||
return self._connections | ||
|
||
@property | ||
def content_url(self): | ||
|
@@ -48,8 +37,20 @@ def created_at(self): | |
return self._created_at | ||
|
||
@property | ||
def updated_at(self): | ||
return self._updated_at | ||
def id(self): | ||
return self._id | ||
|
||
@property | ||
def project_id(self): | ||
return self._project_id | ||
|
||
@project_id.setter | ||
def project_id(self, value): | ||
if value is None: | ||
error = 'Project ID must be defined.' | ||
raise ValueError(error) | ||
else: | ||
self._project_id = value | ||
|
||
@property | ||
def project_name(self): | ||
|
@@ -60,30 +61,16 @@ def tags(self): | |
return self._tags | ||
|
||
@property | ||
def connections(self): | ||
if self._connections is None: | ||
error = 'Datasource item must be populated with connections first.' | ||
raise UnpopulatedPropertyError(error) | ||
return self._connections | ||
def type(self): | ||
return self._type | ||
|
||
@property | ||
def updated_at(self): | ||
return self._updated_at | ||
|
||
def _set_connections(self, connections): | ||
self._connections = connections | ||
|
||
@classmethod | ||
def from_response(cls, resp): | ||
all_datasource_items = list() | ||
parsed_response = ET.fromstring(resp) | ||
all_datasource_xml = parsed_response.findall('.//t:datasource', namespaces=NAMESPACE) | ||
|
||
for datasource_xml in all_datasource_xml: | ||
(id, name, type, content_url, created_at, updated_at, | ||
tags, project_id, project_name, owner_id) = cls._parse_element(datasource_xml) | ||
datasource_item = cls(project_id) | ||
datasource_item._set_values(id, name, type, content_url, created_at, updated_at, | ||
tags, None, project_name, owner_id) | ||
all_datasource_items.append(datasource_item) | ||
return all_datasource_items | ||
|
||
def _parse_common_tags(self, datasource_xml): | ||
if not isinstance(datasource_xml, ET.Element): | ||
datasource_xml = ET.fromstring(datasource_xml).find('.//t:datasource', namespaces=NAMESPACE) | ||
|
@@ -115,6 +102,21 @@ def _set_values(self, id, name, type, content_url, created_at, | |
if owner_id: | ||
self.owner_id = owner_id | ||
|
||
@classmethod | ||
def from_response(cls, resp): | ||
all_datasource_items = list() | ||
parsed_response = ET.fromstring(resp) | ||
all_datasource_xml = parsed_response.findall('.//t:datasource', namespaces=NAMESPACE) | ||
|
||
for datasource_xml in all_datasource_xml: | ||
(id, name, type, content_url, created_at, updated_at, | ||
tags, project_id, project_name, owner_id) = cls._parse_element(datasource_xml) | ||
datasource_item = cls(project_id) | ||
datasource_item._set_values(id, name, type, content_url, created_at, updated_at, | ||
tags, None, project_name, owner_id) | ||
all_datasource_items.append(datasource_item) | ||
return all_datasource_items | ||
|
||
@staticmethod | ||
def _parse_element(datasource_xml): | ||
id = datasource_xml.get('id', None) | ||
|
@@ -141,4 +143,4 @@ def _parse_element(datasource_xml): | |
if owner_elem is not None: | ||
owner_id = owner_elem.get('id', None) | ||
|
||
return id, name, type, content_url, created_at, updated_at, tags, project_id, project_name, owner_id | ||
return id, name, type, content_url, created_at, updated_at, tags, project_id, project_name, owner_id |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
All of your PRs have this commit, which is causing merge conflicts, it'll need to be removed from these branches I think
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.
Hey @t8y8 this is a product of the rebasing usually if you don't force push to the branch, I'll take a look at Chris' changes on his machine when he gets in to make sure