Skip to content

Commit 56241e8

Browse files
author
vbarathan
committed
Fixed bugs 202,209,214,216
1 parent 59d02d8 commit 56241e8

6 files changed

Lines changed: 179 additions & 6 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright (C) 2007 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
import gdata.base.service
19+
import gdata.service
20+
try:
21+
from xml.etree import ElementTree
22+
except ImportError:
23+
from elementtree import ElementTree
24+
import atom
25+
import gdata.base
26+
27+
# Demonstrates queries to the attributes feed
28+
29+
gb_client = gdata.base.service.GBaseService()
30+
q = gdata.base.service.BaseQuery()
31+
q.feed = '/base/feeds/attributes'
32+
q.bq = raw_input('Please item type to query for (ex: housing): ')
33+
34+
print q.ToUri()
35+
feed = gb_client.QueryAttributesFeed(q.ToUri())
36+
37+
print feed.title.text
38+
39+
for entry in feed.entry:
40+
for attr in entry.attribute:
41+
display_str = 'attribute name:%s, type:%s' % (attr.name, attr.type)
42+
values = ''
43+
for value in attr.value:
44+
values += '(' + value.text + ',' + value.count + ')'
45+
if values != '':
46+
display_str += ', values: %s' % values
47+
print ' ' + display_str
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright (C) 2007 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
import gdata.base.service
19+
import gdata.service
20+
try:
21+
from xml.etree import ElementTree
22+
except ImportError:
23+
from elementtree import ElementTree
24+
import atom
25+
import gdata.base
26+
27+
# Demonstrates queries to the itemtypes feed for specified locale.
28+
29+
gb_client = gdata.base.service.GBaseService()
30+
locale = raw_input('Please enter locale (ex: en_US): ')
31+
q = gdata.base.service.BaseQuery()
32+
q.feed = '/base/feeds/itemtypes/%s' % locale
33+
34+
print q.ToUri()
35+
feed = gb_client.QueryItemTypesFeed(q.ToUri())
36+
37+
print feed.title.text
38+
39+
for entry in feed.entry:
40+
print '\t' + entry.title.text
41+
for attr in entry.attributes.attribute:
42+
print '\t\tAttr name:%s, type:%s' % (attr.name, attr.type)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright (C) 2007 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This file demonstrates how to use the Google Data API's Python client library
18+
# to interface with the Codesearch service.
19+
20+
21+
__author__ = 'vbarathan@gmail.com (Prakash Barathan)'
22+
23+
24+
from gdata import service
25+
import gdata.codesearch.service
26+
import gdata
27+
import atom
28+
import getopt
29+
import sys
30+
31+
32+
class CodesearchExample:
33+
34+
def __init__(self):
35+
"""Creates a GData service instance to talk to Codesearch service."""
36+
self.service = gdata.codesearch.service.CodesearchService(
37+
source='Codesearch_Python_Sample-1.0')
38+
39+
def PrintCodeSnippets(self, query):
40+
"""Prints the codesearch results for given query."""
41+
feed = self.service.GetSnippetsFeed(query)
42+
print feed.title.text + " Results for '" + query + "'"
43+
print '============================================'
44+
for entry in feed.entry:
45+
print "" + entry.title.text
46+
for match in entry.match:
47+
print "\tline#" + match.line_number + ":" + match.text.replace('\n', '')
48+
print
49+
50+
51+
def main():
52+
"""The main function runs the CodesearchExample application with user
53+
specified query."""
54+
55+
# parse command line options
56+
try:
57+
opts, args = getopt.getopt(sys.argv[1:], "", ["query="])
58+
except getopt.error, msg:
59+
print ('python CodesearchExample.py --query [query_text]')
60+
sys.exit(2)
61+
62+
query = ''
63+
64+
# Process options
65+
for o, a in opts:
66+
if o == "--query":
67+
query = a
68+
69+
if query == '':
70+
print ('python CodesearchExample.py --query [query]')
71+
sys.exit(2)
72+
73+
sample = CodesearchExample()
74+
sample.PrintCodeSnippets(query)
75+
76+
77+
if __name__ == '__main__':
78+
main()

‎src/gdata/service.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def GenerateOAuthAuthorizationURL(
492492
def UpgradeToOAuthAccessToken(self, authorized_request_token=None,
493493
request_url='%s/accounts/OAuthGetAccessToken' \
494494
% AUTH_SERVER_HOST, oauth_version='1.0'):
495-
"""Upgrades the authorized request token to an access token.
495+
"""Upgrades the authorized request token to an access token and returns it
496496
497497
Args:
498498
authorized_request_token: gdata.auth.OAuthToken (optional) OAuth request
@@ -504,6 +504,9 @@ def UpgradeToOAuthAccessToken(self, authorized_request_token=None,
504504
added by default but here you can override it's value.
505505
request_url: Access token URL. The default is
506506
'https://www.google.com/accounts/OAuthGetAccessToken'.
507+
508+
Returns:
509+
Access token
507510
508511
Raises:
509512
NonOAuthToken if the user's authorized request token is not an OAuth
@@ -536,6 +539,7 @@ def UpgradeToOAuthAccessToken(self, authorized_request_token=None,
536539
token.scopes = authorized_request_token.scopes
537540
token.oauth_input_params = authorized_request_token.oauth_input_params
538541
self.SetOAuthToken(token)
542+
return token
539543
else:
540544
raise TokenUpgradeFailed({'status': response.status,
541545
'reason': 'Non 200 response on upgrade',

‎src/gdata/spreadsheet/service.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"""SpreadsheetsService extends the GDataService to streamline Google
1818
Spreadsheets operations.
1919
20-
GBaseService: Provides methods to query feeds and manipulate items. Extends
21-
GDataService.
20+
SpreadsheetService: Provides methods to query feeds and manipulate items.
21+
Extends GDataService.
2222
2323
DictionaryToParamList: Function which converts a dictionary into a list of
2424
URL arguments (represented as strings). This is a
@@ -303,7 +303,7 @@ def ExecuteBatch(self, batch_feed, url=None, spreadsheet_key=None,
303303
converter: Function (optional) Function to be executed on the server's
304304
response. This function should take one string as a parameter. The
305305
default value is SpreadsheetsCellsFeedFromString which will turn the result
306-
into a gdata.base.GBaseItem object.
306+
into a gdata.spreadsheet.SpreadsheetsCellsFeed object.
307307
308308
Returns:
309309
A gdata.BatchFeed containing the results.

‎src/gdata/youtube/service.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,11 @@ def GetYouTubeVideoCommentEntry(self, uri):
277277
uri, converter=gdata.youtube.YouTubeVideoCommentEntryFromString)
278278

279279
def GetYouTubeUserFeed(self, uri=None, username=None):
280-
"""Retrieve a YouTubeUserFeed.
280+
"""Retrieve a YouTubeVideoFeed of user uploaded videos
281281
282-
Either a uri or a username must be provided.
282+
Either a uri or a username must be provided. This will retrieve list
283+
of videos uploaded by specified user. The uri will be of format
284+
"http://gdata.youtube.com/feeds/api/users/{username}/uploads".
283285
284286
Args:
285287
uri: An optional string representing the URI of the user feed that is

0 commit comments

Comments
 (0)