From 0ff2733eb9cc31d2549a870c1ccf9cffd29abbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Mon, 20 Jun 2005 12:34:04 +0000 Subject: [PATCH] =?UTF-8?q?-=20check=5Ffile'a=20bir=20d=C3=B6n=C3=BC=C5=9F?= =?UTF-8?q?=20de=C4=9Feri=20ekle.=20-=20copy=5Ffile'da=20shutil=20kullan.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/util.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pisi/util.py b/pisi/util.py index 74657aae..1eca2628 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -5,6 +5,8 @@ import os import sys import md5 +import shutil + from ui import ui class FileError(Exception): @@ -17,6 +19,7 @@ def check_file(file, mode = os.F_OK): "shorthand to check if a file exists" if not os.access(file, mode): raise FileError("File " + file + " not found") + return True def check_dir(dir): """check if directory exists, and create if it doesn't. @@ -52,10 +55,12 @@ def copy_file(src,dest): """copy source file to destination file""" check_file(src) check_dir(os.path.dirname(dest)) - fs = file(src, 'rb') - fd = file(dest, 'wb') - for l in fs: - fd.write(l) +#don't reinvent the wheel +# fs = file(src, 'rb') +# fd = file(dest, 'wb') +# for l in fs: +# fd.write(l) + shutil.copyfile(src, dest) def copy_dir(src, dest): """copy source dir to destination dir recursively"""