From 9fac4063051989dbbc78d8967ffaacda80f5189f Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Fri, 8 Jul 2016 20:43:58 -0700 Subject: [PATCH] Working toward making dirsep and extsep cross-platform --- polyloader/_python2.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/polyloader/_python2.py b/polyloader/_python2.py index 72a8894..2fdfe60 100644 --- a/polyloader/_python2.py +++ b/polyloader/_python2.py @@ -6,6 +6,10 @@ import imp import types import pkgutil +SEP = os.sep +EXS = os.extsep +FLS = [('%s' + SEP + '__init__' + EXS + '%s', True), + ('%s' + EXS + '%s', False)] class PolyLoader(): _loader_handlers = [] @@ -85,10 +89,9 @@ class PolyFinder(object): return None path = os.path.realpath(self.path) - fls = [("%s/__init__.%s", True), ("%s.%s", False)] - for (fp, ispkg) in fls: + for (fp, ispkg) in FLS: for (compiler, suffix) in PolyLoader._loader_handlers: - composed_path = fp % ("%s/%s" % (path, subname), suffix) + composed_path = fp % (('%s' + SEP + '%s') % (path, subname), suffix) if os.path.isdir(composed_path): raise IOError("Invalid: Directory name ends in recognized suffix") if os.path.isfile(composed_path):