code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
# mako/pygen.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""utilities for generating and formatting literal Python code."""
import re, string
from StringIO ... | Python |
# mako/lookup.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import os, stat, posixpath, re
from mako import exceptions, util
from mako.template import Template... | Python |
# mako/lexer.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""provides the Lexer class for parsing template strings into parse trees."""
import re, codecs
fro... | Python |
# mako/parsetree.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""defines the parse tree components for Mako templates."""
from mako import exceptions, ast, u... | Python |
# ext/autohandler.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""adds autohandler functionality to Mako templates.
requires that the TemplateLookup class is... | Python |
# ext/preprocessors.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""preprocessing functions, used with the 'preprocessor'
argument on Template, TemplateLooku... | Python |
# ext/babelplugin.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""gettext message extraction via Babel: http://babel.edgewall.org/"""
from StringIO import Str... | Python |
# ext/pygmentplugin.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import re
try:
set
except NameError:
from sets import Set as set
from pygments.lexer... | Python |
# ext/turbogears.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import re, inspect
from mako.lookup import TemplateLookup
from mako.template import Template
cl... | Python |
# mako/codegen.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""provides functionality for rendering a parsetree constructing into module source code."""
impo... | Python |
# mako/util.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import sys
py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)
py24 = sys.versi... | Python |
# mako/ast.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""utilities for analyzing expressions and blocks of Python
code, as well as generating Python from A... | Python |
# mako/pyparser.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""Handles parsing of Python code.
Parsing to AST is done via _ast on Python > 2.5, otherwise th... | Python |
# mako/exceptions.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""exception classes"""
import traceback, sys, re
from mako import util
class MakoException(E... | Python |
# mako/__init__.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
__version__ = '0.5.0'
| Python |
# mako/template.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""Provides the Template class, a facade for parsing, generating and executing
template strings, ... | Python |
# mako/filters.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import re, urllib, htmlentitydefs, codecs
from StringIO import StringIO
from mako import util
xm... | Python |
# mako/_ast_util.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
"""
ast
~~~
The `ast` module helps Python applications to process trees of the Pyth... | Python |
# mako/cache.py
# Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file>
#
# This module is part of Mako and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from mako import exceptions
cache = None
class BeakerMissing(object):
def get_cache(self, name... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import os
import web
import uuid
from mako.lookup import TemplateLookup
from mako import exceptions
__author__ = 'Michael Liao'
class emptyobject(object):
def __getattr__(self, attr):
return ''
def __setattr__(self, attr, value):
... | Python |
from pandas.io.data import DataReader
from pandas.io.data import DataFrame
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from datetime import datetime
from datetime import timedelta
import pandas as pd
import numpy as np
import urllib
import codecs
import csv
import os
import glob
import json
impo... | Python |
import csv
import numpy as np
from pandas import DataFrame
import pandas as pd
# all digits are decreased by 1
len_total = 280
len_freq = 7
len_body = 5
len_star = 2
freq_body = []
freq_star = []
relation_body = np.zeros(shape=(50,50))
relation_star = np.zeros(shape=(11,11))
def rel_body(firstC... | Python |
import sys, string, re, Queue
arith = ['sub', 'div', 'mod', 'cmple', 'add', 'mul', 'cmpeq', 'cmplt']
operators = ['-', '/', '%', '<=', '+', '*', '==', '<']
arith1 = ['neg']
targets = []
local_size = 0;
# get operand
def getOperand(t, sline, access_local):
#GP
if sline[t] == 'GP':
print '(char*)global',
... | Python |
#!/usr/bin/python
# Copyright (C) 2008 Manu Garg.
# Author: Manu Garg <manugarg@gmail.com>
#
# pacparser is a library that provides methods to parse proxy auto-config
# (PAC) files. Please read README file included with this package for more
# information about this library.
#
# pacparser is free software; you can redi... | Python |
#!/usr/bin/python2.5
import pacparser
pacparser.init()
pacparser.parse_pac("wpad.dat")
proxy = pacparser.find_proxy("http://www.manugarg.com")
print proxy
pacparser.cleanup()
# Or simply,
print pacparser.just_find_proxy("wpad.dat", "http://www2.manugarg.com")
| Python |
# Copyright (C) 2007 Manu Garg.
# Author: Manu Garg <manugarg@gmail.com>
#
# pacparser is a library that provides methods to parse proxy auto-config
# (PAC) files. Please read README file included with this package for more
# information about this library.
#
# pacparser is free software; you can redistribute it and/or... | Python |
import shutil
import sys
from distutils import sysconfig
def main():
if sys.platform == 'win32':
shutil.rmtree('%s\\pacparser' % sysconfig.get_python_lib(),
ignore_errors=True)
shutil.copytree('pacparser', '%s\\pacparser' % sysconfig.get_python_lib())
else:
print 'This script should b... | Python |
# Copyright (C) 2007 Manu Garg.
# Author: Manu Garg <manugarg@gmail.com>
#
# pacparser is a library that provides methods to parse proxy auto-config
# (PAC) files. Please read README file included with this package for more
# information about this library.
#
# pacparser is free software; you can redistribute it... | Python |
# Copyright (C) 2007 Manu Garg.
# Author: Manu Garg <manugarg@gmail.com>
#
# pacparser is a library that provides methods to parse proxy auto-config
# (PAC) files. Please read README file included with this package for more
# information about this library.
#
# pacparser is free software; you can redistribute it and/or... | Python |
import cherrypy
import sqlite3
import Common
import os
import time
import hashlib
from postmarkup import render_bbcode
localdir = os.path.dirname(__file__)
absdir = os.path.join(os.getcwd(), localdir)
class User(Common.Template):
def index (self):
return self.default()
index.exposed = True
... | Python |
# -*- coding: UTF-8 -*-
"""
Post Markup
Author: Will McGugan (http://www.willmcgugan.com)
"""
__version__ = "1.1.4"
import re
from urllib import quote, unquote, quote_plus, urlencode
from urlparse import urlparse, urlunparse
pygments_available = True
try:
from pygments import highlight
from ... | Python |
import cherrypy
import sqlite3
import time
from postmarkup import render_bbcode
import Common
class PrivateMessage(Common.Template):
# Call the default function with no arguments
def index(self):
return self.default()
index.exposed = True
# This function handles basically everything. If no ID is given, it
... | Python |
import sqlite3
import getpass
# Create the connection
connection = sqlite3.connect("forum.db")
cursor = connection.cursor()
with open("dump.sql", "w") as f:
for line in connection.iterdump():
f.write("%s\n" % line)
| Python |
import cherrypy
import sqlite3
import time
import Common
class Post(Common.Template):
def index(self):
return self.default()
index.exposed = True
# This function allows users to create new posts. It requres the thread_id
# argument. If Reply is set, it takes the user name and content from
# the given post.... | Python |
import cherrypy
import sqlite3
import time
from postmarkup import render_bbcode
import Common
class Thread(Common.Template):
# Call the default function with no arguments
def index(self):
return self.default()
index.exposed = True
# Default function displays a given thread.
def default(self, id = None):
... | Python |
import cherrypy
import sqlite3
import os.path
import hashlib
# Import our modules
import Common
import Subforum
import Thread
import Post
import User
import Search
import Structure
import PrivateMessage
# root_dir is used by the config file
root_dir = os.path.dirname(os.path.abspath(__file__))
# connect to the datab... | Python |
import sqlite3
import getpass
import hashlib
# Create the connection
connection = sqlite3.connect("forum.db")
cursor = connection.cursor()
# Restore the dump
install_dump = open('install.sql', 'r')
cursor.executescript(install_dump.read())
install_dump.close()
# Add an administrator account
cursor.exec... | Python |
import cherrypy
import sqlite3
import time
import Common
class Subforum(Common.Template):
# Call the default function with no arguments
def index(self):
return self.default()
index.exposed = True
# The default view displays a given subforum. If no ID is given, it
# displays the root subforum
def default(se... | Python |
import cherrypy
import sqlite3
import time
import re
# central base class that other pages inherit
class Template:
# header includes the logo and login/register form
def header(self, title=None):
if title:
title = "%s - %s" % (title,self.getForumName())
else:
title = "%s" % self.getForumName()
out = '''
... | Python |
import cherrypy
import sqlite3
import time
import Common
from postmarkup import render_bbcode
class Search(Common.Template):
def index(self):
return self.default()
index.exposed = True
def default(self, q = None):
# if the user didn't search for anything
if q is None or q == '':
# return an error
... | Python |
import cherrypy
import sqlite3
import time
import Common
# restructure the forum
class Structure(Common.Template):
# Call the default function with no arguments
def index(self):
return self.default()
index.exposed = True
# This function is the default view for the restructure view and shows the
# subforum t... | Python |
import sqlite3 as sql
conn = sql.connect('sample.db')
curs = conn.cursor()
# Create Item table
curs.execute('''create table item
(id integer primary key, itemno text unique,
scancode text, descr text, price real)''')
curs.execute("insert into item values\
(NULL,0001,32187645,... | Python |
import cherrypy
import sqlite3
def connect(thread_index):
# Create a connection and store it in the current thread
cherrypy.thread_data.db = sqlite3.connect('sample.db')
# Tell CherryPy to call "connect" for each thread, when it starts up
cherrypy.engine.subscribe('start_thread', connect)
... | Python |
"""
Tutorial - Multiple objects
This tutorial shows you how to create a site structure through multiple
possibly nested request handler objects.
"""
import cherrypy
class HomePage:
def index(self):
return '''
<p>Hi, this is the home page! Check out the other
fun stuff on this sit... | Python |
"""
Tutorial: HTTP errors
HTTPError is used to return an error response to the client.
CherryPy has lots of options regarding how such errors are
logged, displayed, and formatted.
"""
import os
localDir = os.path.dirname(__file__)
curpath = os.path.normpath(os.path.join(os.getcwd(), localDir))
import cherrypy
cl... | Python |
"""
Tutorial - Hello World
The most basic (working) CherryPy application possible.
"""
# Import CherryPy global namespace
import cherrypy
class HelloWorld:
""" Sample request handler class. """
def index(self):
# CherryPy will call this method for the root URI ("/") and send
# its return val... | Python |
'''
Bonus Tutorial: Using SQLObject
This is a silly little contacts manager application intended to
demonstrate how to use SQLObject from within a CherryPy2 project. It
also shows how to use inline Cheetah templates.
SQLObject is an Object/Relational Mapper that allows you to access
data stored in an RDBMS in a pytho... | Python |
"""
Tutorial: File upload and download
Uploads
-------
When a client uploads a file to a CherryPy application, it's placed
on disk immediately. CherryPy will pass it to your exposed method
as an argument (see "myFile" below); that arg will have a "file"
attribute, which is a handle to the temporary uploaded file.
If... | Python |
"""
Bonus Tutorial: Using generators to return result bodies
Instead of returning a complete result string, you can use the yield
statement to return one result part after another. This may be convenient
in situations where using a template package like CherryPy or Cheetah
would be overkill, and messy string concatena... | Python |
"""
Tutorial - The default method
Request handler objects can implement a method called "default" that
is called when no other suitable method/object could be found.
Essentially, if CherryPy2 can't find a matching request handler object
for the given request URI, it will use the default method of the object
located de... | Python |
"""
Tutorial - Multiple methods
This tutorial shows you how to link to other methods of your request
handler.
"""
import cherrypy
class HelloWorld:
def index(self):
# Let's link to another method here.
return 'We have an <a href="showMessage">important message</a> for you!'
index.exposed... | Python |
"""
Tutorial - Passing variables
This tutorial shows you how to pass GET/POST variables to methods.
"""
import cherrypy
class WelcomePage:
def index(self):
# Ask for the user's name.
return '''
<form action="greetUser" method="GET">
What is your name?
<input ... | Python |
"""
Tutorial - Sessions
Storing session data in CherryPy applications is very easy: cherrypy
provides a dictionary called "session" that represents the session
data for the current user. If you use RAM based sessions, you can store
any kind of object into that dictionary; otherwise, you are limited to
objects that can... | Python |
# This is used in test_config to test unrepr of "from A import B"
thing2 = object() | Python |
"""
Tutorial - Object inheritance
You are free to derive your request handler classes from any base
class you wish. In most real-world applications, you will probably
want to create a central base class used for all your pages, which takes
care of things like printing a common page header and footer.
"""
import cherr... | Python |
###**********************************************###
### Unique Keychain Python Code ###
### ECE 387, Miami University, Spring 2013 ###
### Created By: Andrew Heldt, Lee Mondini and ###
### Shiloh Womack ###
###********************************************... | Python |
#!/usr/bin/python
import pyglet
from anim3d import *
#3d projection setup func
def setup_gl(dims):
global angle
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
gluPerspective(40, float(dims[0])/dims[1], 0.1, 100)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
... | Python |
#!/usr/bin/python
import pyglet
from anim3d import *
#3d projection setup func
def setup_gl(dims):
global angle
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
gluPerspective(40, float(dims[0])/dims[1], 0.1, 100)
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
... | Python |
from pyglet.gl import *
import math
class Face:
def __init__(self, ind, uv):
self.indices = ind
self.uv = uv
class KeyFrame:
def __init__(self, fp, nv):
self.verts = []
self.frame_num = int(fp.readline())
for i in xrange(nv):
(v1, v2, v3) = fp.readline().sp... | Python |
#!BPY
"""
Name: '3Danim (.txt)'
Blender: 243
Group: 'Export'
Tooltip: 'export an animated text format.'
"""
__author__ = 'V Vamsi Krishna'
__version__ = '0.1'
__url__ = ["3danim project, http://code.google.com/p/3danim",
"", "blender", "blenderartists.org"]
__email__ = ["V.Vamsi Krishna, vamsikrishna.v:gmail*com... | Python |
bl_info = {
"name": "Export 3DAnim Format(.txt)",
"author": "V.Vamsi Krishna(vkrishna)",
"version": (1, 0),
"blender": (2, 64, 0),
"api": 40000,
"location": "File > Export > 3DAnim (.txt)",
"description": "Export 3dAnim (.txt)",
"warning": "",
"category": "Import-Export"}
... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Michael Liao (askxuefeng@gmail.com)'
from os import path
from Cheetah.Template import Template
def main():
file = path.join(path.split(__file__)[0], 'home.html')
print 'Compile template %s...' % file
cc = Template.compile(source=None,... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Michael Liao (askxuefeng@gmail.com)'
import datetime
from xml.parsers.expat import ParserCreate
codes = {
0 : u'龙卷风', # tornado
1 : u'热带风暴', # tropical storm
2 : u'飓风', # hurricane
3 : u'风暴', # severe thunderstorm... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
##################################################
## DEPENDENCIES
import sys
import os
import os.path
import __builtin__
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVers... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Michael Liao (askxuefeng@gmail.com)'
from google.appengine.ext import db
class City(db.Model):
name = db.StringProperty(required=True)
aliases = db.StringListProperty(required=True)
code = db.IntegerProperty(required=True)
def f... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Michael Liao (askxuefeng@gmail.com)'
import os
import cgi
import time
import logging
import simplejson
from datetime import date
from google.appengine.api import xmpp
from google.appengine.ext import webapp
from google.appengine.ext.webapp.uti... | Python |
"""
Provides an emulator/replacement for Python's standard import system.
@@TR: Be warned that Import Hooks are in the deepest, darkest corner of Python's
jungle. If you need to start hacking with this, be prepared to get lost for a
while. Also note, this module predates the newstyle import hooks in Python 2.3
http:/... | Python |
'''
Provides an abstract Servlet baseclass for Cheetah's Template class
'''
import sys
import os.path
isWebwareInstalled = False
try:
try:
from ds.appserver.Servlet import Servlet as BaseServlet
except:
from WebKit.Servlet import Servlet as BaseServlet
isWebwareInstalled = True
if not... | Python |
#
| Python |
"Template support for Cheetah"
import sys, os, imp
from Cheetah import Compiler
import pkg_resources
def _recompile_template(package, basename, tfile, classname):
tmpl = pkg_resources.resource_string(package, "%s.tmpl" % basename)
c = Compiler.Compiler(source=tmpl, mainClassName='GenTemplate')
code = str... | Python |
from turbocheetah import cheetahsupport
TurboCheetah = cheetahsupport.TurboCheetah
__all__ = ["TurboCheetah"] | Python |
"""
@@TR: This code is pretty much unsupported.
MondoReport.py -- Batching module for Python and Cheetah.
Version 2001-Nov-18. Doesn't do much practical yet, but the companion
testMondoReport.py passes all its tests.
-Mike Orr (Iron)
TODO: BatchRecord.prev/next/prev_batches/next_batches/query, prev.query,
next.quer... | Python |
# $Id: CGITemplate.py,v 1.6 2006/01/29 02:09:59 tavis_rudd Exp $
"""A subclass of Cheetah.Template for use in CGI scripts.
Usage in a template:
#extends Cheetah.Tools.CGITemplate
#implements respond
$cgiHeaders#slurp
Usage in a template inheriting a Python class:
1. The template
#extends MyPythonClass... | Python |
# $Id: SiteHierarchy.py,v 1.1 2001/10/11 03:25:54 tavis_rudd Exp $
"""Create menus and crumbs from a site hierarchy.
You define the site hierarchy as lists/tuples. Each location in the hierarchy
is a (url, description) tuple. Each list has the base URL/text in the 0
position, and all the children coming after it. A... | Python |
"""
Nothing, but in a friendly way. Good for filling in for objects you want to
hide. If $form.f1 is a RecursiveNull object, then
$form.f1.anything["you"].might("use") will resolve to the empty string.
This module was contributed by Ian Bicking.
"""
class RecursiveNull(object):
def __getattr__(self, attr):
... | Python |
"""This package contains classes, functions, objects and packages contributed
by Cheetah users. They are not used by Cheetah itself. There is no
guarantee that this directory will be included in Cheetah releases, that
these objects will remain here forever, or that they will remain
backward-compatible.
""... | Python |
Version = '2.4.1'
VersionTuple = (2, 4, 1, 'final', 0)
MinCompatibleVersion = '2.0rc6'
MinCompatibleVersionTuple = (2, 0, 0, 'candidate', 6)
####
def convertVersionStringToTuple(s):
versionNum = [0, 0, 0]
releaseType = 'final'
releaseTypeSubNum = 0
if s.find('a')!=-1:
num, releaseTypeSubNum = ... | Python |
"""SourceReader class for Cheetah's Parser and CodeGenerator
"""
import re
import sys
EOLre = re.compile(r'[ \f\t]*(?:\r\n|\r|\n)')
EOLZre = re.compile(r'(?:\r\n|\r|\n|\Z)')
ENCODINGsearch = re.compile("coding[=:]\s*([-\w.]+)").search
class Error(Exception):
pass
class SourceReade... | Python |
import gettext
_ = gettext.gettext
class I18n(object):
def __init__(self, parser):
pass
## junk I'm playing with to test the macro framework
# def parseArgs(self, parser, startPos):
# parser.getWhiteSpace()
# args = parser.getExpression(useNameMapper=False,
# ... | Python |
#
| Python |
# $Id: ErrorCatchers.py,v 1.7 2005/01/03 19:59:07 tavis_rudd Exp $
"""ErrorCatcher class for Cheetah Templates
Meta-Data
================================================================================
Author: Tavis Rudd <tavis@damnsimple.com>
Version: $Revision: 1.7 $
Start Date: 2001/08/01
Last Revision Date: $Date:... | Python |
'''
Compiler classes for Cheetah:
ModuleCompiler aka 'Compiler'
ClassCompiler
MethodCompiler
If you are trying to grok this code start with ModuleCompiler.__init__,
ModuleCompiler.compile, and ModuleCompiler.__getattr__.
'''
import sys
import os
import os.path
from os.path import getmtime, exi... | Python |
'''
Provides several CacheStore backends for Cheetah's caching framework. The
methods provided by these classes have the same semantics as those in the
python-memcached API, except for their return values:
set(key, val, time=0)
set the value unconditionally
add(key, val, time=0)
set only if the server doesn't alr... | Python |
'''
Filters for the #filter directive as well as #transform
#filter results in output filters Cheetah's $placeholders .
#transform results in a filter on the entirety of the output
'''
import sys
# Additional entities WebSafe knows how to transform. No need to include
# '<', '>' or '&' since those wi... | Python |
# $Id: ImportHooks.py,v 1.27 2007/11/16 18:28:47 tavis_rudd Exp $
"""Provides some import hooks to allow Cheetah's .tmpl files to be imported
directly like Python .py modules.
To use these:
import Cheetah.ImportHooks
Cheetah.ImportHooks.install()
Meta-Data
========================================================... | Python |
import os.path
import string
l = ['_'] * 256
for c in string.digits + string.letters:
l[ord(c)] = c
_pathNameTransChars = string.join(l, '')
del l, c
def convertTmplPathToModuleName(tmplPath,
_pathNameTransChars=_pathNameTransChars,
splitdrive=os.pat... | Python |
'''
Provides dummy Transaction and Response classes is used by Cheetah in place
of real Webware transactions when the Template obj is not used directly as a
Webware servlet.
Warning: This may be deprecated in the future, please do not rely on any
specific DummyTransaction or DummyResponse behavior
'''
import loggin... | Python |
"""
Parser classes for Cheetah's Compiler
Classes:
ParseError( Exception )
_LowLevelParser( Cheetah.SourceReader.SourceReader ), basically a lexer
_HighLevelParser( _LowLevelParser )
Parser === _HighLevelParser (an alias)
"""
import os
import sys
import re
from re import DOTALL, MULTILINE
from types import St... | Python |
#!/usr/bin/env python
import os
import pprint
try:
from functools import reduce
except ImportError:
# Assume we have reduce
pass
from Cheetah import Parser
from Cheetah import Compiler
from Cheetah import Template
class Analyzer(Parser.Parser):
def __init__(self, *args, **kwargs):
self.calls... | Python |
try:
from ds.sys.Unspecified import Unspecified
except ImportError:
class _Unspecified:
def __repr__(self):
return 'Unspecified'
def __str__(self):
return 'Unspecified'
Unspecified = _Unspecified()
| Python |
# $Id: TemplateCmdLineIface.py,v 1.13 2006/01/10 20:34:35 tavis_rudd Exp $
"""Provides a command line interface to compiled Cheetah template modules.
Meta-Data
================================================================================
Author: Tavis Rudd <tavis@damnsimple.com>
Version: $Revision: 1.13 $
Start Da... | Python |
"""
client module for memcached (memory cache daemon)
Overview
========
See U{the MemCached homepage<http://www.danga.com/memcached>} for more about memcached.
Usage summary
=============
This should give you a feel for how this module operates::
import memcache
mc = memcache.Client(['127.0.0.1:11211'], d... | Python |
# $Id: WebInputMixin.py,v 1.10 2006/01/06 21:56:54 tavis_rudd Exp $
"""Provides helpers for Template.webInput(), a method for importing web
transaction variables in bulk. See the docstring of webInput for full details.
Meta-Data
================================================================================
Author: ... | Python |
## statprof.py
## Copyright (C) 2004,2005 Andy Wingo <wingo at pobox dot com>
## Copyright (C) 2001 Rob Browning <rlb at defaultvalue dot org>
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foun... | Python |
"""This is a copy of the htmlDecode function in Webware.
@@TR: It implemented more efficiently.
"""
from Cheetah.Utils.htmlEncode import htmlCodesReversed
def htmlDecode(s, codes=htmlCodesReversed):
""" Returns the ASCII decoded version of the given HTML string. This does
NOT remove normal HTML tags like <p... | Python |
#!/usr/bin/env python
"""
Miscellaneous functions/objects used by Cheetah but also useful standalone.
"""
import os # Used in mkdirsWithPyInitFile.
import sys # Used in die.
##################################################
## MISCELLANEOUS FUNCTIONS
def die(reason):
sys.stderr.write(reason... | Python |
"""
Indentation maker.
@@TR: this code is unsupported and largely undocumented ...
This version is based directly on code by Robert Kuzelj
<robert_kuzelj@yahoo.com> and uses his directive syntax. Some classes and
attributes have been renamed. Indentation is output via
$self._CHEETAH__indenter.indent() to prevent '_i... | Python |
"""This is a copy of the htmlEncode function in Webware.
@@TR: It implemented more efficiently.
"""
htmlCodes = [
['&', '&'],
['<', '<'],
['>', '>'],
['"', '"'],
]
htmlCodesReversed = htmlCodes[:]
htmlCodesReversed.reverse()
def htmlEncode(s, codes=htmlCodes):
""" Returns the HTML... | Python |
#
| Python |
import sys
import os.path
import copy as copyModule
from ConfigParser import ConfigParser
import re
from tokenize import Intnumber, Floatnumber, Number
from types import *
import types
import new
import time
from StringIO import StringIO # not cStringIO because of unicode support
import imp # used by S... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.