Skip to content

Address a refactoring concern from #54 #55

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 2 commits into from
Jul 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions tableaudocumentapi/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
###############################################################################
import collections
import itertools
import xml.etree.ElementTree as ET
import xml.sax.saxutils as sax
import zipfile
Expand Down Expand Up @@ -178,16 +179,17 @@ def fields(self):
return self._fields

def _get_all_fields(self):
column_objects = [_column_object_from_column_xml(self._datasourceTree, xml)
for xml in self._datasourceTree.findall('.//column')]
existing_fields = [x.id for x in column_objects]
metadata_fields = (x.text
for x in self._datasourceTree.findall(".//metadata-record[@class='column']/local-name"))

missing_fields = (x for x in metadata_fields if x not in existing_fields)
column_objects.extend((
_column_object_from_metadata_xml(_get_metadata_xml_for_field(self._datasourceTree, field_name))
for field_name in missing_fields
))

return FieldDictionary({k: v for k, v in column_objects})
column_field_objects = self._get_column_objects()
existing_column_fields = [x.id for x in column_field_objects]
metadata_only_field_objects = (x for x in self._get_metadata_objects() if x.id not in existing_column_fields)
field_objects = itertools.chain(column_field_objects, metadata_only_field_objects)

return FieldDictionary({k: v for k, v in field_objects})

def _get_metadata_objects(self):
return (_column_object_from_metadata_xml(x)
for x in self._datasourceTree.findall(".//metadata-record[@class='column']"))

def _get_column_objects(self):
return [_column_object_from_column_xml(self._datasourceTree, xml)
for xml in self._datasourceTree.findall('.//column')]
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy