Index: Lib/test/test_msilib.py =================================================================== --- Lib/test/test_msilib.py (revision 0) +++ Lib/test/test_msilib.py (revision 0) @@ -0,0 +1,25 @@ +from test.test_support import run_unittest, TESTFN, unlink +import unittest +import sys, os +import msilib, msilib.schema + +class MsilibTest(unittest.TestCase): + def tearDown(self): + unlink(TESTFN) + + def test_makeshort(self): + db = msilib.init_database(TESTFN, msilib.schema, + "test", "SomeUUID", + "1.1", "author") + + directory = msilib.Directory(db, None, None, None, 'test', 'test') + self.assertEquals(directory.make_short('foo.txt'), 'FOO.TXT') + self.assertEquals(directory.make_short('foo.2.txt'), 'FOO.2.TXT') + self.assertEquals(directory.make_short('someLongName.txt'), 'SOMELO~1.TXT') + self.assertEquals(directory.make_short('someLongerName.txt'), 'SOMELO~2.TXT') + +def test_main(): + run_unittest(MsilibTest) + +if __name__ == '__main__': + test_main() Index: Lib/msilib/__init__.py =================================================================== --- Lib/msilib/__init__.py (revision 71681) +++ Lib/msilib/__init__.py (working copy) @@ -281,28 +281,16 @@ [(feature.id, component)]) def make_short(self, file): - parts = file.split(".") - if len(parts)>1: - suffix = parts[-1].upper() - else: - suffix = None - prefix = parts[0].upper() - if len(prefix) <= 8 and (not suffix or len(suffix)<=3): - if suffix: - file = prefix+"."+suffix - else: - file = prefix + file = file.upper() + prefix, suffix = os.path.splitext(file) + if len(prefix) <= 8 and len(suffix) <= 4: assert file not in self.short_names else: prefix = prefix[:6] - if suffix: - suffix = suffix[:3] + suffix = suffix[:4] pos = 1 while 1: - if suffix: - file = "%s~%d.%s" % (prefix, pos, suffix) - else: - file = "%s~%d" % (prefix, pos) + file = "%s~%d%s" % (prefix, pos, suffix) if file not in self.short_names: break pos += 1 assert pos < 10000