[google-app-engine-oil] push by ping.nsr...@gmail.com - Introduces the gaeodoc.py for generating pydocs for source codes.... on 2010-11-26 16:23 GMT

3 views
Skip to first unread message

google-app...@googlecode.com

unread,
Nov 26, 2010, 11:23:40 AM11/26/10
to google-app...@googlegroups.com
Revision: 5cbe319ccb
Author: Ping Yeh <pi...@pingyeh.net>
Date: Fri Nov 26 08:22:34 2010
Log: Introduces the gaeodoc.py for generating pydocs for source codes.
Renamed the sample files so they can be imported by gaeodoc.py while
working on source codes in oildrum/lib/gaeo directory.
http://code.google.com/p/google-app-engine-oil/source/detail?r=5cbe319ccb

Added:
/bin/gaeodoc.py
/oildrum/sample/main.py
/oildrum/sample/routes.yaml
/oildrum/sample/settings.py
Deleted:
/oildrum/main-sample.py
/oildrum/routes-sample.yaml
/oildrum/settings-sample.py
Modified:
/bin/gaeo.py
/oildrum/lib/gaeo/model.py
/oildrum/lib/gaeo/view/filters.py

=======================================
--- /dev/null
+++ /bin/gaeodoc.py Fri Nov 26 08:22:34 2010
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+"""A utility script to produce pydocs for GAEO source codes.
+
+This script prepares Python PATH then call pydoc's command line interface
+to do the real work.
+
+To see the pydoc for a source file, run this script like
+ $ gaeodoc.py oildrum/lib/gaeo/controller.py
+Note that you must include the directory part so gaeodoc.py recognizes that
+the argument is a filename. That means prefixing ./ to filenames in current
+directory.
+"""
+
+__author__ = 'Ping Yeh <pi...@pingyeh.net>'
+
+import os
+import pydoc
+import sys
+
+# Define the path to App Engine libraries.
+# TODO: make it work cross all platforms (it is only tested on Mac OS X
now).
+APPENGINE_PATH=('/Applications/GoogleAppEngineLauncher.app/Contents/Resources/'
+ 'GoogleAppEngine-default.bundle/Contents/Resources/'
+ 'google_appengine')
+
+
+def get_gaeo_path():
+ """Gets the GAEO installation path.
+
+ This function derives the GAEO installation path from __file__, i.e.,
+ the path of this script.
+ """
+ binary_path, binary = os.path.split(__file__)
+ gaeo_path, bin = os.path.split(binary_path)
+ return gaeo_path
+
+
+def gaeodoc():
+ """Produces pydoc for files specified in command line."""
+ # Prepare Python PATH for pydoc module to find relevant modules to
import.
+ GAEO_PATH = get_gaeo_path()
+ sys.path.append(APPENGINE_PATH)
+ sys.path.append(os.path.join(APPENGINE_PATH, 'lib', 'yaml', 'lib'))
+ sys.path.append(os.path.join(APPENGINE_PATH, 'lib', 'webob'))
+ sys.path.append(os.path.join(GAEO_PATH, 'oildrum', 'lib'))
+ sys.path.append(os.path.join(GAEO_PATH, 'oildrum', 'sample'))
+
+ # Launch pydoc's command line interface.
+ pydoc.cli()
+
+
+if __name__ == '__main__':
+ gaeodoc()
=======================================
--- /dev/null
+++ /oildrum/sample/main.py Fri Nov 26 08:22:34 2010
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+""" The entry point. """
+
+import os
+import sys
+import settings
+
+PATHS = [settings.APP_DIR, 'lib', os.path.join('lib', 'gaeo')]
+
+def safe_append(path):
+ if path not in sys.path:
+ sys.path.append(path)
+
+def main():
+ cur_path = os.path.dirname(__file__)
+ safe_append(cur_path)
+
+ for p in PATHS:
+ path = os.path.join(cur_path, p)
+ safe_append(path)
+
+ from gaeo.app import GaeoApp, start_app
+ application = GaeoApp()
+ start_app(application)
+
+if __name__ == '__main__':
+ main()
=======================================
--- /dev/null
+++ /oildrum/sample/routes.yaml Fri Nov 26 08:22:34 2010
@@ -0,0 +1,28 @@
+# This YAML file defines the routing rules.
+#
+# The item "routes" is an array of rules.
+# Each rule contains a mandatory pattern and an optional regex
+# and optional parameters.
+#
+# EXAMPLE
+# -------
+# routes:
+# - rule: /
+# parameters:
+# controller: welcome
+# action: index
+# - rule: /:controller/:action/:key
+# - rule: /:controller/:action
+# - rule: /:controller
+#
+# TODO: add an example on regex.
+
+routes:
+- rule: /
+ parameters:
+ controller: welcome
+ action: index
+- rule: /:controller/:action/:key
+- rule: /:controller/:action
+- rule: /:controller
+
=======================================
--- /dev/null
+++ /oildrum/sample/settings.py Fri Nov 26 08:22:34 2010
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+""" The application settings module. """
+
+import os
+
+cur_path = os.path.dirname(__file__)
+
+# General
+DEBUG = False
+APP_DIR = 'application'
+APP_PATH = os.path.join(cur_path, APP_DIR)
+TEMPLATE_DIR = 'templates'
+TEMPLATE_PATH = os.path.join(cur_path, APP_DIR, TEMPLATE_DIR)
+CACHE_TIMEOUT = 3600
+
+# Session
+SESSION_COOKIE_NAME = 'GAEOSSID'
+SESSION_COOKIE_NAME_LENGTH = 64
+SESSION_COOKIE_TIMEOUT = 21600 # 6 hours
+SESSION_COOKIE_PATH = '/'
+
+# Controller
+HANDLE_MISSING_ACTION = True
+
+# View
+VIEW_CLASS = 'AppengineTemplateView'
+
=======================================
--- /oildrum/main-sample.py Tue Sep 28 23:47:08 2010
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-""" The entry point. """
-
-import os
-import sys
-import settings
-
-PATHS = [settings.APP_DIR, 'lib', os.path.join('lib', 'gaeo')]
-
-def safe_append(path):
- if path not in sys.path:
- sys.path.append(path)
-
-def main():
- cur_path = os.path.dirname(__file__)
- safe_append(cur_path)
-
- for p in PATHS:
- path = os.path.join(cur_path, p)
- safe_append(path)
-
- from gaeo.app import GaeoApp, start_app
- application = GaeoApp()
- start_app(application)
-
-if __name__ == '__main__':
- main()
=======================================
--- /oildrum/routes-sample.yaml Sat Nov 20 08:05:58 2010
+++ /dev/null
@@ -1,28 +0,0 @@
-# This YAML file defines the routing rules.
-#
-# The item "routes" is an array of rules.
-# Each rule contains a mandatory pattern and an optional regex
-# and optional parameters.
-#
-# EXAMPLE
-# -------
-# routes:
-# - rule: /
-# parameters:
-# controller: welcome
-# action: index
-# - rule: /:controller/:action/:key
-# - rule: /:controller/:action
-# - rule: /:controller
-#
-# TODO: add an example on regex.
-
-routes:
-- rule: /
- parameters:
- controller: welcome
- action: index
-- rule: /:controller/:action/:key
-- rule: /:controller/:action
-- rule: /:controller
-
=======================================
--- /oildrum/settings-sample.py Mon Nov 15 06:37:03 2010
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-""" The application settings module. """
-
-import os
-
-cur_path = os.path.dirname(__file__)
-
-# General
-DEBUG = False
-APP_DIR = 'application'
-APP_PATH = os.path.join(cur_path, APP_DIR)
-TEMPLATE_DIR = 'templates'
-TEMPLATE_PATH = os.path.join(cur_path, APP_DIR, TEMPLATE_DIR)
-CACHE_TIMEOUT = 3600
-
-# Session
-SESSION_COOKIE_NAME = 'GAEOSSID'
-SESSION_COOKIE_NAME_LENGTH = 64
-SESSION_COOKIE_TIMEOUT = 21600 # 6 hours
-SESSION_COOKIE_PATH = '/'
-
-# Controller
-HANDLE_MISSING_ACTION = True
-
-# View
-VIEW_CLASS = 'AppengineTemplateView'
-
=======================================
--- /bin/gaeo.py Sat Nov 20 08:05:58 2010
+++ /bin/gaeo.py Fri Nov 26 08:22:34 2010
@@ -282,17 +282,12 @@

# copy sample main.py

- copyfile(os.path.join(os.path.dirname(os.path.dirname(__file__)),
- template_base, 'main-sample.py'),
- os.path.join(project_home, 'main.py'))
-
- copyfile(os.path.join(os.path.dirname(os.path.dirname(__file__)),
- template_base, 'settings-sample.py'),
- os.path.join(project_home, 'settings.py'))
-
- copyfile(os.path.join(os.path.dirname(os.path.dirname(__file__)),
- template_base, 'routes-sample.yaml'),
- os.path.join(project_home, 'routes.yaml'))
+ sample_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)),
+ template_base, 'sample')
+ for filename in ('main.py', 'settings.py', 'routes.yaml'):
+ copyfile(os.path.join(sample_dir, filename),
+ os.path.join(project_home, filename))
+
# create the eclipse project file

if create_eclipse_proj:
=======================================
--- /oildrum/lib/gaeo/model.py Fri Nov 26 07:12:06 2010
+++ /oildrum/lib/gaeo/model.py Fri Nov 26 08:22:34 2010
@@ -1,6 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

+"""The gaeo model module.
+
+"""
+
import logging

# gae imports
=======================================
--- /oildrum/lib/gaeo/view/filters.py Tue Sep 28 23:47:08 2010
+++ /oildrum/lib/gaeo/view/filters.py Fri Nov 26 08:22:34 2010
@@ -1,10 +1,10 @@
#!/usr/bin/env python

-from google.appengine.ext import webapp
+from google.appengine.ext.webapp import template
from gaeo.utils import TaiwanTimeZone

# get template register
-register = webapp.template.create_template_register()
+register = template.create_template_register()

@register.filter
def twtz(value):

Reply all
Reply to author
Forward
0 new messages