Added mocks for the generated service objects. Also fixed a bunch of formatting.
diff --git a/samples/api-python-client-doc/main.py b/samples/api-python-client-doc/main.py
index 366f4b0..d5ae558 100755
--- a/samples/api-python-client-doc/main.py
+++ b/samples/api-python-client-doc/main.py
@@ -28,7 +28,11 @@
from google.appengine.ext.webapp import util
# Replicate render_doc here from pydoc.py as it isn't available in Python 2.5
-class _OldStyleClass: pass
+
+
+class _OldStyleClass:
+ pass
+
def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
"""Render text documentation, given an object or a path to an object."""
@@ -77,7 +81,8 @@
def get(self, service_name, version):
service = build(service_name, version)
- page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % pydoc.plain(render_doc(service))
+ page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % (
+ pydoc.plain(render_doc(service)),)
collections = []
for name in dir(service):
@@ -85,7 +90,8 @@
collections.append(name)
for name in collections:
- page = re.sub('(%s) =' % name, r'<a href="/%s/%s/%s">\1</a> =' % (service_name, version, name), page)
+ page = re.sub('(%s) =' % name, r'<a href="/%s/%s/%s">\1</a> =' % (
+ service_name, version, name), page)
self.response.out.write(page)
@@ -101,16 +107,19 @@
service = getattr(service, method)()
method = getattr(service, path[-1])
obj = method()
- page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % pydoc.plain(render_doc(obj))
+ page = "<p><a href='/'>Home</a></p><pre>%s</pre>" % (
+ pydoc.plain(render_doc(obj)),)
if hasattr(method, '__is_resource__'):
collections = []
for name in dir(obj):
- if not "_" in name and callable(getattr(obj, name)) and hasattr(getattr(obj, name), '__is_resource__'):
+ if not "_" in name and callable(getattr(obj, name)) and hasattr(
+ getattr(obj, name), '__is_resource__'):
collections.append(name)
for name in collections:
- page = re.sub('(%s) =' % name, r'<a href="/%s/%s/%s">\1</a> =' % (service_name, version, collection + "/" + name), page)
+ page = re.sub('(%s) =' % name, r'<a href="/%s/%s/%s">\1</a> =' % (
+ service_name, version, collection + "/" + name), page)
self.response.out.write(page)
diff --git a/samples/buzz/buzz.py b/samples/buzz/buzz.py
index 9cebd79..18bdfb0 100644
--- a/samples/buzz/buzz.py
+++ b/samples/buzz/buzz.py
@@ -20,6 +20,7 @@
# Uncomment the next line to get very detailed logging
#httplib2.debuglevel = 4
+
def main():
f = open("buzz.dat", "r")
credentials = pickle.loads(f.read())
diff --git a/samples/customsearch/main.py b/samples/customsearch/main.py
index d13f53c..105f891 100644
--- a/samples/customsearch/main.py
+++ b/samples/customsearch/main.py
@@ -17,9 +17,10 @@
# Uncomment the next line to get very detailed logging
# httplib2.debuglevel = 4
-def main():
- p = build("customsearch", "v1", developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")
+def main():
+ p = build("customsearch", "v1",
+ developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")
res = p.cse().list(
q='lectures',
cx='017576662512468239146:omuauf_lfve',
diff --git a/samples/diacritize/main.py b/samples/diacritize/main.py
index e9bee69..1935868 100644
--- a/samples/diacritize/main.py
+++ b/samples/diacritize/main.py
@@ -20,9 +20,10 @@
# Uncomment the next line to get very detailed logging
# httplib2.debuglevel = 4
-def main():
- p = build("diacritize", "v1", developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")
+def main():
+ p = build("diacritize", "v1",
+ developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")
print p.diacritize().corpus().get(
lang='ar',
last_letter='false',
diff --git a/samples/django_sample/buzz/models.py b/samples/django_sample/buzz/models.py
index 10a83ef..11a408d 100644
--- a/samples/django_sample/buzz/models.py
+++ b/samples/django_sample/buzz/models.py
@@ -8,22 +8,26 @@
from apiclient.ext.django_orm import FlowThreeLeggedField
from apiclient.ext.django_orm import OAuthCredentialsField
-# Create your models here.
-
# The Flow could also be stored in memcache since it is short lived.
+
+
class Flow(models.Model):
id = models.ForeignKey(User, primary_key=True)
flow = FlowThreeLeggedField()
+
class Credential(models.Model):
id = models.ForeignKey(User, primary_key=True)
credential = OAuthCredentialsField()
+
class CredentialAdmin(admin.ModelAdmin):
pass
+
class FlowAdmin(admin.ModelAdmin):
pass
+
admin.site.register(Credential, CredentialAdmin)
admin.site.register(Flow, FlowAdmin)
diff --git a/samples/django_sample/buzz/tests.py b/samples/django_sample/buzz/tests.py
index 2247054..927cadf 100644
--- a/samples/django_sample/buzz/tests.py
+++ b/samples/django_sample/buzz/tests.py
@@ -7,7 +7,9 @@
from django.test import TestCase
+
class SimpleTest(TestCase):
+
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
@@ -20,4 +22,3 @@
>>> 1 + 1 == 2
True
"""}
-
diff --git a/samples/django_sample/buzz/views.py b/samples/django_sample/buzz/views.py
index aeb0ca2..5c5a5d1 100644
--- a/samples/django_sample/buzz/views.py
+++ b/samples/django_sample/buzz/views.py
@@ -11,9 +11,9 @@
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
-print os.environ
STEP2_URI = 'http://localhost:8000/auth_return'
+
@login_required
def index(request):
try:
@@ -45,6 +45,7 @@
f.save()
return HttpResponseRedirect(authorize_url)
+
@login_required
def auth_return(request):
try:
diff --git a/samples/django_sample/settings.py b/samples/django_sample/settings.py
index 834ce1f..565d2e5 100644
--- a/samples/django_sample/settings.py
+++ b/samples/django_sample/settings.py
@@ -10,12 +10,12 @@
MANAGERS = ADMINS
-DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = 'database.sqlite3' # Or path to database file if using sqlite3.
-DATABASE_USER = '' # Not used with sqlite3.
-DATABASE_PASSWORD = '' # Not used with sqlite3.
-DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
-DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = 'database.sqlite3'
+DATABASE_USER = ''
+DATABASE_PASSWORD = ''
+DATABASE_HOST = ''
+DATABASE_PORT = ''
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
@@ -67,7 +67,7 @@
ROOT_URLCONF = 'django_sample.urls'
TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Put strings here, like "/home/html/django_templates"
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(os.path.dirname(__file__), 'templates')
diff --git a/samples/latitude/latitude.py b/samples/latitude/latitude.py
index 492300c..029b74a 100644
--- a/samples/latitude/latitude.py
+++ b/samples/latitude/latitude.py
@@ -20,6 +20,7 @@
# Uncomment to get detailed logging
# httplib2.debuglevel = 4
+
def main():
f = open("latitude.dat", "r")
credentials = pickle.loads(f.read())
@@ -32,11 +33,11 @@
body = {
"data": {
- "kind":"latitude#location",
- "latitude":37.420352,
- "longitude":-122.083389,
- "accuracy":130,
- "altitude":35
+ "kind": "latitude#location",
+ "latitude": 37.420352,
+ "longitude": -122.083389,
+ "accuracy": 130,
+ "altitude": 35
}
}
print p.currentLocation().insert(body=body).execute()
diff --git a/samples/latitude/three_legged_dance.py b/samples/latitude/three_legged_dance.py
index d8d89ba..56f4f59 100644
--- a/samples/latitude/three_legged_dance.py
+++ b/samples/latitude/three_legged_dance.py
@@ -36,10 +36,10 @@
# https://www.google.com/accounts/ManageDomains
consumer_key='REGISTERED DOMAIN NAME',
consumer_secret='KEY GIVEN DURING REGISTRATION',
- user_agent='google-api-client-python-latitude-cmdline/1.0',
+ user_agent='google-api-client-python-latitude/1.0',
domain='REGISTERED DOMAIN NAME',
scope='https://www.googleapis.com/auth/latitude',
- xoauth_displayname='Google API Latitude Client Example App',
+ xoauth_displayname='Google API Latitude Example',
location='current',
granularity='city'
)
diff --git a/samples/local/main.py b/samples/local/main.py
index 7c62fef..472ac5a 100644
--- a/samples/local/main.py
+++ b/samples/local/main.py
@@ -22,9 +22,10 @@
import pickle
import pprint
-DISCOVERY_URI = ('http://gregorio-ub.i:3990/discovery/v0.2beta1/describe/'
+DISCOVERY_URI = ('http://localhost:3990/discovery/v0.2beta1/describe/'
'{api}/{apiVersion}')
+
def main():
http = httplib2.Http()
diff --git a/samples/moderator/moderator.py b/samples/moderator/moderator.py
index da8d344..89ec9ca 100644
--- a/samples/moderator/moderator.py
+++ b/samples/moderator/moderator.py
@@ -20,6 +20,7 @@
# Uncomment to get detailed logging
# httplib2.debuglevel = 4
+
def main():
f = open("moderator.dat", "r")
credentials = pickle.loads(f.read())
@@ -32,7 +33,7 @@
series_body = {
"data": {
- "description": "Share and rank tips for eating healthily on the cheaps!",
+ "description": "Share and rank tips for eating healthy and cheap!",
"name": "Eating Healthy & Cheap",
"videoSubmissionAllowed": False
}
@@ -47,7 +48,8 @@
"presenter": "liz"
}
}
- topic = p.topics().insert(seriesId=series['id']['seriesId'], body=topic_body).execute()
+ topic = p.topics().insert(seriesId=series['id']['seriesId'],
+ body=topic_body).execute()
print "Created a new topic"
submission_body = {
@@ -69,7 +71,9 @@
"vote": "PLUS"
}
}
- p.votes().insert(seriesId=topic['id']['seriesId'], submissionId=submission['id']['submissionId'], body=vote_body)
+ p.votes().insert(seriesId=topic['id']['seriesId'],
+ submissionId=submission['id']['submissionId'],
+ body=vote_body)
print "Voted on the submission"
diff --git a/samples/threadqueue/main.py b/samples/threadqueue/main.py
index 1b3b6af..4e5c511 100644
--- a/samples/threadqueue/main.py
+++ b/samples/threadqueue/main.py
@@ -22,6 +22,7 @@
Implements an exponential backoff algorithm.
"""
+
def __init__(self, maxretries=8):
self.retry = 0
self.maxretries = maxretries
@@ -36,7 +37,7 @@
def fail(self):
self.retry += 1
- delay = 2**self.retry
+ delay = 2 ** self.retry
time.sleep(delay)
@@ -67,8 +68,8 @@
t.daemon = True
t.start()
-def main():
+def main():
f = open("moderator.dat", "r")
credentials = pickle.loads(f.read())
f.close()
@@ -98,7 +99,8 @@
"presenter": "me"
}
}
- topic_request = p.topics().insert(seriesId=series['id']['seriesId'], body=topic_body)
+ topic_request = p.topics().insert(seriesId=series['id']['seriesId'],
+ body=topic_body)
print "Adding request to queue"
queue.put(topic_request)
diff --git a/samples/threadqueue/three_legged_dance.py b/samples/threadqueue/three_legged_dance.py
index 97f4d11..b833e3a 100644
--- a/samples/threadqueue/three_legged_dance.py
+++ b/samples/threadqueue/three_legged_dance.py
@@ -32,7 +32,7 @@
flow = FlowThreeLegged(moderator_discovery,
consumer_key='anonymous',
consumer_secret='anonymous',
- user_agent='google-api-client-python-threadqueue-sample/1.0',
+ user_agent='google-api-client-python-thread-sample/1.0',
domain='anonymous',
scope='https://www.googleapis.com/auth/moderator',
#scope='tag:google.com,2010:auth/moderator',
diff --git a/samples/translate/main.py b/samples/translate/main.py
index cf0e4e7..24f0648 100644
--- a/samples/translate/main.py
+++ b/samples/translate/main.py
@@ -18,9 +18,11 @@
# Uncomment the next line to get very detailed logging
# httplib2.debuglevel = 4
+
def main():
- p = build("translate", "v2", developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")
+ p = build("translate", "v2",
+ developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")
print p.translations().list(
source="en",
target="fr",