/usr/lib/python2.7/dist-packages/cvs2svn_lib/symbol_database.py is in cvs2svn 2.4.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 | # (Be in -*- python -*- mode.)
#
# ====================================================================
# Copyright (c) 2000-2008 CollabNet. All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals. For exact contribution history, see the revision
# history and logs, available at http://cvs2svn.tigris.org/.
# ====================================================================
"""This module contains the SymbolDatabase class."""
import cPickle
from cvs2svn_lib import config
from cvs2svn_lib.artifact_manager import artifact_manager
class SymbolDatabase:
"""Read-only access to symbol database.
This class allows iteration and lookups id -> symbol, where symbol
is a TypedSymbol instance. The whole database is read into memory
upon construction."""
def __init__(self):
# A map { id : TypedSymbol }
self._symbols = {}
f = open(artifact_manager.get_temp_file(config.SYMBOL_DB), 'rb')
symbols = cPickle.load(f)
f.close()
for symbol in symbols:
self._symbols[symbol.id] = symbol
def get_symbol(self, id):
"""Return the symbol instance with id ID.
Raise KeyError if the symbol is not known."""
return self._symbols[id]
def __iter__(self):
"""Iterate over the Symbol instances within this database."""
return self._symbols.itervalues()
def close(self):
self._symbols = None
def create_symbol_database(symbols):
"""Create and fill a symbol database.
Record each symbol that is listed in SYMBOLS, which is an iterable
containing Trunk and TypedSymbol objects."""
f = open(artifact_manager.get_temp_file(config.SYMBOL_DB), 'wb')
cPickle.dump(symbols, f, -1)
f.close()
|