Пример #1
0
    def test_proxy(self):
        class A(object):
            def foo(self):
                return 'foo'

        a = Proxy()
        def raise_error():
            a.foo()
        self.assertRaises(AttributeError, raise_error)

        a.initialize(A())
        self.assertEqual(a.foo(), 'foo')
Пример #2
0
    def test_proxy(self):
        class A(object):
            def foo(self):
                return 'foo'

        a = Proxy()

        def raise_error():
            a.foo()

        self.assertRaises(AttributeError, raise_error)

        a.initialize(A())
        self.assertEqual(a.foo(), 'foo')
Пример #3
0
    def test_proxy_database(self):
        database_proxy = Proxy()

        class DummyModel(Model):
            test_field = CharField()
            class Meta:
                database = database_proxy

        # Un-initialized will raise an AttributeError.
        self.assertRaises(AttributeError, DummyModel.create_table)

        # Initialize the object.
        database_proxy.initialize(SqliteDatabase(':memory:'))

        # Do some queries, verify it is working.
        DummyModel.create_table()
        DummyModel.create(test_field='foo')
        self.assertEqual(DummyModel.get().test_field, 'foo')
        DummyModel.drop_table()
Пример #4
0
    def test_proxy_database(self):
        database_proxy = Proxy()

        class DummyModel(Model):
            test_field = CharField()

            class Meta:
                database = database_proxy

        # Un-initialized will raise an AttributeError.
        self.assertRaises(AttributeError, DummyModel.create_table)

        # Initialize the object.
        database_proxy.initialize(SqliteDatabase(':memory:'))

        # Do some queries, verify it is working.
        DummyModel.create_table()
        DummyModel.create(test_field='foo')
        self.assertEqual(DummyModel.get().test_field, 'foo')
        DummyModel.drop_table()
Пример #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from peewee import *
from playhouse.proxy import Proxy
import logging, setproctitle, argparse, time, re, codecs, traceback, os, sys, random
from mnformats import mnjson
from mnformats.xlsxwrapper import XlsxWrapper

golddb_proxy = Proxy()


class UnknownFieldType(object):
    pass


class BaseModel(Model):
    class Meta:
        database = golddb_proxy


class Lemma(BaseModel):
    lemma = CharField(max_length=128)

    class Meta:
        db_table = 'lemma'


class Sent(BaseModel):
    mtext = TextField()
    sid = CharField(max_length=128)
Пример #6
0
Contains autogenerated classes (via :py:mod:`peewee`) that mirrors the structure of the database,
and higher-level methods for accessing the database to retrieve concept labels, and to insert
LMs and CMs.

.. moduleauthor:: Jisup <*****@*****.**>
"""
from peewee import *
from playhouse.proxy import Proxy
import sys, os
import re
import cPickle as pickle
from collections import Counter
import logging

gmrdatabase_proxy = Proxy()


class UnknownFieldType(object):
    pass


class BaseModel(Model):
    class Meta:
        database = gmrdatabase_proxy


class Admin(BaseModel):
    comments = TextField(null=True)
    date = DateField()
    owner = CharField(max_length=4)
Пример #7
0
Contains classes autogenerated via peewee that mirror the structure of the database, as well
as higher-level routines for inserting LMs into the database.

.. moduleauthor:: Jisup <*****@*****.**>
"""

from peewee import *
from playhouse.proxy import Proxy
import json, re, sys, logging, pprint, traceback, os, codecs, setproctitle
import MySQLdb
from metanetrdf import MetaNetRepository
from mnformats import mnjson
import argparse
from multiprocessing import Pool

mnlmdatabase_proxy = Proxy()

class UnknownFieldType(object):
    pass

class BaseModel(Model):
    class Meta:
        database = mnlmdatabase_proxy

class Lm(BaseModel):
    cm = CharField(null=True)
    cxn = CharField(null=True)
    name = CharField(null=True)
    nickname = CharField(null=True)
    sourcelemma = CharField(null=True)
    sourceframe = CharField(null=True)
Пример #8
0
def route(path, **options):
    def outer_wrap(f):
        @wraps(f)
        def inner_wrap(*args, **kwargs):
            r = f(*args, **kwargs)
            return Response(dumps(r), content_type="application/json")
        endpoint = options.pop('endpoint', None)
        app.add_url_rule(path, endpoint, inner_wrap, **options)
    return outer_wrap


@route("/")
def index():
    return "Tasker v-" + config.version

db = Proxy()
db.initialize(peewee.SqliteDatabase(config.database_name,
                                    threadlocals=True))
# 4 view: list
#         dependency graph
#         timeline
#         todo per personns
class HouseTask(peewee.Model):
    floor = peewee.TextField(default="RC")
    room = peewee.TextField(default="None")
    name = peewee.TextField(default="")
    price = peewee.IntegerField(default=0)
    start_date = peewee.DateTimeField(default=None, null=True)
    duration = peewee.IntegerField(default=1)
    valid = peewee.BooleanField(default=False)
    description = peewee.TextField(default="")
Пример #9
0
# Written by Jason Sydes and Peter Batzel.
# Advised by Thomas Desvignes.

# Python 3 imports
from __future__ import absolute_import
from __future__ import division

# peewee - python ORM
from peewee import *
from playhouse.proxy import Proxy

# For peewee datetimes
import datetime

# The peewee database proxy
DB_PROXY = Proxy()

###############
### Classes ###
###############


class SequenceDB(Model):
    """Database table to cache the sequence database used in the genomic
    alignment.

    For example, if using BBMap, this will be a BBMap database.
    """

    name = CharField()
    created_at = DateTimeField(default=datetime.datetime.now, null=False)