def __init__( self, connection_string=None, connection=None, adaptor=None, minconn=1, maxconn=1, poolkey=None, **args ): conn_str = re.sub(r'\s+', ' ', connection_string) if connection_string else None Dict.__init__( self, connection_string=conn_str, connection=connection, adaptor=adaptor, minconn=minconn, maxconn=maxconn, **args ) if self.connection is None: if self.adaptor is None: self.adaptor = importlib.import_module('sqlite3') elif isinstance(self.adaptor, str): self.adaptor = importlib.import_module(self.adaptor) if self.connection_string is not None: if self.adaptor.__name__ == 'psycopg2': self.pool = importlib.import_module('psycopg2.pool').ThreadedConnectionPool( self.minconn or 1, self.maxconn or 1, self.connection_string or '' ) self.connection = self.pool.getconn(key=self.poolkey) else: self.connection = self.adaptor.connect(self.connection_string or '') if 'sqlite3' in self.adaptor.__name__: self.execute("pragma foreign_keys = ON")
def __init__(self, canon=None): if type(canon)==Canon: self.canon = canon else: Dict.__init__(self, canon=Canon.from_xml(XML(fn=canon))) for book in self.canon.books: book.rexp = re.compile(book.pattern, flags=re.I+re.U)
def __init__(self, **args): Dict.__init__(self, **args) if self.id is not None: self.id = int(self.id) if self.ch is not None: self.ch = int(self.ch) if self.vs is not None: self.vs = int(self.vs)
def __init__(self, fn=None, data=None, ext=None, **args): if type(fn) == str: fn = self.normpath(fn) elif isinstance(fn, self.__class__): fn = str(fn) if ext is not None: fn = os.path.splitext(fn)[0] + ext Dict.__init__(self, fn=fn, data=data, **args)
def __init__(self, loader_class=None, loader_args={}, **Email): """set up an emailer with a particular Email config""" Dict.__init__(self, **Email) if loader_class is None: from tornado.template import Loader as loader_class if Email.get('template_path') is not None: self.loader = loader_class(Email.get('template_path'), **loader_args) if self.default_encoding is None: self.default_encoding = 'UTF-8'
def __init__(self, default=None, **namespaces): Dict.__init__(self) if default is not None: nsmap = {None:default} nsmap.update(**{k:namespaces[k] for k in namespaces.keys() if namespaces[k] != default}) else: nsmap = namespaces self.__dict__['nsmap'] = nsmap for key in namespaces: # each namespace gets its own method. named for its key self[key] = ElementMaker(namespace=namespaces[key], nsmap=nsmap) self._ = ElementMaker(namespace=default, nsmap=nsmap)
def __init__(self, url=None, local=None, parent_path=None, username=None, password=None, trust_server_cert=True, svn=None, svnmucc=None, svnlook=None, access_file=None): Dict.__init__(self, url=URL(url or ''), local=local, parent_path=parent_path, username=username, password=password, trust_server_cert=trust_server_cert, svn=svn or 'svn', svnmucc=svnmucc or 'svnmucc', svnlook=svnlook or 'svnlook') if access_file is not None: # load the access file from .svn_access_file import SVNAccessFile self.access_file = SVNAccessFile(access_file)
def __init__(self, path, ingpath=None, outpath=None, errpath=None, **args): """ path [REQ'D] = the filesystem path to the queue directory. Created if it doesn't exist. ingpath = the 'processing' directory, defaults to path+"/ING". outpath = the 'finished' directory, defaults to path+"/OUT". errpath = the 'error' directory, defaults to path+'/ERR'. **args = any other arguments you want to define for your queue class. """ if not os.path.exists(path): os.makedirs(path) if ingpath is None: ingpath = path + '/ING' if not os.path.exists(ingpath): os.makedirs(ingpath) if outpath is None: outpath = path + '/OUT' if not os.path.exists(outpath): os.makedirs(outpath) if errpath is None: errpath = path + '/ERR' if not os.path.exists(errpath): os.makedirs(errpath) Dict.__init__(self, path=path, ingpath=ingpath, outpath=outpath, errpath=errpath, **args)
def __init__(self, pattern, patterns=Patterns, **args): """Take a given pattern and return a Route object, which is used by RouteMap to create a route map. pattern: a url pattern, with named args in brackets: {var} name can take pattern indicator: {var:int} defaults to {var:slug} args: give default values for other variables handler: the name of the handler action: the name of the handler method to use Example: >>> routes = [Route("/{handler:slug}/"), ... Route("/users/{username:slug}/", handler='users')] >>> for route in routes: print(route.pattern, "(handler=%s)" % route.handler) ^/(?P<handler>[\w\$\-\_\.\+\!\*\(\)\, %%@]+)/?$ (handler=None) ^/users/(?P<username>[\w\$\-\_\.\+\!\*\(\)\, %%@]+)/?$ (handler=users) """ Dict.__init__(self, **args) self.pattern = self.parse(pattern, patterns=patterns) self.regex = self.compile(self.pattern)
def __init__(self, fn=None, mode='r', compression=ZIP_DEFLATED, **args): Dict.__init__(self, fn=fn, mode=mode, compression=compression, **args) if fn is not None: self.zipfile = ZipFile(self.fn, mode=mode, compression=compression)
def __init__(self, db, **args): self.__dict__['db'] = db Dict.__init__(self, **args)
def __init__(self, fn=None, data=None, **args): if type(fn)==str: fn=fn.strip().replace('\\ ', ' ') Dict.__init__(self, fn=fn, data=data, **args)
def __init__(self, template_path, **smtp): Dict.__init__(self, template_path=template_path, smtp=Dict(**smtp)) self.template_loader = tornado.template.Loader(template_path)