From c1806fdf2fb09d2ad468f70a22e768555c320251 Mon Sep 17 00:00:00 2001 From: rzaitov Date: Tue, 12 Nov 2013 11:44:36 +0400 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5=D0=BC?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommandBuilders/CreateBackupCommandBuilder.py | 4 ++-- .../CommandBuilders/DeleteBackupCommandBuilder.py | 4 ++-- .../CommandBuilders/RestoreBackupCommandBuilder.py | 4 ++-- .../Tests/ManualTests/create_backup_test.py | 2 +- .../UnitTests/ParserBackup/test_create_backup.py | 12 ++++++------ .../UnitTests/ParserBackup/test_deleteBackup.py | 12 ++++++------ .../UnitTests/ParserBackup/test_restoreBackup.py | 12 ++++++------ .../commands/BaseBackupCommand/BaseBackupCommand.py | 11 ++++++----- .../BaseBackupCommand/CreateBackupCommand.py | 6 ++++-- .../BaseBackupCommand/RestoreBackupCommand.py | 4 ++-- .../parsers/ParserBackup/BackupArguments.py | 11 ----------- .../parsers/ParserBackup/ParserBackupBase.py | 9 +++------ scripts/TouchinBuild/run_manual_tests.py | 4 ++-- 13 files changed, 42 insertions(+), 53 deletions(-) delete mode 100644 scripts/TouchinBuild/parsers/ParserBackup/BackupArguments.py diff --git a/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py index a1de956..ddb1c34 100644 --- a/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py @@ -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 diff --git a/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py index 05d0720..5fd5b66 100644 --- a/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py @@ -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 diff --git a/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py index bef5c0c..00f328d 100644 --- a/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py @@ -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 diff --git a/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py b/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py index 48bc235..99303cc 100644 --- a/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py +++ b/scripts/TouchinBuild/Tests/ManualTests/create_backup_test.py @@ -1,6 +1,6 @@ from CommandBuilders.CreateBackupCommandBuilder import CreateBackupCommandBuilder -line = "create backup for 'BuildSample'" +line = "create backup for '.'" cmdBuilder = CreateBackupCommandBuilder() command = cmdBuilder.getCommandFor(line) diff --git a/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_create_backup.py b/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_create_backup.py index 43af7bb..1f60683 100644 --- a/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_create_backup.py +++ b/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_create_backup.py @@ -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) \ No newline at end of file + self.assertEqual('/Some/Abs/Path', folderPath) \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_deleteBackup.py b/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_deleteBackup.py index 153da7b..c8dfbd5 100644 --- a/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_deleteBackup.py +++ b/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_deleteBackup.py @@ -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) \ No newline at end of file + self.assertEqual('/Some/Abs/Path', folderPath) \ No newline at end of file diff --git a/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_restoreBackup.py b/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_restoreBackup.py index 589e897..6e9437e 100644 --- a/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_restoreBackup.py +++ b/scripts/TouchinBuild/Tests/UnitTests/ParserBackup/test_restoreBackup.py @@ -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) \ No newline at end of file + self.assertEqual('/Some/Abs/Path', folderPath) \ No newline at end of file diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py index 1ac6215..45acc23 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/BaseBackupCommand.py @@ -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) \ No newline at end of file diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py index f7ae199..516e12b 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/CreateBackupCommand.py @@ -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) diff --git a/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py b/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py index 35ac176..c74085a 100644 --- a/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py +++ b/scripts/TouchinBuild/commands/BaseBackupCommand/RestoreBackupCommand.py @@ -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() diff --git a/scripts/TouchinBuild/parsers/ParserBackup/BackupArguments.py b/scripts/TouchinBuild/parsers/ParserBackup/BackupArguments.py deleted file mode 100644 index fd8d84a..0000000 --- a/scripts/TouchinBuild/parsers/ParserBackup/BackupArguments.py +++ /dev/null @@ -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) - - diff --git a/scripts/TouchinBuild/parsers/ParserBackup/ParserBackupBase.py b/scripts/TouchinBuild/parsers/ParserBackup/ParserBackupBase.py index 96ffba6..e80ba1b 100644 --- a/scripts/TouchinBuild/parsers/ParserBackup/ParserBackupBase.py +++ b/scripts/TouchinBuild/parsers/ParserBackup/ParserBackupBase.py @@ -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 diff --git a/scripts/TouchinBuild/run_manual_tests.py b/scripts/TouchinBuild/run_manual_tests.py index 6ae322c..c0fff48 100644 --- a/scripts/TouchinBuild/run_manual_tests.py +++ b/scripts/TouchinBuild/run_manual_tests.py @@ -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