##// END OF EJS Templates
util & scmutil: adapt read/write helpers as request by mpm
Dan Villiom Podlaski Christiansen -
r14167:0e475380 default
parent child Browse files
Show More
@@ -139,15 +139,22 b' class abstractopener(object):'
139 139 '''Prevent instantiation; don't call this from subclasses.'''
140 140 raise NotImplementedError('attempted instantiating ' + str(type(self)))
141 141
142 def read(self, *args, **kwargs):
143 fp = self(*args, **kwargs)
142 def read(self, path):
143 fp = self(path, 'rb')
144 144 try:
145 145 return fp.read()
146 146 finally:
147 147 fp.close()
148 148
149 def write(self, data, *args, **kwargs):
150 fp = self(*args, **kwargs)
149 def write(self, path, data):
150 fp = self(path, 'wb')
151 try:
152 return fp.write(data)
153 finally:
154 fp.close()
155
156 def append(self, path, data):
157 fp = self(path, 'ab')
151 158 try:
152 159 return fp.write(data)
153 160 finally:
@@ -778,8 +778,15 b' def readfile(path):'
778 778 finally:
779 779 fp.close()
780 780
781 def writefile(path, mode, text):
782 fp = open(path, mode)
781 def writefile(path, text):
782 fp = open(path, 'wb')
783 try:
784 fp.write(text)
785 finally:
786 fp.close()
787
788 def appendfile(path, text):
789 fp = open(path, 'ab')
783 790 try:
784 791 fp.write(text)
785 792 finally:
General Comments 0
You need to be logged in to leave comments. Login now