<commit_before>#!/usr/bin/env python
#
# Copyright 2007 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.
#

__author__ = '<EMAIL> (<NAME>)'


import inspect
import pydoc
import re

from apiclient.discovery import build

from google.appengine.ext import webapp
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

def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
    """Render text documentation, given an object or a path to an object."""
    object, name = pydoc.resolve(thing, forceload)
    desc = pydoc.describe(object)
    module = inspect.getmodule(object)
    if name and '.' in name:
        desc += ' in ' + name[:name.rfind('.')]
    elif module and module is not object:
        desc += ' in module ' + module.__name__
    if type(object) is type(_OldStyleClass()):
        # If the passed object is an instance of an old-style class,
        # document its available methods instead of its value.
        object = object.__class__
    elif not (inspect.ismodule(object) or
              inspect.isclass(object) or
              inspect.isroutine(object) or
              inspect.isgetsetdescriptor(object) or
              inspect.ismemberdescriptor(object) or
              isinstance(object, property)):
        # If the passed object is a piece of data or an instance,
        # document its available methods instead of its value.
        object = type(object)
        desc += ' object'
    return title % desc + '\n\n' + pydoc.text.document(object, name)


class MainHandler(webapp.RequestHandler):

  def get(self):
    self.response.out.write("""
    <h1>Google API Client for Python Documentation</h1>
    <ul>
      <li><a href='/buzz/v1'>buzz</a>
      <li><a href='/moderator/v1'>moderator</a>
      <li><a href='/latitude/v1'>latitude</a>
    </ul>
    """)


class ServiceHandler(webapp.RequestHandler):

  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))

    collections = []
    for name in dir(service):
      if not "_" in name and callable(getattr(service, name)):
        collections.append(name)
<commit_msg>Updated api-python-client-doc application to list the three new APIs<commit_after>#!/usr/bin/env python
#
# Copyright 2007 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.
#

__author__ = '<EMAIL> (<NAME>)'


import inspect
import pydoc
import re

from apiclient.discovery import build

from google.appengine.ext import webapp
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

def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
    """Render text documentation, given an object or a path to an object."""
    object, name = pydoc.resolve(thing, forceload)
    desc = pydoc.describe(object)
    module = inspect.getmodule(object)
    if name and '.' in name:
        desc += ' in ' + name[:name.rfind('.')]
    elif module and module is not object:
        desc += ' in module ' + module.__name__
    if type(object) is type(_OldStyleClass()):
        # If the passed object is an instance of an old-style class,
        # document its available methods instead of its value.
        object = object.__class__
    elif not (inspect.ismodule(object) or
              inspect.isclass(object) or
              inspect.isroutine(object) or
              inspect.isgetsetdescriptor(object) or
              inspect.ismemberdescriptor(object) or
              isinstance(object, property)):
        # If the passed object is a piece of data or an instance,
        # document its available methods instead of its value.
        object = type(object)
        desc += ' object'
    return title % desc + '\n\n' + pydoc.text.document(object, name)


class MainHandler(webapp.RequestHandler):

  def get(self):
    self.response.out.write("""
    <h1>Google API Client for Python Documentation</h1>
    <ul>
      <li><a href='/buzz/v1'>buzz</a>
      <li><a href='/moderator/v1'>moderator</a>
      <li><a href='/latitude/v1'>latitude</a>
      <li><a href='/customsearch/v1'>customsearch</a>
      <li><a href='/diacritize/v1'>diacritize</a>
      <li><a href='/translate/v2'>translate</a>
    </ul>
    """)


class ServiceHandler(webapp.RequestHandler):

  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))

    collections = []
    for name in dir(service):
      if not "_" in name and callable(getattr(service, name)):
        collections.append(name)

{'fraction_non_alphanumeric': 0.11248923341946598, 'fraction_numerical': 0.006029285099052541, 'mean_word_length': 3.2410518626734843, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1771106', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1704, 'n_words': 574}