Fix some formatting.
This commit is contained in:
parent
9b3c019edb
commit
bd92d82219
|
@ -5,7 +5,7 @@
|
||||||
# itself while defining objects that the database will return.
|
# itself while defining objects that the database will return.
|
||||||
#
|
#
|
||||||
|
|
||||||
import rcs, re
|
import rcs, os
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -50,11 +50,19 @@ class PVVDB:
|
||||||
def __init__(self, base):
|
def __init__(self, base):
|
||||||
# Find the record definition file, read it, verify it and
|
# Find the record definition file, read it, verify it and
|
||||||
# set the legal set of fields.
|
# set the legal set of fields.
|
||||||
pass
|
self.base = base # base database directory
|
||||||
|
self.locks = [] # list of activated locks
|
||||||
|
self.rcs = rcs.RCS() # an RCS interface function
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
# clean up locks and such before being deleted.
|
# clean up locks and such before being deleted.
|
||||||
pass
|
for username in self.locks:
|
||||||
|
self.rcs.unlock(username)
|
||||||
|
|
||||||
|
def __filename(self, username):
|
||||||
|
# transform the username into a tuple with the full name of
|
||||||
|
# the databasefile and the latest revision number.
|
||||||
|
return self.rcs.rcsname(os.path.join(self.base, username))
|
||||||
|
|
||||||
def __format(self, file_path):
|
def __format(self, file_path):
|
||||||
# parses and verifies the .format files for a database.
|
# parses and verifies the .format files for a database.
|
||||||
|
@ -63,18 +71,22 @@ class PVVDB:
|
||||||
for line in fh:
|
for line in fh:
|
||||||
if line[0] == "#":
|
if line[0] == "#":
|
||||||
continue
|
continue
|
||||||
name, value = line.strip().split(":", 1)
|
name, value = line.strip().split(":", 1)
|
||||||
value = value.split("#", 1)[0].strip()
|
value = value.split("#", 1)[0].strip()
|
||||||
if not value in ['scalar', 'list']:
|
if not value in ['scalar', 'list']:
|
||||||
raise PVVDBError, "%s not legal .format datatype." % value
|
raise PVVDBError, "%s not legal .format datatype." % value
|
||||||
fmt[name] = value
|
fmt[name] = value
|
||||||
return fmt
|
return fmt
|
||||||
|
|
||||||
def lock(self, username):
|
def lock(self, username, pedantic=False):
|
||||||
# Lock the record.
|
# Lock the record.
|
||||||
pass
|
if username in self.locks and pedantic:
|
||||||
|
raise PVVDBError, "%s already locked." % `username`
|
||||||
|
self.rcs.lock(self.__filename(username))
|
||||||
|
self.locks.append(username)
|
||||||
|
|
||||||
|
|
||||||
def unlock(self, username):
|
def unlock(self, username, pedantic=False):
|
||||||
# Unlock the record.
|
# Unlock the record.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Reference in New Issue