/usr/share/pyshared/Codeville/db.py is in codeville 0.8.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # Written by Ross Cohen
# See LICENSE.txt for license information.
from os import path
try:
from bsddb3 import db
version_info = db.__version__.split('.')
if version_info < [4,1]:
raise ImportError
if db.version() < (4,1):
raise ImportError
except ImportError:
from bsddb import db
version_info = db.__version__.split('.')
if version_info < [4,1]:
raise ImportError, 'bsddb 4.1 or higher is required'
if db.version() < (4,1):
raise ImportError, 'berkeleydb 4.1 or higher is required'
history_format_version = 1
rebuild_format_version = 4
class VersionMismatchException(Exception): pass
def check_format_version(dir):
try:
fd = open(path.join(dir, 'format'), 'r')
ver = int(fd.read())
fd.close()
except IOError:
ver = 0
if ver != history_format_version:
raise VersionMismatchException, (history_format_version, ver)
return
def check_rebuild_version(dir):
try:
fd = open(path.join(dir, 'rebuild_format'), 'r')
ver = int(fd.read())
fd.close()
except IOError:
ver = 0
if ver != rebuild_format_version:
raise VersionMismatchException, (rebuild_format_version, ver)
return
def write_format_version(dir):
fd = open(path.join(dir, 'format'), 'w')
fd.write(str(history_format_version))
fd.close()
return
def write_rebuild_version(dir):
fd = open(path.join(dir, 'rebuild_format'), 'w')
fd.write(str(rebuild_format_version))
fd.close()
return
class ChangeDBs:
def __init__(self, dbenv, name, flags, txn):
self.indexdb = db.DB(dbEnv=dbenv)
self.indexdb.open(name[0] + 'index.db', dbtype=db.DB_BTREE, flags=flags, txn=txn)
self.dagdb = db.DB(dbEnv=dbenv)
self.dagdb.open(name + '-dag.db', dbtype=db.DB_BTREE, flags=flags, txn=txn)
self.mergedb = db.DB(dbEnv=dbenv)
self.mergedb.open(name + '-merges.db', dbtype=db.DB_BTREE, flags=flags, txn=txn)
return
def close(self):
self.indexdb.close()
self.dagdb.close()
self.mergedb.close()
return
|