My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 304 attachment: fields_attrbypath.patch (1.0 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Index: src/googlecl/base.py
===================================================================
--- src/googlecl/base.py (revision 437)
+++ src/googlecl/base.py (working copy)
@@ -610,6 +610,12 @@
NoneType to leave newlines in place.

"""
+ def getattr_by_path(object, attr_path):
+ attr = attr_path[0]
+ if len(attr_path) == 1:
+ return getattr(object, attr).text
+ return getattr_by_path(getattr(object, attr), attr_path[1:])
+
import sys

return_string = ''
@@ -630,8 +636,8 @@
LOG.debug(err.args[0] + ' (Did not add value for field ' + attr + ')')
except AttributeError, err:
try:
- # Last ditch effort to blindly grab the attribute
- val = getattr(wrapped_entry.entry, attr).text or missing_field_value
+ attr_path = attr.split('/')
+ val = getattr_by_path(wrapped_entry.entry, attr_path) or missing_field_value
except AttributeError:
val = missing_field_value
# Apparently, atom(?) doesn't always return a Unicode type when there are
Powered by Google Project Hosting