Remove old files.
diff --git a/discovery_extras.py b/discovery_extras.py
deleted file mode 100644
index 3e5a553..0000000
--- a/discovery_extras.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (C) 2010 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Generate a skeleton discovery extras document.
-
-For the given API, retrieve the discovery document,
-strip out the guts of each method description
-and put :
-"""
-
-__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-
-import os
-import os.path
-import sys
-
-from anyjson import simplejson
-
-
-def main():
- for filename in sys.argv[1:]:
- f = file(filename, "r")
- dis = simplejson.load(f)
- f.close()
-
- api = dis['name']
- version = dis['version']
- resources = dis['resources']
- for res_name, res_desc in resources.iteritems():
- methods = res_desc['methods']
- for method_name, method_desc in methods.iteritems():
- methods[method_name] = {}
- path, basename = os.path.split(filename)
- newfilename = os.path.join(path, "skel-" + basename)
- f = file(newfilename, "w")
- simplejson.dump(dis, f, sort_keys=True, indent=2 * ' ')
- f.close()
-
-
-if __name__ == '__main__':
- main()
diff --git a/oacurl.py b/oacurl.py
deleted file mode 100644
index 740baf2..0000000
--- a/oacurl.py
+++ /dev/null
@@ -1,160 +0,0 @@
-# Copyright (C) 2010 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-from apiclient.discovery import build
-from apiclient.oauth import FlowThreeLegged
-
-import datetime
-import httplib2
-import logging
-import oauth_wrap
-import optparse
-import os
-import sys
-
-
-def load_properties_file(path):
- properties = {}
- for line in open(path):
- line = line.strip()
- if line.startswith('#'):
- continue
-
- key,value = line.split('=')
- properties[key.strip()] = value.strip()
- return properties
-
-
-def save_properties(consumer_key, consumer_secret, token_key, token_secret, path):
- file = open(path, 'w')
-
- # File format and order is based on oacurl.java's defaults
- now = datetime.datetime.today()
- now_string = now.strftime('%a %b %d %H:%m:%S %Z %Y')
- file.write('#%s\n' % now_string)
- file.write('consumerSecret=%s\n' % consumer_secret)
- file.write('accessToken=%s\n' % token_key)
- file.write('consumerKey=%s\n' % consumer_key)
- file.write('accessTokenSecret=%s\n' % token_secret)
- file.close()
-
-
-def fetch(url):
- logging.debug('Now fetching: %s' % url)
-
- path = os.path.expanduser('~/.oacurl.properties')
- if not os.path.exists(path):
- logging.debug('User is not logged in.')
-
- print 'You are not logged in'
- sys.exit(1)
-
- properties = load_properties_file(path)
- oauth_parameters = {
- 'consumer_key': properties['consumerKey'],
- 'consumer_secret' : properties['consumerSecret'],
- 'oauth_token' : properties['accessToken'],
- 'oauth_token_secret':properties['accessTokenSecret']}
-
- http = oauth_wrap.get_authorised_http(oauth_parameters)
- response, content = http.request(url)
- logging.debug(response)
- logging.debug(content)
-
- return response,content
-
-
-def buzz_login():
- buzz_discovery = build("buzz", "v1").auth_discovery()
-
- flow = FlowThreeLegged(buzz_discovery,
- consumer_key='anonymous',
- consumer_secret='anonymous',
- user_agent='google-api-client-python-buzz-cmdline/1.0',
- domain='anonymous',
- scope='https://www.googleapis.com/auth/buzz',
- xoauth_displayname='oacurl.py')
-
- authorize_url = flow.step1_get_authorize_url()
-
- print 'Go to the following link in your browser:'
- print authorize_url
- print
-
- accepted = 'n'
- while accepted.lower() == 'n':
- accepted = raw_input('Have you authorized me? (y/n) ')
- verification = raw_input('What is the verification code? ').strip()
-
- credentials = flow.step2_exchange(verification)
- path = os.path.expanduser('~/.oacurl.properties')
- save_properties('anonymous', 'anonymous', credentials.token.key, credentials.token.secret,path)
-
-
-def generic_login():
- #TODO(ade) Implement support for other services
- print 'Support for services other than Buzz is not implemented yet. Sorry.'
-
-
-def login(options):
- if options.buzz:
- buzz_login()
- else:
- generic_login()
-
-
-def get_command(args):
- if args and args[0] == 'login':
- return 'login'
- if args and args[0] == 'fetch':
- return 'fetch'
- return None
-
-
-def configure_logging(options):
- if options.verbose:
- logging.basicConfig(level=logging.DEBUG)
-
-
-def main():
- usage = '''Usage: python %prog [options] fetch <url>
- Example: python %prog -v fetch "https://www.googleapis.com/buzz/v1/people/@me/@self?alt=json&pp=1"
- '''
- parser = optparse.OptionParser(usage=usage)
- parser.set_defaults(verbose=False)
- parser.add_option('-v', '--verbose', action='store_true', dest='verbose')
- parser.add_option('-q', '--quiet', action='store_false', dest='verbose')
- parser.add_option('--buzz', action='store_true', dest='buzz')
-
- (options, args) = parser.parse_args()
-
- configure_logging(options)
- logging.debug('Options: %s and Args: %s' % (str(options), str(args)))
-
- command = get_command(args)
-
- if not command:
- parser.error('Invalid arguments')
- return
-
- if command == 'fetch':
- response, content = fetch(args[1])
- print response
- print content
- return
-
- if command == 'login':
- login(options)
-
-if __name__ == '__main__':
- main()
\ No newline at end of file
diff --git a/oauth_wrap.py b/oauth_wrap.py
deleted file mode 100644
index 2c0786f..0000000
--- a/oauth_wrap.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (C) 2010 Google Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import httplib2
-import oauth2 as oauth
-import simplejson
-
-
-def oauth_wrap(consumer, token, http):
- """
- Args:
- http - An instance of httplib2.Http
- or something that acts like it.
-
- Returns:
- A modified instance of http that was passed in.
-
- Example:
-
- h = httplib2.Http()
- h = oauth_wrap(h)
-
- Grumble. You can't create a new OAuth
- subclass of httplib2.Authenication because
- it never gets passed the absolute URI, which is
- needed for signing. So instead we have to overload
- 'request' with a closure that adds in the
- Authorization header and then calls the original version
- of 'request().
- """
- request_orig = http.request
- signer = oauth.SignatureMethod_HMAC_SHA1()
-
- def new_request(uri, method='GET', body=None, headers=None,
- redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None):
- """Modify the request headers to add the appropriate
- Authorization header."""
- req = oauth.Request.from_consumer_and_token(
- consumer, token, http_method=method, http_url=uri)
- req.sign_request(signer, consumer, token)
- if headers == None:
- headers = {}
- headers.update(req.to_header())
- headers['user-agent'] = 'jcgregorio-test-client'
- return request_orig(uri, method, body, headers, redirections,
- connection_type)
-
- http.request = new_request
- return http
-
-def get_authorised_http(oauth_params):
- consumer = oauth.Consumer(oauth_params['consumer_key'],
- oauth_params['consumer_secret'])
- token = oauth.Token(oauth_params['oauth_token'],
- oauth_params['oauth_token_secret'])
-
- # Create a simple monkeypatch for httplib2.Http.request
- # just adds in the oauth authorization header and then calls
- # the original request().
- http = httplib2.Http()
- return oauth_wrap(consumer, token, http)
-
-def get_wrapped_http(filename='oauth_token.dat'):
- f = open(filename, 'r')
- oauth_params = simplejson.loads(f.read())
-
- return get_authorised_http(oauth_params)