mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-22 21:00:44 +00:00
switching to pathspec for globbing
This commit is contained in:
parent
04dec26a3a
commit
6444fa3d5a
@ -3,8 +3,8 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import anyconfig
|
import anyconfig
|
||||||
|
import pathspec
|
||||||
from appdirs import AppDirs
|
from appdirs import AppDirs
|
||||||
from globmatch import glob_match
|
|
||||||
from jsonschema._utils import format_as_index
|
from jsonschema._utils import format_as_index
|
||||||
from pkg_resources import resource_filename
|
from pkg_resources import resource_filename
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class Settings(object):
|
|||||||
tmp_dict["logging"]["level"] = levels[log_level]
|
tmp_dict["logging"]["level"] = levels[log_level]
|
||||||
|
|
||||||
if len(tmp_dict["rules"]["files"]) == 0:
|
if len(tmp_dict["rules"]["files"]) == 0:
|
||||||
tmp_dict["rules"]["files"] = "*"
|
tmp_dict["rules"]["files"] = ["*"]
|
||||||
else:
|
else:
|
||||||
tmp_dict["rules"]["files"] = tmp_dict["rules"]["files"]
|
tmp_dict["rules"]["files"] = tmp_dict["rules"]["files"]
|
||||||
self.args_files = True
|
self.args_files = True
|
||||||
@ -148,12 +148,12 @@ class Settings(object):
|
|||||||
utils.sysexit_with_message("{schema}: {msg}".format(schema=schema_error, msg=e.message))
|
utils.sysexit_with_message("{schema}: {msg}".format(schema=schema_error, msg=e.message))
|
||||||
|
|
||||||
def _update_filelist(self):
|
def _update_filelist(self):
|
||||||
include = self.config["rules"]["files"]
|
includes = self.config["rules"]["files"]
|
||||||
excludes = self.config["rules"]["exclude_files"]
|
excludes = self.config["rules"]["exclude_files"]
|
||||||
ignore_dotfiles = self.config["rules"]["ignore_dotfiles"]
|
ignore_dotfiles = self.config["rules"]["ignore_dotfiles"]
|
||||||
|
|
||||||
if ignore_dotfiles and not self.args_files:
|
if ignore_dotfiles and not self.args_files:
|
||||||
excludes.append(".")
|
excludes.append(".*")
|
||||||
else:
|
else:
|
||||||
del excludes[:]
|
del excludes[:]
|
||||||
|
|
||||||
@ -164,8 +164,10 @@ class Settings(object):
|
|||||||
os.path.relpath(os.path.normpath(os.path.join(root, filename))))
|
os.path.relpath(os.path.normpath(os.path.join(root, filename))))
|
||||||
|
|
||||||
valid = []
|
valid = []
|
||||||
|
includespec = pathspec.PathSpec.from_lines('gitwildmatch', includes)
|
||||||
|
excludespec = pathspec.PathSpec.from_lines('gitwildmatch', excludes)
|
||||||
for item in filelist:
|
for item in filelist:
|
||||||
if glob_match(item, include) and not glob_match(item, excludes):
|
if includespec.match_file(item) and not excludespec.match_file(item):
|
||||||
valid.append(item)
|
valid.append(item)
|
||||||
|
|
||||||
self.config["rules"]["files"] = valid
|
self.config["rules"]["files"] = valid
|
||||||
|
Loading…
Reference in New Issue
Block a user