offgrep 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: offgrep
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A lousy ripgrep rip-off in pure Python
5
5
  Keywords: grep,recursive
6
6
  Author: Rainer Schwarzbach
@@ -5,7 +5,7 @@ build-backend = "uv_build"
5
5
 
6
6
  [project]
7
7
  name = "offgrep"
8
- version = "0.1.0"
8
+ version = "0.1.1"
9
9
  description = "A lousy ripgrep rip-off in pure Python"
10
10
  readme = "README.md"
11
11
  authors = [
@@ -75,8 +75,10 @@ def find_in_files(
75
75
  #
76
76
  #
77
77
  #
78
- except UnicodeDecodeError as unicode_error:
79
- debug("assuming binary file %s because of %r", single_file, unicode_error)
78
+ except UnicodeDecodeError:
79
+ debug(
80
+ "assuming binary file %s because of unicode decode error", single_file
81
+ )
80
82
  except OSError as os_error:
81
83
  error(str(os_error))
82
84
  continue
@@ -8,7 +8,6 @@ from dataclasses import dataclass
8
8
  from enum import StrEnum
9
9
  from functools import lru_cache
10
10
  from logging import debug, warning
11
- from os.path import normcase
12
11
  from pathlib import Path
13
12
  from re import compile as re_compile, escape
14
13
  from typing import Self
@@ -70,7 +69,7 @@ class CompiledPattern:
70
69
  """Pattern to match relative file paths"""
71
70
 
72
71
  def __init__(
73
- self, regex_pattern: str, negated: bool = False, use_normcase: bool = True
72
+ self, regex_pattern: str, negated: bool = False, case_sensitive: bool = True
74
73
  ) -> None:
75
74
  """compile the RE pattern
76
75
 
@@ -78,13 +77,13 @@ class CompiledPattern:
78
77
  regex_pattern: the regular expression pattern
79
78
  negated: Flag indicating whether the pattern excludes (`False`)
80
79
  or re-includes a previously excluded path (`True`)
81
- use_normcase: Flag indicating whether to normalize the pattern
82
- and the relative paths according to the operating system
83
- defaults (`True`), or to always match case sensitive (`False`)
80
+ case_sensitive: Flag indicating whether to use case sensitive
81
+ file name matching or not. Converts regex_pattern to lower case
82
+ if set `False`.
84
83
  """
85
84
  self.negated = negated
86
- self.regex_pattern = normcase(regex_pattern) if use_normcase else regex_pattern
87
- self.use_normcase = use_normcase
85
+ self.regex_pattern = regex_pattern.lower() if case_sensitive else regex_pattern
86
+ self.case_sensitive = case_sensitive
88
87
  self._cre = re_compile(regex_pattern)
89
88
 
90
89
  def matches(self, relative_path: str) -> bool:
@@ -96,14 +95,14 @@ class CompiledPattern:
96
95
  Returns:
97
96
  `True` if the path matches the pattern, `False` if not
98
97
  """
99
- if self.use_normcase:
100
- relative_path = normcase(relative_path)
98
+ if self.case_sensitive:
99
+ relative_path = relative_path.lower()
101
100
  #
102
101
  return self._cre.match(relative_path) is not None
103
102
 
104
103
  @classmethod
105
104
  def from_gitignore_line(
106
- cls, gitignore_line: str, use_normcase: bool = True
105
+ cls, gitignore_line: str, case_sensitive: bool = True
107
106
  ) -> Self:
108
107
  """Factory method: compiled pattern from a `.gitignore` entry
109
108
 
@@ -111,9 +110,8 @@ class CompiledPattern:
111
110
  gitignore_line: a line from a `.gitignore` file
112
111
  (or `$GIT_DIR/info/exclude`, or the file specified by the
113
112
  `core.excludesFile` configuration directive)
114
- use_normcase: Flag indicating whether to normalize the pattern
115
- and the relative paths according to the operating system
116
- defaults (`True`), or to always match case sensitive (`False`)
113
+ case_sensitive: Flag indicating whether to use case sensitive
114
+ file name matching or not
117
115
 
118
116
  Returns:
119
117
  a new instance
@@ -135,7 +133,7 @@ class CompiledPattern:
135
133
  return cls(
136
134
  gitignore_pattern_to_full_regex(gitignore_line),
137
135
  negated=_negated,
138
- use_normcase=use_normcase,
136
+ case_sensitive=case_sensitive,
139
137
  )
140
138
 
141
139
 
File without changes
File without changes
File without changes
File without changes
File without changes