From 59ee1c8714baf9aababa6d74aa50b1990b1dc0af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Fri, 8 Jul 2005 18:10:14 +0000 Subject: [PATCH] =?UTF-8?q?ActionsAPI=20i=C3=A7inde=20d=C3=BCzenlemeler,?= =?UTF-8?q?=20dosed=20native=20python'a=20=C3=A7evrildi.=20Sonu=C3=A7=20ol?= =?UTF-8?q?arak=20bash=20i=C3=A7inde=20RegularExpr.=20magic=20var=20kendil?= =?UTF-8?q?eri=20de=20birazdan=20commit=20edilecek.=20Bu=20regular=20exp.?= =?UTF-8?q?=20denen=20illet=20acayip=20bir=C5=9Fey...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/actionsapi/pisitools.py | 41 ++++++++++++++---------------------- pisi/actionsapi/utils.py | 8 ++++++- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/pisi/actionsapi/pisitools.py b/pisi/actionsapi/pisitools.py index 925f90e3..594c90d7 100644 --- a/pisi/actionsapi/pisitools.py +++ b/pisi/actionsapi/pisitools.py @@ -5,7 +5,11 @@ import os import gzip import shutil +import fileinput +import re +import sys +from utils import makedirs from pisi.util import copy_file # actions api modules @@ -19,12 +23,9 @@ def dodoc(*documentList): + env.src_version + '-' \ + env.src_release - try: - os.makedirs(os.path.join(env.install_dir, + makedirs(os.path.join(env.install_dir, dirs.doc, srcTag)) - except OSError: - pass for document in documentList: if os.access(document, os.F_OK): @@ -34,18 +35,15 @@ def dodoc(*documentList): srcTag, os.path.basename(document))) -def dosed(filename, *sedPattern): - #FIXME: Convert to python - for pattern in sedPattern: - os.system('sed -i -e \'' + pattern + '\' ' + filename) +def dosed(filename, searchPattern, replacePattern = ''): + for line in fileinput.input(filename, inplace = 1): + line = re.sub(searchPattern, replacePattern, line) + sys.stdout.write(line) def dosbin(filename, destination=glb.dirs.sbin): env = glb.env - try: - os.makedirs(os.path.join(env.install_dir, destination)) - except OSError: - pass + makedirs(os.path.join(env.install_dir, destination)) if os.access(filename, os.F_OK): copy_file(filename, @@ -59,10 +57,8 @@ def doman(filename): man, postfix = filename.split('.') destDir = os.path.join(env.install_dir, dirs.man, "man" + postfix) - try: - os.makedirs(destDir) - except OSError: - pass + + makedirs(destDir) gzfile = gzip.GzipFile(filename + '.gz', 'w', 9) gzfile.writelines(file(filename).xreadlines()) @@ -75,19 +71,14 @@ def doman(filename): def domove(source, destination): env = glb.env - try: - os.makedirs(env.install_dir + '/' + os.path.dirname(destination)) - except OSError: - pass + makedirs(env.install_dir + '/' + os.path.dirname(destination)) shutil.move(env.install_dir + '/' + source, env.install_dir + '/' + destination) def dosym(source, destination): env = glb.env - try: - os.makedirs( env.install_dir + '/' + os.path.dirname(destination)) - except OSError: - pass + makedirs( env.install_dir + '/' + os.path.dirname(destination)) - os.symlink(source, env.install_dir + destination) + if not os.path.islink(env.install_dir + destination): + os.symlink(source, env.install_dir + destination) diff --git a/pisi/actionsapi/utils.py b/pisi/actionsapi/utils.py index cbd04880..f3b5c7ce 100644 --- a/pisi/actionsapi/utils.py +++ b/pisi/actionsapi/utils.py @@ -17,5 +17,11 @@ def createTmpDir(): path = mkdtemp() return path -def chmod(filename, mode=0755): +def chmod(filename, mode = 0755): os.chmod(filename, mode) + +def makedirs(directoryName): + try: + os.makedirs(directoryName) + except OSError: + pass