]> git.decadent.org.uk Git - dak.git/blobdiff - utils.py
Fix checking for source files with +'s in them.
[dak.git] / utils.py
index 40e36cd9c6a1c79111550a616a72ccb095e6320c..409113ef93da6dad8084e3245d088fe995c6e0d4 100644 (file)
--- a/utils.py
+++ b/utils.py
@@ -1,6 +1,6 @@
 # Utility functions
 # Copyright (C) 2000  James Troup <james@nocrew.org>
-# $Id: utils.py,v 1.4 2000-11-27 03:15:26 troup Exp $
+# $Id: utils.py,v 1.6 2000-12-01 17:33:29 troup Exp $
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -206,6 +206,8 @@ def move (src, dest):
        os.umask(umask);
     #print "Moving %s to %s..." % (src, dest);
     shutil.copy2(src, dest);
+    if os.path.exists(dest) and stat.S_ISDIR(os.stat(dest)[stat.ST_MODE]):
+       dest = dest + '/' + os.path.basename(src);
     os.chmod(dest, 0664);
     os.unlink(src);
 
@@ -220,6 +222,8 @@ def copy (src, dest):
        os.umask(umask);
     #print "Copying %s to %s..." % (src, dest);
     shutil.copy2(src, dest);
+    if os.path.exists(dest) and stat.S_ISDIR(os.stat(dest)[stat.ST_MODE]):
+       dest = dest + '/' + os.path.basename(src);
     os.chmod(dest, 0664);
 
 ######################################################################################
@@ -252,3 +256,12 @@ def which_conf_file ():
 
 ######################################################################################
 
+# Escape characters which have meaning to SQL's regex comparison operator ('~')
+# (woefully incomplete)
+
+def regex_safe (s):
+    s = string.replace(s, '+', '\\\\+');
+    return s
+
+######################################################################################
+