mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-20 09:04:36 +01:00
Removed some XXXes.
This commit is contained in:
parent
aa83ab2420
commit
0ff76320ee
18
src/utils.py
18
src/utils.py
@ -210,12 +210,9 @@ def dqrepr(s):
|
|||||||
# return '"' + repr("'\x00" + s)[6:]
|
# return '"' + repr("'\x00" + s)[6:]
|
||||||
return '"%s"' % s.encode('string_escape').replace('"', '\\"')
|
return '"%s"' % s.encode('string_escape').replace('"', '\\"')
|
||||||
|
|
||||||
#XXX We're using this to centralize how we quote a string since %r/repr()
|
|
||||||
# doesn't play nicely with unicode characters. This eventually needs to be
|
|
||||||
# replaced to *not* use repr()
|
|
||||||
def quoted(s):
|
def quoted(s):
|
||||||
"""Returns a quoted s."""
|
"""Returns a quoted s."""
|
||||||
return repr(s)
|
return '"%s"' % s
|
||||||
|
|
||||||
nonEscapedSlashes = re.compile(r'(?<!\\)/')
|
nonEscapedSlashes = re.compile(r'(?<!\\)/')
|
||||||
def perlReToPythonRe(s):
|
def perlReToPythonRe(s):
|
||||||
@ -265,7 +262,6 @@ def perlReToReplacer(s):
|
|||||||
else:
|
else:
|
||||||
return lambda s: r.sub(replace, s, 1)
|
return lambda s: r.sub(replace, s, 1)
|
||||||
|
|
||||||
# XXX Should we find a way to allow $1, $2, etc.?
|
|
||||||
_perlVarSubstituteRe = re.compile(r'\$\{([^}]+)\}|\$([a-zA-Z][a-zA-Z0-9]*)')
|
_perlVarSubstituteRe = re.compile(r'\$\{([^}]+)\}|\$([a-zA-Z][a-zA-Z0-9]*)')
|
||||||
def perlVariableSubstitute(vars, text):
|
def perlVariableSubstitute(vars, text):
|
||||||
def replacer(m):
|
def replacer(m):
|
||||||
@ -782,11 +778,15 @@ class AtomicFile(file):
|
|||||||
# (the target) already exists. shutil.move handles those
|
# (the target) already exists. shutil.move handles those
|
||||||
# intricacies for us.
|
# intricacies for us.
|
||||||
|
|
||||||
# XXX There's a bug in Python <= 2.4 that allows this to
|
# This raises IOError if we can't write to the file. Since
|
||||||
# clobber read-only files. We should workaround this at
|
# in *nix, it only takes write perms to the *directory* to
|
||||||
# some point (probably by including a fixed shutil.py in
|
# rename a file (and shutil.move will use os.rename if
|
||||||
# others/.
|
# possible), we first check if we have the write permission
|
||||||
|
# and only then do we write.
|
||||||
|
fd = file(self.filename, 'a')
|
||||||
|
fd.close()
|
||||||
shutil.move(self.tempFilename, self.filename)
|
shutil.move(self.tempFilename, self.filename)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError, 'AtomicFile.close called after rollback.'
|
raise ValueError, 'AtomicFile.close called after rollback.'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user