Remove ensure_slash(), optimize the code
authorBrian Dolbec <dolsen@gentoo.org>
Tue, 11 Jun 2013 02:15:31 +0000 (19:15 -0700)
committerW. Trevor King <wking@tremily.us>
Tue, 11 Jun 2013 13:50:28 +0000 (09:50 -0400)
Just print an ERROR message if it os.path.separator is not '/'.
Remove unused import.

setup.py

index f3aa7b43895cdc817110efd97f92f8fd84294b8a..734c0fe826267cd1595138038b39427910faba6e 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -22,8 +22,8 @@ from __future__ import print_function
 
 import codecs as _codecs
 from distutils.core import setup as _setup, Command
-import itertools as _itertools
 import os as _os
+import sys
 
 from catalyst import __version__
 from catalyst.version import set_release_version, get_version
@@ -34,6 +34,11 @@ package_name = 'catalyst'
 tag = '{0}-{1}'.format(package_name, __version__)
 
 
+if _os.path.sep != '/':
+       print("ERROR: This system does not appear to be a 'POSIX' system.")
+       print("Catalyst is meant to install and run on a 'GENTOO' system only.")
+       sys.exit(2)
+
 def files(root, target):
        """Iterate through all the file paths under `root`
 
@@ -42,21 +47,13 @@ def files(root, target):
 
        [1]: http://docs.python.org/2/distutils/setupscript.html#writing-the-setup-script
        """
-       def ensure_slash(path):
-               if _os.path.sep != '/':
-                       path.replace(_os.path.sep, '/')
-               return path
-       filedict = {}
        for dirpath, dirnames, filenames in _os.walk(root):
                key = _os.path.join(target, dirpath)
                filepaths = []
                for _file in filenames:
-                       _filepath = ensure_slash(_os.path.join(dirpath, _file))
+                       _filepath = _os.path.join(dirpath, _file)
                        filepaths.append(_filepath)
-               filedict[key] = filepaths
-       for key in sorted(filedict):
-               if len(filedict[key]):
-                       yield (key, filedict[key])
+               yield (key, filepaths)
 
 
 _data_files = [('/etc/catalyst', ['etc/catalyst.conf','etc/catalystrc']),