mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 14:10:41 +01:00
Prefixed some non-public method names with an underscore.
This commit is contained in:
parent
612a8e1183
commit
e9c52f6a5f
@ -78,12 +78,12 @@ class TransactionMixin(python.Object):
|
|||||||
def _replacement(self, filename):
|
def _replacement(self, filename):
|
||||||
return self.dirize(self.REPLACEMENTS, self.escape(filename))
|
return self.dirize(self.REPLACEMENTS, self.escape(filename))
|
||||||
|
|
||||||
def checkCwd(self):
|
def _checkCwd(self):
|
||||||
expected = File.contents(self.dirize('cwd'))
|
expected = File.contents(self.dirize('cwd'))
|
||||||
if os.getcwd() != expected:
|
if os.getcwd() != expected:
|
||||||
raise InvalidCwd(expected)
|
raise InvalidCwd(expected)
|
||||||
|
|
||||||
def journalCommands(self):
|
def _journalCommands(self):
|
||||||
journal = file(self._journalName)
|
journal = file(self._journalName)
|
||||||
for line in journal:
|
for line in journal:
|
||||||
line = line.rstrip('\n')
|
line = line.rstrip('\n')
|
||||||
@ -116,7 +116,7 @@ class Transaction(TransactionMixin):
|
|||||||
cwd.write(os.getcwd())
|
cwd.write(os.getcwd())
|
||||||
cwd.close()
|
cwd.close()
|
||||||
|
|
||||||
def journalCommand(self, command, *args):
|
def _journalCommand(self, command, *args):
|
||||||
File.writeLine(self._journal,
|
File.writeLine(self._journal,
|
||||||
'%s %s' % (command, ' '.join(map(str, args))))
|
'%s %s' % (command, ' '.join(map(str, args))))
|
||||||
self._journal.flush()
|
self._journal.flush()
|
||||||
@ -125,24 +125,24 @@ class Transaction(TransactionMixin):
|
|||||||
File.copy(filename, self._original(filename))
|
File.copy(filename, self._original(filename))
|
||||||
|
|
||||||
def replace(self, filename):
|
def replace(self, filename):
|
||||||
self.checkCwd()
|
self._checkCwd()
|
||||||
self._makeOriginal(filename)
|
self._makeOriginal(filename)
|
||||||
self.journalCommand('replace', filename)
|
self._journalCommand('replace', filename)
|
||||||
return File.open(self._replacement(filename))
|
return File.open(self._replacement(filename))
|
||||||
|
|
||||||
def append(self, filename):
|
def append(self, filename):
|
||||||
self.checkCwd()
|
self._checkCwd()
|
||||||
length = os.stat(filename).st_size
|
length = os.stat(filename).st_size
|
||||||
self.journalCommand('append', filename, length)
|
self._journalCommand('append', filename, length)
|
||||||
replacement = self._replacement(filename)
|
replacement = self._replacement(filename)
|
||||||
File.copy(filename, replacement)
|
File.copy(filename, replacement)
|
||||||
return file(replacement, 'a')
|
return file(replacement, 'a')
|
||||||
|
|
||||||
def commit(self, removeWhenComplete=True):
|
def commit(self, removeWhenComplete=True):
|
||||||
self._journal.close()
|
self._journal.close()
|
||||||
self.checkCwd()
|
self._checkCwd()
|
||||||
File.touch(self.dirize('commit'))
|
File.touch(self.dirize('commit'))
|
||||||
for (command, args) in self.journalCommands():
|
for (command, args) in self._journalCommands():
|
||||||
methodName = 'commit%s' % command.capitalize()
|
methodName = 'commit%s' % command.capitalize()
|
||||||
getattr(self, methodName)(*args)
|
getattr(self, methodName)(*args)
|
||||||
File.touch(self.dirize('committed'))
|
File.touch(self.dirize('committed'))
|
||||||
@ -158,10 +158,10 @@ class Transaction(TransactionMixin):
|
|||||||
|
|
||||||
class Rollback(TransactionMixin):
|
class Rollback(TransactionMixin):
|
||||||
def rollback(self, removeWhenComplete=True):
|
def rollback(self, removeWhenComplete=True):
|
||||||
self.checkCwd()
|
self._checkCwd()
|
||||||
if not os.path.exists(self.dirize('commit')):
|
if not os.path.exists(self.dirize('commit')):
|
||||||
return # No action taken; commit hadn't begun.
|
return # No action taken; commit hadn't begun.
|
||||||
for (command, args) in self.journalCommands():
|
for (command, args) in self._journalCommands():
|
||||||
methodName = 'rollback%s' % command.capitalize()
|
methodName = 'rollback%s' % command.capitalize()
|
||||||
getattr(self, methodName)(*args)
|
getattr(self, methodName)(*args)
|
||||||
if removeWhenComplete:
|
if removeWhenComplete:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user