# Utility functions
# Copyright (C) 2000 James Troup <james@nocrew.org>
-# $Id: utils.py,v 1.2 2000-11-25 04:18:30 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
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);
+def copy (src, dest):
+ if os.path.exists(dest) and stat.S_ISDIR(os.stat(dest)[stat.ST_MODE]):
+ dest_dir = dest;
+ else:
+ dest_dir = os.path.dirname(dest);
+ if not os.path.exists(dest_dir):
+ umask = os.umask(00000);
+ os.makedirs(dest_dir, 02775);
+ 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);
+
######################################################################################
# FIXME: this is inherently nasty. Can't put this mapping in a conf
res = socket.gethostbyaddr(socket.gethostname());
if res[0] == 'pandora.debian.org':
return 'non-US';
- elif res[1] == 'auric.debian.org':
+ elif res[0] == 'auric.debian.org':
return 'ftp-master';
else:
raise unknown_hostname_exc, res;
######################################################################################
+# Escape characters which have meaning to SQL's regex comparison operator ('~')
+# (woefully incomplete)
+
+def regex_safe (s):
+ s = string.replace(s, '+', '\\\\+');
+ return s
+
+######################################################################################
+