diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2011-03-27 08:10:46 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2011-03-27 08:10:46 (GMT) |
commit | 49b0ce06f01a27c98a61a1287ea1b8d40c0f2e51 (patch) | |
tree | 1ddf7a2cbc01a886e25603bcb4aae1705fc762d9 /Lib/msilib | |
parent | 8c05568e06794ecc81410cc42f07e0295c4727f2 (diff) | |
download | cpython-49b0ce06f01a27c98a61a1287ea1b8d40c0f2e51.zip cpython-49b0ce06f01a27c98a61a1287ea1b8d40c0f2e51.tar.gz cpython-49b0ce06f01a27c98a61a1287ea1b8d40c0f2e51.tar.bz2 |
Fix short file name generation in bdist_msi.
Patch by Christoph Gohlke.
Closes #7639.
Diffstat (limited to 'Lib/msilib')
-rw-r--r-- | Lib/msilib/__init__.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Lib/msilib/__init__.py b/Lib/msilib/__init__.py index 1aa0637..d7a31c0 100644 --- a/Lib/msilib/__init__.py +++ b/Lib/msilib/__init__.py @@ -174,10 +174,10 @@ def add_tables(db, module): def make_id(str): #str = str.replace(".", "_") # colons are allowed - str = str.replace(" ", "_") - str = str.replace("-", "_") - if str[0] in string.digits: - str = "_"+str + for c in " -+~;": + str = str.replace(c, "_") + if str[0] in (string.digits + "."): + str = "_" + str assert re.match("^[A-Za-z_][A-Za-z0-9_.]*$", str), "FILE"+str return str @@ -285,19 +285,28 @@ class Directory: [(feature.id, component)]) def make_short(self, file): + oldfile = file + file = file.replace('+', '_') + file = ''.join(c for c in file if not c in ' "/\[]:;=,') parts = file.split(".") - if len(parts)>1: + if len(parts) > 1: + prefix = "".join(parts[:-1]).upper() suffix = parts[-1].upper() + if not prefix: + prefix = suffix + suffix = None else: + prefix = file.upper() suffix = None - prefix = parts[0].upper() - if len(prefix) <= 8 and (not suffix or len(suffix)<=3): + if len(parts) < 3 and len(prefix) <= 8 and file == oldfile and ( + not suffix or len(suffix) <= 3): if suffix: file = prefix+"."+suffix else: file = prefix - assert file not in self.short_names else: + file = None + if file is None or file in self.short_names: prefix = prefix[:6] if suffix: suffix = suffix[:3] |