Commits

Anonymous committed 0792bf8

code cleanup.

git-svn-id: file:///tmp/pyinstaller-svn/trunk@1715 6d373633-9ee7-468a-befa-14b9e37bb2df

  • Participants
  • Parent commits 8b1f824

Comments (0)

Files changed (1)

File PyInstaller/mf.py

                     for attr, val in hook.attrs:
                         setattr(mod, attr, val)
                 if hasattr(hook, 'datas'):
-                    # hook.datas is a list of globs of files or directories to bundle
-                    # as datafiles. For each glob, a destination directory is specified.
-                    for g,dest_dir in hook.datas:
-                        if dest_dir: dest_dir += "/"
+                    # hook.datas is a list of globs of files or
+                    # directories to bundle as datafiles. For each
+                    # glob, a destination directory is specified.
+                    def _visit((base, dest_dir, datas), dirname, names):
+                        for fn in names:
+                            fn = os.path.join(dirname, fn)
+                            if os.path.isfile(fn):
+                                datas.append((dest_dir + fn[len(base)+1:], fn, 'DATA'))
+
+                    datas = mod.datas # shortcut
+                    for g, dest_dir in hook.datas:
+                        if dest_dir: dest_dir += os.sep
                         for fn in glob.glob(g):
                             if os.path.isfile(fn):
-                                mod.datas.append((dest_dir + os.path.basename(fn), fn, 'DATA'))
+                                datas.append((dest_dir + os.path.basename(fn), fn, 'DATA'))
                             else:
-                                def visit((base,dest_dir,datas), dirname, names):
-                                    for fn in names:
-                                        fn = os.path.join(dirname, fn)
-                                        if os.path.isfile(fn):
-                                            datas.append((dest_dir + fn[len(base)+1:], fn, 'DATA'))
-                                os.path.walk(fn, visit, (os.path.dirname(fn),dest_dir,mod.datas))
+                                os.path.walk(fn, _visit,
+                                             (os.path.dirname(fn), dest_dir, datas))
                 if fqname != mod.__name__:
                     logger.warn("%s is changing it's name to %s",
                                 fqname, mod.__name__)