Skip to content

Commit 925c8fb

Browse files
authored
Merge pull request google#1 from omni-digital/task/2to3
Naively running 2to3 over the codebase
2 parents 3541dfa + bfed3a0 commit 925c8fb

59 files changed

Lines changed: 1569 additions & 1560 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎setup.py‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525

2626
setup(
2727
name='gdata',
28-
version='2.0.18',
28+
version='2.0.19',
2929
description='Python client library for Google data APIs',
3030
long_description = """\
3131
The Google data Python client library makes it easy to interact with
32-
Google services through the Google Data APIs. This library provides data
32+
Google services through the Google Data APIs. This library provides data
3333
models and service modules for the the following Google data services:
3434
- Google Calendar data API
3535
- Google Contacts data API
@@ -52,9 +52,9 @@
5252
- Google Content API For Shopping
5353
- Google App Marketplace API
5454
- Google Content API for Shopping
55-
- core Google data API functionality
56-
The core Google data code provides sufficient functionality to use this
57-
library with any Google data API (even if a module hasn't been written for
55+
- core Google data API functionality
56+
The core Google data code provides sufficient functionality to use this
57+
library with any Google data API (even if a module hasn't been written for
5858
it yet). For example, this client can be used with the Notebook API. This
5959
library may also be used with any Atom Publishing Protocol service (AtomPub).
6060
""",
@@ -63,39 +63,39 @@
6363
license='Apache 2.0',
6464
url='http://code.google.com/p/gdata-python-client/',
6565
packages=[
66-
'atom',
67-
'gdata',
68-
'gdata.acl',
69-
'gdata.alt',
70-
'gdata.analytics',
71-
'gdata.apps',
72-
'gdata.apps.adminsettings',
73-
'gdata.apps.audit',
74-
'gdata.apps.emailsettings',
66+
'atom',
67+
'gdata',
68+
'gdata.acl',
69+
'gdata.alt',
70+
'gdata.analytics',
71+
'gdata.apps',
72+
'gdata.apps.adminsettings',
73+
'gdata.apps.audit',
74+
'gdata.apps.emailsettings',
7575
'gdata.apps.groups',
7676
'gdata.apps.migration',
7777
'gdata.apps.multidomain',
78-
'gdata.apps.organization',
79-
'gdata.blogger',
80-
'gdata.calendar',
78+
'gdata.apps.organization',
79+
'gdata.blogger',
80+
'gdata.calendar',
8181
'gdata.calendar_resource',
82-
'gdata.codesearch',
83-
'gdata.contacts',
84-
'gdata.contentforshopping',
85-
'gdata.docs',
86-
'gdata.dublincore',
87-
'gdata.exif',
88-
'gdata.geo',
89-
'gdata.media',
90-
'gdata.oauth',
82+
'gdata.codesearch',
83+
'gdata.contacts',
84+
'gdata.contentforshopping',
85+
'gdata.docs',
86+
'gdata.dublincore',
87+
'gdata.exif',
88+
'gdata.geo',
89+
'gdata.media',
90+
'gdata.oauth',
9191
'gdata.opensearch',
92-
'gdata.photos',
92+
'gdata.photos',
9393
'gdata.projecthosting',
94-
'gdata.sites',
95-
'gdata.spreadsheet',
96-
'gdata.spreadsheets',
97-
'gdata.webmastertools',
98-
'gdata.youtube',
94+
'gdata.sites',
95+
'gdata.spreadsheet',
96+
'gdata.spreadsheets',
97+
'gdata.webmastertools',
98+
'gdata.youtube',
9999
],
100100
package_dir = {'gdata':'src/gdata', 'atom':'src/atom'},
101101
install_requires=required

‎src/atom/__init__.py‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def optional_warn_function(*args, **kwargs):
9393
# Preserve the original name to avoid masking all decorated functions as
9494
# 'deprecated_function'
9595
try:
96-
optional_warn_function.func_name = f.func_name
96+
optional_warn_function.__name__ = f.__name__
9797
except TypeError:
9898
pass # In Python2.3 we can't set the func_name
9999
return optional_warn_function
@@ -121,7 +121,7 @@ def CreateClassFromXMLString(target_class, xml_string, string_encoding=None):
121121
match those of the target class.
122122
"""
123123
encoding = string_encoding or XML_STRING_ENCODING
124-
if encoding and isinstance(xml_string, unicode):
124+
if encoding and isinstance(xml_string, str):
125125
xml_string = xml_string.encode(encoding)
126126
tree = ElementTree.fromstring(xml_string)
127127
return _CreateClassFromElementTree(target_class, tree)
@@ -183,11 +183,11 @@ def _HarvestElementTree(self, tree):
183183
# Fill in the instance members from the contents of the XML tree.
184184
for child in tree:
185185
self._ConvertElementTreeToMember(child)
186-
for attribute, value in tree.attrib.iteritems():
186+
for attribute, value in tree.attrib.items():
187187
self._ConvertElementAttributeToMember(attribute, value)
188188
# Encode the text string according to the desired encoding type. (UTF-8)
189189
if tree.text:
190-
if MEMBER_STRING_ENCODING is unicode:
190+
if MEMBER_STRING_ENCODING is str:
191191
self.text = tree.text
192192
else:
193193
self.text = tree.text.encode(MEMBER_STRING_ENCODING)
@@ -199,7 +199,7 @@ def _ConvertElementTreeToMember(self, child_tree, current_class=None):
199199
def _ConvertElementAttributeToMember(self, attribute, value):
200200
# Encode the attribute value's string with the desired type Default UTF-8
201201
if value:
202-
if MEMBER_STRING_ENCODING is unicode:
202+
if MEMBER_STRING_ENCODING is str:
203203
self.extension_attributes[attribute] = value
204204
else:
205205
self.extension_attributes[attribute] = value.encode(
@@ -209,15 +209,15 @@ def _ConvertElementAttributeToMember(self, attribute, value):
209209
def _AddMembersToElementTree(self, tree):
210210
for child in self.extension_elements:
211211
child._BecomeChildElement(tree)
212-
for attribute, value in self.extension_attributes.iteritems():
212+
for attribute, value in self.extension_attributes.items():
213213
if value:
214-
if isinstance(value, unicode) or MEMBER_STRING_ENCODING is unicode:
214+
if isinstance(value, str) or MEMBER_STRING_ENCODING is str:
215215
tree.attrib[attribute] = value
216216
else:
217217
# Decode the value from the desired encoding (default UTF-8).
218218
tree.attrib[attribute] = value.decode(MEMBER_STRING_ENCODING)
219219
if self.text:
220-
if isinstance(self.text, unicode) or MEMBER_STRING_ENCODING is unicode:
220+
if isinstance(self.text, str) or MEMBER_STRING_ENCODING is str:
221221
tree.text = self.text
222222
else:
223223
tree.text = self.text.decode(MEMBER_STRING_ENCODING)
@@ -278,7 +278,7 @@ def __init__(self, extension_elements=None, extension_attributes=None,
278278

279279
def _ConvertElementTreeToMember(self, child_tree):
280280
# Find the element's tag in this class's list of child members
281-
if self.__class__._children.has_key(child_tree.tag):
281+
if child_tree.tag in self.__class__._children:
282282
member_name = self.__class__._children[child_tree.tag][0]
283283
member_class = self.__class__._children[child_tree.tag][1]
284284
# If the class member is supposed to contain a list, make sure the
@@ -297,13 +297,13 @@ def _ConvertElementTreeToMember(self, child_tree):
297297

298298
def _ConvertElementAttributeToMember(self, attribute, value):
299299
# Find the attribute in this class's list of attributes.
300-
if self.__class__._attributes.has_key(attribute):
300+
if attribute in self.__class__._attributes:
301301
# Find the member of this class which corresponds to the XML attribute
302302
# (lookup in current_class._attributes) and set this member to the
303303
# desired value (using self.__dict__).
304304
if value:
305305
# Encode the string to capture non-ascii characters (default UTF-8)
306-
if MEMBER_STRING_ENCODING is unicode:
306+
if MEMBER_STRING_ENCODING is str:
307307
setattr(self, self.__class__._attributes[attribute], value)
308308
else:
309309
setattr(self, self.__class__._attributes[attribute],
@@ -318,7 +318,7 @@ def _AddMembersToElementTree(self, tree):
318318
# This uses the class's _children dictionary to find the members which
319319
# should become XML child nodes.
320320
member_node_names = [values[0] for tag, values in
321-
self.__class__._children.iteritems()]
321+
self.__class__._children.items()]
322322
for member_name in member_node_names:
323323
member = getattr(self, member_name)
324324
if member is None:
@@ -329,10 +329,10 @@ def _AddMembersToElementTree(self, tree):
329329
else:
330330
member._BecomeChildElement(tree)
331331
# Convert the members of this class which are XML attributes.
332-
for xml_attribute, member_name in self.__class__._attributes.iteritems():
332+
for xml_attribute, member_name in self.__class__._attributes.items():
333333
member = getattr(self, member_name)
334334
if member is not None:
335-
if isinstance(member, unicode) or MEMBER_STRING_ENCODING is unicode:
335+
if isinstance(member, str) or MEMBER_STRING_ENCODING is str:
336336
tree.attrib[xml_attribute] = member
337337
else:
338338
tree.attrib[xml_attribute] = member.decode(MEMBER_STRING_ENCODING)
@@ -1374,7 +1374,7 @@ def _TransferToElementTree(self, element_tree):
13741374
else:
13751375
element_tree.tag = self.tag
13761376

1377-
for key, value in self.attributes.iteritems():
1377+
for key, value in self.attributes.items():
13781378
element_tree.attrib[key] = value
13791379

13801380
for child in self.children:
@@ -1451,7 +1451,7 @@ def _ExtensionElementFromElementTree(element_tree):
14511451
namespace = None
14521452
tag = element_tag
14531453
extension = ExtensionElement(namespace=namespace, tag=tag)
1454-
for key, value in element_tree.attrib.iteritems():
1454+
for key, value in element_tree.attrib.items():
14551455
extension.attributes[key] = value
14561456
for child in element_tree:
14571457
extension.children.append(_ExtensionElementFromElementTree(child))
@@ -1475,7 +1475,7 @@ def deprecated_function(*args, **kwargs):
14751475
# Preserve the original name to avoid masking all decorated functions as
14761476
# 'deprecated_function'
14771477
try:
1478-
deprecated_function.func_name = f.func_name
1478+
deprecated_function.__name__ = f.__name__
14791479
except TypeError:
14801480
# Setting the func_name is not allowed in Python2.3.
14811481
pass

‎src/atom/client.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def request(self, method=None, uri=None, auth_token=None,
8585
# Modify the request based on the AtomPubClient settings and parameters
8686
# passed in to the request.
8787
http_request = self.modify_request(http_request)
88-
if isinstance(uri, (str, unicode)):
88+
if isinstance(uri, str):
8989
uri = atom.http_core.Uri.parse_uri(uri)
9090
if uri is not None:
9191
uri.modify_request(http_request)
92-
if isinstance(method, (str, unicode)):
92+
if isinstance(method, str):
9393
http_request.method = method
9494
# Any unrecognized arguments are assumed to be capable of modifying the
9595
# HTTP request.
96-
for name, value in kwargs.iteritems():
96+
for name, value in kwargs.items():
9797
if value is not None:
9898
if hasattr(value, 'modify_request'):
9999
value.modify_request(http_request)
@@ -218,7 +218,7 @@ def modify_request(self, http_request):
218218
An atom.http_core.HttpRequest() with the added custom headers.
219219
"""
220220

221-
for name, value in self.headers.iteritems():
221+
for name, value in self.headers.items():
222222
if value is not None:
223223
http_request.headers[name] = value
224224
return http_request

‎src/atom/core.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _list_xml_members(cls):
9393
if not pair[0].startswith('_') and pair[0] != 'text':
9494
member_type = pair[1]
9595
if (isinstance(member_type, tuple) or isinstance(member_type, list)
96-
or isinstance(member_type, (str, unicode))
96+
or isinstance(member_type, str)
9797
or (inspect.isclass(member_type)
9898
and issubclass(member_type, XmlElement))):
9999
members.append(pair)
@@ -173,7 +173,7 @@ def _get_rules(cls, version):
173173
attributes[target[version-1]] = member_name
174174
else:
175175
attributes[target[-1]] = member_name
176-
elif isinstance(target, (str, unicode)):
176+
elif isinstance(target, str):
177177
# This member points to an XML attribute.
178178
attributes[target] = member_name
179179
elif issubclass(target, XmlElement):
@@ -207,7 +207,7 @@ def get_elements(self, tag=None, namespace=None, version=1):
207207
matches = []
208208
ignored1, elements, ignored2 = self.__class__._get_rules(version)
209209
if elements:
210-
for qname, element_def in elements.iteritems():
210+
for qname, element_def in elements.items():
211211
member = getattr(self, element_def[0])
212212
if member:
213213
if _qname_matches(tag, namespace, qname):
@@ -253,7 +253,7 @@ def get_attributes(self, tag=None, namespace=None, version=1):
253253
matches = []
254254
ignored1, ignored2, attributes = self.__class__._get_rules(version)
255255
if attributes:
256-
for qname, attribute_def in attributes.iteritems():
256+
for qname, attribute_def in attributes.items():
257257
if isinstance(attribute_def, (list, tuple)):
258258
attribute_def = attribute_def[0]
259259
member = getattr(self, attribute_def)
@@ -262,7 +262,7 @@ def get_attributes(self, tag=None, namespace=None, version=1):
262262
if member:
263263
if _qname_matches(tag, namespace, qname):
264264
matches.append(XmlAttribute(qname, member))
265-
for qname, value in self._other_attributes.iteritems():
265+
for qname, value in self._other_attributes.items():
266266
if _qname_matches(tag, namespace, qname):
267267
matches.append(XmlAttribute(qname, value))
268268
return matches
@@ -288,7 +288,7 @@ def _harvest_tree(self, tree, version=1):
288288
else:
289289
self._other_elements.append(_xml_element_from_tree(element, XmlElement,
290290
version))
291-
for attrib, value in tree.attrib.iteritems():
291+
for attrib, value in tree.attrib.items():
292292
if attributes and attrib in attributes:
293293
setattr(self, attributes[attrib], value)
294294
else:
@@ -318,7 +318,7 @@ def _attach_members(self, tree, version=1, encoding=None):
318318
encoding = encoding or STRING_ENCODING
319319
# Add the expected elements and attributes to the tree.
320320
if elements:
321-
for tag, element_def in elements.iteritems():
321+
for tag, element_def in elements.items():
322322
member = getattr(self, element_def[0])
323323
# If this is a repeating element and there are members in the list.
324324
if member and element_def[2]:
@@ -327,21 +327,21 @@ def _attach_members(self, tree, version=1, encoding=None):
327327
elif member:
328328
member._become_child(tree, version)
329329
if attributes:
330-
for attribute_tag, member_name in attributes.iteritems():
330+
for attribute_tag, member_name in attributes.items():
331331
value = getattr(self, member_name)
332332
if value:
333333
tree.attrib[attribute_tag] = value
334334
# Add the unexpected (other) elements and attributes to the tree.
335335
for element in self._other_elements:
336336
element._become_child(tree, version)
337-
for key, value in self._other_attributes.iteritems():
337+
for key, value in self._other_attributes.items():
338338
# I'm not sure if unicode can be used in the attribute name, so for now
339339
# we assume the encoding is correct for the attribute name.
340-
if not isinstance(value, unicode):
340+
if not isinstance(value, str):
341341
value = value.decode(encoding)
342342
tree.attrib[key] = value
343343
if self.text:
344-
if isinstance(self.text, unicode):
344+
if isinstance(self.text, str):
345345
tree.text = self.text
346346
else:
347347
tree.text = self.text.decode(encoding)
@@ -512,7 +512,7 @@ def parse(xml_string, target_class=None, version=1, encoding=None):
512512
"""
513513
if target_class is None:
514514
target_class = XmlElement
515-
if isinstance(xml_string, unicode):
515+
if isinstance(xml_string, str):
516516
if encoding is None:
517517
xml_string = xml_string.encode(STRING_ENCODING)
518518
else:

0 commit comments

Comments
 (0)