+# FIXME: if the above isn't great, this can't be either :)
+
+def which_apt_conf_file ():
+ archive = where_am_i ();
+ if archive == 'non-US':
+ return '/org/non-us.debian.org/katie/apt.conf-non-US';
+ elif archive == 'ftp-master':
+ return '/org/ftp.debian.org/katie/apt.conf';
+ else:
+ raise unknown_hostname_exc, archive
+
+######################################################################################
+
+# Escape characters which have meaning to SQL's regex comparison operator ('~')
+# (woefully incomplete)
+
+def regex_safe (s):
+ s = string.replace(s, '+', '\\\\+');
+ s = string.replace(s, '.', '\\\\.');
+ return s
+
+######################################################################################
+
+# Perform a substition of template
+def TemplateSubst(Map,Template):
+ for x in Map.keys():
+ Template = string.replace(Template,x,Map[x]);
+ return Template;
+
+######################################################################################
+
+def fubar(msg, exit_code=1):
+ sys.stderr.write("E: %s\n" % (msg));
+ sys.exit(exit_code);
+
+def warn(msg):
+ sys.stderr.write("W: %s\n" % (msg));
+
+######################################################################################
+
+# Returns the user name with a laughable attempt at rfc822 conformancy
+# (read: removing stray periods).
+def whoami ():
+ return string.replace(string.split(pwd.getpwuid(os.getuid())[4],',')[0], '.', '');
+