From 225c9dea08ed3c6055caebedf35b3167068b99be Mon Sep 17 00:00:00 2001 From: rzaitov Date: Thu, 7 Nov 2013 19:23:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BB=20=D0=BF=D0=B0=D0=BF=D0=BA=D1=83?= =?UTF-8?q?=20backupParser=20ParserBackup=20=D0=BF=D0=BE=D1=82=D0=BE=D0=BC?= =?UTF-8?q?=D1=83=20=D1=87=D1=82=D0=BE=20=D0=B2=D1=81=D0=B5=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B0=D1=87=D0=B8=D0=BD=D0=B0=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D1=81=20backup=20=D0=BF=D0=BE=D0=BF=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B2=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=B3=D0=B8=D1=82=20=D0=B8=D0=B3?= =?UTF-8?q?=D0=BD=D0=BE=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateBackupCommandBuilder.py | 2 +- .../DeleteBackupCommandBuilder.py | 2 +- .../RestoreBackupCommandBuilder.py | 2 +- .../ParserBackup/CreateBackupArguments.py | 11 +++++++ .../ParserBackup/CreateBackupParser.py | 32 +++++++++++++++++++ .../ParserBackup/DeleteBackupParser.py | 23 +++++++++++++ .../ParserBackup/RestoreBackupParser.py | 24 ++++++++++++++ .../parsers/ParserBackup/__init__.py | 1 + 8 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 scripts/TouchinBuild/parsers/ParserBackup/CreateBackupArguments.py create mode 100644 scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py create mode 100644 scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py create mode 100644 scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py create mode 100644 scripts/TouchinBuild/parsers/ParserBackup/__init__.py diff --git a/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py index fdb8ce1..c6719da 100644 --- a/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/CreateBackupCommandBuilder.py @@ -1,5 +1,5 @@ from commands.CreateBackupCommand import CreateBackupCommand -from parsers.BackupParser.CreateBackupParser import CreateBackupParser +from parsers.ParserBackup.CreateBackupParser import CreateBackupParser class CreateBackupCommandBuilder: diff --git a/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py index aca9028..4e66812 100644 --- a/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/DeleteBackupCommandBuilder.py @@ -1,5 +1,5 @@ from commands.DeleteBackupCommand import DeleteBackupCommand -from parsers.BackupParser.DeleteBackupParser import DeleteBackupParser +from parsers.ParserBackup.DeleteBackupParser import DeleteBackupParser class DeleteBackupCommandBuilder: diff --git a/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py b/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py index a0afc02..dc9404b 100644 --- a/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py +++ b/scripts/TouchinBuild/CommandBuilders/RestoreBackupCommandBuilder.py @@ -1,5 +1,5 @@ from commands.RestoreBackupCommand import RestoreBackupCommand -from parsers.BackupParser.RestoreBackupParser import RestoreBackupParser +from parsers.ParserBackup.RestoreBackupParser import RestoreBackupParser class RestoreBackupCommandBuilder: diff --git a/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupArguments.py b/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupArguments.py new file mode 100644 index 0000000..fbeea2b --- /dev/null +++ b/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupArguments.py @@ -0,0 +1,11 @@ +class CreateBackupArguments: + def __init__(self): + self.folderName = None + + def getSourceFolderName(self): + return self.folderName + + def getBackupFolderName(self): + return "backup.{0}".format(self.folderName) + + diff --git a/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py b/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py new file mode 100644 index 0000000..f8a782c --- /dev/null +++ b/scripts/TouchinBuild/parsers/ParserBackup/CreateBackupParser.py @@ -0,0 +1,32 @@ +import re + +from parsers.ParserBackup.CreateBackupArguments import CreateBackupArguments +from parsers.LineParser import LineParser + + +class CreateBackupParser(LineParser): + def __init__(self): + LineParser.__init__(self) + self.__createBackupArguments = CreateBackupArguments() + + def parseLine(self, line): + assert line is not None + + folderNameRegexp = r"'(?P[^']+)'$" + + regexpSource = self.startsWith('create backup for') + folderNameRegexp + regexp = re.compile(regexpSource, re.UNICODE) + + match = regexp.match(line) + self._guardMatch(match, line, regexpSource) + + folderName = match.group('folder') + self.__createBackupArguments.folderName = folderName + + return self.__createBackupArguments + + def isValidLine(self, line): + assert line is not None + + isValid = line.startswith('create backup') + return isValid diff --git a/scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py b/scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py new file mode 100644 index 0000000..2b4e3cc --- /dev/null +++ b/scripts/TouchinBuild/parsers/ParserBackup/DeleteBackupParser.py @@ -0,0 +1,23 @@ +import re + +from parsers.LineParser import LineParser + + +class DeleteBackupParser(LineParser): + def __init__(self): + LineParser.__init__(self) + + def parseLine(self, line): + assert line is not None + + regexpSource = r'delete backup\s*' + regexp = re.compile(regexpSource, re.UNICODE) + + match = regexp.match(line) + self._guardMatch(match, line, regexpSource) + + def isValidLine(self, line): + assert line is not None + + isValid = line.startswith('delete backup') + return isValid diff --git a/scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py b/scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py new file mode 100644 index 0000000..6357ed5 --- /dev/null +++ b/scripts/TouchinBuild/parsers/ParserBackup/RestoreBackupParser.py @@ -0,0 +1,24 @@ +import re + +from parsers.LineParser import LineParser + + +class RestoreBackupParser(LineParser): + def __init__(self): + LineParser.__init__(self) + + def parseLine(self, line): + assert line is not None + + regexpSource = r'restore from backup\s*' + regexp = re.compile(regexpSource, re.UNICODE) + + match = regexp.match(line) + self._guardMatch(match, line, regexpSource) + + def isValidLine(self, line): + assert line is not None + + isValid = line.startswith('restore from backup') + return isValid + diff --git a/scripts/TouchinBuild/parsers/ParserBackup/__init__.py b/scripts/TouchinBuild/parsers/ParserBackup/__init__.py new file mode 100644 index 0000000..cc31abc --- /dev/null +++ b/scripts/TouchinBuild/parsers/ParserBackup/__init__.py @@ -0,0 +1 @@ +__author__ = 'rzaitov'