##// END OF EJS Templates
opener: introduce tryread helper...
Matt Mackall -
r16455:154219f3 default
parent child Browse files
Show More
@@ -159,6 +159,15 class abstractopener(object):
159 '''Prevent instantiation; don't call this from subclasses.'''
159 '''Prevent instantiation; don't call this from subclasses.'''
160 raise NotImplementedError('attempted instantiating ' + str(type(self)))
160 raise NotImplementedError('attempted instantiating ' + str(type(self)))
161
161
162 def tryread(self, path):
163 'gracefully return an empty string for missing files'
164 try:
165 return self.read(path)
166 except IOError, inst:
167 if inst.errno != errno.ENOENT:
168 raise
169 return ""
170
162 def read(self, path):
171 def read(self, path):
163 fp = self(path, 'rb')
172 fp = self(path, 'rb')
164 try:
173 try:
General Comments 0
You need to be logged in to leave comments. Login now