This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import pprint | |
import re | |
test_text = { | |
'test_1' : { | |
'description' : "no change", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Meta(type): | |
def __new__(cls, clsname, bases, dct): | |
print "__new__" | |
print cls | |
print clsname | |
print bases | |
print dct | |
attrs = dct.pop('_pairs') | |
for v, k in attrs: | |
setattr(cls, k, v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filenames_has_directory(filenames, directory): | |
"""if this appears to be a directory, great | |
treat directories as / instead of os.path, because we write with '/' | |
""" | |
if directory[-1] != '/': | |
directory = directory + '/' | |
directory_len = len(directory) | |
for fname in filenames: | |
if fname[:directory_len] == directory: | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_application(settings, parent_registry): | |
""" WSGI application for rendering the debug toolbar.""" | |
... | |
config.add_route('debugtoolbar.request.sql_csv', '/{request_id}/sql.csv') | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
log = logging.getLogger(__name__) | |
import pyramid.renderers | |
from pyramid.path import caller_package | |
from ... import lib | |
def render(renderer_name, value, request=None, package=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
session.framework = beaker | |
session.key = SessionID | |
session.type = file | |
session.data_dir = %(here)s/data/ssessions/data | |
session.lock_dir = %(here)s/data/ssessions/lock | |
session.secret = 123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
## a list of available tabs | |
tabs_available = ['one', 'two', 'three'] | |
## create an 'empty' dict | |
tab_panes = dict([(i,'') for i in tabs_available]) | |
## what should be our selected tab | |
if request.tab_active and request.tab_active in tabs_available : | |
tab_selected = request.tab_active |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bleach | |
sample_text = """<button class="navbar-toggle collapsed" data-target=".navbar-collapse" data-toggle="collapse" type="button"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button>""" | |
tags_ok = [ 'button', 'span', ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import * | |
from sqlalchemy.orm import * | |
from sqlalchemy.ext.declarative import declarative_base | |
import sqlalchemy.exc | |
import base64 | |
Base = declarative_base() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from sqlalchemy import event | |
from sqlalchemy.engine import Engine as SaEngine | |
from sqlalchemy.orm import Session as SaSession | |
logger = logging.getLogger("sqlalchemy.engine.base.Engine") | |
@event.listens_for(SaEngine, "before_cursor_execute") | |
def before_cursor_execute(conn, cursor, statement, |
OlderNewer