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 sqlalchemy as sa | |
import sqlalchemy.orm as orm | |
from sqlalchemy.orm import class_mapper, exc as orm_exc | |
def query_property(db_session, query_cls=None): | |
class query(object): | |
def __get__(s, instance, owner): | |
try: | |
mapper = class_mapper(owner) | |
if mapper: |
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 sys | |
import logging | |
logging.basicConfig() | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
handler = logging.FileHandler("bank.log", ) | |
handler.setLevel(logging.ERROR) | |
logger.addHandler(handler) |
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 | |
import tulip | |
logging.basicConfig(level=logging.DEBUG) | |
class EchoProtocol(tulip.Protocol): | |
def connection_made(self, transport): | |
self.transport = transport | |
logging.info("connection_made: {0}".format(transport)) |
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
# deb http://packages.linuxmint.com/ maya main upstream import | |
# deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse | |
# deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse | |
# deb http://security.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse | |
# deb http://archive.canonical.com/ubuntu/ precise partner | |
# deb http://packages.medibuntu.org/ precise free non-free | |
# deb http://packages.linuxmint.com/ nadia main upstream import | |
# deb http://archive.ubuntu.com/ubuntu/ quantal main restricted universe multiverse | |
# deb http://archive.ubuntu.com/ubuntu/ quantal-updates main restricted universe multiverse |
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 os | |
import distlib.wheel | |
from paver.easy import * | |
here=os.path.dirname(__file__) | |
options( | |
here=here, | |
wheeldir=os.path.join(here, "dists"), | |
) |
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 coverage | |
here = os.path.dirname(__file__) | |
@task | |
def test(options): | |
""" run tests | |
""" | |
cov = coverage.coverage(source=options.test['source']) |
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
[app:admin] | |
paste.app_factory = your.app.admin:main | |
[app:site] | |
paste.app_factory = your.app.user:main | |
[server:admin] | |
use = egg:waitress | |
port = 8080 |
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
""" | |
http://ja.wikipedia.org/wiki/トポロジカルソート | |
""" | |
nodes = [ | |
7, | |
5, | |
3, | |
11, | |
8, |
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
@task | |
def freeze(): | |
dist_path = distlib.database.DistributionPath() | |
print() | |
print('.. contents::') | |
print() | |
for d in dist_path.get_distributions(): | |
print() | |
print("{dist.name} = {dist.version}".format(dist=d)) | |
print("=" * 80) |
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
# In mymodule.py | |
from zope.proxy import ProxyBase, setProxiedObject | |
hoge = ProxyBase(None) | |
def setup_hoge(): | |
setProxiedObject(hoge, 'hoge') |