/home/fresvfqn/waterdamagerestorationandrepairsmithtown.com/Compressed/bsddb.tar
dbutils.pyo000064400000003133150536075210006747 0ustar00�
{fc@soddlmZddlZejddkZer@ddUnddlZddZdZdZ
d	�ZdS(
i����(tsleepNiisfrom . import dbg�?i�gn��!	@cOs�t}|jdd�}d|kr.|d=nx�tr�y|||�SWq1tjk
r�trutjd|�nt|�|d9}|tkr�t}n|d8}|dkr��q�q1Xq1WdS(s?DeadlockWrap(function, *_args, **_kwargs) - automatically retries
    function in case of a database deadlock.

    This is a function intended to be used to wrap database calls such
    that they perform retrys with exponentially backing off sleeps in
    between when a DBLockDeadlockError exception is raised.

    A 'max_retries' parameter may optionally be passed to prevent it
    from retrying forever (in which case the exception will be reraised).

        d = DB(...)
        d.open(...)
        DeadlockWrap(d.put, "foo", data="bar")  # set key "foo" to "bar"
    tmax_retriesi����s%dbutils.DeadlockWrap: sleeping %1.3f
iiN(	t_deadlock_MinSleepTimetgettTruetdbtDBLockDeadlockErrort_deadlock_VerboseFiletwritet_sleept_deadlock_MaxSleepTime(tfunctiont_argst_kwargst	sleeptimeR((s%/usr/lib64/python2.7/bsddb/dbutils.pytDeadlockWrap/s$
	

	
(ttimeRR	tsystversion_infotabsolute_importRRR
tNoneRR(((s%/usr/lib64/python2.7/bsddb/dbutils.pyt<module>s
dbutils.py000064400000005624150536075210006577 0ustar00#------------------------------------------------------------------------
#
# Copyright (C) 2000 Autonomous Zone Industries
#
# License:      This is free software.  You may use this software for any
#               purpose including modification/redistribution, so long as
#               this header remains intact and that you do not claim any
#               rights of ownership or authorship of this software.  This
#               software has been tested, but no warranty is expressed or
#               implied.
#
# Author: Gregory P. Smith <greg@krypto.org>
#
# Note: I don't know how useful this is in reality since when a
#       DBLockDeadlockError happens the current transaction is supposed to be
#       aborted.  If it doesn't then when the operation is attempted again
#       the deadlock is still happening...
#       --Robin
#
#------------------------------------------------------------------------


#
# import the time.sleep function in a namespace safe way to allow
# "from bsddb.dbutils import *"
#
from time import sleep as _sleep

import sys
absolute_import = (sys.version_info[0] >= 3)
if absolute_import :
    # Because this syntaxis is not valid before Python 2.5
    exec("from . import db")
else :
    import db

# always sleep at least N seconds between retrys
_deadlock_MinSleepTime = 1.0/128
# never sleep more than N seconds between retrys
_deadlock_MaxSleepTime = 3.14159

# Assign a file object to this for a "sleeping" message to be written to it
# each retry
_deadlock_VerboseFile = None


def DeadlockWrap(function, *_args, **_kwargs):
    """DeadlockWrap(function, *_args, **_kwargs) - automatically retries
    function in case of a database deadlock.

    This is a function intended to be used to wrap database calls such
    that they perform retrys with exponentially backing off sleeps in
    between when a DBLockDeadlockError exception is raised.

    A 'max_retries' parameter may optionally be passed to prevent it
    from retrying forever (in which case the exception will be reraised).

        d = DB(...)
        d.open(...)
        DeadlockWrap(d.put, "foo", data="bar")  # set key "foo" to "bar"
    """
    sleeptime = _deadlock_MinSleepTime
    max_retries = _kwargs.get('max_retries', -1)
    if 'max_retries' in _kwargs:
        del _kwargs['max_retries']
    while True:
        try:
            return function(*_args, **_kwargs)
        except db.DBLockDeadlockError:
            if _deadlock_VerboseFile:
                _deadlock_VerboseFile.write(
                    'dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
            _sleep(sleeptime)
            # exponential backoff in the sleep time
            sleeptime *= 2
            if sleeptime > _deadlock_MaxSleepTime:
                sleeptime = _deadlock_MaxSleepTime
            max_retries -= 1
            if max_retries == -1:
                raise


#------------------------------------------------------------------------
dbshelve.pyo000064400000031336150536075210007103 0ustar00�
{fc@s�dZddlZejddkZer6ddUnddlZejddkrdddlZnzejdkr�ddlZn\ddlZej�Zej	�z)ej
dd	d
de�ddlZWdej�X[ej
Z
d�Zejdkrdd
lmZnddlZejZejdejddd�Zdejfd��YZdefd��YZddd��YZdS(sNManage shelves of pickled objects using bsddb database files for the
storage.
i����Niisfrom . import dbiitignoretmessages1the cPickle module has been removed in Python 3.0tcategorycCstj|d|�S(Ntprotocol(tcPickletdumps(tobjectR((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt_dumpsDs(t	DictMixini�cCs�t|�td�kr�|}|dkr6tj}q�|dkrKd}q�|dkrctj}q�|dkr{tj}q�|dkr�tjtjB}q�tjd�nt|�}|j|||||�|S(	s(
    A simple factory function for compatibility with the standard
    shleve.py module.  It can be used like this, where key is a string
    and data is a pickleable object:

        from bsddb import dbshelve
        db = dbshelve.open(filename)

        db[key] = data

        db.close()
    ttrtrwitwtctnsJflags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags(ttypetdbt	DB_RDONLYt	DB_CREATEtDB_TRUNCATEtDBErrortDBShelftopen(tfilenametflagstmodetfiletypetdbenvtdbnametsflagtd((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRPs 	t
DBShelveErrorcBseZRS((t__name__t
__module__(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRssRcBseZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dd�Zej
dkrud�Znd�Zd
�Zd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd�Zddd�Zddd�Zddd�Zdd�ZRS(s�A shelf to hold pickled objects, built upon a bsddb DB object.  It
    automatically pickles/unpickles data objects going to/from the DB.
    cCs:tj|�|_t|_tr-t|_n	d|_dS(Ni(RtDBtTruet_closedtHIGHEST_PROTOCOLR(tselfR((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__init__zs
	cCs|j�dS(N(tclose(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__del__�scCst|j|�S(sTMany methods we can just pass through to the DB object.
        (See below)
        (tgetattrR(R&tname((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__getattr__�scCs
t|j�S(N(tlenR(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__len__�scCs|j|}tj|�S(N(RRtloads(R&tkeytdata((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__getitem__�s
cCs#t||j�}||j|<dS(N(RRR(R&R0tvalueR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__setitem__�scCs|j|=dS(N(R(R&R0((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__delitem__�scCs-|dk	r|jj|�S|jj�SdS(N(tNoneRtkeys(R&ttxn((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR7�siiccs#x|jj�D]}|VqWdS(N(RR7(R&tk((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__iter__�scOs |jj||�t|_dS(N(RRtFalseR$(R&targstkwargs((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�scOs |jj||�t|_dS(N(RR(R#R$(R&R<R=((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR(�scCs1|jrdt|�Stt|j���SdS(Ns<DBShelf @ 0x%x - closed>(R$tidtreprtdictt	iteritems(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__repr__�s	cCsm|dk	r!|jj|�}n|jj�}g}x0|D](\}}|j|tj|�f�q=W|S(N(R6RtitemstappendRR/(R&R8RCtnewitemsR9tv((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRC�s cCs@|dk	r!|jj|�}n|jj�}ttj|�S(N(R6RtvaluestmapRR/(R&R8RG((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRG�scCs%t||j�}|jj||�S(N(RRRRD(R&R3R8R1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__append�scCs5|j�tjkr(|j|d|�Std�dS(NR8sOappend() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO(tget_typeRtDB_RECNOt_DBShelf__appendR(R&R3R8((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRD�sicCs"|d�}|jj|||�S(NcSsYtjddks"t|t�r4tj|�}ntjt|d��}|||�S(Niis	iso8859-1(tsystversion_infot
isinstancetbytesRR/(tpriKeytpriDatatrealCallbackR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt_shelf_callback�s"(Rt	associate(R&tsecondaryDBtcallbackRRT((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRU�scOsK|jj||�}ytj|�SWntttjfk
rF|SXdS(N(RtgetRR/tEOFErrort	TypeErrortUnpicklingError(R&R<tkwR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRX�s
cCs:t||j�}|jj||||�}tj|�S(N(RRRRXRR/(R&R0R3R8RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_both�scCs+t|jj||��}|j|_|S(N(t
DBShelfCursorRtcursorR(R&R8RR
((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR_scCs+t||j�}|jj||||�S(N(RRRtput(R&R0R3R8RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR`scCs
t�dS(N(tNotImplementedError(R&t
cursorListR((s&/usr/lib64/python2.7/bsddb/dbshelve.pytjoinsN(ii(R R!t__doc__R6R'R)R,R.R2R4R5R7RMRNR:RR(RBRCRGRLRDRURXR]R_R`Rc(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRvs0			
							
	R^cBseZdZd�Zd�Zd�Zdd�Zdd�Zd�Zd�Z	d	�Z
d
�Zdd�Zdd�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZeZd�ZRS(s
    cCs
||_dS(N(tdbc(R&R_((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR'!scCs|j�dS(N(R((R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR)$scCst|j|�S(sHSome methods we can just pass through to the cursor object.  (See below)(R*Re(R&R+((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR,(sicCs(t|jj|��}|j|_|S(N(R^RetdupR(R&RR
((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRf/scCs(t||j�}|jj|||�S(N(RRReR`(R&R0R3RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR`5scGs-t|�}t|d|�}||�dS(Nsget_%d(R-R*(R&R<tcounttmethod((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRX:scCs|jj|�}|j|�S(N(ReRXt_extract(R&Rtrec((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_1?scCs"|jj||�}|j|�S(N(ReRXRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_2CscCs4t||j�}|jj||�}|j|�S(N(RRReRXRi(R&R0R3RR1Rj((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_3GscCs|j|tjB�S(N(RkRt
DB_CURRENT(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytcurrentMR	cCs|j|tjB�S(N(RkRtDB_FIRST(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytfirstNR	cCs|j|tjB�S(N(RkRtDB_LAST(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytlastOR	cCs|j|tjB�S(N(RkRtDB_NEXT(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytnextPR	cCs|j|tjB�S(N(RkRtDB_PREV(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytprevQR	cCs|j|tjB�S(N(RkRt
DB_CONSUME(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytconsumeRR	cCs|j|tjB�S(N(RkRtDB_NEXT_DUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytnext_dupSR	cCs|j|tjB�S(N(RkRt
DB_NEXT_NODUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt
next_nodupTR	cCs|j|tjB�S(N(RkRt
DB_PREV_NODUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt
prev_nodupUR	cCs4t||j�}|jj||�}|j|�S(N(RRReR]Ri(R&R0R3RR1Rj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR]XscCs"|jj||�}|j|�S(N(RetsetRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�^scCs"|jj||�}|j|�S(N(Ret	set_rangeRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�bscCs"|jj||�}|j|�S(N(Ret	set_recnoRi(R&trecnoRRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�fscCsq|dkrdS|\}}tjddks>t|t�rQ|tj|�fS|tjt|d��fSdS(Niis	iso8859-1(R6RMRNRORPRR/(R&RjR0R1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRils"(R R!RdR'R)R,RfR`RXRkRlRmRoRqRsRuRwRyR{R}RR]R�R�R�tset_bothRi(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR^s2							(ii(ii((RdRMRNtabsolute_importRRtwarningstcatch_warningsRt	__enter__tfilterwarningstDeprecationWarningt__exit__R%RtUserDictRtMutableMappingtcollectionsRtDB_HASHR6RRRRR^(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt<module>s<
			"�dbtables.py000064400000074222150536075210006711 0ustar00#-----------------------------------------------------------------------
#
# Copyright (C) 2000, 2001 by Autonomous Zone Industries
# Copyright (C) 2002 Gregory P. Smith
#
# License:      This is free software.  You may use this software for any
#               purpose including modification/redistribution, so long as
#               this header remains intact and that you do not claim any
#               rights of ownership or authorship of this software.  This
#               software has been tested, but no warranty is expressed or
#               implied.
#
#   --  Gregory P. Smith <greg@krypto.org>

# This provides a simple database table interface built on top of
# the Python Berkeley DB 3 interface.
#
_cvsid = '$Id$'

import re
import sys
import copy
import random
import struct


if sys.version_info[0] >= 3 :
    import pickle
else :
    if sys.version_info < (2, 6) :
        import cPickle as pickle
    else :
        # When we drop support for python 2.4
        # we could use: (in 2.5 we need a __future__ statement)
        #
        #    with warnings.catch_warnings():
        #        warnings.filterwarnings(...)
        #        ...
        #
        # We can not use "with" as is, because it would be invalid syntax
        # in python 2.4 and (with no __future__) 2.5.
        # Here we simulate "with" following PEP 343 :
        import warnings
        w = warnings.catch_warnings()
        w.__enter__()
        try :
            warnings.filterwarnings('ignore',
                message='the cPickle module has been removed in Python 3.0',
                category=DeprecationWarning)
            import cPickle as pickle
        finally :
            w.__exit__()
        del w

try:
    # For Pythons w/distutils pybsddb
    from bsddb3 import db
except ImportError:
    # For Python 2.3
    from bsddb import db

class TableDBError(StandardError):
    pass
class TableAlreadyExists(TableDBError):
    pass


class Cond:
    """This condition matches everything"""
    def __call__(self, s):
        return 1

class ExactCond(Cond):
    """Acts as an exact match condition function"""
    def __init__(self, strtomatch):
        self.strtomatch = strtomatch
    def __call__(self, s):
        return s == self.strtomatch

class PrefixCond(Cond):
    """Acts as a condition function for matching a string prefix"""
    def __init__(self, prefix):
        self.prefix = prefix
    def __call__(self, s):
        return s[:len(self.prefix)] == self.prefix

class PostfixCond(Cond):
    """Acts as a condition function for matching a string postfix"""
    def __init__(self, postfix):
        self.postfix = postfix
    def __call__(self, s):
        return s[-len(self.postfix):] == self.postfix

class LikeCond(Cond):
    """
    Acts as a function that will match using an SQL 'LIKE' style
    string.  Case insensitive and % signs are wild cards.
    This isn't perfect but it should work for the simple common cases.
    """
    def __init__(self, likestr, re_flags=re.IGNORECASE):
        # escape python re characters
        chars_to_escape = '.*+()[]?'
        for char in chars_to_escape :
            likestr = likestr.replace(char, '\\'+char)
        # convert %s to wildcards
        self.likestr = likestr.replace('%', '.*')
        self.re = re.compile('^'+self.likestr+'$', re_flags)
    def __call__(self, s):
        return self.re.match(s)

#
# keys used to store database metadata
#
_table_names_key = '__TABLE_NAMES__'  # list of the tables in this db
_columns = '._COLUMNS__'  # table_name+this key contains a list of columns

def _columns_key(table):
    return table + _columns

#
# these keys are found within table sub databases
#
_data =  '._DATA_.'  # this+column+this+rowid key contains table data
_rowid = '._ROWID_.' # this+rowid+this key contains a unique entry for each
                     # row in the table.  (no data is stored)
_rowid_str_len = 8   # length in bytes of the unique rowid strings


def _data_key(table, col, rowid):
    return table + _data + col + _data + rowid

def _search_col_data_key(table, col):
    return table + _data + col + _data

def _search_all_data_key(table):
    return table + _data

def _rowid_key(table, rowid):
    return table + _rowid + rowid + _rowid

def _search_rowid_key(table):
    return table + _rowid

def contains_metastrings(s) :
    """Verify that the given string does not contain any
    metadata strings that might interfere with dbtables database operation.
    """
    if (s.find(_table_names_key) >= 0 or
        s.find(_columns) >= 0 or
        s.find(_data) >= 0 or
        s.find(_rowid) >= 0):
        # Then
        return 1
    else:
        return 0


class bsdTableDB :
    def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600,
                 recover=0, dbflags=0):
        """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600)

        Open database name in the dbhome Berkeley DB directory.
        Use keyword arguments when calling this constructor.
        """
        self.db = None
        myflags = db.DB_THREAD
        if create:
            myflags |= db.DB_CREATE
        flagsforenv = (db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_INIT_LOG |
                       db.DB_INIT_TXN | dbflags)
        # DB_AUTO_COMMIT isn't a valid flag for env.open()
        try:
            dbflags |= db.DB_AUTO_COMMIT
        except AttributeError:
            pass
        if recover:
            flagsforenv = flagsforenv | db.DB_RECOVER
        self.env = db.DBEnv()
        # enable auto deadlock avoidance
        self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
        self.env.open(dbhome, myflags | flagsforenv)
        if truncate:
            myflags |= db.DB_TRUNCATE
        self.db = db.DB(self.env)
        # this code relies on DBCursor.set* methods to raise exceptions
        # rather than returning None
        self.db.set_get_returns_none(1)
        # allow duplicate entries [warning: be careful w/ metadata]
        self.db.set_flags(db.DB_DUP)
        self.db.open(filename, db.DB_BTREE, dbflags | myflags, mode)
        self.dbfilename = filename

        if sys.version_info[0] >= 3 :
            class cursor_py3k(object) :
                def __init__(self, dbcursor) :
                    self._dbcursor = dbcursor

                def close(self) :
                    return self._dbcursor.close()

                def set_range(self, search) :
                    v = self._dbcursor.set_range(bytes(search, "iso8859-1"))
                    if v is not None :
                        v = (v[0].decode("iso8859-1"),
                                v[1].decode("iso8859-1"))
                    return v

                def __next__(self) :
                    v = getattr(self._dbcursor, "next")()
                    if v is not None :
                        v = (v[0].decode("iso8859-1"),
                                v[1].decode("iso8859-1"))
                    return v

            class db_py3k(object) :
                def __init__(self, db) :
                    self._db = db

                def cursor(self, txn=None) :
                    return cursor_py3k(self._db.cursor(txn=txn))

                def has_key(self, key, txn=None) :
                    return getattr(self._db,"has_key")(bytes(key, "iso8859-1"),
                            txn=txn)

                def put(self, key, value, flags=0, txn=None) :
                    key = bytes(key, "iso8859-1")
                    if value is not None :
                        value = bytes(value, "iso8859-1")
                    return self._db.put(key, value, flags=flags, txn=txn)

                def put_bytes(self, key, value, txn=None) :
                    key = bytes(key, "iso8859-1")
                    return self._db.put(key, value, txn=txn)

                def get(self, key, txn=None, flags=0) :
                    key = bytes(key, "iso8859-1")
                    v = self._db.get(key, txn=txn, flags=flags)
                    if v is not None :
                        v = v.decode("iso8859-1")
                    return v

                def get_bytes(self, key, txn=None, flags=0) :
                    key = bytes(key, "iso8859-1")
                    return self._db.get(key, txn=txn, flags=flags)

                def delete(self, key, txn=None) :
                    key = bytes(key, "iso8859-1")
                    return self._db.delete(key, txn=txn)

                def close (self) :
                    return self._db.close()

            self.db = db_py3k(self.db)
        else :  # Python 2.x
            pass

        # Initialize the table names list if this is a new database
        txn = self.env.txn_begin()
        try:
            if not getattr(self.db, "has_key")(_table_names_key, txn):
                getattr(self.db, "put_bytes", self.db.put) \
                        (_table_names_key, pickle.dumps([], 1), txn=txn)
        # Yes, bare except
        except:
            txn.abort()
            raise
        else:
            txn.commit()
        # TODO verify more of the database's metadata?
        self.__tablecolumns = {}

    def __del__(self):
        self.close()

    def close(self):
        if self.db is not None:
            self.db.close()
            self.db = None
        if self.env is not None:
            self.env.close()
            self.env = None

    def checkpoint(self, mins=0):
        self.env.txn_checkpoint(mins)

    def sync(self):
        self.db.sync()

    def _db_print(self) :
        """Print the database to stdout for debugging"""
        print "******** Printing raw database for debugging ********"
        cur = self.db.cursor()
        try:
            key, data = cur.first()
            while 1:
                print repr({key: data})
                next = cur.next()
                if next:
                    key, data = next
                else:
                    cur.close()
                    return
        except db.DBNotFoundError:
            cur.close()


    def CreateTable(self, table, columns):
        """CreateTable(table, columns) - Create a new table in the database.

        raises TableDBError if it already exists or for other DB errors.
        """
        assert isinstance(columns, list)

        txn = None
        try:
            # checking sanity of the table and column names here on
            # table creation will prevent problems elsewhere.
            if contains_metastrings(table):
                raise ValueError(
                    "bad table name: contains reserved metastrings")
            for column in columns :
                if contains_metastrings(column):
                    raise ValueError(
                        "bad column name: contains reserved metastrings")

            columnlist_key = _columns_key(table)
            if getattr(self.db, "has_key")(columnlist_key):
                raise TableAlreadyExists, "table already exists"

            txn = self.env.txn_begin()
            # store the table's column info
            getattr(self.db, "put_bytes", self.db.put)(columnlist_key,
                    pickle.dumps(columns, 1), txn=txn)

            # add the table name to the tablelist
            tablelist = pickle.loads(getattr(self.db, "get_bytes",
                self.db.get) (_table_names_key, txn=txn, flags=db.DB_RMW))
            tablelist.append(table)
            # delete 1st, in case we opened with DB_DUP
            self.db.delete(_table_names_key, txn=txn)
            getattr(self.db, "put_bytes", self.db.put)(_table_names_key,
                    pickle.dumps(tablelist, 1), txn=txn)

            txn.commit()
            txn = None
        except db.DBError, dberror:
            if txn:
                txn.abort()
            if sys.version_info < (2, 6) :
                raise TableDBError, dberror[1]
            else :
                raise TableDBError, dberror.args[1]


    def ListTableColumns(self, table):
        """Return a list of columns in the given table.
        [] if the table doesn't exist.
        """
        assert isinstance(table, str)
        if contains_metastrings(table):
            raise ValueError, "bad table name: contains reserved metastrings"

        columnlist_key = _columns_key(table)
        if not getattr(self.db, "has_key")(columnlist_key):
            return []
        pickledcolumnlist = getattr(self.db, "get_bytes",
                self.db.get)(columnlist_key)
        if pickledcolumnlist:
            return pickle.loads(pickledcolumnlist)
        else:
            return []

    def ListTables(self):
        """Return a list of tables in this database."""
        pickledtablelist = self.db.get_get(_table_names_key)
        if pickledtablelist:
            return pickle.loads(pickledtablelist)
        else:
            return []

    def CreateOrExtendTable(self, table, columns):
        """CreateOrExtendTable(table, columns)

        Create a new table in the database.

        If a table of this name already exists, extend it to have any
        additional columns present in the given list as well as
        all of its current columns.
        """
        assert isinstance(columns, list)

        try:
            self.CreateTable(table, columns)
        except TableAlreadyExists:
            # the table already existed, add any new columns
            txn = None
            try:
                columnlist_key = _columns_key(table)
                txn = self.env.txn_begin()

                # load the current column list
                oldcolumnlist = pickle.loads(
                    getattr(self.db, "get_bytes",
                        self.db.get)(columnlist_key, txn=txn, flags=db.DB_RMW))
                # create a hash table for fast lookups of column names in the
                # loop below
                oldcolumnhash = {}
                for c in oldcolumnlist:
                    oldcolumnhash[c] = c

                # create a new column list containing both the old and new
                # column names
                newcolumnlist = copy.copy(oldcolumnlist)
                for c in columns:
                    if not c in oldcolumnhash:
                        newcolumnlist.append(c)

                # store the table's new extended column list
                if newcolumnlist != oldcolumnlist :
                    # delete the old one first since we opened with DB_DUP
                    self.db.delete(columnlist_key, txn=txn)
                    getattr(self.db, "put_bytes", self.db.put)(columnlist_key,
                                pickle.dumps(newcolumnlist, 1),
                                txn=txn)

                txn.commit()
                txn = None

                self.__load_column_info(table)
            except db.DBError, dberror:
                if txn:
                    txn.abort()
                if sys.version_info < (2, 6) :
                    raise TableDBError, dberror[1]
                else :
                    raise TableDBError, dberror.args[1]


    def __load_column_info(self, table) :
        """initialize the self.__tablecolumns dict"""
        # check the column names
        try:
            tcolpickles = getattr(self.db, "get_bytes",
                    self.db.get)(_columns_key(table))
        except db.DBNotFoundError:
            raise TableDBError, "unknown table: %r" % (table,)
        if not tcolpickles:
            raise TableDBError, "unknown table: %r" % (table,)
        self.__tablecolumns[table] = pickle.loads(tcolpickles)

    def __new_rowid(self, table, txn) :
        """Create a new unique row identifier"""
        unique = 0
        while not unique:
            # Generate a random 64-bit row ID string
            # (note: might have <64 bits of true randomness
            # but it's plenty for our database id needs!)
            blist = []
            for x in xrange(_rowid_str_len):
                blist.append(random.randint(0,255))
            newid = struct.pack('B'*_rowid_str_len, *blist)

            if sys.version_info[0] >= 3 :
                newid = newid.decode("iso8859-1")  # 8 bits

            # Guarantee uniqueness by adding this key to the database
            try:
                self.db.put(_rowid_key(table, newid), None, txn=txn,
                            flags=db.DB_NOOVERWRITE)
            except db.DBKeyExistError:
                pass
            else:
                unique = 1

        return newid


    def Insert(self, table, rowdict) :
        """Insert(table, datadict) - Insert a new row into the table
        using the keys+values from rowdict as the column values.
        """

        txn = None
        try:
            if not getattr(self.db, "has_key")(_columns_key(table)):
                raise TableDBError, "unknown table"

            # check the validity of each column name
            if not table in self.__tablecolumns:
                self.__load_column_info(table)
            for column in rowdict.keys() :
                if not self.__tablecolumns[table].count(column):
                    raise TableDBError, "unknown column: %r" % (column,)

            # get a unique row identifier for this row
            txn = self.env.txn_begin()
            rowid = self.__new_rowid(table, txn=txn)

            # insert the row values into the table database
            for column, dataitem in rowdict.items():
                # store the value
                self.db.put(_data_key(table, column, rowid), dataitem, txn=txn)

            txn.commit()
            txn = None

        except db.DBError, dberror:
            # WIBNI we could just abort the txn and re-raise the exception?
            # But no, because TableDBError is not related to DBError via
            # inheritance, so it would be backwards incompatible.  Do the next
            # best thing.
            info = sys.exc_info()
            if txn:
                txn.abort()
                self.db.delete(_rowid_key(table, rowid))
            if sys.version_info < (2, 6) :
                raise TableDBError, dberror[1], info[2]
            else :
                raise TableDBError, dberror.args[1], info[2]


    def Modify(self, table, conditions={}, mappings={}):
        """Modify(table, conditions={}, mappings={}) - Modify items in rows matching 'conditions' using mapping functions in 'mappings'

        * table - the table name
        * conditions - a dictionary keyed on column names containing
          a condition callable expecting the data string as an
          argument and returning a boolean.
        * mappings - a dictionary keyed on column names containing a
          condition callable expecting the data string as an argument and
          returning the new string for that column.
        """

        try:
            matching_rowids = self.__Select(table, [], conditions)

            # modify only requested columns
            columns = mappings.keys()
            for rowid in matching_rowids.keys():
                txn = None
                try:
                    for column in columns:
                        txn = self.env.txn_begin()
                        # modify the requested column
                        try:
                            dataitem = self.db.get(
                                _data_key(table, column, rowid),
                                txn=txn)
                            self.db.delete(
                                _data_key(table, column, rowid),
                                txn=txn)
                        except db.DBNotFoundError:
                             # XXXXXXX row key somehow didn't exist, assume no
                             # error
                            dataitem = None
                        dataitem = mappings[column](dataitem)
                        if dataitem is not None:
                            self.db.put(
                                _data_key(table, column, rowid),
                                dataitem, txn=txn)
                        txn.commit()
                        txn = None

                # catch all exceptions here since we call unknown callables
                except:
                    if txn:
                        txn.abort()
                    raise

        except db.DBError, dberror:
            if sys.version_info < (2, 6) :
                raise TableDBError, dberror[1]
            else :
                raise TableDBError, dberror.args[1]

    def Delete(self, table, conditions={}):
        """Delete(table, conditions) - Delete items matching the given
        conditions from the table.

        * conditions - a dictionary keyed on column names containing
          condition functions expecting the data string as an
          argument and returning a boolean.
        """

        try:
            matching_rowids = self.__Select(table, [], conditions)

            # delete row data from all columns
            columns = self.__tablecolumns[table]
            for rowid in matching_rowids.keys():
                txn = None
                try:
                    txn = self.env.txn_begin()
                    for column in columns:
                        # delete the data key
                        try:
                            self.db.delete(_data_key(table, column, rowid),
                                           txn=txn)
                        except db.DBNotFoundError:
                            # XXXXXXX column may not exist, assume no error
                            pass

                    try:
                        self.db.delete(_rowid_key(table, rowid), txn=txn)
                    except db.DBNotFoundError:
                        # XXXXXXX row key somehow didn't exist, assume no error
                        pass
                    txn.commit()
                    txn = None
                except db.DBError, dberror:
                    if txn:
                        txn.abort()
                    raise
        except db.DBError, dberror:
            if sys.version_info < (2, 6) :
                raise TableDBError, dberror[1]
            else :
                raise TableDBError, dberror.args[1]


    def Select(self, table, columns, conditions={}):
        """Select(table, columns, conditions) - retrieve specific row data
        Returns a list of row column->value mapping dictionaries.

        * columns - a list of which column data to return.  If
          columns is None, all columns will be returned.
        * conditions - a dictionary keyed on column names
          containing callable conditions expecting the data string as an
          argument and returning a boolean.
        """
        try:
            if not table in self.__tablecolumns:
                self.__load_column_info(table)
            if columns is None:
                columns = self.__tablecolumns[table]
            matching_rowids = self.__Select(table, columns, conditions)
        except db.DBError, dberror:
            if sys.version_info < (2, 6) :
                raise TableDBError, dberror[1]
            else :
                raise TableDBError, dberror.args[1]
        # return the matches as a list of dictionaries
        return matching_rowids.values()


    def __Select(self, table, columns, conditions):
        """__Select() - Used to implement Select and Delete (above)
        Returns a dictionary keyed on rowids containing dicts
        holding the row data for columns listed in the columns param
        that match the given conditions.
        * conditions is a dictionary keyed on column names
        containing callable conditions expecting the data string as an
        argument and returning a boolean.
        """
        # check the validity of each column name
        if not table in self.__tablecolumns:
            self.__load_column_info(table)
        if columns is None:
            columns = self.tablecolumns[table]
        for column in (columns + conditions.keys()):
            if not self.__tablecolumns[table].count(column):
                raise TableDBError, "unknown column: %r" % (column,)

        # keyed on rows that match so far, containings dicts keyed on
        # column names containing the data for that row and column.
        matching_rowids = {}
        # keys are rowids that do not match
        rejected_rowids = {}

        # attempt to sort the conditions in such a way as to minimize full
        # column lookups
        def cmp_conditions(atuple, btuple):
            a = atuple[1]
            b = btuple[1]
            if type(a) is type(b):

                # Needed for python 3. "cmp" vanished in 3.0.1
                def cmp(a, b) :
                    if a==b : return 0
                    if a<b : return -1
                    return 1

                if isinstance(a, PrefixCond) and isinstance(b, PrefixCond):
                    # longest prefix first
                    return cmp(len(b.prefix), len(a.prefix))
                if isinstance(a, LikeCond) and isinstance(b, LikeCond):
                    # longest likestr first
                    return cmp(len(b.likestr), len(a.likestr))
                return 0
            if isinstance(a, ExactCond):
                return -1
            if isinstance(b, ExactCond):
                return 1
            if isinstance(a, PrefixCond):
                return -1
            if isinstance(b, PrefixCond):
                return 1
            # leave all unknown condition callables alone as equals
            return 0

        if sys.version_info < (2, 6) :
            conditionlist = conditions.items()
            conditionlist.sort(cmp_conditions)
        else :  # Insertion Sort. Please, improve
            conditionlist = []
            for i in conditions.items() :
                for j, k in enumerate(conditionlist) :
                    r = cmp_conditions(k, i)
                    if r == 1 :
                        conditionlist.insert(j, i)
                        break
                else :
                    conditionlist.append(i)

        # Apply conditions to column data to find what we want
        cur = self.db.cursor()
        column_num = -1
        for column, condition in conditionlist:
            column_num = column_num + 1
            searchkey = _search_col_data_key(table, column)
            # speedup: don't linear search columns within loop
            if column in columns:
                savethiscolumndata = 1  # save the data for return
            else:
                savethiscolumndata = 0  # data only used for selection

            try:
                key, data = cur.set_range(searchkey)
                while key[:len(searchkey)] == searchkey:
                    # extract the rowid from the key
                    rowid = key[-_rowid_str_len:]

                    if not rowid in rejected_rowids:
                        # if no condition was specified or the condition
                        # succeeds, add row to our match list.
                        if not condition or condition(data):
                            if not rowid in matching_rowids:
                                matching_rowids[rowid] = {}
                            if savethiscolumndata:
                                matching_rowids[rowid][column] = data
                        else:
                            if rowid in matching_rowids:
                                del matching_rowids[rowid]
                            rejected_rowids[rowid] = rowid

                    key, data = cur.next()

            except db.DBError, dberror:
                if dberror.args[0] != db.DB_NOTFOUND:
                    raise
                continue

        cur.close()

        # we're done selecting rows, garbage collect the reject list
        del rejected_rowids

        # extract any remaining desired column data from the
        # database for the matching rows.
        if len(columns) > 0:
            for rowid, rowdata in matching_rowids.items():
                for column in columns:
                    if column in rowdata:
                        continue
                    try:
                        rowdata[column] = self.db.get(
                            _data_key(table, column, rowid))
                    except db.DBError, dberror:
                        if sys.version_info < (2, 6) :
                            if dberror[0] != db.DB_NOTFOUND:
                                raise
                        else :
                            if dberror.args[0] != db.DB_NOTFOUND:
                                raise
                        rowdata[column] = None

        # return the matches
        return matching_rowids


    def Drop(self, table):
        """Remove an entire table from the database"""
        txn = None
        try:
            txn = self.env.txn_begin()

            # delete the column list
            self.db.delete(_columns_key(table), txn=txn)

            cur = self.db.cursor(txn)

            # delete all keys containing this tables column and row info
            table_key = _search_all_data_key(table)
            while 1:
                try:
                    key, data = cur.set_range(table_key)
                except db.DBNotFoundError:
                    break
                # only delete items in this table
                if key[:len(table_key)] != table_key:
                    break
                cur.delete()

            # delete all rowids used by this table
            table_key = _search_rowid_key(table)
            while 1:
                try:
                    key, data = cur.set_range(table_key)
                except db.DBNotFoundError:
                    break
                # only delete items in this table
                if key[:len(table_key)] != table_key:
                    break
                cur.delete()

            cur.close()

            # delete the tablename from the table name list
            tablelist = pickle.loads(
                getattr(self.db, "get_bytes", self.db.get)(_table_names_key,
                    txn=txn, flags=db.DB_RMW))
            try:
                tablelist.remove(table)
            except ValueError:
                # hmm, it wasn't there, oh well, that's what we want.
                pass
            # delete 1st, incase we opened with DB_DUP
            self.db.delete(_table_names_key, txn=txn)
            getattr(self.db, "put_bytes", self.db.put)(_table_names_key,
                    pickle.dumps(tablelist, 1), txn=txn)

            txn.commit()
            txn = None

            if table in self.__tablecolumns:
                del self.__tablecolumns[table]

        except db.DBError, dberror:
            if txn:
                txn.abort()
            raise TableDBError(dberror.args[1])
dbrecio.py000064400000012274150536075210006537 0ustar00
"""
File-like objects that read from or write to a bsddb record.

This implements (nearly) all stdio methods.

f = DBRecIO(db, key, txn=None)
f.close()           # explicitly release resources held
flag = f.isatty()   # always false
pos = f.tell()      # get current position
f.seek(pos)         # set current position
f.seek(pos, mode)   # mode 0: absolute; 1: relative; 2: relative to EOF
buf = f.read()      # read until EOF
buf = f.read(n)     # read up to n bytes
f.truncate([size])  # truncate file at to at most size (default: current pos)
f.write(buf)        # write at current position
f.writelines(list)  # for line in list: f.write(line)

Notes:
- fileno() is left unimplemented so that code which uses it triggers
  an exception early.
- There's a simple test set (see end of this file) - not yet updated
  for DBRecIO.
- readline() is not implemented yet.


From:
    Itamar Shtull-Trauring <itamar@maxnm.com>
"""

import errno
import string

class DBRecIO:
    def __init__(self, db, key, txn=None):
        self.db = db
        self.key = key
        self.txn = txn
        self.len = None
        self.pos = 0
        self.closed = 0
        self.softspace = 0

    def close(self):
        if not self.closed:
            self.closed = 1
            del self.db, self.txn

    def isatty(self):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        return 0

    def seek(self, pos, mode = 0):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        if mode == 1:
            pos = pos + self.pos
        elif mode == 2:
            pos = pos + self.len
        self.pos = max(0, pos)

    def tell(self):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        return self.pos

    def read(self, n = -1):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        if n < 0:
            newpos = self.len
        else:
            newpos = min(self.pos+n, self.len)

        dlen = newpos - self.pos

        r = self.db.get(self.key, txn=self.txn, dlen=dlen, doff=self.pos)
        self.pos = newpos
        return r

    __fixme = """
    def readline(self, length=None):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        if self.buflist:
            self.buf = self.buf + string.joinfields(self.buflist, '')
            self.buflist = []
        i = string.find(self.buf, '\n', self.pos)
        if i < 0:
            newpos = self.len
        else:
            newpos = i+1
        if length is not None:
            if self.pos + length < newpos:
                newpos = self.pos + length
        r = self.buf[self.pos:newpos]
        self.pos = newpos
        return r

    def readlines(self, sizehint = 0):
        total = 0
        lines = []
        line = self.readline()
        while line:
            lines.append(line)
            total += len(line)
            if 0 < sizehint <= total:
                break
            line = self.readline()
        return lines
    """

    def truncate(self, size=None):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        if size is None:
            size = self.pos
        elif size < 0:
            raise IOError(errno.EINVAL,
                                      "Negative size not allowed")
        elif size < self.pos:
            self.pos = size
        self.db.put(self.key, "", txn=self.txn, dlen=self.len-size, doff=size)

    def write(self, s):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        if not s: return
        if self.pos > self.len:
            self.buflist.append('\0'*(self.pos - self.len))
            self.len = self.pos
        newpos = self.pos + len(s)
        self.db.put(self.key, s, txn=self.txn, dlen=len(s), doff=self.pos)
        self.pos = newpos

    def writelines(self, list):
        self.write(string.joinfields(list, ''))

    def flush(self):
        if self.closed:
            raise ValueError, "I/O operation on closed file"


"""
# A little test suite

def _test():
    import sys
    if sys.argv[1:]:
        file = sys.argv[1]
    else:
        file = '/etc/passwd'
    lines = open(file, 'r').readlines()
    text = open(file, 'r').read()
    f = StringIO()
    for line in lines[:-2]:
        f.write(line)
    f.writelines(lines[-2:])
    if f.getvalue() != text:
        raise RuntimeError, 'write failed'
    length = f.tell()
    print 'File length =', length
    f.seek(len(lines[0]))
    f.write(lines[1])
    f.seek(0)
    print 'First line =', repr(f.readline())
    here = f.tell()
    line = f.readline()
    print 'Second line =', repr(line)
    f.seek(-len(line), 1)
    line2 = f.read(len(line))
    if line != line2:
        raise RuntimeError, 'bad result after seek back'
    f.seek(len(line2), 1)
    list = f.readlines()
    line = list[-1]
    f.seek(f.tell() - len(line))
    line2 = f.read()
    if line != line2:
        raise RuntimeError, 'bad result after seek back from EOF'
    print 'Read', len(list), 'more lines'
    print 'File length =', f.tell()
    if f.tell() != length:
        raise RuntimeError, 'bad length'
    f.close()

if __name__ == '__main__':
    _test()
"""
db.pyc000064400000001120150536075210005644 0ustar00�
{fc@s�ddlZejddkZesnejd�rQddlTddlmZq�ddlTddlmZn2ejd�r�ddUddUnd	dUd
dUdS(i����Niisbsddb3.(t*(t__version__sfrom ._pybsddb import *s!from ._pybsddb import __version__sfrom ._bsddb import *sfrom ._bsddb import __version__(tsystversion_infotabsolute_importt__name__t
startswitht_pybsddbRt_bsddb(((s /usr/lib64/python2.7/bsddb/db.pyt<module>(s

db.pyo000064400000001120150536075210005660 0ustar00�
{fc@s�ddlZejddkZesnejd�rQddlTddlmZq�ddlTddlmZn2ejd�r�ddUddUnd	dUd
dUdS(i����Niisbsddb3.(t*(t__version__sfrom ._pybsddb import *s!from ._pybsddb import __version__sfrom ._bsddb import *sfrom ._bsddb import __version__(tsystversion_infotabsolute_importt__name__t
startswitht_pybsddbRt_bsddb(((s /usr/lib64/python2.7/bsddb/db.pyt<module>(s

dbobj.pyc000064400000044607150536075210006360 0ustar00�
{fc@s�ddlZejddkZer0ddUnddlZejdkr^ddlmZnddlZejZddd	��YZd
efd��YZ	ddd
��YZ
dS(i����Niisfrom . import dbii(t	DictMixintDBEnvcBseZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ej�d'kr�d�Znd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&ej�d(kr}d%�Z'd&�Z(nRS()cOstj||�|_dS(N(tdbRt_cobj(tselftargstkwargs((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__init__'scOs|jj||�S(N(Rtclose(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR*scOs|jj||�S(N(Rtopen(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR	,scOs|jj||�S(N(Rtremove(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
.scOs|jj||�S(N(Rtset_shm_key(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR0scOs|jj||�S(N(Rt
set_cachesize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR2scOs|jj||�S(N(Rtset_data_dir(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
4scOs|jj||�S(N(Rt	set_flags(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR6scOs|jj||�S(N(Rtset_lg_bsize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR8scOs|jj||�S(N(Rt
set_lg_dir(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR:scOs|jj||�S(N(Rt
set_lg_max(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR<scOs|jj||�S(N(Rt
set_lk_detect(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR>siicOs|jj||�S(N(Rt
set_lk_max(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRAscOs|jj||�S(N(Rtset_lk_max_locks(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRCscOs|jj||�S(N(Rtset_lk_max_lockers(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyREscOs|jj||�S(N(Rtset_lk_max_objects(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRGscOs|jj||�S(N(Rtset_mp_mmapsize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRIscOs|jj||�S(N(Rtset_timeout(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRKscOs|jj||�S(N(Rtset_tmp_dir(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRMscOs|jj||�S(N(Rt	txn_begin(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyROscOs|jj||�S(N(Rttxn_checkpoint(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRQscOs|jj||�S(N(Rttxn_stat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRSscOs|jj||�S(N(Rt
set_tx_max(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRUscOs|jj||�S(N(Rtset_tx_timestamp(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRWscOs|jj||�S(N(Rtlock_detect(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRYscOs|jj||�S(N(Rtlock_get(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR [scOs|jj||�S(N(Rtlock_id(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR!]scOs|jj||�S(N(Rtlock_put(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR"_scOs|jj||�S(N(Rt	lock_stat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR#ascOs|jj||�S(N(Rtlog_archive(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR$cscOs|jj||�S(N(Rtset_get_returns_none(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR%fscOs|jj||�S(N(Rtlog_stat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR&iscOs|jj||�S(N(Rtdbremove(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR'lscOs|jj||�S(N(Rtdbrename(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR(nscOs|jj||�S(N(Rtset_encrypt(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR)pscOs|jj||�S(N(Rtfileid_reset(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR*tscOs|jj||�S(N(Rt	lsn_reset(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR+ws(ii(ii()t__name__t
__module__RRR	R
RRR
RRRRRRtversionRRRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+(((s#/usr/lib64/python2.7/bsddb/dbobj.pyR&sN																																			tDBcBs�eZd�Zd�Zd�Zd�Zd�Zejd5krNd�Z	nd�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6RS(6cOs#tj|jf||�|_dS(N(RR/R(RtdbenvRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR|scCs
t|j�S(N(tlenR(R((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__len__�scCs|j|S(N(R(Rtarg((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__getitem__�scCs||j|<dS(N(R(Rtkeytvalue((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__setitem__�scCs|j|=dS(N(R(RR3((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__delitem__�siicCs
|jj�S(N(Rt__iter__(R((s#/usr/lib64/python2.7/bsddb/dbobj.pyR9�scOs|jj||�S(N(Rtappend(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR:�scOs|jj||�S(N(Rt	associate(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR;�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(Rtconsume(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR<�scOs|jj||�S(N(Rtconsume_wait(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR=�scOs|jj||�S(N(Rtcursor(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR>�scOs|jj||�S(N(Rtdelete(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR?�scOs|jj||�S(N(Rtfd(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR@�scOs|jj||�S(N(Rtget(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRA�scOs|jj||�S(N(Rtpget(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRB�scOs|jj||�S(N(Rtget_both(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRC�scOs|jj||�S(N(Rtget_byteswapped(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRD�scOs|jj||�S(N(Rtget_size(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRE�scOs|jj||�S(N(Rtget_type(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRF�scOs|jj||�S(N(Rtjoin(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRG�scOs|jj||�S(N(Rt	key_range(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRH�scOs|jj||�S(N(Rthas_key(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRI�scOs|jj||�S(N(Rtitems(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRJ�scOs|jj||�S(N(Rtkeys(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRK�scOs|jj||�S(N(RR	(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR	�scOs|jj||�S(N(Rtput(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRL�scOs|jj||�S(N(RR
(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
�scOs|jj||�S(N(Rtrename(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRM�scOs|jj||�S(N(Rt
set_bt_minkey(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRN�scOs|jj||�S(N(Rtset_bt_compare(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRO�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(Rtset_dup_compare(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRP�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(Rt
set_h_ffactor(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRQ�scOs|jj||�S(N(Rtset_h_nelem(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRR�scOs|jj||�S(N(Rt
set_lorder(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRS�scOs|jj||�S(N(Rtset_pagesize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRT�scOs|jj||�S(N(Rtset_re_delim(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRU�scOs|jj||�S(N(Rt
set_re_len(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRV�scOs|jj||�S(N(Rt
set_re_pad(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRW�scOs|jj||�S(N(Rt
set_re_source(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRX�scOs|jj||�S(N(Rtset_q_extentsize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRY�scOs|jj||�S(N(Rtstat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRZ�scOs|jj||�S(N(Rtsync(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR[�scOs|jj||�S(N(Rttype(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR\�scOs|jj||�S(N(Rtupgrade(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR]�scOs|jj||�S(N(Rtvalues(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR^�scOs|jj||�S(N(Rtverify(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR_�scOs|jj||�S(N(RR%(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR%�scOs|jj||�S(N(RR)(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR)�s(ii(7R,R-RR2R4R7R8tsystversion_infoR9R:R;RR<R=R>R?R@RARBRCRDRERFRGRHRIRJRKR	RLR
RMRNRORRPRRQRRRSRTRURVRWRXRYRZR[R\R]R^R_R%R)(((s#/usr/lib64/python2.7/bsddb/dbobj.pyR/{sh																																																	t
DBSequencecBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�ZRS(cOstj||�|_dS(N(RRbR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(RRA(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRA�scOs|jj||�S(N(Rtget_dbp(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRc�scOs|jj||�S(N(Rtget_key(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRd�scOs|jj||�S(N(Rt
init_value(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRe�scOs|jj||�S(N(RR	(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR	�scOs|jj||�S(N(RR
(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
�scOs|jj||�S(N(RRZ(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRZ�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRscOs|jj||�S(N(Rt	set_range(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRfscOs|jj||�S(N(Rt
get_cachesize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRgscOs|jj||�S(N(Rt	get_flags(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRhscOs|jj||�S(N(Rt	get_range(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRi	s(R,R-RRRARcRdReR	R
RZRRRfRgRhRi(((s#/usr/lib64/python2.7/bsddb/dbobj.pyRb�s														(ii(((R`Ratabsolute_importRtUserDictRtMutableMappingtcollectionsRR/Rb(((s#/usr/lib64/python2.7/bsddb/dbobj.pyt<module>s	Updbrecio.pyo000064400000012265150536075210006716 0ustar00�
{fc@s5dZddlZddlZddd��YZdS(s�
File-like objects that read from or write to a bsddb record.

This implements (nearly) all stdio methods.

f = DBRecIO(db, key, txn=None)
f.close()           # explicitly release resources held
flag = f.isatty()   # always false
pos = f.tell()      # get current position
f.seek(pos)         # set current position
f.seek(pos, mode)   # mode 0: absolute; 1: relative; 2: relative to EOF
buf = f.read()      # read until EOF
buf = f.read(n)     # read up to n bytes
f.truncate([size])  # truncate file at to at most size (default: current pos)
f.write(buf)        # write at current position
f.writelines(list)  # for line in list: f.write(line)

Notes:
- fileno() is left unimplemented so that code which uses it triggers
  an exception early.
- There's a simple test set (see end of this file) - not yet updated
  for DBRecIO.
- readline() is not implemented yet.


From:
    Itamar Shtull-Trauring <itamar@maxnm.com>
i����NtDBRecIOcBsteZd
d�Zd�Zd�Zdd�Zd�Zdd�ZdZ	d
d	�Z
d
�Zd�Zd�Z
RS(cCsC||_||_||_d|_d|_d|_d|_dS(Ni(tdbtkeyttxntNonetlentpostclosedt	softspace(tselfRRR((s%/usr/lib64/python2.7/bsddb/dbrecio.pyt__init__#s						cCs%|js!d|_|`|`ndS(Ni(RRR(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pytclose,s		cCs|jrtd�ndS(NsI/O operation on closed filei(Rt
ValueError(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pytisatty1s	icCsc|jrtd�n|dkr1||j}n|dkrM||j}ntd|�|_dS(NsI/O operation on closed fileiii(RRRRtmax(R	Rtmode((s%/usr/lib64/python2.7/bsddb/dbrecio.pytseek6s	cCs|jrtd�n|jS(NsI/O operation on closed file(RRR(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pyttell?s	i����cCs�|jrtd�n|dkr-|j}nt|j||j�}||j}|jj|jd|jd|d|j�}||_|S(NsI/O operation on closed fileiRtdlentdoff(	RRRtminRRtgetRR(R	tntnewposRtr((s%/usr/lib64/python2.7/bsddb/dbrecio.pytreadDs	
-	s|
    def readline(self, length=None):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        if self.buflist:
            self.buf = self.buf + string.joinfields(self.buflist, '')
            self.buflist = []
        i = string.find(self.buf, '
', self.pos)
        if i < 0:
            newpos = self.len
        else:
            newpos = i+1
        if length is not None:
            if self.pos + length < newpos:
                newpos = self.pos + length
        r = self.buf[self.pos:newpos]
        self.pos = newpos
        return r

    def readlines(self, sizehint = 0):
        total = 0
        lines = []
        line = self.readline()
        while line:
            lines.append(line)
            total += len(line)
            if 0 < sizehint <= total:
                break
            line = self.readline()
        return lines
    c	Cs�|jrtd�n|dkr-|j}n<|dkrNttjd��n||jkri||_n|jj|j	dd|j
d|j|d|�dS(NsI/O operation on closed fileisNegative size not allowedtRRR(RRRRtIOErrorterrnotEINVALRtputRRR(R	tsize((s%/usr/lib64/python2.7/bsddb/dbrecio.pyttruncaters		c	Cs�|jrtd�n|sdS|j|jkr^|jjd|j|j�|j|_n|jt|�}|jj|j|d|j	dt|�d|j�||_dS(NsI/O operation on closed filesRRR(
RRRRtbuflisttappendRRRR(R	tsR((s%/usr/lib64/python2.7/bsddb/dbrecio.pytwrite~s	4cCs|jtj|d��dS(NR(R$tstringt
joinfields(R	tlist((s%/usr/lib64/python2.7/bsddb/dbrecio.pyt
writelines�scCs|jrtd�ndS(NsI/O operation on closed file(RR(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pytflush�s	N(t__name__t
__module__RR
RR
RRRt_DBRecIO__fixmeR R$R(R)(((s%/usr/lib64/python2.7/bsddb/dbrecio.pyR"s					,		((t__doc__RR%R(((s%/usr/lib64/python2.7/bsddb/dbrecio.pyt<module>s�dbutils.pyc000064400000003133150536075210006733 0ustar00�
{fc@soddlmZddlZejddkZer@ddUnddlZddZdZdZ
d	�ZdS(
i����(tsleepNiisfrom . import dbg�?i�gn��!	@cOs�t}|jdd�}d|kr.|d=nx�tr�y|||�SWq1tjk
r�trutjd|�nt|�|d9}|tkr�t}n|d8}|dkr��q�q1Xq1WdS(s?DeadlockWrap(function, *_args, **_kwargs) - automatically retries
    function in case of a database deadlock.

    This is a function intended to be used to wrap database calls such
    that they perform retrys with exponentially backing off sleeps in
    between when a DBLockDeadlockError exception is raised.

    A 'max_retries' parameter may optionally be passed to prevent it
    from retrying forever (in which case the exception will be reraised).

        d = DB(...)
        d.open(...)
        DeadlockWrap(d.put, "foo", data="bar")  # set key "foo" to "bar"
    tmax_retriesi����s%dbutils.DeadlockWrap: sleeping %1.3f
iiN(	t_deadlock_MinSleepTimetgettTruetdbtDBLockDeadlockErrort_deadlock_VerboseFiletwritet_sleept_deadlock_MaxSleepTime(tfunctiont_argst_kwargst	sleeptimeR((s%/usr/lib64/python2.7/bsddb/dbutils.pytDeadlockWrap/s$
	

	
(ttimeRR	tsystversion_infotabsolute_importRRR
tNoneRR(((s%/usr/lib64/python2.7/bsddb/dbutils.pyt<module>s
db.py000064400000005252150536075210005513 0ustar00#----------------------------------------------------------------------
#  Copyright (c) 1999-2001, Digital Creations, Fredericksburg, VA, USA
#  and Andrew Kuchling. All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions are
#  met:
#
#    o Redistributions of source code must retain the above copyright
#      notice, this list of conditions, and the disclaimer that follows.
#
#    o Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions, and the following disclaimer in
#      the documentation and/or other materials provided with the
#      distribution.
#
#    o Neither the name of Digital Creations nor the names of its
#      contributors may be used to endorse or promote products derived
#      from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS
#  IS* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#  PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL
#  CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
#  DAMAGE.
#----------------------------------------------------------------------


# This module is just a placeholder for possible future expansion, in
# case we ever want to augment the stuff in _db in any way.  For now
# it just simply imports everything from _db.

import sys
absolute_import = (sys.version_info[0] >= 3)

if not absolute_import :
    if __name__.startswith('bsddb3.') :
        # import _pybsddb binary as it should be the more recent version from
        # a standalone pybsddb addon package than the version included with
        # python as bsddb._bsddb.
        from _pybsddb import *
        from _pybsddb import __version__
    else:
        from _bsddb import *
        from _bsddb import __version__
else :
    # Because this syntaxis is not valid before Python 2.5
    if __name__.startswith('bsddb3.') :
        exec("from ._pybsddb import *")
        exec("from ._pybsddb import __version__")
    else :
        exec("from ._bsddb import *")
        exec("from ._bsddb import __version__")
__init__.pyo000064400000030242150536075210007041 0ustar00�
{fc@s}dZddlZejddkZejdkr�ejdkr�ddlZejrzedkrzejded�nej	d	d
ed�nybedkr�er�ddUnddl
Z
e
Zdd
lm
ZnddlZdd
lm
ZWn*ek
r!ddlZeje=�nXeZZejZejZddlZddlZddlmZejdkr�ddlZejZnddlZejZdefd��YZdefd��YZddddddddd�Z!ddddddddd�Z"ddddddddddd�
Z#d�Z$d�Z%yddl&Z'['Wnek
rxde_(nXdS(s�Support for Berkeley DB 4.3 through 5.3 with a simple interface.

For the full featured object oriented interface use the bsddb.db module
instead.  It mirrors the Oracle Berkeley DB C API.
i����Niiiitbsddb3sQin 3.x, the bsddb module has been removed; please use the pybsddb project insteadtignores.*CObject.*sbsddb.__init__sfrom . import _pybsddb(tDeadlockWrap(treft_iter_mixincBs,eZd�Zd�Zd�Zd�ZRS(cCsAt|jj�}t|�}t||j|��|j|<|S(N(t
_DeadlockWraptdbtcursortidRt_gen_cref_cleanert_cursor_refs(tselftcurtkey((s&/usr/lib64/python2.7/bsddb/__init__.pyt_make_iter_cursor_scs��fd�S(Ncs�jj�d�S(N(R
tpoptNone(R(R
R(s&/usr/lib64/python2.7/bsddb/__init__.pyt<lambda>it((RR
((R
Rs&/usr/lib64/python2.7/bsddb/__init__.pyR	esccsAt|_|jd7_y�y�|j�}t|jddd�d}|Vt|d�}x�y"t|ddd�d}|VWq]tjk
r�|jr�t	d��n|j�}t|j
|ddd�t|d�}q]Xq]WWn'tjk
r�ntjk
rnXWn|jd8_�nX|jd8_dS(Niitnexts'Database changed size during iteration.(tFalset_kill_iterationt_in_iterRRtfirsttgetattrt_bsddbtDBCursorClosedErrortRuntimeErrortsettDBNotFoundError(RRR
R((s&/usr/lib64/python2.7/bsddb/__init__.pyt__iter__ks4			ccsH|js
dSt|_|jd7_y�y�|j�}t|j�}|d}|Vt|d�}x�yt|�}|d}|VWqgtj	k
r�|jr�t
d��n|j�}t|j|ddd�t|d�}qgXqgWWn'tjk
rntj	k
rnXWn|jd8_�nX|jd8_dS(NiiRs'Database changed size during iteration.(
RRRRRRRRRRRRR(RRtkvR
R((s&/usr/lib64/python2.7/bsddb/__init__.pyt	iteritems�s<		

		(t__name__t
__module__RR	RR (((s&/usr/lib64/python2.7/bsddb/__init__.pyR^s			)t
_DBWithCursorcBs�eZdZd�Zd�Zd�Zdd�Zd�Zd�Zd�Z	e
jdkrid�Znd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Ze
jddkr�eZnd�Zd�Zd�Zd�ZRS(s�
    A simple wrapper around DB that makes it look like the bsddbobject in
    the old module.  It uses a cursor as needed to provide DB traversal.
    cCsJ||_|jjd�d|_d|_i|_d|_t|_dS(Ni(	Rtset_get_returns_noneRtdbct
saved_dbc_keyR
RRR(RR((s&/usr/lib64/python2.7/bsddb/__init__.pyt__init__�s	
				cCs|j�dS(N(tclose(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt__del__�scCs\|jdkrXt|jj�|_|jdk	rXt|jj|j�d|_qXndS(N(R%RRRRR&R(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt_checkCursor�s
icCs�|jrq|j}d|_|r^y#t|jddd�d|_Wq^tjk
rZq^Xnt|j�~nx<|jj	�D]+}|�}|dk	r�t|j�q�q�WdS(Ni(
R%RRtcurrentR&RtDBErrorR(R
tvalues(Rtsavetctcref((s&/usr/lib64/python2.7/bsddb/__init__.pyt
_closeCursors�s			#
	cCs|jdkrtd�ndS(Ns$BSDDB object has already been closed(RRterror(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt
_checkOpen�scCs
|jdk	S(N(RR(R((s&/usr/lib64/python2.7/bsddb/__init__.pytisOpen�scs�j�t�fd��S(Ncs
t�j�S(N(tlenR((R(s&/usr/lib64/python2.7/bsddb/__init__.pyRR(R3R(R((Rs&/usr/lib64/python2.7/bsddb/__init__.pyt__len__s
iicCs5|j�r(ttt|jj���Stt��S(N(R4treprtdictRRtitems(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt__repr__scs �j�t��fd��S(Ncs�j�S(N(R((R
R(s&/usr/lib64/python2.7/bsddb/__init__.pyRR(R3R(RR
((R
Rs&/usr/lib64/python2.7/bsddb/__init__.pyt__getitem__s
csX�j��j��jr5��kr5t�_n���fd�}t|�dS(Ncs��j�<dS(N(R((R
Rtvalue(s&/usr/lib64/python2.7/bsddb/__init__.pytwrapFs(R3R1RtTrueRR(RR
R<R=((R
RR<s&/usr/lib64/python2.7/bsddb/__init__.pyt__setitem__s

csU�j��j��jr5��kr5t�_n��fd�}t|�dS(Ncs�j�=dS(N(R((R
R(s&/usr/lib64/python2.7/bsddb/__init__.pyR=s(R3R1RR>RR(RR
R=((R
Rs&/usr/lib64/python2.7/bsddb/__init__.pyt__delitem__s

cCsr|jdd�|jdk	r2t|jj�nd}|jdk	r\t|jj�}nd|_d|_|S(NR.i(R1R%RRR(R(Rtv((s&/usr/lib64/python2.7/bsddb/__init__.pyR("s		cCs|j�t|jj�S(N(R3RRtkeys(R((s&/usr/lib64/python2.7/bsddb/__init__.pyRB-s
cCs|j�t|jj|�S(N(R3RRthas_key(RR
((s&/usr/lib64/python2.7/bsddb/__init__.pyRC1s
cCs'|j�|j�t|jj|�S(N(R3R*RR%t	set_range(RR
((s&/usr/lib64/python2.7/bsddb/__init__.pytset_location5s

cCs0|j�|j�tt|jd��}|S(NR(R3R*RRR%(Rtrv((s&/usr/lib64/python2.7/bsddb/__init__.pyR:s

iicCs*|j�|j�t|jj�}|S(N(R3R*RR%tprev(RRF((s&/usr/lib64/python2.7/bsddb/__init__.pytpreviousCs

cCs3|j�d|_|j�t|jj�}|S(N(R3RR&R*RR%R(RRF((s&/usr/lib64/python2.7/bsddb/__init__.pyRIs

	
cCs3|j�d|_|j�t|jj�}|S(N(R3RR&R*RR%tlast(RRF((s&/usr/lib64/python2.7/bsddb/__init__.pyRIQs

	
cCs|j�t|jj�S(N(R3RRtsync(R((s&/usr/lib64/python2.7/bsddb/__init__.pyRJYs
(ii(R!R"t__doc__R'R)R*R1R3R4R6tsystversion_infoR:R;R?R@R(RBRCRERt__next__RHRRIRJ(((s&/usr/lib64/python2.7/bsddb/__init__.pyR#�s0																				R/i�c	Cs�t||�}	t|�}
tj|
�}|j|�|dk	rS|j|�n|dk	ro|j|�n|dk	r�|j|�n|dk	r�|j	|�n|j
|tj|	|�t|�S(N(
t
_checkflagt
_openDBEnvRtDBt	set_flagsRtset_pagesizet
set_lordert
set_h_ffactortset_h_nelemtopentDB_HASHR#(tfiletflagtmodetpgsizetffactortnelemt	cachesizetlorderthflagstflagstetd((s&/usr/lib64/python2.7/bsddb/__init__.pythashopenas
c	Cs�t||�}	t|�}
tj|
�}|dk	rF|j|�n|dk	rb|j|�n|j|�|dk	r�|j|�n|dk	r�|j	|�n|j
|tj|	|�t|�S(N(
RORPRRQRRSRTRRt
set_bt_minkeyt
set_bt_maxkeyRWtDB_BTREER#(RYRZR[tbtflagsR_t
maxkeypaget
minkeypageR\R`RbRcRd((s&/usr/lib64/python2.7/bsddb/__init__.pytbtopenqs
cCst||�}t|�}tj|�}
|dk	rF|
j|�n|dk	rb|
j|�n|
j|�|dk	r�|
j|�n|dk	r�|
j	|�n|	dk	r�|
j
|	�n|
dk	r�|
j|
�n|
j|tj
||�t|
�S(N(RORPRRQRRSRTRRtset_re_delimt
set_re_lent
set_re_sourcet
set_re_padRWtDB_RECNOR#(RYRZR[trnflagsR_R\R`trlentdelimtsourcetpadRbRcRd((s&/usr/lib64/python2.7/bsddb/__init__.pytrnopen�s$
cCs�tj�}|dk	rC|dkr7|jd|�qCtd�n|jtj�|jdtjtj	Btj
BtjBtjB�|S(NiPiscachesize must be >= 20480t.(
RtDBEnvRt
set_cachesizeR2t
set_lk_detecttDB_LOCK_DEFAULTRWt
DB_PRIVATEt	DB_CREATEt	DB_THREADtDB_INIT_LOCKt
DB_INIT_MPOOL(R_Rc((s&/usr/lib64/python2.7/bsddb/__init__.pyRP�s/cCs�|dkrtj}n�|dkr-d}n|dkrEtj}ng|dkr]tj}nO|dkr�tj}|dk	r�tjj|�r�tj|�q�n	td�|tj	BS(NtrtrwitwR/tns+flags should be one of 'r', 'w', 'c' or 'n'(
Rt	DB_RDONLYR~RtostpathtisfiletunlinkR2R(RZRYRb((s&/usr/lib64/python2.7/bsddb/__init__.pyRO�s			(ii(ii(ii()RKRLRMtabsolute_importtwarningstpy3kwarningR!twarnpy3ktDeprecationWarningtfilterwarningst_pybsddbRtbsddb3.dbutilsRRt
bsddb.dbutilstImportErrortmodulesRt_dbt__version__R,R2R�tweakrefRtUserDictt	DictMixintMutableMappingtcollectionsRR#RReRlRwRPROtthreadtTR(((s&/usr/lib64/python2.7/bsddb/__init__.pyt<module>(sb	




			b�		
dbrecio.pyc000064400000012265150536075210006702 0ustar00�
{fc@s5dZddlZddlZddd��YZdS(s�
File-like objects that read from or write to a bsddb record.

This implements (nearly) all stdio methods.

f = DBRecIO(db, key, txn=None)
f.close()           # explicitly release resources held
flag = f.isatty()   # always false
pos = f.tell()      # get current position
f.seek(pos)         # set current position
f.seek(pos, mode)   # mode 0: absolute; 1: relative; 2: relative to EOF
buf = f.read()      # read until EOF
buf = f.read(n)     # read up to n bytes
f.truncate([size])  # truncate file at to at most size (default: current pos)
f.write(buf)        # write at current position
f.writelines(list)  # for line in list: f.write(line)

Notes:
- fileno() is left unimplemented so that code which uses it triggers
  an exception early.
- There's a simple test set (see end of this file) - not yet updated
  for DBRecIO.
- readline() is not implemented yet.


From:
    Itamar Shtull-Trauring <itamar@maxnm.com>
i����NtDBRecIOcBsteZd
d�Zd�Zd�Zdd�Zd�Zdd�ZdZ	d
d	�Z
d
�Zd�Zd�Z
RS(cCsC||_||_||_d|_d|_d|_d|_dS(Ni(tdbtkeyttxntNonetlentpostclosedt	softspace(tselfRRR((s%/usr/lib64/python2.7/bsddb/dbrecio.pyt__init__#s						cCs%|js!d|_|`|`ndS(Ni(RRR(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pytclose,s		cCs|jrtd�ndS(NsI/O operation on closed filei(Rt
ValueError(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pytisatty1s	icCsc|jrtd�n|dkr1||j}n|dkrM||j}ntd|�|_dS(NsI/O operation on closed fileiii(RRRRtmax(R	Rtmode((s%/usr/lib64/python2.7/bsddb/dbrecio.pytseek6s	cCs|jrtd�n|jS(NsI/O operation on closed file(RRR(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pyttell?s	i����cCs�|jrtd�n|dkr-|j}nt|j||j�}||j}|jj|jd|jd|d|j�}||_|S(NsI/O operation on closed fileiRtdlentdoff(	RRRtminRRtgetRR(R	tntnewposRtr((s%/usr/lib64/python2.7/bsddb/dbrecio.pytreadDs	
-	s|
    def readline(self, length=None):
        if self.closed:
            raise ValueError, "I/O operation on closed file"
        if self.buflist:
            self.buf = self.buf + string.joinfields(self.buflist, '')
            self.buflist = []
        i = string.find(self.buf, '
', self.pos)
        if i < 0:
            newpos = self.len
        else:
            newpos = i+1
        if length is not None:
            if self.pos + length < newpos:
                newpos = self.pos + length
        r = self.buf[self.pos:newpos]
        self.pos = newpos
        return r

    def readlines(self, sizehint = 0):
        total = 0
        lines = []
        line = self.readline()
        while line:
            lines.append(line)
            total += len(line)
            if 0 < sizehint <= total:
                break
            line = self.readline()
        return lines
    c	Cs�|jrtd�n|dkr-|j}n<|dkrNttjd��n||jkri||_n|jj|j	dd|j
d|j|d|�dS(NsI/O operation on closed fileisNegative size not allowedtRRR(RRRRtIOErrorterrnotEINVALRtputRRR(R	tsize((s%/usr/lib64/python2.7/bsddb/dbrecio.pyttruncaters		c	Cs�|jrtd�n|sdS|j|jkr^|jjd|j|j�|j|_n|jt|�}|jj|j|d|j	dt|�d|j�||_dS(NsI/O operation on closed filesRRR(
RRRRtbuflisttappendRRRR(R	tsR((s%/usr/lib64/python2.7/bsddb/dbrecio.pytwrite~s	4cCs|jtj|d��dS(NR(R$tstringt
joinfields(R	tlist((s%/usr/lib64/python2.7/bsddb/dbrecio.pyt
writelines�scCs|jrtd�ndS(NsI/O operation on closed file(RR(R	((s%/usr/lib64/python2.7/bsddb/dbrecio.pytflush�s	N(t__name__t
__module__RR
RR
RRRt_DBRecIO__fixmeR R$R(R)(((s%/usr/lib64/python2.7/bsddb/dbrecio.pyR"s					,		((t__doc__RR%R(((s%/usr/lib64/python2.7/bsddb/dbrecio.pyt<module>s�dbtables.pyc000064400000057722150536075210007062 0ustar00�
{fc@s!dZddlZddlZddlZddlZddlZejddkrdddlZnzejd(kr�ddlZn\ddl	Z	e	j
�Zej�z)e	j
ddd	d
e�ddlZWdej�X[yddlmZWn!ek
rddlmZnXdefd
��YZdefd��YZdd)d��YZdefd��YZdefd��YZdefd��YZdefd��YZdZdZd�ZdZdZ dZ!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&d*d'��YZ(dS(+s$Id$i����Niiiitignoretmessages1the cPickle module has been removed in Python 3.0tcategory(tdbtTableDBErrorcBseZRS((t__name__t
__module__(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR>stTableAlreadyExistscBseZRS((RR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR@stCondcBseZdZd�ZRS(s!This condition matches everythingcCsdS(Ni((tselfts((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__call__Fs(RRt__doc__R(((s&/usr/lib64/python2.7/bsddb/dbtables.pyRDst	ExactCondcBs eZdZd�Zd�ZRS(s)Acts as an exact match condition functioncCs
||_dS(N(t
strtomatch(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__init__KscCs
||jkS(N(R(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyRMs(RRRRR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR
Is	t
PrefixCondcBs eZdZd�Zd�ZRS(s9Acts as a condition function for matching a string prefixcCs
||_dS(N(tprefix(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyRRscCs|t|j� |jkS(N(tlenR(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyRTs(RRRRR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyRPs	tPostfixCondcBs eZdZd�Zd�ZRS(s:Acts as a condition function for matching a string postfixcCs
||_dS(N(tpostfix(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyRYscCs|t|j�|jkS(N(RR(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyR[s(RRRRR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyRWs	tLikeCondcBs&eZdZejd�Zd�ZRS(s�
    Acts as a function that will match using an SQL 'LIKE' style
    string.  Case insensitive and % signs are wild cards.
    This isn't perfect but it should work for the simple common cases.
    cCsfd}x$|D]}|j|d|�}q
W|jdd�|_tjd|jd|�|_dS(Ns.*+()[]?s\t%s.*t^t$(treplacetlikestrtretcompile(R	Rtre_flagstchars_to_escapetchar((s&/usr/lib64/python2.7/bsddb/dbtables.pyRds

cCs|jj|�S(N(Rtmatch(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyRls(RRRRt
IGNORECASERR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR^st__TABLE_NAMES__s._COLUMNS__cCs|tS(N(t_columns(ttable((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_columns_keyuss._DATA_.s	._ROWID_.icCs|t|t|S(N(t_data(R$tcoltrowid((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	_data_key�scCs|t|tS(N(R&(R$R'((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_search_col_data_key�scCs|tS(N(R&(R$((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_search_all_data_key�scCs|t|tS(N(t_rowid(R$R(((s&/usr/lib64/python2.7/bsddb/dbtables.pyt
_rowid_key�scCs|tS(N(R,(R$((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_search_rowid_key�scCs`|jt�dksT|jt�dksT|jt�dksT|jt�dkrXdSdSdS(s�Verify that the given string does not contain any
    metadata strings that might interfere with dbtables database operation.
    iiN(tfindt_table_names_keyR#R&R,(R
((s&/usr/lib64/python2.7/bsddb/dbtables.pytcontains_metastrings�st
bsdTableDBcBs�eZdddddd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Ziid�Zid�Zid�Zd�Zd�ZRS(ii�cs"d|_tj}|r(|tjO}ntjtjBtjBtjB|B}	y|tjO}Wnt	k
rnnX|r�|	tj
B}	ntj�|_|jj
tj�|jj|||	B�|r�|tjO}ntj|j�|_|jjd�|jjtj�|jj|tj||B|�||_tjddkr�dtfd��Y�dtf�fd��Y}
|
|j�|_n|jj�}yVt|jd�t|�s�t|jd	|jj�ttjgd�d
|�nWn|j ��nX|j!�i|_"dS(s�bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600)

        Open database name in the dbhome Berkeley DB directory.
        Use keyword arguments when calling this constructor.
        iiitcursor_py3kcBs,eZd�Zd�Zd�Zd�ZRS(cSs
||_dS(N(t	_dbcursor(R	tdbcursor((s&/usr/lib64/python2.7/bsddb/dbtables.pyR�scSs
|jj�S(N(R4tclose(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyR6�scSsT|jjt|d��}|dk	rP|djd�|djd�f}n|S(Ns	iso8859-1ii(R4t	set_rangetbytestNonetdecode(R	tsearchtv((s&/usr/lib64/python2.7/bsddb/dbtables.pyR7�s
cSsNt|jd��}|dk	rJ|djd�|djd�f}n|S(Ntnextis	iso8859-1i(tgetattrR4R9R:(R	R<((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__next__�s
(RRRR6R7R?(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR3�s			tdb_py3kcs}eZd�Zd
�fd�Zd
d�Zdd
d�Zd
d�Zd
dd�Zd
dd�Z	d
d�Z
d	�ZRS(cSs
||_dS(N(t_db(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyR�scs�|jjd|��S(Nttxn(RAtcursor(R	RB(R3(s&/usr/lib64/python2.7/bsddb/dbtables.pyRC�scSs%t|jd�t|d�d|�S(Nthas_keys	iso8859-1RB(R>RAR8(R	tkeyRB((s&/usr/lib64/python2.7/bsddb/dbtables.pyRD�sicSsLt|d�}|dk	r-t|d�}n|jj||d|d|�S(Ns	iso8859-1tflagsRB(R8R9RAtput(R	REtvalueRFRB((s&/usr/lib64/python2.7/bsddb/dbtables.pyRG�scSs(t|d�}|jj||d|�S(Ns	iso8859-1RB(R8RARG(R	RERHRB((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	put_bytes�scSsOt|d�}|jj|d|d|�}|dk	rK|jd�}n|S(Ns	iso8859-1RBRF(R8RAtgetR9R:(R	RERBRFR<((s&/usr/lib64/python2.7/bsddb/dbtables.pyRJ�s
cSs+t|d�}|jj|d|d|�S(Ns	iso8859-1RBRF(R8RARJ(R	RERBRF((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	get_bytes�scSs%t|d�}|jj|d|�S(Ns	iso8859-1RB(R8RAtdelete(R	RERB((s&/usr/lib64/python2.7/bsddb/dbtables.pyRL�scSs
|jj�S(N(RAR6(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyR6�sN(RRRR9RCRDRGRIRJRKRLR6((R3(s&/usr/lib64/python2.7/bsddb/dbtables.pyR@�s	RDRIRBN(#R9Rt	DB_THREADt	DB_CREATEt
DB_INIT_MPOOLtDB_INIT_LOCKtDB_INIT_LOGtDB_INIT_TXNtDB_AUTO_COMMITtAttributeErrort
DB_RECOVERtDBEnvtenvt
set_lk_detecttDB_LOCK_DEFAULTtopentDB_TRUNCATEtDBtset_get_returns_nonet	set_flagstDB_DUPtDB_BTREEt
dbfilenametsystversion_infotobjectt	txn_beginR>R0RGtpickletdumpstaborttcommitt_bsdTableDB__tablecolumns(R	tfilenametdbhometcreatettruncatetmodetrecovertdbflagstmyflagstflagsforenvR@RB((R3s&/usr/lib64/python2.7/bsddb/dbtables.pyR�sF		"
 	'#

cCs|j�dS(N(R6(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__del__scCsT|jdk	r(|jj�d|_n|jdk	rP|jj�d|_ndS(N(RR9R6RW(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyR6s

cCs|jj|�dS(N(RWttxn_checkpoint(R	tmins((s&/usr/lib64/python2.7/bsddb/dbtables.pyt
checkpointscCs|jj�dS(N(Rtsync(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyRx scCs�dGH|jj�}y^|j�\}}xEti||6�GH|j�}|r_|\}}q,|j�dSq,WWntjk
r�|j�nXdS(s*Print the database to stdout for debuggings5******** Printing raw database for debugging ********N(RRCtfirsttreprR=R6tDBNotFoundError(R	tcurREtdataR=((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	_db_print#s
cCs�t|t�st�d}y^t|�r9td��nx)|D]!}t|�r@td��q@q@Wt|�}t|jd�|�r�t	d�n|j
j�}t|jd|jj�|t
j|d�d|�t
jt|jd|jj�td|d	tj��}|j|�|jjtd|�t|jd|jj�tt
j|d�d|�|j�d}WnXtjk
r�}|r�|j�ntjd
kr�t|d�q�t|jd�nXdS(s�CreateTable(table, columns) - Create a new table in the database.

        raises TableDBError if it already exists or for other DB errors.
        s-bad table name: contains reserved metastringss.bad column name: contains reserved metastringsRDstable already existsRIiRBRKRFiiN(ii(t
isinstancetlisttAssertionErrorR9R1t
ValueErrorR%R>RRRWReRGRfRgtloadsRJR0tDB_RMWtappendRLRitDBErrorRhRbRcRtargs(R	R$tcolumnsRBtcolumntcolumnlist_keyt	tablelisttdberror((s&/usr/lib64/python2.7/bsddb/dbtables.pytCreateTable5s<
'



cCs�t|t�st�t|�r-td�nt|�}t|jd�|�sUgSt|jd|jj�|�}|r�t	j
|�SgSdS(s\Return a list of columns in the given table.
        [] if the table doesn't exist.
        s-bad table name: contains reserved metastringsRDRKN(RtstrR�R1R�R%R>RRJRfR�(R	R$R�tpickledcolumnlist((s&/usr/lib64/python2.7/bsddb/dbtables.pytListTableColumnses
cCs-|jjt�}|r%tj|�SgSdS(s)Return a list of tables in this database.N(Rtget_getR0RfR�(R	tpickledtablelist((s&/usr/lib64/python2.7/bsddb/dbtables.pyt
ListTablesws
c
Cs�t|t�st�y|j||�Wn�tk
r�d}y+t|�}|jj�}t	j
t|jd|jj
�|d|dtj��}i}x|D]}|||<q�Wtj|�}x*|D]"}||kr�|j|�q�q�W||krL|jj|d|�t|jd|jj�|t	j|d�d|�n|j�d}|j|�Wq�tjk
r�}	|r�|j�ntjd	kr�t|	d�q�t|	jd�q�XnXdS(
sCreateOrExtendTable(table, columns)

        Create a new table in the database.

        If a table of this name already exists, extend it to have any
        additional columns present in the given list as well as
        all of its current columns.
        RKRBRFRIiiiN(ii(RR�R�R�RR9R%RWReRfR�R>RRJR�tcopyR�RLRGRgRit_bsdTableDB__load_column_infoR�RhRbRcRR�(
R	R$R�RBR�t
oldcolumnlistt
oldcolumnhashtct
newcolumnlistR�((s&/usr/lib64/python2.7/bsddb/dbtables.pytCreateOrExtendTables@	
'




cCs�y+t|jd|jj�t|��}Wn$tjk
rQtd|f�nX|sktd|f�ntj|�|j|<dS(s'initialize the self.__tablecolumns dictRKsunknown table: %rN(	R>RRJR%R{RRfR�Rj(R	R$ttcolpickles((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__load_column_info�scCs�d}x�|s�g}x-tt�D]}|jtjdd��q"Wtjdt|�}tjddkr�|j	d�}ny/|j
jt||�d	d|dt
j�Wnt
jk
r�q	Xd}q	W|S(
s"Create a new unique row identifierii�tBis	iso8859-1RBRFiN(txranget_rowid_str_lenR�trandomtrandinttstructtpackRbRcR:RRGR-R9tDB_NOOVERWRITEtDBKeyExistError(R	R$RBtuniquetblisttxtnewid((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__new_rowid�s	!
c	Cs�d}yt|jd�t|��s3td�n||jkrR|j|�nx=|j�D]/}|j|j|�s_td|f�q_q_W|j	j
�}|j|d|�}x?|j�D]1\}}|jj
t|||�|d|�q�W|j�d}Wn�tjk
r�}tj�}|rV|j�|jjt||��ntjd	kr|t|d|d�q�t|jd|d�nXdS(
s�Insert(table, datadict) - Insert a new row into the table
        using the keys+values from rowdict as the column values.
        RDs
unknown tablesunknown column: %rRBiiiN(ii(R9R>RR%RRjR�tkeystcountRWRet_bsdTableDB__new_rowidtitemsRGR)RiR�Rbtexc_infoRhRLR-RcR�(	R	R$trowdictRBR�R(tdataitemR�tinfo((s&/usr/lib64/python2.7/bsddb/dbtables.pytInsert�s.)


cCs�yA|j|g|�}|j�}x|j�D]}d}y�x�|D]�}|jj�}yJ|jjt|||�d|�}	|jjt|||�d|�Wntj	k
r�d}	nX|||	�}	|	dk	r|jj
t|||�|	d|�n|j�d}qGWWq1|r5|j�n�q1Xq1WWnEtj
k
r�}
tjdkrut|
d�q�t|
jd�nXdS(sModify(table, conditions={}, mappings={}) - Modify items in rows matching 'conditions' using mapping functions in 'mappings'

        * table - the table name
        * conditions - a dictionary keyed on column names containing
          a condition callable expecting the data string as an
          argument and returning a boolean.
        * mappings - a dictionary keyed on column names containing a
          condition callable expecting the data string as an argument and
          returning the new string for that column.
        RBiiiN(ii(t_bsdTableDB__SelectR�R9RWReRRJR)RLR{RGRiRhR�RbRcRR�(R	R$t
conditionstmappingstmatching_rowidsR�R(RBR�R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytModifys@
			
	

c	Csiy|j|g|�}|j|}x�|j�D]�}d}y�|jj�}xK|D]C}y&|jjt|||�d|�WqWtj	k
r�qWXqWWy#|jjt
||�d|�Wntj	k
r�nX|j�d}Wq2tjk
r}|r|j
�n�q2Xq2WWnEtjk
rd}tjdkrQt|d�qet|jd�nXdS(sDelete(table, conditions) - Delete items matching the given
        conditions from the table.

        * conditions - a dictionary keyed on column names containing
          condition functions expecting the data string as an
          argument and returning a boolean.
        RBiiiN(ii(R�RjR�R9RWReRRLR)R{R-RiR�RhRbRcRR�(	R	R$R�R�R�R(RBR�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytDeleteBs6	

#


cCs�yT||jkr"|j|�n|dkr>|j|}n|j|||�}WnEtjk
r�}tjdkr�t|d�q�t|j	d�nX|j
�S(s�Select(table, columns, conditions) - retrieve specific row data
        Returns a list of row column->value mapping dictionaries.

        * columns - a list of which column data to return.  If
          columns is None, all columns will be returned.
        * conditions - a dictionary keyed on column names
          containing callable conditions expecting the data string as an
          argument and returning a boolean.
        iiiN(ii(RjR�R9R�RR�RbRcRR�tvalues(R	R$R�R�R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytSelectos
cCs�||jkr|j|�n|dkr;|j|}nxA||j�D]/}|j|j|�sLtd|f�qLqLWi}i}d�}tjd	kr�|j	�}|j
|�nvg}xm|j	�D]_}	xVt|�D];\}
}|||	�}|dkr�|j|
|	�Pq�q�W|j
|	�q�W|jj�}
d}xH|D]@\}}|d}t||�}||kr�d}nd}y�|
j|�\}}x�|t|� |krW|t}||krB|s�||�r||kri||<n|r?||||<q?qB||kr5||=n|||<n|
j�\}}q�WWqQtjk
r�}|jdtjkrQ�qQqQqQXqQW|
j�~t|�dkr�x�|j	�D]�\}}x�|D]�}||kr�q�ny&|jjt|||��||<Wq�tjk
r{}tjd
krR|dtjkrn�qnn|jdtjkrn�nd||<q�Xq�Wq�Wn|S(s�__Select() - Used to implement Select and Delete (above)
        Returns a dictionary keyed on rowids containing dicts
        holding the row data for columns listed in the columns param
        that match the given conditions.
        * conditions is a dictionary keyed on column names
        containing callable conditions expecting the data string as an
        argument and returning a boolean.
        sunknown column: %rcSs|d}|d}t|�t|�kr�d�}t|t�rrt|t�rr|t|j�t|j��St|t�r�t|t�r�|t|j�t|j��SdSt|t�r�dSt|t�r�dSt|t�r�dSt|t�r�dSdS(NicSs$||krdS||kr dSdS(Nii����i((tatb((s&/usr/lib64/python2.7/bsddb/dbtables.pytcmp�s
ii����(ttypeRRRRRRR
(tatupletbtupleR�R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytcmp_conditions�s$

	iiii����iN(ii(ii(RjR�R9ttablecolumnsR�R�RRbRcR�tsortt	enumeratetinsertR�RRCR*R7RR�R=R�R�tDB_NOTFOUNDR6RJR)(R	R$R�R�R�R�trejected_rowidsR�t
conditionlisttitjtktrR|t
column_numt	conditiont	searchkeytsavethiscolumndataRER}R(R�trowdata((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__Select�s�
	
	




		c	Cs8d}y�|jj�}|jjt|�d|�|jj|�}t|�}xYy|j|�\}}Wntj	k
r�PnX|t
|� |kr�Pn|j�qUWt|�}xYy|j|�\}}Wntj	k
r�PnX|t
|� |krPn|j�q�W|j�t
jt|jd|jj�td|dtj��}y|j|�Wntk
r}nX|jjtd|�t|jd|jj�tt
j|d�d|�|j�d}||jkr�|j|=nWn<tjk
r3}|r|j�nt|jd��nXdS(s(Remove an entire table from the databaseRBRKRFRIiN(R9RWReRRLR%RCR+R7R{RR.R6RfR�R>RJR0R�tremoveR�RGRgRiRjR�RhRR�(	R	R$RBR|t	table_keyRER}R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytDropsT



(RRRRtR6RwRxR~R�R�R�R�R�R�R�R�R�R�R�R�(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR2�s&	r					0			:			,6-	�(ii((()t_cvsidRRbR�R�R�RcRftcPickletwarningstcatch_warningstwt	__enter__tfilterwarningstDeprecationWarningt__exit__tbsddb3RtImportErrortbsddbt
StandardErrorRRRR
RRRR0R#R%R&R,R�R)R*R+R-R.R1R2(((s&/usr/lib64/python2.7/bsddb/dbtables.pyt<module>sV

							dbobj.py000064400000026103150536075210006204 0ustar00#-------------------------------------------------------------------------
#  This file contains real Python object wrappers for DB and DBEnv
#  C "objects" that can be usefully subclassed.  The previous SWIG
#  based interface allowed this thanks to SWIG's shadow classes.
#   --  Gregory P. Smith
#-------------------------------------------------------------------------
#
# (C) Copyright 2001  Autonomous Zone Industries
#
# License:  This is free software.  You may use this software for any
#           purpose including modification/redistribution, so long as
#           this header remains intact and that you do not claim any
#           rights of ownership or authorship of this software.  This
#           software has been tested, but no warranty is expressed or
#           implied.
#

#
# TODO it would be *really nice* to have an automatic shadow class populator
# so that new methods don't need to be added  here manually after being
# added to _bsddb.c.
#

import sys
absolute_import = (sys.version_info[0] >= 3)
if absolute_import :
    # Because this syntaxis is not valid before Python 2.5
    exec("from . import db")
else :
    import db

if sys.version_info < (2, 6) :
    from UserDict import DictMixin as MutableMapping
else :
    import collections
    MutableMapping = collections.MutableMapping

class DBEnv:
    def __init__(self, *args, **kwargs):
        self._cobj = db.DBEnv(*args, **kwargs)

    def close(self, *args, **kwargs):
        return self._cobj.close(*args, **kwargs)
    def open(self, *args, **kwargs):
        return self._cobj.open(*args, **kwargs)
    def remove(self, *args, **kwargs):
        return self._cobj.remove(*args, **kwargs)
    def set_shm_key(self, *args, **kwargs):
        return self._cobj.set_shm_key(*args, **kwargs)
    def set_cachesize(self, *args, **kwargs):
        return self._cobj.set_cachesize(*args, **kwargs)
    def set_data_dir(self, *args, **kwargs):
        return self._cobj.set_data_dir(*args, **kwargs)
    def set_flags(self, *args, **kwargs):
        return self._cobj.set_flags(*args, **kwargs)
    def set_lg_bsize(self, *args, **kwargs):
        return self._cobj.set_lg_bsize(*args, **kwargs)
    def set_lg_dir(self, *args, **kwargs):
        return self._cobj.set_lg_dir(*args, **kwargs)
    def set_lg_max(self, *args, **kwargs):
        return self._cobj.set_lg_max(*args, **kwargs)
    def set_lk_detect(self, *args, **kwargs):
        return self._cobj.set_lk_detect(*args, **kwargs)
    if db.version() < (4,5):
        def set_lk_max(self, *args, **kwargs):
            return self._cobj.set_lk_max(*args, **kwargs)
    def set_lk_max_locks(self, *args, **kwargs):
        return self._cobj.set_lk_max_locks(*args, **kwargs)
    def set_lk_max_lockers(self, *args, **kwargs):
        return self._cobj.set_lk_max_lockers(*args, **kwargs)
    def set_lk_max_objects(self, *args, **kwargs):
        return self._cobj.set_lk_max_objects(*args, **kwargs)
    def set_mp_mmapsize(self, *args, **kwargs):
        return self._cobj.set_mp_mmapsize(*args, **kwargs)
    def set_timeout(self, *args, **kwargs):
        return self._cobj.set_timeout(*args, **kwargs)
    def set_tmp_dir(self, *args, **kwargs):
        return self._cobj.set_tmp_dir(*args, **kwargs)
    def txn_begin(self, *args, **kwargs):
        return self._cobj.txn_begin(*args, **kwargs)
    def txn_checkpoint(self, *args, **kwargs):
        return self._cobj.txn_checkpoint(*args, **kwargs)
    def txn_stat(self, *args, **kwargs):
        return self._cobj.txn_stat(*args, **kwargs)
    def set_tx_max(self, *args, **kwargs):
        return self._cobj.set_tx_max(*args, **kwargs)
    def set_tx_timestamp(self, *args, **kwargs):
        return self._cobj.set_tx_timestamp(*args, **kwargs)
    def lock_detect(self, *args, **kwargs):
        return self._cobj.lock_detect(*args, **kwargs)
    def lock_get(self, *args, **kwargs):
        return self._cobj.lock_get(*args, **kwargs)
    def lock_id(self, *args, **kwargs):
        return self._cobj.lock_id(*args, **kwargs)
    def lock_put(self, *args, **kwargs):
        return self._cobj.lock_put(*args, **kwargs)
    def lock_stat(self, *args, **kwargs):
        return self._cobj.lock_stat(*args, **kwargs)
    def log_archive(self, *args, **kwargs):
        return self._cobj.log_archive(*args, **kwargs)

    def set_get_returns_none(self, *args, **kwargs):
        return self._cobj.set_get_returns_none(*args, **kwargs)

    def log_stat(self, *args, **kwargs):
        return self._cobj.log_stat(*args, **kwargs)

    def dbremove(self, *args, **kwargs):
        return self._cobj.dbremove(*args, **kwargs)
    def dbrename(self, *args, **kwargs):
        return self._cobj.dbrename(*args, **kwargs)
    def set_encrypt(self, *args, **kwargs):
        return self._cobj.set_encrypt(*args, **kwargs)

    if db.version() >= (4,4):
        def fileid_reset(self, *args, **kwargs):
            return self._cobj.fileid_reset(*args, **kwargs)

        def lsn_reset(self, *args, **kwargs):
            return self._cobj.lsn_reset(*args, **kwargs)


class DB(MutableMapping):
    def __init__(self, dbenv, *args, **kwargs):
        # give it the proper DBEnv C object that its expecting
        self._cobj = db.DB(*((dbenv._cobj,) + args), **kwargs)

    # TODO are there other dict methods that need to be overridden?
    def __len__(self):
        return len(self._cobj)
    def __getitem__(self, arg):
        return self._cobj[arg]
    def __setitem__(self, key, value):
        self._cobj[key] = value
    def __delitem__(self, arg):
        del self._cobj[arg]

    if sys.version_info >= (2, 6) :
        def __iter__(self) :
            return self._cobj.__iter__()

    def append(self, *args, **kwargs):
        return self._cobj.append(*args, **kwargs)
    def associate(self, *args, **kwargs):
        return self._cobj.associate(*args, **kwargs)
    def close(self, *args, **kwargs):
        return self._cobj.close(*args, **kwargs)
    def consume(self, *args, **kwargs):
        return self._cobj.consume(*args, **kwargs)
    def consume_wait(self, *args, **kwargs):
        return self._cobj.consume_wait(*args, **kwargs)
    def cursor(self, *args, **kwargs):
        return self._cobj.cursor(*args, **kwargs)
    def delete(self, *args, **kwargs):
        return self._cobj.delete(*args, **kwargs)
    def fd(self, *args, **kwargs):
        return self._cobj.fd(*args, **kwargs)
    def get(self, *args, **kwargs):
        return self._cobj.get(*args, **kwargs)
    def pget(self, *args, **kwargs):
        return self._cobj.pget(*args, **kwargs)
    def get_both(self, *args, **kwargs):
        return self._cobj.get_both(*args, **kwargs)
    def get_byteswapped(self, *args, **kwargs):
        return self._cobj.get_byteswapped(*args, **kwargs)
    def get_size(self, *args, **kwargs):
        return self._cobj.get_size(*args, **kwargs)
    def get_type(self, *args, **kwargs):
        return self._cobj.get_type(*args, **kwargs)
    def join(self, *args, **kwargs):
        return self._cobj.join(*args, **kwargs)
    def key_range(self, *args, **kwargs):
        return self._cobj.key_range(*args, **kwargs)
    def has_key(self, *args, **kwargs):
        return self._cobj.has_key(*args, **kwargs)
    def items(self, *args, **kwargs):
        return self._cobj.items(*args, **kwargs)
    def keys(self, *args, **kwargs):
        return self._cobj.keys(*args, **kwargs)
    def open(self, *args, **kwargs):
        return self._cobj.open(*args, **kwargs)
    def put(self, *args, **kwargs):
        return self._cobj.put(*args, **kwargs)
    def remove(self, *args, **kwargs):
        return self._cobj.remove(*args, **kwargs)
    def rename(self, *args, **kwargs):
        return self._cobj.rename(*args, **kwargs)
    def set_bt_minkey(self, *args, **kwargs):
        return self._cobj.set_bt_minkey(*args, **kwargs)
    def set_bt_compare(self, *args, **kwargs):
        return self._cobj.set_bt_compare(*args, **kwargs)
    def set_cachesize(self, *args, **kwargs):
        return self._cobj.set_cachesize(*args, **kwargs)
    def set_dup_compare(self, *args, **kwargs) :
        return self._cobj.set_dup_compare(*args, **kwargs)
    def set_flags(self, *args, **kwargs):
        return self._cobj.set_flags(*args, **kwargs)
    def set_h_ffactor(self, *args, **kwargs):
        return self._cobj.set_h_ffactor(*args, **kwargs)
    def set_h_nelem(self, *args, **kwargs):
        return self._cobj.set_h_nelem(*args, **kwargs)
    def set_lorder(self, *args, **kwargs):
        return self._cobj.set_lorder(*args, **kwargs)
    def set_pagesize(self, *args, **kwargs):
        return self._cobj.set_pagesize(*args, **kwargs)
    def set_re_delim(self, *args, **kwargs):
        return self._cobj.set_re_delim(*args, **kwargs)
    def set_re_len(self, *args, **kwargs):
        return self._cobj.set_re_len(*args, **kwargs)
    def set_re_pad(self, *args, **kwargs):
        return self._cobj.set_re_pad(*args, **kwargs)
    def set_re_source(self, *args, **kwargs):
        return self._cobj.set_re_source(*args, **kwargs)
    def set_q_extentsize(self, *args, **kwargs):
        return self._cobj.set_q_extentsize(*args, **kwargs)
    def stat(self, *args, **kwargs):
        return self._cobj.stat(*args, **kwargs)
    def sync(self, *args, **kwargs):
        return self._cobj.sync(*args, **kwargs)
    def type(self, *args, **kwargs):
        return self._cobj.type(*args, **kwargs)
    def upgrade(self, *args, **kwargs):
        return self._cobj.upgrade(*args, **kwargs)
    def values(self, *args, **kwargs):
        return self._cobj.values(*args, **kwargs)
    def verify(self, *args, **kwargs):
        return self._cobj.verify(*args, **kwargs)
    def set_get_returns_none(self, *args, **kwargs):
        return self._cobj.set_get_returns_none(*args, **kwargs)

    def set_encrypt(self, *args, **kwargs):
        return self._cobj.set_encrypt(*args, **kwargs)


class DBSequence:
    def __init__(self, *args, **kwargs):
        self._cobj = db.DBSequence(*args, **kwargs)

    def close(self, *args, **kwargs):
        return self._cobj.close(*args, **kwargs)
    def get(self, *args, **kwargs):
        return self._cobj.get(*args, **kwargs)
    def get_dbp(self, *args, **kwargs):
        return self._cobj.get_dbp(*args, **kwargs)
    def get_key(self, *args, **kwargs):
        return self._cobj.get_key(*args, **kwargs)
    def init_value(self, *args, **kwargs):
        return self._cobj.init_value(*args, **kwargs)
    def open(self, *args, **kwargs):
        return self._cobj.open(*args, **kwargs)
    def remove(self, *args, **kwargs):
        return self._cobj.remove(*args, **kwargs)
    def stat(self, *args, **kwargs):
        return self._cobj.stat(*args, **kwargs)
    def set_cachesize(self, *args, **kwargs):
        return self._cobj.set_cachesize(*args, **kwargs)
    def set_flags(self, *args, **kwargs):
        return self._cobj.set_flags(*args, **kwargs)
    def set_range(self, *args, **kwargs):
        return self._cobj.set_range(*args, **kwargs)
    def get_cachesize(self, *args, **kwargs):
        return self._cobj.get_cachesize(*args, **kwargs)
    def get_flags(self, *args, **kwargs):
        return self._cobj.get_flags(*args, **kwargs)
    def get_range(self, *args, **kwargs):
        return self._cobj.get_range(*args, **kwargs)
dbshelve.pyc000064400000031336150536075210007067 0ustar00�
{fc@s�dZddlZejddkZer6ddUnddlZejddkrdddlZnzejdkr�ddlZn\ddlZej�Zej	�z)ej
dd	d
de�ddlZWdej�X[ej
Z
d�Zejdkrdd
lmZnddlZejZejdejddd�Zdejfd��YZdefd��YZddd��YZdS(sNManage shelves of pickled objects using bsddb database files for the
storage.
i����Niisfrom . import dbiitignoretmessages1the cPickle module has been removed in Python 3.0tcategorycCstj|d|�S(Ntprotocol(tcPickletdumps(tobjectR((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt_dumpsDs(t	DictMixini�cCs�t|�td�kr�|}|dkr6tj}q�|dkrKd}q�|dkrctj}q�|dkr{tj}q�|dkr�tjtjB}q�tjd�nt|�}|j|||||�|S(	s(
    A simple factory function for compatibility with the standard
    shleve.py module.  It can be used like this, where key is a string
    and data is a pickleable object:

        from bsddb import dbshelve
        db = dbshelve.open(filename)

        db[key] = data

        db.close()
    ttrtrwitwtctnsJflags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags(ttypetdbt	DB_RDONLYt	DB_CREATEtDB_TRUNCATEtDBErrortDBShelftopen(tfilenametflagstmodetfiletypetdbenvtdbnametsflagtd((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRPs 	t
DBShelveErrorcBseZRS((t__name__t
__module__(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRssRcBseZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dd�Zej
dkrud�Znd�Zd
�Zd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd�Zddd�Zddd�Zddd�Zdd�ZRS(s�A shelf to hold pickled objects, built upon a bsddb DB object.  It
    automatically pickles/unpickles data objects going to/from the DB.
    cCs:tj|�|_t|_tr-t|_n	d|_dS(Ni(RtDBtTruet_closedtHIGHEST_PROTOCOLR(tselfR((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__init__zs
	cCs|j�dS(N(tclose(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__del__�scCst|j|�S(sTMany methods we can just pass through to the DB object.
        (See below)
        (tgetattrR(R&tname((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__getattr__�scCs
t|j�S(N(tlenR(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__len__�scCs|j|}tj|�S(N(RRtloads(R&tkeytdata((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__getitem__�s
cCs#t||j�}||j|<dS(N(RRR(R&R0tvalueR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__setitem__�scCs|j|=dS(N(R(R&R0((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__delitem__�scCs-|dk	r|jj|�S|jj�SdS(N(tNoneRtkeys(R&ttxn((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR7�siiccs#x|jj�D]}|VqWdS(N(RR7(R&tk((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__iter__�scOs |jj||�t|_dS(N(RRtFalseR$(R&targstkwargs((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�scOs |jj||�t|_dS(N(RR(R#R$(R&R<R=((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR(�scCs1|jrdt|�Stt|j���SdS(Ns<DBShelf @ 0x%x - closed>(R$tidtreprtdictt	iteritems(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__repr__�s	cCsm|dk	r!|jj|�}n|jj�}g}x0|D](\}}|j|tj|�f�q=W|S(N(R6RtitemstappendRR/(R&R8RCtnewitemsR9tv((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRC�s cCs@|dk	r!|jj|�}n|jj�}ttj|�S(N(R6RtvaluestmapRR/(R&R8RG((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRG�scCs%t||j�}|jj||�S(N(RRRRD(R&R3R8R1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__append�scCs5|j�tjkr(|j|d|�Std�dS(NR8sOappend() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO(tget_typeRtDB_RECNOt_DBShelf__appendR(R&R3R8((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRD�sicCs"|d�}|jj|||�S(NcSsYtjddks"t|t�r4tj|�}ntjt|d��}|||�S(Niis	iso8859-1(tsystversion_infot
isinstancetbytesRR/(tpriKeytpriDatatrealCallbackR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt_shelf_callback�s"(Rt	associate(R&tsecondaryDBtcallbackRRT((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRU�scOsK|jj||�}ytj|�SWntttjfk
rF|SXdS(N(RtgetRR/tEOFErrort	TypeErrortUnpicklingError(R&R<tkwR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRX�s
cCs:t||j�}|jj||||�}tj|�S(N(RRRRXRR/(R&R0R3R8RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_both�scCs+t|jj||��}|j|_|S(N(t
DBShelfCursorRtcursorR(R&R8RR
((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR_scCs+t||j�}|jj||||�S(N(RRRtput(R&R0R3R8RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR`scCs
t�dS(N(tNotImplementedError(R&t
cursorListR((s&/usr/lib64/python2.7/bsddb/dbshelve.pytjoinsN(ii(R R!t__doc__R6R'R)R,R.R2R4R5R7RMRNR:RR(RBRCRGRLRDRURXR]R_R`Rc(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRvs0			
							
	R^cBseZdZd�Zd�Zd�Zdd�Zdd�Zd�Zd�Z	d	�Z
d
�Zdd�Zdd�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZeZd�ZRS(s
    cCs
||_dS(N(tdbc(R&R_((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR'!scCs|j�dS(N(R((R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR)$scCst|j|�S(sHSome methods we can just pass through to the cursor object.  (See below)(R*Re(R&R+((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR,(sicCs(t|jj|��}|j|_|S(N(R^RetdupR(R&RR
((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRf/scCs(t||j�}|jj|||�S(N(RRReR`(R&R0R3RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR`5scGs-t|�}t|d|�}||�dS(Nsget_%d(R-R*(R&R<tcounttmethod((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRX:scCs|jj|�}|j|�S(N(ReRXt_extract(R&Rtrec((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_1?scCs"|jj||�}|j|�S(N(ReRXRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_2CscCs4t||j�}|jj||�}|j|�S(N(RRReRXRi(R&R0R3RR1Rj((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_3GscCs|j|tjB�S(N(RkRt
DB_CURRENT(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytcurrentMR	cCs|j|tjB�S(N(RkRtDB_FIRST(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytfirstNR	cCs|j|tjB�S(N(RkRtDB_LAST(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytlastOR	cCs|j|tjB�S(N(RkRtDB_NEXT(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytnextPR	cCs|j|tjB�S(N(RkRtDB_PREV(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytprevQR	cCs|j|tjB�S(N(RkRt
DB_CONSUME(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytconsumeRR	cCs|j|tjB�S(N(RkRtDB_NEXT_DUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytnext_dupSR	cCs|j|tjB�S(N(RkRt
DB_NEXT_NODUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt
next_nodupTR	cCs|j|tjB�S(N(RkRt
DB_PREV_NODUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt
prev_nodupUR	cCs4t||j�}|jj||�}|j|�S(N(RRReR]Ri(R&R0R3RR1Rj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR]XscCs"|jj||�}|j|�S(N(RetsetRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�^scCs"|jj||�}|j|�S(N(Ret	set_rangeRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�bscCs"|jj||�}|j|�S(N(Ret	set_recnoRi(R&trecnoRRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR�fscCsq|dkrdS|\}}tjddks>t|t�rQ|tj|�fS|tjt|d��fSdS(Niis	iso8859-1(R6RMRNRORPRR/(R&RjR0R1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRils"(R R!RdR'R)R,RfR`RXRkRlRmRoRqRsRuRwRyR{R}RR]R�R�R�tset_bothRi(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR^s2							(ii(ii((RdRMRNtabsolute_importRRtwarningstcatch_warningsRt	__enter__tfilterwarningstDeprecationWarningt__exit__R%RtUserDictRtMutableMappingtcollectionsRtDB_HASHR6RRRRR^(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt<module>s<
			"�dbshelve.py000064400000026446150536075210006732 0ustar00#------------------------------------------------------------------------
#           Copyright (c) 1997-2001 by Total Control Software
#                         All Rights Reserved
#------------------------------------------------------------------------
#
# Module Name:  dbShelve.py
#
# Description:  A reimplementation of the standard shelve.py that
#               forces the use of cPickle, and DB.
#
# Creation Date:    11/3/97 3:39:04PM
#
# License:      This is free software.  You may use this software for any
#               purpose including modification/redistribution, so long as
#               this header remains intact and that you do not claim any
#               rights of ownership or authorship of this software.  This
#               software has been tested, but no warranty is expressed or
#               implied.
#
# 13-Dec-2000:  Updated to be used with the new bsddb3 package.
#               Added DBShelfCursor class.
#
#------------------------------------------------------------------------

"""Manage shelves of pickled objects using bsddb database files for the
storage.
"""

#------------------------------------------------------------------------

import sys
absolute_import = (sys.version_info[0] >= 3)
if absolute_import :
    # Because this syntaxis is not valid before Python 2.5
    exec("from . import db")
else :
    import db

if sys.version_info[0] >= 3 :
    import cPickle  # Will be converted to "pickle" by "2to3"
else :
    if sys.version_info < (2, 6) :
        import cPickle
    else :
        # When we drop support for python 2.4
        # we could use: (in 2.5 we need a __future__ statement)
        #
        #    with warnings.catch_warnings():
        #        warnings.filterwarnings(...)
        #        ...
        #
        # We can not use "with" as is, because it would be invalid syntax
        # in python 2.4 and (with no __future__) 2.5.
        # Here we simulate "with" following PEP 343 :
        import warnings
        w = warnings.catch_warnings()
        w.__enter__()
        try :
            warnings.filterwarnings('ignore',
                message='the cPickle module has been removed in Python 3.0',
                category=DeprecationWarning)
            import cPickle
        finally :
            w.__exit__()
        del w

HIGHEST_PROTOCOL = cPickle.HIGHEST_PROTOCOL
def _dumps(object, protocol):
    return cPickle.dumps(object, protocol=protocol)

if sys.version_info < (2, 6) :
    from UserDict import DictMixin as MutableMapping
else :
    import collections
    MutableMapping = collections.MutableMapping

#------------------------------------------------------------------------


def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH,
         dbenv=None, dbname=None):
    """
    A simple factory function for compatibility with the standard
    shleve.py module.  It can be used like this, where key is a string
    and data is a pickleable object:

        from bsddb import dbshelve
        db = dbshelve.open(filename)

        db[key] = data

        db.close()
    """
    if type(flags) == type(''):
        sflag = flags
        if sflag == 'r':
            flags = db.DB_RDONLY
        elif sflag == 'rw':
            flags = 0
        elif sflag == 'w':
            flags =  db.DB_CREATE
        elif sflag == 'c':
            flags =  db.DB_CREATE
        elif sflag == 'n':
            flags = db.DB_TRUNCATE | db.DB_CREATE
        else:
            raise db.DBError, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"

    d = DBShelf(dbenv)
    d.open(filename, dbname, filetype, flags, mode)
    return d

#---------------------------------------------------------------------------

class DBShelveError(db.DBError): pass


class DBShelf(MutableMapping):
    """A shelf to hold pickled objects, built upon a bsddb DB object.  It
    automatically pickles/unpickles data objects going to/from the DB.
    """
    def __init__(self, dbenv=None):
        self.db = db.DB(dbenv)
        self._closed = True
        if HIGHEST_PROTOCOL:
            self.protocol = HIGHEST_PROTOCOL
        else:
            self.protocol = 1


    def __del__(self):
        self.close()


    def __getattr__(self, name):
        """Many methods we can just pass through to the DB object.
        (See below)
        """
        return getattr(self.db, name)


    #-----------------------------------
    # Dictionary access methods

    def __len__(self):
        return len(self.db)


    def __getitem__(self, key):
        data = self.db[key]
        return cPickle.loads(data)


    def __setitem__(self, key, value):
        data = _dumps(value, self.protocol)
        self.db[key] = data


    def __delitem__(self, key):
        del self.db[key]


    def keys(self, txn=None):
        if txn is not None:
            return self.db.keys(txn)
        else:
            return self.db.keys()

    if sys.version_info >= (2, 6) :
        def __iter__(self) :  # XXX: Load all keys in memory :-(
            for k in self.db.keys() :
                yield k

        # Do this when "DB"  support iteration
        # Or is it enough to pass thru "getattr"?
        #
        # def __iter__(self) :
        #    return self.db.__iter__()


    def open(self, *args, **kwargs):
        self.db.open(*args, **kwargs)
        self._closed = False


    def close(self, *args, **kwargs):
        self.db.close(*args, **kwargs)
        self._closed = True


    def __repr__(self):
        if self._closed:
            return '<DBShelf @ 0x%x - closed>' % (id(self))
        else:
            return repr(dict(self.iteritems()))


    def items(self, txn=None):
        if txn is not None:
            items = self.db.items(txn)
        else:
            items = self.db.items()
        newitems = []

        for k, v in items:
            newitems.append( (k, cPickle.loads(v)) )
        return newitems

    def values(self, txn=None):
        if txn is not None:
            values = self.db.values(txn)
        else:
            values = self.db.values()

        return map(cPickle.loads, values)

    #-----------------------------------
    # Other methods

    def __append(self, value, txn=None):
        data = _dumps(value, self.protocol)
        return self.db.append(data, txn)

    def append(self, value, txn=None):
        if self.get_type() == db.DB_RECNO:
            return self.__append(value, txn=txn)
        raise DBShelveError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"


    def associate(self, secondaryDB, callback, flags=0):
        def _shelf_callback(priKey, priData, realCallback=callback):
            # Safe in Python 2.x because expresion short circuit
            if sys.version_info[0] < 3 or isinstance(priData, bytes) :
                data = cPickle.loads(priData)
            else :
                data = cPickle.loads(bytes(priData, "iso8859-1"))  # 8 bits
            return realCallback(priKey, data)

        return self.db.associate(secondaryDB, _shelf_callback, flags)


    #def get(self, key, default=None, txn=None, flags=0):
    def get(self, *args, **kw):
        # We do it with *args and **kw so if the default value wasn't
        # given nothing is passed to the extension module.  That way
        # an exception can be raised if set_get_returns_none is turned
        # off.
        data = self.db.get(*args, **kw)
        try:
            return cPickle.loads(data)
        except (EOFError, TypeError, cPickle.UnpicklingError):
            return data  # we may be getting the default value, or None,
                         # so it doesn't need unpickled.

    def get_both(self, key, value, txn=None, flags=0):
        data = _dumps(value, self.protocol)
        data = self.db.get(key, data, txn, flags)
        return cPickle.loads(data)


    def cursor(self, txn=None, flags=0):
        c = DBShelfCursor(self.db.cursor(txn, flags))
        c.protocol = self.protocol
        return c


    def put(self, key, value, txn=None, flags=0):
        data = _dumps(value, self.protocol)
        return self.db.put(key, data, txn, flags)


    def join(self, cursorList, flags=0):
        raise NotImplementedError


    #----------------------------------------------
    # Methods allowed to pass-through to self.db
    #
    #    close,  delete, fd, get_byteswapped, get_type, has_key,
    #    key_range, open, remove, rename, stat, sync,
    #    upgrade, verify, and all set_* methods.


#---------------------------------------------------------------------------

class DBShelfCursor:
    """
    """
    def __init__(self, cursor):
        self.dbc = cursor

    def __del__(self):
        self.close()


    def __getattr__(self, name):
        """Some methods we can just pass through to the cursor object.  (See below)"""
        return getattr(self.dbc, name)


    #----------------------------------------------

    def dup(self, flags=0):
        c = DBShelfCursor(self.dbc.dup(flags))
        c.protocol = self.protocol
        return c


    def put(self, key, value, flags=0):
        data = _dumps(value, self.protocol)
        return self.dbc.put(key, data, flags)


    def get(self, *args):
        count = len(args)  # a method overloading hack
        method = getattr(self, 'get_%d' % count)
        method(*args)

    def get_1(self, flags):
        rec = self.dbc.get(flags)
        return self._extract(rec)

    def get_2(self, key, flags):
        rec = self.dbc.get(key, flags)
        return self._extract(rec)

    def get_3(self, key, value, flags):
        data = _dumps(value, self.protocol)
        rec = self.dbc.get(key, flags)
        return self._extract(rec)


    def current(self, flags=0): return self.get_1(flags|db.DB_CURRENT)
    def first(self, flags=0): return self.get_1(flags|db.DB_FIRST)
    def last(self, flags=0): return self.get_1(flags|db.DB_LAST)
    def next(self, flags=0): return self.get_1(flags|db.DB_NEXT)
    def prev(self, flags=0): return self.get_1(flags|db.DB_PREV)
    def consume(self, flags=0): return self.get_1(flags|db.DB_CONSUME)
    def next_dup(self, flags=0): return self.get_1(flags|db.DB_NEXT_DUP)
    def next_nodup(self, flags=0): return self.get_1(flags|db.DB_NEXT_NODUP)
    def prev_nodup(self, flags=0): return self.get_1(flags|db.DB_PREV_NODUP)


    def get_both(self, key, value, flags=0):
        data = _dumps(value, self.protocol)
        rec = self.dbc.get_both(key, flags)
        return self._extract(rec)


    def set(self, key, flags=0):
        rec = self.dbc.set(key, flags)
        return self._extract(rec)

    def set_range(self, key, flags=0):
        rec = self.dbc.set_range(key, flags)
        return self._extract(rec)

    def set_recno(self, recno, flags=0):
        rec = self.dbc.set_recno(recno, flags)
        return self._extract(rec)

    set_both = get_both

    def _extract(self, rec):
        if rec is None:
            return None
        else:
            key, data = rec
            # Safe in Python 2.x because expresion short circuit
            if sys.version_info[0] < 3 or isinstance(data, bytes) :
                return key, cPickle.loads(data)
            else :
                return key, cPickle.loads(bytes(data, "iso8859-1"))  # 8 bits

    #----------------------------------------------
    # Methods allowed to pass-through to self.dbc
    #
    # close, count, delete, get_recno, join_item


#---------------------------------------------------------------------------
dbobj.pyo000064400000044607150536075210006374 0ustar00�
{fc@s�ddlZejddkZer0ddUnddlZejdkr^ddlmZnddlZejZddd	��YZd
efd��YZ	ddd
��YZ
dS(i����Niisfrom . import dbii(t	DictMixintDBEnvcBseZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ej�d'kr�d�Znd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&ej�d(kr}d%�Z'd&�Z(nRS()cOstj||�|_dS(N(tdbRt_cobj(tselftargstkwargs((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__init__'scOs|jj||�S(N(Rtclose(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR*scOs|jj||�S(N(Rtopen(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR	,scOs|jj||�S(N(Rtremove(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
.scOs|jj||�S(N(Rtset_shm_key(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR0scOs|jj||�S(N(Rt
set_cachesize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR2scOs|jj||�S(N(Rtset_data_dir(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
4scOs|jj||�S(N(Rt	set_flags(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR6scOs|jj||�S(N(Rtset_lg_bsize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR8scOs|jj||�S(N(Rt
set_lg_dir(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR:scOs|jj||�S(N(Rt
set_lg_max(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR<scOs|jj||�S(N(Rt
set_lk_detect(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR>siicOs|jj||�S(N(Rt
set_lk_max(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRAscOs|jj||�S(N(Rtset_lk_max_locks(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRCscOs|jj||�S(N(Rtset_lk_max_lockers(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyREscOs|jj||�S(N(Rtset_lk_max_objects(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRGscOs|jj||�S(N(Rtset_mp_mmapsize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRIscOs|jj||�S(N(Rtset_timeout(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRKscOs|jj||�S(N(Rtset_tmp_dir(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRMscOs|jj||�S(N(Rt	txn_begin(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyROscOs|jj||�S(N(Rttxn_checkpoint(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRQscOs|jj||�S(N(Rttxn_stat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRSscOs|jj||�S(N(Rt
set_tx_max(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRUscOs|jj||�S(N(Rtset_tx_timestamp(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRWscOs|jj||�S(N(Rtlock_detect(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRYscOs|jj||�S(N(Rtlock_get(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR [scOs|jj||�S(N(Rtlock_id(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR!]scOs|jj||�S(N(Rtlock_put(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR"_scOs|jj||�S(N(Rt	lock_stat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR#ascOs|jj||�S(N(Rtlog_archive(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR$cscOs|jj||�S(N(Rtset_get_returns_none(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR%fscOs|jj||�S(N(Rtlog_stat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR&iscOs|jj||�S(N(Rtdbremove(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR'lscOs|jj||�S(N(Rtdbrename(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR(nscOs|jj||�S(N(Rtset_encrypt(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR)pscOs|jj||�S(N(Rtfileid_reset(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR*tscOs|jj||�S(N(Rt	lsn_reset(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR+ws(ii(ii()t__name__t
__module__RRR	R
RRR
RRRRRRtversionRRRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+(((s#/usr/lib64/python2.7/bsddb/dbobj.pyR&sN																																			tDBcBs�eZd�Zd�Zd�Zd�Zd�Zejd5krNd�Z	nd�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6RS(6cOs#tj|jf||�|_dS(N(RR/R(RtdbenvRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR|scCs
t|j�S(N(tlenR(R((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__len__�scCs|j|S(N(R(Rtarg((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__getitem__�scCs||j|<dS(N(R(Rtkeytvalue((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__setitem__�scCs|j|=dS(N(R(RR3((s#/usr/lib64/python2.7/bsddb/dbobj.pyt__delitem__�siicCs
|jj�S(N(Rt__iter__(R((s#/usr/lib64/python2.7/bsddb/dbobj.pyR9�scOs|jj||�S(N(Rtappend(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR:�scOs|jj||�S(N(Rt	associate(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR;�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(Rtconsume(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR<�scOs|jj||�S(N(Rtconsume_wait(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR=�scOs|jj||�S(N(Rtcursor(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR>�scOs|jj||�S(N(Rtdelete(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR?�scOs|jj||�S(N(Rtfd(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR@�scOs|jj||�S(N(Rtget(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRA�scOs|jj||�S(N(Rtpget(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRB�scOs|jj||�S(N(Rtget_both(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRC�scOs|jj||�S(N(Rtget_byteswapped(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRD�scOs|jj||�S(N(Rtget_size(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRE�scOs|jj||�S(N(Rtget_type(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRF�scOs|jj||�S(N(Rtjoin(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRG�scOs|jj||�S(N(Rt	key_range(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRH�scOs|jj||�S(N(Rthas_key(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRI�scOs|jj||�S(N(Rtitems(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRJ�scOs|jj||�S(N(Rtkeys(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRK�scOs|jj||�S(N(RR	(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR	�scOs|jj||�S(N(Rtput(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRL�scOs|jj||�S(N(RR
(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
�scOs|jj||�S(N(Rtrename(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRM�scOs|jj||�S(N(Rt
set_bt_minkey(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRN�scOs|jj||�S(N(Rtset_bt_compare(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRO�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(Rtset_dup_compare(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRP�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(Rt
set_h_ffactor(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRQ�scOs|jj||�S(N(Rtset_h_nelem(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRR�scOs|jj||�S(N(Rt
set_lorder(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRS�scOs|jj||�S(N(Rtset_pagesize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRT�scOs|jj||�S(N(Rtset_re_delim(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRU�scOs|jj||�S(N(Rt
set_re_len(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRV�scOs|jj||�S(N(Rt
set_re_pad(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRW�scOs|jj||�S(N(Rt
set_re_source(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRX�scOs|jj||�S(N(Rtset_q_extentsize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRY�scOs|jj||�S(N(Rtstat(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRZ�scOs|jj||�S(N(Rtsync(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR[�scOs|jj||�S(N(Rttype(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR\�scOs|jj||�S(N(Rtupgrade(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR]�scOs|jj||�S(N(Rtvalues(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR^�scOs|jj||�S(N(Rtverify(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR_�scOs|jj||�S(N(RR%(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR%�scOs|jj||�S(N(RR)(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR)�s(ii(7R,R-RR2R4R7R8tsystversion_infoR9R:R;RR<R=R>R?R@RARBRCRDRERFRGRHRIRJRKR	RLR
RMRNRORRPRRQRRRSRTRURVRWRXRYRZR[R\R]R^R_R%R)(((s#/usr/lib64/python2.7/bsddb/dbobj.pyR/{sh																																																	t
DBSequencecBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�ZRS(cOstj||�|_dS(N(RRbR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(RRA(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRA�scOs|jj||�S(N(Rtget_dbp(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRc�scOs|jj||�S(N(Rtget_key(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRd�scOs|jj||�S(N(Rt
init_value(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRe�scOs|jj||�S(N(RR	(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR	�scOs|jj||�S(N(RR
(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR
�scOs|jj||�S(N(RRZ(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRZ�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyR�scOs|jj||�S(N(RR(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRscOs|jj||�S(N(Rt	set_range(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRfscOs|jj||�S(N(Rt
get_cachesize(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRgscOs|jj||�S(N(Rt	get_flags(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRhscOs|jj||�S(N(Rt	get_range(RRR((s#/usr/lib64/python2.7/bsddb/dbobj.pyRi	s(R,R-RRRARcRdReR	R
RZRRRfRgRhRi(((s#/usr/lib64/python2.7/bsddb/dbobj.pyRb�s														(ii(((R`Ratabsolute_importRtUserDictRtMutableMappingtcollectionsRR/Rb(((s#/usr/lib64/python2.7/bsddb/dbobj.pyt<module>s	Up__init__.py000064400000037164150536075210006674 0ustar00#----------------------------------------------------------------------
#  Copyright (c) 1999-2001, Digital Creations, Fredericksburg, VA, USA
#  and Andrew Kuchling. All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions are
#  met:
#
#    o Redistributions of source code must retain the above copyright
#      notice, this list of conditions, and the disclaimer that follows.
#
#    o Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions, and the following disclaimer in
#      the documentation and/or other materials provided with the
#      distribution.
#
#    o Neither the name of Digital Creations nor the names of its
#      contributors may be used to endorse or promote products derived
#      from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS
#  IS* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#  PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL
#  CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
#  DAMAGE.
#----------------------------------------------------------------------


"""Support for Berkeley DB 4.3 through 5.3 with a simple interface.

For the full featured object oriented interface use the bsddb.db module
instead.  It mirrors the Oracle Berkeley DB C API.
"""

import sys
absolute_import = (sys.version_info[0] >= 3)

if (sys.version_info >= (2, 6)) and (sys.version_info < (3, 0)) :
    import warnings
    if sys.py3kwarning and (__name__ != 'bsddb3') :
        warnings.warnpy3k("in 3.x, the bsddb module has been removed; "
                          "please use the pybsddb project instead",
                          DeprecationWarning, 2)
    warnings.filterwarnings("ignore", ".*CObject.*", DeprecationWarning,
                            "bsddb.__init__")

try:
    if __name__ == 'bsddb3':
        # import _pybsddb binary as it should be the more recent version from
        # a standalone pybsddb addon package than the version included with
        # python as bsddb._bsddb.
        if absolute_import :
            # Because this syntaxis is not valid before Python 2.5
            exec("from . import _pybsddb")
        else :
            import _pybsddb
        _bsddb = _pybsddb
        from bsddb3.dbutils import DeadlockWrap as _DeadlockWrap
    else:
        import _bsddb
        from bsddb.dbutils import DeadlockWrap as _DeadlockWrap
except ImportError:
    # Remove ourselves from sys.modules
    import sys
    del sys.modules[__name__]
    raise

# bsddb3 calls it db, but provide _db for backwards compatibility
db = _db = _bsddb
__version__ = db.__version__

error = db.DBError  # So bsddb.error will mean something...

#----------------------------------------------------------------------

import sys, os

from weakref import ref

if sys.version_info < (2, 6) :
    import UserDict
    MutableMapping = UserDict.DictMixin
else :
    import collections
    MutableMapping = collections.MutableMapping

class _iter_mixin(MutableMapping):
    def _make_iter_cursor(self):
        cur = _DeadlockWrap(self.db.cursor)
        key = id(cur)
        self._cursor_refs[key] = ref(cur, self._gen_cref_cleaner(key))
        return cur

    def _gen_cref_cleaner(self, key):
        # use generate the function for the weakref callback here
        # to ensure that we do not hold a strict reference to cur
        # in the callback.
        return lambda ref: self._cursor_refs.pop(key, None)

    def __iter__(self):
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()

                # FIXME-20031102-greg: race condition.  cursor could
                # be closed by another thread before this call.

                # since we're only returning keys, we call the cursor
                # methods with flags=0, dlen=0, dofs=0
                key = _DeadlockWrap(cur.first, 0,0,0)[0]
                yield key

                next = getattr(cur, "next")
                while 1:
                    try:
                        key = _DeadlockWrap(next, 0,0,0)[0]
                        yield key
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError('Database changed size '
                                               'during iteration.')
                        cur = self._make_iter_cursor()
                        # FIXME-20031101-greg: race condition.  cursor could
                        # be closed by another thread before this call.
                        _DeadlockWrap(cur.set, key,0,0,0)
                        next = getattr(cur, "next")
            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                # the database was modified during iteration.  abort.
                pass
# When Python 2.4 not supported in bsddb3, we can change this to "finally"
        except :
            self._in_iter -= 1
            raise

        self._in_iter -= 1

    def iteritems(self):
        if not self.db:
            return
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()

                # FIXME-20031102-greg: race condition.  cursor could
                # be closed by another thread before this call.

                kv = _DeadlockWrap(cur.first)
                key = kv[0]
                yield kv

                next = getattr(cur, "next")
                while 1:
                    try:
                        kv = _DeadlockWrap(next)
                        key = kv[0]
                        yield kv
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError('Database changed size '
                                               'during iteration.')
                        cur = self._make_iter_cursor()
                        # FIXME-20031101-greg: race condition.  cursor could
                        # be closed by another thread before this call.
                        _DeadlockWrap(cur.set, key,0,0,0)
                        next = getattr(cur, "next")
            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                # the database was modified during iteration.  abort.
                pass
# When Python 2.4 not supported in bsddb3, we can change this to "finally"
        except :
            self._in_iter -= 1
            raise

        self._in_iter -= 1


class _DBWithCursor(_iter_mixin):
    """
    A simple wrapper around DB that makes it look like the bsddbobject in
    the old module.  It uses a cursor as needed to provide DB traversal.
    """
    def __init__(self, db):
        self.db = db
        self.db.set_get_returns_none(0)

        # FIXME-20031101-greg: I believe there is still the potential
        # for deadlocks in a multithreaded environment if someone
        # attempts to use the any of the cursor interfaces in one
        # thread while doing a put or delete in another thread.  The
        # reason is that _checkCursor and _closeCursors are not atomic
        # operations.  Doing our own locking around self.dbc,
        # self.saved_dbc_key and self._cursor_refs could prevent this.
        # TODO: A test case demonstrating the problem needs to be written.

        # self.dbc is a DBCursor object used to implement the
        # first/next/previous/last/set_location methods.
        self.dbc = None
        self.saved_dbc_key = None

        # a collection of all DBCursor objects currently allocated
        # by the _iter_mixin interface.
        self._cursor_refs = {}
        self._in_iter = 0
        self._kill_iteration = False

    def __del__(self):
        self.close()

    def _checkCursor(self):
        if self.dbc is None:
            self.dbc = _DeadlockWrap(self.db.cursor)
            if self.saved_dbc_key is not None:
                _DeadlockWrap(self.dbc.set, self.saved_dbc_key)
                self.saved_dbc_key = None

    # This method is needed for all non-cursor DB calls to avoid
    # Berkeley DB deadlocks (due to being opened with DB_INIT_LOCK
    # and DB_THREAD to be thread safe) when intermixing database
    # operations that use the cursor internally with those that don't.
    def _closeCursors(self, save=1):
        if self.dbc:
            c = self.dbc
            self.dbc = None
            if save:
                try:
                    self.saved_dbc_key = _DeadlockWrap(c.current, 0,0,0)[0]
                except db.DBError:
                    pass
            _DeadlockWrap(c.close)
            del c
        for cref in self._cursor_refs.values():
            c = cref()
            if c is not None:
                _DeadlockWrap(c.close)

    def _checkOpen(self):
        if self.db is None:
            raise error, "BSDDB object has already been closed"

    def isOpen(self):
        return self.db is not None

    def __len__(self):
        self._checkOpen()
        return _DeadlockWrap(lambda: len(self.db))  # len(self.db)

    if sys.version_info >= (2, 6) :
        def __repr__(self) :
            if self.isOpen() :
                return repr(dict(_DeadlockWrap(self.db.items)))
            return repr(dict())

    def __getitem__(self, key):
        self._checkOpen()
        return _DeadlockWrap(lambda: self.db[key])  # self.db[key]

    def __setitem__(self, key, value):
        self._checkOpen()
        self._closeCursors()
        if self._in_iter and key not in self:
            self._kill_iteration = True
        def wrapF():
            self.db[key] = value
        _DeadlockWrap(wrapF)  # self.db[key] = value

    def __delitem__(self, key):
        self._checkOpen()
        self._closeCursors()
        if self._in_iter and key in self:
            self._kill_iteration = True
        def wrapF():
            del self.db[key]
        _DeadlockWrap(wrapF)  # del self.db[key]

    def close(self):
        self._closeCursors(save=0)
        if self.dbc is not None:
            _DeadlockWrap(self.dbc.close)
        v = 0
        if self.db is not None:
            v = _DeadlockWrap(self.db.close)
        self.dbc = None
        self.db = None
        return v

    def keys(self):
        self._checkOpen()
        return _DeadlockWrap(self.db.keys)

    def has_key(self, key):
        self._checkOpen()
        return _DeadlockWrap(self.db.has_key, key)

    def set_location(self, key):
        self._checkOpen()
        self._checkCursor()
        return _DeadlockWrap(self.dbc.set_range, key)

    def next(self):  # Renamed by "2to3"
        self._checkOpen()
        self._checkCursor()
        rv = _DeadlockWrap(getattr(self.dbc, "next"))
        return rv

    if sys.version_info[0] >= 3 :  # For "2to3" conversion
        next = __next__

    def previous(self):
        self._checkOpen()
        self._checkCursor()
        rv = _DeadlockWrap(self.dbc.prev)
        return rv

    def first(self):
        self._checkOpen()
        # fix 1725856: don't needlessly try to restore our cursor position
        self.saved_dbc_key = None
        self._checkCursor()
        rv = _DeadlockWrap(self.dbc.first)
        return rv

    def last(self):
        self._checkOpen()
        # fix 1725856: don't needlessly try to restore our cursor position
        self.saved_dbc_key = None
        self._checkCursor()
        rv = _DeadlockWrap(self.dbc.last)
        return rv

    def sync(self):
        self._checkOpen()
        return _DeadlockWrap(self.db.sync)


#----------------------------------------------------------------------
# Compatibility object factory functions

def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
            cachesize=None, lorder=None, hflags=0):

    flags = _checkflag(flag, file)
    e = _openDBEnv(cachesize)
    d = db.DB(e)
    d.set_flags(hflags)
    if pgsize is not None:    d.set_pagesize(pgsize)
    if lorder is not None:    d.set_lorder(lorder)
    if ffactor is not None:   d.set_h_ffactor(ffactor)
    if nelem is not None:     d.set_h_nelem(nelem)
    d.open(file, db.DB_HASH, flags, mode)
    return _DBWithCursor(d)

#----------------------------------------------------------------------

def btopen(file, flag='c', mode=0666,
            btflags=0, cachesize=None, maxkeypage=None, minkeypage=None,
            pgsize=None, lorder=None):

    flags = _checkflag(flag, file)
    e = _openDBEnv(cachesize)
    d = db.DB(e)
    if pgsize is not None: d.set_pagesize(pgsize)
    if lorder is not None: d.set_lorder(lorder)
    d.set_flags(btflags)
    if minkeypage is not None: d.set_bt_minkey(minkeypage)
    if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
    d.open(file, db.DB_BTREE, flags, mode)
    return _DBWithCursor(d)

#----------------------------------------------------------------------


def rnopen(file, flag='c', mode=0666,
            rnflags=0, cachesize=None, pgsize=None, lorder=None,
            rlen=None, delim=None, source=None, pad=None):

    flags = _checkflag(flag, file)
    e = _openDBEnv(cachesize)
    d = db.DB(e)
    if pgsize is not None: d.set_pagesize(pgsize)
    if lorder is not None: d.set_lorder(lorder)
    d.set_flags(rnflags)
    if delim is not None: d.set_re_delim(delim)
    if rlen is not None: d.set_re_len(rlen)
    if source is not None: d.set_re_source(source)
    if pad is not None: d.set_re_pad(pad)
    d.open(file, db.DB_RECNO, flags, mode)
    return _DBWithCursor(d)

#----------------------------------------------------------------------

def _openDBEnv(cachesize):
    e = db.DBEnv()
    if cachesize is not None:
        if cachesize >= 20480:
            e.set_cachesize(0, cachesize)
        else:
            raise error, "cachesize must be >= 20480"
    e.set_lk_detect(db.DB_LOCK_DEFAULT)
    e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL)
    return e

def _checkflag(flag, file):
    if flag == 'r':
        flags = db.DB_RDONLY
    elif flag == 'rw':
        flags = 0
    elif flag == 'w':
        flags =  db.DB_CREATE
    elif flag == 'c':
        flags =  db.DB_CREATE
    elif flag == 'n':
        flags = db.DB_CREATE
        #flags = db.DB_CREATE | db.DB_TRUNCATE
        # we used db.DB_TRUNCATE flag for this before but Berkeley DB
        # 4.2.52 changed to disallowed truncate with txn environments.
        if file is not None and os.path.isfile(file):
            os.unlink(file)
    else:
        raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
    return flags | db.DB_THREAD

#----------------------------------------------------------------------


# This is a silly little hack that allows apps to continue to use the
# DB_THREAD flag even on systems without threads without freaking out
# Berkeley DB.
#
# This assumes that if Python was built with thread support then
# Berkeley DB was too.

try:
    # 2to3 automatically changes "import thread" to "import _thread"
    import thread as T
    del T

except ImportError:
    db.DB_THREAD = 0

#----------------------------------------------------------------------
__init__.pyc000064400000030242150536075210007025 0ustar00�
{fc@s}dZddlZejddkZejdkr�ejdkr�ddlZejrzedkrzejded�nej	d	d
ed�nybedkr�er�ddUnddl
Z
e
Zdd
lm
ZnddlZdd
lm
ZWn*ek
r!ddlZeje=�nXeZZejZejZddlZddlZddlmZejdkr�ddlZejZnddlZejZdefd��YZdefd��YZddddddddd�Z!ddddddddd�Z"ddddddddddd�
Z#d�Z$d�Z%yddl&Z'['Wnek
rxde_(nXdS(s�Support for Berkeley DB 4.3 through 5.3 with a simple interface.

For the full featured object oriented interface use the bsddb.db module
instead.  It mirrors the Oracle Berkeley DB C API.
i����Niiiitbsddb3sQin 3.x, the bsddb module has been removed; please use the pybsddb project insteadtignores.*CObject.*sbsddb.__init__sfrom . import _pybsddb(tDeadlockWrap(treft_iter_mixincBs,eZd�Zd�Zd�Zd�ZRS(cCsAt|jj�}t|�}t||j|��|j|<|S(N(t
_DeadlockWraptdbtcursortidRt_gen_cref_cleanert_cursor_refs(tselftcurtkey((s&/usr/lib64/python2.7/bsddb/__init__.pyt_make_iter_cursor_scs��fd�S(Ncs�jj�d�S(N(R
tpoptNone(R(R
R(s&/usr/lib64/python2.7/bsddb/__init__.pyt<lambda>it((RR
((R
Rs&/usr/lib64/python2.7/bsddb/__init__.pyR	esccsAt|_|jd7_y�y�|j�}t|jddd�d}|Vt|d�}x�y"t|ddd�d}|VWq]tjk
r�|jr�t	d��n|j�}t|j
|ddd�t|d�}q]Xq]WWn'tjk
r�ntjk
rnXWn|jd8_�nX|jd8_dS(Niitnexts'Database changed size during iteration.(tFalset_kill_iterationt_in_iterRRtfirsttgetattrt_bsddbtDBCursorClosedErrortRuntimeErrortsettDBNotFoundError(RRR
R((s&/usr/lib64/python2.7/bsddb/__init__.pyt__iter__ks4			ccsH|js
dSt|_|jd7_y�y�|j�}t|j�}|d}|Vt|d�}x�yt|�}|d}|VWqgtj	k
r�|jr�t
d��n|j�}t|j|ddd�t|d�}qgXqgWWn'tjk
rntj	k
rnXWn|jd8_�nX|jd8_dS(NiiRs'Database changed size during iteration.(
RRRRRRRRRRRRR(RRtkvR
R((s&/usr/lib64/python2.7/bsddb/__init__.pyt	iteritems�s<		

		(t__name__t
__module__RR	RR (((s&/usr/lib64/python2.7/bsddb/__init__.pyR^s			)t
_DBWithCursorcBs�eZdZd�Zd�Zd�Zdd�Zd�Zd�Zd�Z	e
jdkrid�Znd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Ze
jddkr�eZnd�Zd�Zd�Zd�ZRS(s�
    A simple wrapper around DB that makes it look like the bsddbobject in
    the old module.  It uses a cursor as needed to provide DB traversal.
    cCsJ||_|jjd�d|_d|_i|_d|_t|_dS(Ni(	Rtset_get_returns_noneRtdbct
saved_dbc_keyR
RRR(RR((s&/usr/lib64/python2.7/bsddb/__init__.pyt__init__�s	
				cCs|j�dS(N(tclose(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt__del__�scCs\|jdkrXt|jj�|_|jdk	rXt|jj|j�d|_qXndS(N(R%RRRRR&R(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt_checkCursor�s
icCs�|jrq|j}d|_|r^y#t|jddd�d|_Wq^tjk
rZq^Xnt|j�~nx<|jj	�D]+}|�}|dk	r�t|j�q�q�WdS(Ni(
R%RRtcurrentR&RtDBErrorR(R
tvalues(Rtsavetctcref((s&/usr/lib64/python2.7/bsddb/__init__.pyt
_closeCursors�s			#
	cCs|jdkrtd�ndS(Ns$BSDDB object has already been closed(RRterror(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt
_checkOpen�scCs
|jdk	S(N(RR(R((s&/usr/lib64/python2.7/bsddb/__init__.pytisOpen�scs�j�t�fd��S(Ncs
t�j�S(N(tlenR((R(s&/usr/lib64/python2.7/bsddb/__init__.pyRR(R3R(R((Rs&/usr/lib64/python2.7/bsddb/__init__.pyt__len__s
iicCs5|j�r(ttt|jj���Stt��S(N(R4treprtdictRRtitems(R((s&/usr/lib64/python2.7/bsddb/__init__.pyt__repr__scs �j�t��fd��S(Ncs�j�S(N(R((R
R(s&/usr/lib64/python2.7/bsddb/__init__.pyRR(R3R(RR
((R
Rs&/usr/lib64/python2.7/bsddb/__init__.pyt__getitem__s
csX�j��j��jr5��kr5t�_n���fd�}t|�dS(Ncs��j�<dS(N(R((R
Rtvalue(s&/usr/lib64/python2.7/bsddb/__init__.pytwrapFs(R3R1RtTrueRR(RR
R<R=((R
RR<s&/usr/lib64/python2.7/bsddb/__init__.pyt__setitem__s

csU�j��j��jr5��kr5t�_n��fd�}t|�dS(Ncs�j�=dS(N(R((R
R(s&/usr/lib64/python2.7/bsddb/__init__.pyR=s(R3R1RR>RR(RR
R=((R
Rs&/usr/lib64/python2.7/bsddb/__init__.pyt__delitem__s

cCsr|jdd�|jdk	r2t|jj�nd}|jdk	r\t|jj�}nd|_d|_|S(NR.i(R1R%RRR(R(Rtv((s&/usr/lib64/python2.7/bsddb/__init__.pyR("s		cCs|j�t|jj�S(N(R3RRtkeys(R((s&/usr/lib64/python2.7/bsddb/__init__.pyRB-s
cCs|j�t|jj|�S(N(R3RRthas_key(RR
((s&/usr/lib64/python2.7/bsddb/__init__.pyRC1s
cCs'|j�|j�t|jj|�S(N(R3R*RR%t	set_range(RR
((s&/usr/lib64/python2.7/bsddb/__init__.pytset_location5s

cCs0|j�|j�tt|jd��}|S(NR(R3R*RRR%(Rtrv((s&/usr/lib64/python2.7/bsddb/__init__.pyR:s

iicCs*|j�|j�t|jj�}|S(N(R3R*RR%tprev(RRF((s&/usr/lib64/python2.7/bsddb/__init__.pytpreviousCs

cCs3|j�d|_|j�t|jj�}|S(N(R3RR&R*RR%R(RRF((s&/usr/lib64/python2.7/bsddb/__init__.pyRIs

	
cCs3|j�d|_|j�t|jj�}|S(N(R3RR&R*RR%tlast(RRF((s&/usr/lib64/python2.7/bsddb/__init__.pyRIQs

	
cCs|j�t|jj�S(N(R3RRtsync(R((s&/usr/lib64/python2.7/bsddb/__init__.pyRJYs
(ii(R!R"t__doc__R'R)R*R1R3R4R6tsystversion_infoR:R;R?R@R(RBRCRERt__next__RHRRIRJ(((s&/usr/lib64/python2.7/bsddb/__init__.pyR#�s0																				R/i�c	Cs�t||�}	t|�}
tj|
�}|j|�|dk	rS|j|�n|dk	ro|j|�n|dk	r�|j|�n|dk	r�|j	|�n|j
|tj|	|�t|�S(N(
t
_checkflagt
_openDBEnvRtDBt	set_flagsRtset_pagesizet
set_lordert
set_h_ffactortset_h_nelemtopentDB_HASHR#(tfiletflagtmodetpgsizetffactortnelemt	cachesizetlorderthflagstflagstetd((s&/usr/lib64/python2.7/bsddb/__init__.pythashopenas
c	Cs�t||�}	t|�}
tj|
�}|dk	rF|j|�n|dk	rb|j|�n|j|�|dk	r�|j|�n|dk	r�|j	|�n|j
|tj|	|�t|�S(N(
RORPRRQRRSRTRRt
set_bt_minkeyt
set_bt_maxkeyRWtDB_BTREER#(RYRZR[tbtflagsR_t
maxkeypaget
minkeypageR\R`RbRcRd((s&/usr/lib64/python2.7/bsddb/__init__.pytbtopenqs
cCst||�}t|�}tj|�}
|dk	rF|
j|�n|dk	rb|
j|�n|
j|�|dk	r�|
j|�n|dk	r�|
j	|�n|	dk	r�|
j
|	�n|
dk	r�|
j|
�n|
j|tj
||�t|
�S(N(RORPRRQRRSRTRRtset_re_delimt
set_re_lent
set_re_sourcet
set_re_padRWtDB_RECNOR#(RYRZR[trnflagsR_R\R`trlentdelimtsourcetpadRbRcRd((s&/usr/lib64/python2.7/bsddb/__init__.pytrnopen�s$
cCs�tj�}|dk	rC|dkr7|jd|�qCtd�n|jtj�|jdtjtj	Btj
BtjBtjB�|S(NiPiscachesize must be >= 20480t.(
RtDBEnvRt
set_cachesizeR2t
set_lk_detecttDB_LOCK_DEFAULTRWt
DB_PRIVATEt	DB_CREATEt	DB_THREADtDB_INIT_LOCKt
DB_INIT_MPOOL(R_Rc((s&/usr/lib64/python2.7/bsddb/__init__.pyRP�s/cCs�|dkrtj}n�|dkr-d}n|dkrEtj}ng|dkr]tj}nO|dkr�tj}|dk	r�tjj|�r�tj|�q�n	td�|tj	BS(NtrtrwitwR/tns+flags should be one of 'r', 'w', 'c' or 'n'(
Rt	DB_RDONLYR~RtostpathtisfiletunlinkR2R(RZRYRb((s&/usr/lib64/python2.7/bsddb/__init__.pyRO�s			(ii(ii(ii()RKRLRMtabsolute_importtwarningstpy3kwarningR!twarnpy3ktDeprecationWarningtfilterwarningst_pybsddbRtbsddb3.dbutilsRRt
bsddb.dbutilstImportErrortmodulesRt_dbt__version__R,R2R�tweakrefRtUserDictt	DictMixintMutableMappingtcollectionsRR#RReRlRwRPROtthreadtTR(((s&/usr/lib64/python2.7/bsddb/__init__.pyt<module>(sb	




			b�		
dbtables.pyo000064400000057513150536075210007074 0ustar00�
{fc@s!dZddlZddlZddlZddlZddlZejddkrdddlZnzejd(kr�ddlZn\ddl	Z	e	j
�Zej�z)e	j
ddd	d
e�ddlZWdej�X[yddlmZWn!ek
rddlmZnXdefd
��YZdefd��YZdd)d��YZdefd��YZdefd��YZdefd��YZdefd��YZdZdZd�ZdZdZ dZ!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&d*d'��YZ(dS(+s$Id$i����Niiiitignoretmessages1the cPickle module has been removed in Python 3.0tcategory(tdbtTableDBErrorcBseZRS((t__name__t
__module__(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR>stTableAlreadyExistscBseZRS((RR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR@stCondcBseZdZd�ZRS(s!This condition matches everythingcCsdS(Ni((tselfts((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__call__Fs(RRt__doc__R(((s&/usr/lib64/python2.7/bsddb/dbtables.pyRDst	ExactCondcBs eZdZd�Zd�ZRS(s)Acts as an exact match condition functioncCs
||_dS(N(t
strtomatch(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__init__KscCs
||jkS(N(R(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyRMs(RRRRR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR
Is	t
PrefixCondcBs eZdZd�Zd�ZRS(s9Acts as a condition function for matching a string prefixcCs
||_dS(N(tprefix(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyRRscCs|t|j� |jkS(N(tlenR(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyRTs(RRRRR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyRPs	tPostfixCondcBs eZdZd�Zd�ZRS(s:Acts as a condition function for matching a string postfixcCs
||_dS(N(tpostfix(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyRYscCs|t|j�|jkS(N(RR(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyR[s(RRRRR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyRWs	tLikeCondcBs&eZdZejd�Zd�ZRS(s�
    Acts as a function that will match using an SQL 'LIKE' style
    string.  Case insensitive and % signs are wild cards.
    This isn't perfect but it should work for the simple common cases.
    cCsfd}x$|D]}|j|d|�}q
W|jdd�|_tjd|jd|�|_dS(Ns.*+()[]?s\t%s.*t^t$(treplacetlikestrtretcompile(R	Rtre_flagstchars_to_escapetchar((s&/usr/lib64/python2.7/bsddb/dbtables.pyRds

cCs|jj|�S(N(Rtmatch(R	R
((s&/usr/lib64/python2.7/bsddb/dbtables.pyRls(RRRRt
IGNORECASERR(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR^st__TABLE_NAMES__s._COLUMNS__cCs|tS(N(t_columns(ttable((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_columns_keyuss._DATA_.s	._ROWID_.icCs|t|t|S(N(t_data(R$tcoltrowid((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	_data_key�scCs|t|tS(N(R&(R$R'((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_search_col_data_key�scCs|tS(N(R&(R$((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_search_all_data_key�scCs|t|tS(N(t_rowid(R$R(((s&/usr/lib64/python2.7/bsddb/dbtables.pyt
_rowid_key�scCs|tS(N(R,(R$((s&/usr/lib64/python2.7/bsddb/dbtables.pyt_search_rowid_key�scCs`|jt�dksT|jt�dksT|jt�dksT|jt�dkrXdSdSdS(s�Verify that the given string does not contain any
    metadata strings that might interfere with dbtables database operation.
    iiN(tfindt_table_names_keyR#R&R,(R
((s&/usr/lib64/python2.7/bsddb/dbtables.pytcontains_metastrings�st
bsdTableDBcBs�eZdddddd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Ziid�Zid�Zid�Zd�Zd�ZRS(ii�cs"d|_tj}|r(|tjO}ntjtjBtjBtjB|B}	y|tjO}Wnt	k
rnnX|r�|	tj
B}	ntj�|_|jj
tj�|jj|||	B�|r�|tjO}ntj|j�|_|jjd�|jjtj�|jj|tj||B|�||_tjddkr�dtfd��Y�dtf�fd��Y}
|
|j�|_n|jj�}yVt|jd�t|�s�t|jd	|jj�ttjgd�d
|�nWn|j ��nX|j!�i|_"dS(s�bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600)

        Open database name in the dbhome Berkeley DB directory.
        Use keyword arguments when calling this constructor.
        iiitcursor_py3kcBs,eZd�Zd�Zd�Zd�ZRS(cSs
||_dS(N(t	_dbcursor(R	tdbcursor((s&/usr/lib64/python2.7/bsddb/dbtables.pyR�scSs
|jj�S(N(R4tclose(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyR6�scSsT|jjt|d��}|dk	rP|djd�|djd�f}n|S(Ns	iso8859-1ii(R4t	set_rangetbytestNonetdecode(R	tsearchtv((s&/usr/lib64/python2.7/bsddb/dbtables.pyR7�s
cSsNt|jd��}|dk	rJ|djd�|djd�f}n|S(Ntnextis	iso8859-1i(tgetattrR4R9R:(R	R<((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__next__�s
(RRRR6R7R?(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR3�s			tdb_py3kcs}eZd�Zd
�fd�Zd
d�Zdd
d�Zd
d�Zd
dd�Zd
dd�Z	d
d�Z
d	�ZRS(cSs
||_dS(N(t_db(R	R((s&/usr/lib64/python2.7/bsddb/dbtables.pyR�scs�|jjd|��S(Nttxn(RAtcursor(R	RB(R3(s&/usr/lib64/python2.7/bsddb/dbtables.pyRC�scSs%t|jd�t|d�d|�S(Nthas_keys	iso8859-1RB(R>RAR8(R	tkeyRB((s&/usr/lib64/python2.7/bsddb/dbtables.pyRD�sicSsLt|d�}|dk	r-t|d�}n|jj||d|d|�S(Ns	iso8859-1tflagsRB(R8R9RAtput(R	REtvalueRFRB((s&/usr/lib64/python2.7/bsddb/dbtables.pyRG�scSs(t|d�}|jj||d|�S(Ns	iso8859-1RB(R8RARG(R	RERHRB((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	put_bytes�scSsOt|d�}|jj|d|d|�}|dk	rK|jd�}n|S(Ns	iso8859-1RBRF(R8RAtgetR9R:(R	RERBRFR<((s&/usr/lib64/python2.7/bsddb/dbtables.pyRJ�s
cSs+t|d�}|jj|d|d|�S(Ns	iso8859-1RBRF(R8RARJ(R	RERBRF((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	get_bytes�scSs%t|d�}|jj|d|�S(Ns	iso8859-1RB(R8RAtdelete(R	RERB((s&/usr/lib64/python2.7/bsddb/dbtables.pyRL�scSs
|jj�S(N(RAR6(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyR6�sN(RRRR9RCRDRGRIRJRKRLR6((R3(s&/usr/lib64/python2.7/bsddb/dbtables.pyR@�s	RDRIRBN(#R9Rt	DB_THREADt	DB_CREATEt
DB_INIT_MPOOLtDB_INIT_LOCKtDB_INIT_LOGtDB_INIT_TXNtDB_AUTO_COMMITtAttributeErrort
DB_RECOVERtDBEnvtenvt
set_lk_detecttDB_LOCK_DEFAULTtopentDB_TRUNCATEtDBtset_get_returns_nonet	set_flagstDB_DUPtDB_BTREEt
dbfilenametsystversion_infotobjectt	txn_beginR>R0RGtpickletdumpstaborttcommitt_bsdTableDB__tablecolumns(R	tfilenametdbhometcreatettruncatetmodetrecovertdbflagstmyflagstflagsforenvR@RB((R3s&/usr/lib64/python2.7/bsddb/dbtables.pyR�sF		"
 	'#

cCs|j�dS(N(R6(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__del__scCsT|jdk	r(|jj�d|_n|jdk	rP|jj�d|_ndS(N(RR9R6RW(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyR6s

cCs|jj|�dS(N(RWttxn_checkpoint(R	tmins((s&/usr/lib64/python2.7/bsddb/dbtables.pyt
checkpointscCs|jj�dS(N(Rtsync(R	((s&/usr/lib64/python2.7/bsddb/dbtables.pyRx scCs�dGH|jj�}y^|j�\}}xEti||6�GH|j�}|r_|\}}q,|j�dSq,WWntjk
r�|j�nXdS(s*Print the database to stdout for debuggings5******** Printing raw database for debugging ********N(RRCtfirsttreprR=R6tDBNotFoundError(R	tcurREtdataR=((s&/usr/lib64/python2.7/bsddb/dbtables.pyt	_db_print#s
cCs�d}y^t|�r$td��nx)|D]!}t|�r+td��q+q+Wt|�}t|jd�|�r�td�n|jj�}t|jd|jj	�|t
j|d�d|�t
jt|jd|jj
�td|d	tj��}|j|�|jjtd|�t|jd|jj	�tt
j|d�d|�|j�d}WnXtjk
r�}|r�|j�ntjd
kr�t|d�q�t|jd�nXdS(s�CreateTable(table, columns) - Create a new table in the database.

        raises TableDBError if it already exists or for other DB errors.
        s-bad table name: contains reserved metastringss.bad column name: contains reserved metastringsRDstable already existsRIiRBRKRFiiN(ii(R9R1t
ValueErrorR%R>RRRWReRGRfRgtloadsRJR0tDB_RMWtappendRLRitDBErrorRhRbRcRtargs(R	R$tcolumnsRBtcolumntcolumnlist_keyt	tablelisttdberror((s&/usr/lib64/python2.7/bsddb/dbtables.pytCreateTable5s:
'



cCs|t|�rtd�nt|�}t|jd�|�s@gSt|jd|jj�|�}|rttj|�SgSdS(s\Return a list of columns in the given table.
        [] if the table doesn't exist.
        s-bad table name: contains reserved metastringsRDRKN(R1RR%R>RRJRfR�(R	R$R�tpickledcolumnlist((s&/usr/lib64/python2.7/bsddb/dbtables.pytListTableColumnses
cCs-|jjt�}|r%tj|�SgSdS(s)Return a list of tables in this database.N(Rtget_getR0RfR�(R	tpickledtablelist((s&/usr/lib64/python2.7/bsddb/dbtables.pyt
ListTablesws
c
Cs�y|j||�Wn�tk
r�d}y+t|�}|jj�}tjt|j	d|j	j
�|d|dt	j��}i}x|D]}|||<q�Wtj|�}x*|D]"}||kr�|j
|�q�q�W||kr7|j	j|d|�t|j	d|j	j�|tj|d�d|�n|j�d}|j|�Wq�t	jk
r�}	|r}|j�ntjd	kr�t|	d�q�t|	jd�q�XnXdS(
sCreateOrExtendTable(table, columns)

        Create a new table in the database.

        If a table of this name already exists, extend it to have any
        additional columns present in the given list as well as
        all of its current columns.
        RKRBRFRIiiiN(ii(R�RR9R%RWReRfR�R>RRJR�tcopyR�RLRGRgRit_bsdTableDB__load_column_infoR�RhRbRcRR�(
R	R$R�RBR�t
oldcolumnlistt
oldcolumnhashtct
newcolumnlistR�((s&/usr/lib64/python2.7/bsddb/dbtables.pytCreateOrExtendTables>
'




cCs�y+t|jd|jj�t|��}Wn$tjk
rQtd|f�nX|sktd|f�ntj|�|j|<dS(s'initialize the self.__tablecolumns dictRKsunknown table: %rN(	R>RRJR%R{RRfR�Rj(R	R$ttcolpickles((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__load_column_info�scCs�d}x�|s�g}x-tt�D]}|jtjdd��q"Wtjdt|�}tjddkr�|j	d�}ny/|j
jt||�d	d|dt
j�Wnt
jk
r�q	Xd}q	W|S(
s"Create a new unique row identifierii�tBis	iso8859-1RBRFiN(txranget_rowid_str_lenR�trandomtrandinttstructtpackRbRcR:RRGR-R9tDB_NOOVERWRITEtDBKeyExistError(R	R$RBtuniquetblisttxtnewid((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__new_rowid�s	!
c	Cs�d}yt|jd�t|��s3td�n||jkrR|j|�nx=|j�D]/}|j|j|�s_td|f�q_q_W|j	j
�}|j|d|�}x?|j�D]1\}}|jj
t|||�|d|�q�W|j�d}Wn�tjk
r�}tj�}|rV|j�|jjt||��ntjd	kr|t|d|d�q�t|jd|d�nXdS(
s�Insert(table, datadict) - Insert a new row into the table
        using the keys+values from rowdict as the column values.
        RDs
unknown tablesunknown column: %rRBiiiN(ii(R9R>RR%RRjR�tkeystcountRWRet_bsdTableDB__new_rowidtitemsRGR)RiR�Rbtexc_infoRhRLR-RcR�(	R	R$trowdictRBR�R(tdataitemR�tinfo((s&/usr/lib64/python2.7/bsddb/dbtables.pytInsert�s.)


cCs�yA|j|g|�}|j�}x|j�D]}d}y�x�|D]�}|jj�}yJ|jjt|||�d|�}	|jjt|||�d|�Wntj	k
r�d}	nX|||	�}	|	dk	r|jj
t|||�|	d|�n|j�d}qGWWq1|r5|j�n�q1Xq1WWnEtj
k
r�}
tjdkrut|
d�q�t|
jd�nXdS(sModify(table, conditions={}, mappings={}) - Modify items in rows matching 'conditions' using mapping functions in 'mappings'

        * table - the table name
        * conditions - a dictionary keyed on column names containing
          a condition callable expecting the data string as an
          argument and returning a boolean.
        * mappings - a dictionary keyed on column names containing a
          condition callable expecting the data string as an argument and
          returning the new string for that column.
        RBiiiN(ii(t_bsdTableDB__SelectR�R9RWReRRJR)RLR{RGRiRhR�RbRcRR�(R	R$t
conditionstmappingstmatching_rowidsR�R(RBR�R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytModifys@
			
	

c	Csiy|j|g|�}|j|}x�|j�D]�}d}y�|jj�}xK|D]C}y&|jjt|||�d|�WqWtj	k
r�qWXqWWy#|jjt
||�d|�Wntj	k
r�nX|j�d}Wq2tjk
r}|r|j
�n�q2Xq2WWnEtjk
rd}tjdkrQt|d�qet|jd�nXdS(sDelete(table, conditions) - Delete items matching the given
        conditions from the table.

        * conditions - a dictionary keyed on column names containing
          condition functions expecting the data string as an
          argument and returning a boolean.
        RBiiiN(ii(R�RjR�R9RWReRRLR)R{R-RiR�RhRbRcRR�(	R	R$R�R�R�R(RBR�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytDeleteBs6	

#


cCs�yT||jkr"|j|�n|dkr>|j|}n|j|||�}WnEtjk
r�}tjdkr�t|d�q�t|j	d�nX|j
�S(s�Select(table, columns, conditions) - retrieve specific row data
        Returns a list of row column->value mapping dictionaries.

        * columns - a list of which column data to return.  If
          columns is None, all columns will be returned.
        * conditions - a dictionary keyed on column names
          containing callable conditions expecting the data string as an
          argument and returning a boolean.
        iiiN(ii(RjR�R9R�RR�RbRcRR�tvalues(R	R$R�R�R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytSelectos
cCs�||jkr|j|�n|dkr;|j|}nxA||j�D]/}|j|j|�sLtd|f�qLqLWi}i}d�}tjd	kr�|j	�}|j
|�nvg}xm|j	�D]_}	xVt|�D];\}
}|||	�}|dkr�|j|
|	�Pq�q�W|j
|	�q�W|jj�}
d}xH|D]@\}}|d}t||�}||kr�d}nd}y�|
j|�\}}x�|t|� |krW|t}||krB|s�||�r||kri||<n|r?||||<q?qB||kr5||=n|||<n|
j�\}}q�WWqQtjk
r�}|jdtjkrQ�qQqQqQXqQW|
j�~t|�dkr�x�|j	�D]�\}}x�|D]�}||kr�q�ny&|jjt|||��||<Wq�tjk
r{}tjd
krR|dtjkrn�qnn|jdtjkrn�nd||<q�Xq�Wq�Wn|S(s�__Select() - Used to implement Select and Delete (above)
        Returns a dictionary keyed on rowids containing dicts
        holding the row data for columns listed in the columns param
        that match the given conditions.
        * conditions is a dictionary keyed on column names
        containing callable conditions expecting the data string as an
        argument and returning a boolean.
        sunknown column: %rcSs|d}|d}t|�t|�kr�d�}t|t�rrt|t�rr|t|j�t|j��St|t�r�t|t�r�|t|j�t|j��SdSt|t�r�dSt|t�r�dSt|t�r�dSt|t�r�dSdS(NicSs$||krdS||kr dSdS(Nii����i((tatb((s&/usr/lib64/python2.7/bsddb/dbtables.pytcmp�s
ii����(ttypet
isinstanceRRRRRR
(tatupletbtupleR�R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytcmp_conditions�s$

	iiii����iN(ii(ii(RjR�R9ttablecolumnsR�R�RRbRcR�tsortt	enumeratetinsertR�RRCR*R7RR�R=R�R�tDB_NOTFOUNDR6RJR)(R	R$R�R�R�R�trejected_rowidsR�t
conditionlisttitjtktrR|t
column_numt	conditiont	searchkeytsavethiscolumndataRER}R(R�trowdata((s&/usr/lib64/python2.7/bsddb/dbtables.pyt__Select�s�
	
	




		c	Cs8d}y�|jj�}|jjt|�d|�|jj|�}t|�}xYy|j|�\}}Wntj	k
r�PnX|t
|� |kr�Pn|j�qUWt|�}xYy|j|�\}}Wntj	k
r�PnX|t
|� |krPn|j�q�W|j�t
jt|jd|jj�td|dtj��}y|j|�Wntk
r}nX|jjtd|�t|jd|jj�tt
j|d�d|�|j�d}||jkr�|j|=nWn<tjk
r3}|r|j�nt|jd��nXdS(s(Remove an entire table from the databaseRBRKRFRIiN(R9RWReRRLR%RCR+R7R{RR.R6RfR�R>RJR0R�tremoveRRGRgRiRjR�RhRR�(	R	R$RBR|t	table_keyRER}R�R�((s&/usr/lib64/python2.7/bsddb/dbtables.pytDropsT



(RRRRtR6RwRxR~R�R�R�R�R�R�R�R�R�R�R�R�(((s&/usr/lib64/python2.7/bsddb/dbtables.pyR2�s&	r					0			:			,6-	�(ii((()t_cvsidRRbR�R�R�RcRftcPickletwarningstcatch_warningstwt	__enter__tfilterwarningstDeprecationWarningt__exit__tbsddb3RtImportErrortbsddbt
StandardErrorRRRR
RRRR0R#R%R&R,R�R)R*R+R-R.R1R2(((s&/usr/lib64/python2.7/bsddb/dbtables.pyt<module>sV