Реализовал задание на копирование файлов

This commit is contained in:
Rustam Zaitov 2013-10-28 02:45:30 +04:00
parent 140398e101
commit 535766f376
3 changed files with 17 additions and 4 deletions

View File

@ -2,7 +2,7 @@ from CommandBuilders.CopyCommandBuilder import CopyCommandBuilder
from ManualTests.path_provider import PathProvider
line1 = "copy 'BuildSample/BuildSample.sln' to 'BuildSample/BuildSample.txt'"
line2 = "copy 'BuildSample/BuildSample.sln' to '~/tmp/BuildSample.sln'"
line2 = "copy 'BuildSample/BuildSample.sln' to '~/Downloads/BuildSample.sln'"
baseDir = '../'
path_provider = PathProvider(baseDir)

View File

@ -1,4 +1,5 @@
import shutil
import os
class CopyCommand:
def __init__(self, pathProvider, copyArguments):
@ -9,5 +10,16 @@ class CopyCommand:
self.__copyArguments = copyArguments
def execute(self):
shutil.copy(self.__copyArguments.source, self.__copyArguments.target)
source = self.__expandPath(self.__copyArguments.source)
target = self.__expandPath(self.__copyArguments.target)
shutil.copy(source, target)
def __expandPath(self, path):
path = os.path.expanduser(path)
if not os.path.isabs(path):
path = self.__pathProvider.resolveAbsPath(path)
return path

View File

@ -1,2 +1,3 @@
import ManualTests.csproj_test
import ManualTests.info_plist_test
#import ManualTests.csproj_test
#import ManualTests.info_plist_test
import ManualTests.copy_test