убрал неиспользуемый класс

This commit is contained in:
rzaitov 2013-11-12 11:44:36 +04:00
parent 91fce4f1b6
commit c1806fdf2f
13 changed files with 42 additions and 53 deletions

View File

@ -16,7 +16,7 @@ class CreateBackupCommandBuilder:
assert line is not None
parser = CreateBackupParser()
backupArguments = parser.parseLine(line)
folderPath = parser.parseLine(line)
command = CreateBackupCommand(backupArguments)
command = CreateBackupCommand(folderPath)
return command

View File

@ -18,7 +18,7 @@ class DeleteBackupCommandBuilder:
assert line is not None
parser = DeleteBackupParser()
backupArguments = parser.parseLine(line)
folderPath = parser.parseLine(line)
command = DeleteBackupCommand(backupArguments)
command = DeleteBackupCommand(folderPath)
return command

View File

@ -18,7 +18,7 @@ class RestoreBackupCommandBuilder:
assert line is not None
parser = RestoreBackupParser()
backupArguments = parser.parseLine(line)
folderPath = parser.parseLine(line)
command = RestoreBackupCommand(backupArguments)
command = RestoreBackupCommand(folderPath)
return command

View File

@ -1,6 +1,6 @@
from CommandBuilders.CreateBackupCommandBuilder import CreateBackupCommandBuilder
line = "create backup for 'BuildSample'"
line = "create backup for '.'"
cmdBuilder = CreateBackupCommandBuilder()
command = cmdBuilder.getCommandFor(line)

View File

@ -8,18 +8,18 @@ class TestCreateBackup(unittest.TestCase):
def test_parseCurrentDir(self):
line = "create backup for '.'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('.', backupArg.folderPath)
self.assertEqual('.', folderPath)
def test_parseRelativePath(self):
line = "create backup for '../Some/Path'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('../Some/Path', backupArg.folderPath)
self.assertEqual('../Some/Path', folderPath)
def test_parseAbsPath(self):
line = "create backup for '/Some/Abs/Path'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('/Some/Abs/Path', backupArg.folderPath)
self.assertEqual('/Some/Abs/Path', folderPath)

View File

@ -8,18 +8,18 @@ class TestDeleteBackup(unittest.TestCase):
def test_parseCurrentDir(self):
line = "delete backup '.'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('.', backupArg.folderPath)
self.assertEqual('.', folderPath)
def test_parseRelativePath(self):
line = "delete backup '../Some/Path'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('../Some/Path', backupArg.folderPath)
self.assertEqual('../Some/Path', folderPath)
def test_parseAbsPath(self):
line = "delete backup '/Some/Abs/Path'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('/Some/Abs/Path', backupArg.folderPath)
self.assertEqual('/Some/Abs/Path', folderPath)

View File

@ -8,18 +8,18 @@ class TestRestoreBackup(unittest.TestCase):
def test_parseCurrentDir(self):
line = "restore from backup '.'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('.', backupArg.folderPath)
self.assertEqual('.', folderPath)
def test_parseRelativePath(self):
line = "restore from backup '../Some/Path'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('../Some/Path', backupArg.folderPath)
self.assertEqual('../Some/Path', folderPath)
def test_parseAbsPath(self):
line = "restore from backup '/Some/Abs/Path'"
backupArg = self.parser.parseLine(line)
folderPath = self.parser.parseLine(line)
self.assertEqual('/Some/Abs/Path', backupArg.folderPath)
self.assertEqual('/Some/Abs/Path', folderPath)

View File

@ -2,16 +2,17 @@ import os
class BaseBackupCommand:
def __init__(self, backupArguments):
assert backupArguments is not None
def __init__(self, folderPath):
assert folderPath is not None
self.backupArguments = backupArguments
self.folderPath = folderPath
def getAbsSrc(self):
return self.getAbs(self.backupArguments.getSourceFolderName())
return self.getAbs(self.folderPath)
def getAbsDst(self):
return self.getAbs(self.backupArguments.getBackupFolderName())
srcDirName = os.path.dirname(self.folderPath)
return self.getAbs('backup'.format(srcDirName))
def getAbs(self, path):
return os.path.abspath(path)

View File

@ -3,12 +3,14 @@ from commands.BaseBackupCommand.BaseBackupCommand import BaseBackupCommand
class CreateBackupCommand(BaseBackupCommand):
def __init__(self, backupArguments):
BaseBackupCommand.__init__(self, backupArguments)
def __init__(self, folderPath):
BaseBackupCommand.__init__(self, folderPath)
def execute(self):
src = self.getAbsSrc()
backupDir = self.getAbsDst()
print src, backupDir
shutil.rmtree(backupDir, ignore_errors=True)
shutil.copytree(src, backupDir, symlinks=False)

View File

@ -3,8 +3,8 @@ from commands.BaseBackupCommand.BaseBackupCommand import BaseBackupCommand
class RestoreBackupCommand(BaseBackupCommand):
def __init__(self, backupArguments):
BaseBackupCommand.__init__(self, backupArguments)
def __init__(self, folderPath):
BaseBackupCommand.__init__(self, folderPath)
def execute(self):
src = self.getAbsSrc()

View File

@ -1,11 +0,0 @@
class BackupArguments:
def __init__(self):
self.folderPath = None
def getSourceFolderName(self):
return self.folderPath
def getBackupFolderName(self):
return "backup.{0}".format(self.folderPath)

View File

@ -1,13 +1,10 @@
import re
from parsers.LineParser import LineParser
from parsers.ParserBackup.BackupArguments import BackupArguments
class ParserBackupBase(LineParser):
def __init__(self):
LineParser.__init__(self)
self.__backupArguments = BackupArguments()
self.folderName = None
def parseLine(self, line):
assert line is not None
@ -19,9 +16,9 @@ class ParserBackupBase(LineParser):
self._guardMatch(match, line, regexpSource)
folderName = match.group('folder')
self.__backupArguments.folderPath = folderName
self.folderName = folderName
return self.__backupArguments
return self.folderName
def getMatchInfo(self, line):
return None, None

View File

@ -9,8 +9,8 @@ os.chdir(baseDir)
#import Tests.ManualTests.csproj_test
#import ManualTests.info_plist_test
#import ManualTests.copy_test
#import Tests.ManualTests.create_backup_test
import Tests.ManualTests.delete_backup_test
import Tests.ManualTests.create_backup_test
#import Tests.ManualTests.delete_backup_test
#import Tests.ManualTests.restore_backup_test
#import ManualTests.csproj_test
#import ManualTests.run_sh_command