@@ -72,7 +72,7 @@ def flush_changes(self, *args, **kwargs):
7272
7373
7474
75- class GitConfigParser (cp .RawConfigParser ,LockFile ):
75+ class GitConfigParser (cp .RawConfigParser ,object ):
7676"""
7777Implements specifics required to read git style configuration files.
7878
@@ -91,6 +91,15 @@ class GitConfigParser(cp.RawConfigParser, LockFile):
9191"""
9292__metaclass__ = _MetaParserBuilder
9393
94+
95+ #{ Configuration
96+ # The lock type determines the type of lock to use in new configuration readers.
97+ # They must be compatible to the LockFile interface.
98+ # A suitable alternative would be the BlockingLockFile
99+ t_lock = LockFile
100+
101+ #} END configuration
102+
94103OPTCRE = re .compile (
95104r'\s?(?P<option>[^:=\s][^:=]*)' # very permissive, incuding leading whitespace
96105r'\s*(?P<vi>[:=])\s*' # any number of space/tab,
@@ -102,7 +111,7 @@ class GitConfigParser(cp.RawConfigParser, LockFile):
102111
103112# list of RawConfigParser methods able to change the instance
104113_mutating_methods_ = ("add_section" ,"remove_section" ,"remove_option" ,"set" )
105- __slots__ = ("_sections" ,"_defaults" ,"_file_or_files" ,"_read_only" ,"_is_initialized" )
114+ __slots__ = ("_sections" ,"_defaults" ,"_file_or_files" ,"_read_only" ,"_is_initialized" , '_lock' )
106115
107116def __init__ (self ,file_or_files ,read_only = True ):
108117"""
@@ -125,7 +134,7 @@ def __init__(self, file_or_files, read_only=True):
125134self ._file_or_files = file_or_files
126135self ._read_only = read_only
127136self ._is_initialized = False
128-
137+ self . _lock = None
129138
130139if not read_only :
131140if isinstance (file_or_files , (tuple ,list )):
@@ -136,9 +145,9 @@ def __init__(self, file_or_files, read_only=True):
136145file_or_files = file_or_files .name
137146# END get filename from handle/stream
138147# initialize lock base - we want to write
139- LockFile . __init__ ( self , file_or_files )
148+ self . _lock = self . t_lock ( file_or_files )
140149
141- self ._obtain_lock_or_raise ()
150+ self ._lock . _obtain_lock ()
142151# END read-only check
143152
144153
@@ -148,7 +157,7 @@ def __del__(self):
148157"""
149158# checking for the lock here makes sure we do not raise during write()
150159# in case an invalid parser was created who could not get a lock
151- if self .read_only or not self ._has_lock ():
160+ if self .read_only or not self ._lock . _has_lock ():
152161return
153162
154163try :
@@ -157,7 +166,7 @@ def __del__(self):
157166except IOError ,e :
158167print "Exception during destruction of GitConfigParser: %s" % str (e )
159168finally :
160- self ._release_lock ()
169+ self ._lock . _release_lock ()
161170
162171def optionxform (self ,optionstr ):
163172"""
@@ -303,7 +312,7 @@ def write(self):
303312a file lock
304313"""
305314self ._assure_writable ("write" )
306- self ._obtain_lock_or_raise ()
315+ self ._lock . _obtain_lock ()
307316
308317
309318fp = self ._file_or_files