Skip to content
Snippets Groups Projects
Commit 0e475380 authored by Dan Villiom Podlaski Christiansen's avatar Dan Villiom Podlaski Christiansen
Browse files

util & scmutil: adapt read/write helpers as request by mpm

parent 9cbff8a3
No related branches found
No related tags found
No related merge requests found
......@@ -139,10 +139,10 @@
'''Prevent instantiation; don't call this from subclasses.'''
raise NotImplementedError('attempted instantiating ' + str(type(self)))
def read(self, *args, **kwargs):
fp = self(*args, **kwargs)
def read(self, path):
fp = self(path, 'rb')
try:
return fp.read()
finally:
fp.close()
......@@ -144,10 +144,17 @@
try:
return fp.read()
finally:
fp.close()
def write(self, data, *args, **kwargs):
fp = self(*args, **kwargs)
def write(self, path, data):
fp = self(path, 'wb')
try:
return fp.write(data)
finally:
fp.close()
def append(self, path, data):
fp = self(path, 'ab')
try:
return fp.write(data)
finally:
......
......@@ -778,8 +778,15 @@
finally:
fp.close()
def writefile(path, mode, text):
fp = open(path, mode)
def writefile(path, text):
fp = open(path, 'wb')
try:
fp.write(text)
finally:
fp.close()
def appendfile(path, text):
fp = open(path, 'ab')
try:
fp.write(text)
finally:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment