~mdw
/
stgit
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add prune-safety to StGIT
[stgit]
/
stgit
/
utils.py
diff --git
a/stgit/utils.py
b/stgit/utils.py
index
b941f7c
..
5749b3b
100644
(file)
--- a/
stgit/utils.py
+++ b/
stgit/utils.py
@@
-23,44
+23,44
@@
def read_string(filename, multiline = False):
"""
f = file(filename, 'r')
if multiline:
"""
f = file(filename, 'r')
if multiline:
-
string
= f.read()
+
result
= f.read()
else:
else:
-
string
= f.readline().strip()
+
result
= f.readline().strip()
f.close()
f.close()
- return
string
+ return
result
-def write_string(filename,
string
, multiline = False):
- """Writes
string
to file and truncates it
+def write_string(filename,
line
, multiline = False):
+ """Writes
'line'
to file and truncates it
"""
f = file(filename, 'w+')
if multiline:
"""
f = file(filename, 'w+')
if multiline:
- f.write(
string
)
+ f.write(
line
)
else:
else:
- print >> f,
string
+ print >> f,
line
f.close()
f.close()
-def append_strings(filename,
string
s):
- """Appends
string
sequence to file
+def append_strings(filename,
line
s):
+ """Appends
'lines'
sequence to file
"""
f = file(filename, 'a+')
"""
f = file(filename, 'a+')
- for
string in string
s:
- print >> f,
string
+ for
line in line
s:
+ print >> f,
line
f.close()
f.close()
-def append_string(filename,
string
):
- """Appends
string
to file
+def append_string(filename,
line
):
+ """Appends
'line'
to file
"""
f = file(filename, 'a+')
"""
f = file(filename, 'a+')
- print >> f,
string
+ print >> f,
line
f.close()
f.close()
-def insert_string(filename,
string
):
- """Inserts
a string
at the beginning of the file
+def insert_string(filename,
line
):
+ """Inserts
'line'
at the beginning of the file
"""
f = file(filename, 'r+')
lines = f.readlines()
f.seek(0); f.truncate()
"""
f = file(filename, 'r+')
lines = f.readlines()
f.seek(0); f.truncate()
- print >> f,
string
+ print >> f,
line
f.writelines(lines)
f.close()
f.writelines(lines)
f.close()