summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kreuter <richard@10gen.com>2010-04-08 10:20:26 -0400
committerRichard Kreuter <richard@10gen.com>2010-04-08 10:21:58 -0400
commit05a16ff3dd14df0f2f47c799912d7a55d83e8dee (patch)
treebf989f906df7e9da30dd82d0b9907fa73f4323bd
parent5cad0d6a80c2b94e877f56bc7f67b3ce825ee094 (diff)
downloadmongo-05a16ff3dd14df0f2f47c799912d7a55d83e8dee.tar.gz
Implement subset of PEP 3101 so makedist.py will run on Python<2.6.
-rwxr-xr-xbuildscripts/makedist.py75
1 files changed, 57 insertions, 18 deletions
diff --git a/buildscripts/makedist.py b/buildscripts/makedist.py
index cfdcb58b752..0b61f952c38 100755
--- a/buildscripts/makedist.py
+++ b/buildscripts/makedist.py
@@ -54,6 +54,7 @@ import socket
import time
import os.path
import tempfile
+import string
# For the moment, we don't handle any of the errors we raise, so it
# suffices to have a simple subclass of Exception that just
@@ -638,25 +639,63 @@ class ScriptFile(object):
self.distro_version = configurator.default("distro_version")
self.distro_arch = configurator.default("distro_arch")
+ def bogoformat(self, fmt, **kwargs):
+ r = ''
+ i = 0
+ while True:
+ c = fmt[i]
+ if c in '{}':
+ i+=1
+ c2=fmt[i]
+ if c2 == c:
+ r+=c
+ else:
+ j=i
+ while True:
+ p=fmt[j:].find('}')
+ if p == -1:
+ raise Exception("malformed format string starting at %d: no closing brace" % i)
+ else:
+ j+=p
+ if len(fmt) > (j+1) and fmt[j+1]=='}':
+ j+=2
+ else:
+ break
+ key = fmt[i:j]
+ r+=kwargs[key]
+ i=j
+ else:
+ r+=c
+ i+=1
+ if i==len(fmt):
+ return r
+
+ def fmt(self, formatter, **kwargs):
+ try:
+ return string.Formatter.format(formatter, kwargs)
+ finally:
+ return self.bogoformat(formatter, **kwargs)
+
def genscript(self):
- return self.formatter.format(mongo_version=self.mongo_version,
- distro_name=self.distro_name,
- distro_version=self.distro_version,
- distro_arch=self.distro_arch,
- pkg_prereq_str=" ".join(self.pkg_prereqs),
- pkg_name=self.pkg_name,
- pkg_name_suffix=self.pkg_name_suffix,
- pkg_version=self.pkg_version,
- pkg_product_dir=self.pkg_product_dir,
- # KLUDGE: rpm specs and deb
- # control files use
- # comma-separated conflicts,
- # but there's no reason to
- # suppose this works elsewhere
- pkg_name_conflicts = ", ".join([self.pkg_name+conflict for conflict in self.pkg_name_conflicts]),
- mongo_arch=self.mongo_arch,
- mongo_pub_version=self.mongo_pub_version
-)
+ return self.fmt(self.formatter,
+ mongo_version=self.mongo_version,
+ distro_name=self.distro_name,
+ distro_version=self.distro_version,
+ distro_arch=self.distro_arch,
+ pkg_prereq_str=" ".join(self.pkg_prereqs),
+ pkg_name=self.pkg_name,
+ pkg_name_suffix=self.pkg_name_suffix,
+ pkg_version=self.pkg_version,
+ pkg_product_dir=self.pkg_product_dir,
+ # KLUDGE: rpm specs and deb
+ # control files use
+ # comma-separated conflicts,
+ # but there's no reason to
+ # suppose this works elsewhere
+ pkg_name_conflicts = ", ".join([self.pkg_name+conflict for conflict in self.pkg_name_conflicts]),
+ mongo_arch=self.mongo_arch,
+ mongo_pub_version=self.mongo_pub_version
+ )
def __enter__(self):
self.localscript=None