fnmatch exclude, module check
This commit is contained in:
parent
a0aba9a0bb
commit
c9066cf691
|
@ -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"):
|
||||
|
|
|
@ -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"])
|
||||
|
|
Loading…
Reference in New Issue