fnmatch exclude, module check

This commit is contained in:
Frank 2015-10-24 20:40:20 -04:00
parent a0aba9a0bb
commit c9066cf691
2 changed files with 9 additions and 4 deletions

View File

@ -296,7 +296,7 @@ class Configuration(RawConfigParser):
if self.has_option(section, option):
exclude = self.get(section, option)
exclude += [".git", ".gitignore", "README", "build/", "dist/",
"setup.py", "MANIFEST", "PKG-INFO",
"setup.py", "MANIFEST", "PKG-INFO", "*.pyc",
self.get("setup", "changelog"),
self.get("setup", "package-root")]
for location in self.get("setup", "additional-packages"):

View File

@ -1,11 +1,12 @@
from os import walk, remove
from os.path import sep, join, exists, normpath
from os.path import sep, join, exists, normpath, basename
from re import findall, sub
from distutils.core import setup
from distutils.command.install import install
from pprint import pprint
from fileinput import FileInput
from re import sub, match
from fnmatch import fnmatch
from Configuration import *
@ -29,7 +30,8 @@ class Setup:
for location in locations:
if exists(location):
for root, dirs, files in walk(location, followlinks=True):
packages.append(root.replace(sep, "."))
if exists(join(root, "__init__.py")):
packages.append(root.replace(sep, "."))
return packages
def build_data_map(self):
@ -48,12 +50,15 @@ class Setup:
def remove_excluded(self, paths, root, exclude):
removal = []
for path in paths:
if normpath(join(root, path)) in exclude:
if self.contains_path(join(root, path), exclude):
removal.append(path)
for path in removal:
paths.remove(path)
return paths
def contains_path(self, path, container):
return any(fnmatch(path, rule) or fnmatch(basename(path), rule) for rule in container)
def translate_title(self):
config = self.config.get_section("setup")
title = config["title"].replace(" ", config["whitespace-placeholder"])