file_query_text 0.1.8__py3-none-any.whl → 0.1.9__py3-none-any.whl

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.
@@ -2,4 +2,4 @@
2
2
  SQL-like interface for querying files in your filesystem.
3
3
  """
4
4
 
5
- __version__ = "0.1.8"
5
+ __version__ = "0.1.9"
@@ -46,8 +46,15 @@ basic_condition = Group(IDENTIFIER + COMPARISON_OP + VALUE)
46
46
 
47
47
  # Define logical expressions using infixNotation for better handling of AND and OR
48
48
  condition_expr = Forward()
49
+
50
+ # Define a new pattern for the NOT LIKE operator
51
+ not_like_condition = Group(IDENTIFIER + NOT + LIKE + VALUE)
52
+
53
+ # Include both basic conditions and NOT LIKE conditions
54
+ basic_expr = basic_condition | not_like_condition
55
+
49
56
  condition_expr <<= infixNotation(
50
- basic_condition,
57
+ basic_expr,
51
58
  [
52
59
  (NOT, 1, opAssoc.RIGHT),
53
60
  (AND, 2, opAssoc.LEFT),
file_query_text/main.py CHANGED
@@ -149,6 +149,20 @@ def evaluate_conditions(file_path, condition):
149
149
  elif len(expr) == 2 and expr[0] == "NOT":
150
150
  return not eval_expr(expr[1])
151
151
 
152
+ # 4. Special case for NOT LIKE: [attr, 'NOT', 'LIKE', value]
153
+ elif len(expr) == 4 and expr[1] == "NOT" and expr[2] == "LIKE":
154
+ attr_val = get_file_attr(expr[0])
155
+ val = expr[3].strip("'") if isinstance(expr[3], str) else expr[3]
156
+
157
+ if attr_val is None:
158
+ return True # If attribute doesn't exist, NOT LIKE is True
159
+
160
+ # Convert SQL LIKE pattern (with % wildcards) to regex pattern
161
+ pattern = re.escape(val).replace('\\%', '%') # Unescape % after escaping everything else
162
+ pattern = pattern.replace("%", ".*")
163
+ pattern = f"^{pattern}$" # Anchor pattern to match whole string
164
+ return not bool(re.search(pattern, str(attr_val), re.IGNORECASE))
165
+
152
166
  return False
153
167
 
154
168
  return eval_expr(condition.asList())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: file_query_text
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: SQL-like interface for querying files in your filesystem
5
5
  Author-email: nik <42a11b@nikdav.is>
6
6
  License-Expression: MIT
@@ -128,3 +128,15 @@ Find all markdown files in a specific year's folder:
128
128
  ```
129
129
  fq "path LIKE '%/2023/%' AND extension == 'md'"
130
130
  ```
131
+
132
+ ### Excluding files with NOT LIKE
133
+
134
+ Find all JavaScript files in src directory except those in lib folders:
135
+ ```
136
+ fq "path LIKE 'src%' AND path NOT LIKE '%lib%' AND extension == 'js'"
137
+ ```
138
+
139
+ Find all Python files that don't have "test" in their name:
140
+ ```
141
+ fq "extension == 'py' AND name NOT LIKE '%test%'"
142
+ ```
@@ -0,0 +1,10 @@
1
+ file_query_text/__init__.py,sha256=DscljOkp8bJlAFVMhb6P8fV2gFzCHmf9BhSd60zI9Xg,89
2
+ file_query_text/cli.py,sha256=eijCT1pHk4wtBhhmFHyeTOoLNz0zwk7Bm4izRLrjZb4,3709
3
+ file_query_text/gitignore_parser.py,sha256=PZk5MKyW5e8NXCyfC8w3r2JIp1HeF5CpZ5MdXOWlPNM,7734
4
+ file_query_text/grammar.py,sha256=shs5Vh30ybAhsrEjRmSaiUAtt1PKDHvw4nVJ6mktmBM,1906
5
+ file_query_text/main.py,sha256=cjp7FiyaRHN4rV8l5DsLN5ZYqfLir8nKC2vj70v30PI,8446
6
+ file_query_text-0.1.9.dist-info/METADATA,sha256=PlhAF2sao4kDe28BcIbi6fcgTWKXmUOgcALb7psYpY8,3058
7
+ file_query_text-0.1.9.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ file_query_text-0.1.9.dist-info/entry_points.txt,sha256=rNFYWzvcIsUZkGNsc_E_B5HyYRnqqdj_u8_IeQpw1wo,48
9
+ file_query_text-0.1.9.dist-info/top_level.txt,sha256=o1FzSvLa6kSV61b7RLHWRhEezc96m05YwIKqjuWUSxU,16
10
+ file_query_text-0.1.9.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- file_query_text/__init__.py,sha256=-84ne-3HrCOzvhTwsN8M7-xOwSv24H1wen5OvnEo6_s,89
2
- file_query_text/cli.py,sha256=eijCT1pHk4wtBhhmFHyeTOoLNz0zwk7Bm4izRLrjZb4,3709
3
- file_query_text/gitignore_parser.py,sha256=PZk5MKyW5e8NXCyfC8w3r2JIp1HeF5CpZ5MdXOWlPNM,7734
4
- file_query_text/grammar.py,sha256=mnyOd4UPg489Z-HQcxEySI41H02iDZRBbpaL3-mOFMU,1693
5
- file_query_text/main.py,sha256=YswvqX-4yLGZ_qSTFBUjFxG7OAoLyB9FQ2PIVY-CpoU,7688
6
- file_query_text-0.1.8.dist-info/METADATA,sha256=EPLhtU8ysQfuEo9pZGv7hVRa8YOeiCgSZIEgi7q6Shk,2753
7
- file_query_text-0.1.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- file_query_text-0.1.8.dist-info/entry_points.txt,sha256=rNFYWzvcIsUZkGNsc_E_B5HyYRnqqdj_u8_IeQpw1wo,48
9
- file_query_text-0.1.8.dist-info/top_level.txt,sha256=o1FzSvLa6kSV61b7RLHWRhEezc96m05YwIKqjuWUSxU,16
10
- file_query_text-0.1.8.dist-info/RECORD,,