Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _create_ignore_spec(self, build_ignore_patterns):
return PathSpec.from_lines(GitWildMatchPattern, build_ignore_patterns or [])
def _prepare_repo_files_for_packaging(
repository_dirpath, dirpath_with_original_files_with_git_filters, force_if_dirty):
repo = git.Repo(repository_dirpath)
if not force_if_dirty and repo.git.status("--porcelain"):
print(("Repository contains local changes."
" Please remove or commit changes before proceeding."),
file=sys.stderr)
exit(1)
path_specs = _get_path_specs_with_git_filters_from_gitattributes(repository_dirpath)
spec_obj = pathspec.PathSpec.from_lines(
pathspec.patterns.gitwildmatch.GitWildMatchPattern, path_specs)
relative_filepaths_with_git_filters = [
match for match in spec_obj.match_tree(repository_dirpath)]
_move_files_with_filters_to_temporary_location(
repository_dirpath,
relative_filepaths_with_git_filters,
dirpath_with_original_files_with_git_filters)
_reset_files_with_filters_and_activate_smudge_filters(repo, path_specs)
return relative_filepaths_with_git_filters
if self.intransitive:
jvm_targets = set(self.context.target_roots).intersection(jvm_targets)
build_ignore_patterns = self.context.options.for_global_scope().build_ignore or []
project = Project(self.project_name,
self.python,
self.skip_java,
self.skip_scala,
self.use_source_root,
get_buildroot(),
debug_port,
self.context,
jvm_targets,
not self.intransitive,
self.TargetUtil(self.context),
PathSpec.from_lines(GitWildMatchPattern, build_ignore_patterns))
if self.python:
python_source_paths = self.get_options().python_source_paths
python_test_paths = self.get_options().python_test_paths
python_lib_paths = self.get_options().python_lib_paths
project.configure_python(python_source_paths, python_test_paths, python_lib_paths)
extra_source_paths = self.get_options().extra_jvm_source_paths
extra_test_paths = self.get_options().extra_jvm_test_paths
all_targets = project.configure_jvm(extra_source_paths, extra_test_paths)
return all_targets, project
def __init__(self, build_file_parser, project_tree, build_ignore_patterns=None, exclude_target_regexps=None,
subproject_roots=None):
"""Create a BuildFileAddressMapper.
:param build_file_parser: An instance of BuildFileParser
:param build_file_type: A subclass of BuildFile used to construct and cache BuildFile objects
"""
self._build_file_parser = build_file_parser
self._spec_path_to_address_map_map = {} # {spec_path: {address: addressable}} mapping
self._project_tree = project_tree
self._build_ignore_patterns = PathSpec.from_lines(GitWildMatchPattern, build_ignore_patterns or [])
self._exclude_target_regexps = exclude_target_regexps or []
self._exclude_patterns = [re.compile(pattern) for pattern in self._exclude_target_regexps]
self.subproject_roots = subproject_roots or []
def __init__(self, build_file_parser, project_tree, build_ignore_patterns=None, exclude_target_regexps=None,
subproject_roots=None):
"""Create a BuildFileAddressMapper.
:param build_file_parser: An instance of BuildFileParser
:param build_file_type: A subclass of BuildFile used to construct and cache BuildFile objects
"""
self._build_file_parser = build_file_parser
self._spec_path_to_address_map_map = {} # {spec_path: {address: addressable}} mapping
self._project_tree = project_tree
self._build_ignore_patterns = PathSpec.from_lines(GitWildMatchPattern, build_ignore_patterns or [])
self._exclude_target_regexps = exclude_target_regexps or []
self._exclude_patterns = [re.compile(pattern) for pattern in self._exclude_target_regexps]
self.subproject_roots = subproject_roots or []
Escape special characters in the given string.
*s* (:class:`unicode` or :class:`bytes`) a filename or a string
that you want to escape, usually before adding it to a `.gitignore`
Returns the escaped string (:class:`unicode`, :class:`bytes`)
"""
# Reference: https://git-scm.com/docs/gitignore#_pattern_format
meta_characters = r"[]!*#?"
return "".join("\\" + x if x in meta_characters else x for x in s)
util.register_pattern('gitwildmatch', GitWildMatchPattern)
class GitIgnorePattern(GitWildMatchPattern):
"""
The :class:`GitIgnorePattern` class is deprecated by :class:`GitWildMatchPattern`.
This class only exists to maintain compatibility with v0.4.
"""
def __init__(self, *args, **kw):
"""
Warn about deprecation.
"""
self._deprecated()
return super(GitIgnorePattern, self).__init__(*args, **kw)
@staticmethod
def _deprecated():
"""
Warn about deprecation.