file_query_text 0.1.9__tar.gz → 0.1.11__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.
- {file_query_text-0.1.9 → file_query_text-0.1.11}/PKG-INFO +1 -1
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text/__init__.py +1 -1
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text/cli.py +1 -1
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text/main.py +27 -18
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text.egg-info/PKG-INFO +1 -1
- {file_query_text-0.1.9 → file_query_text-0.1.11}/pyproject.toml +1 -1
- {file_query_text-0.1.9 → file_query_text-0.1.11}/README.md +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text/gitignore_parser.py +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text/grammar.py +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text.egg-info/SOURCES.txt +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text.egg-info/dependency_links.txt +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text.egg-info/entry_points.txt +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text.egg-info/requires.txt +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text.egg-info/top_level.txt +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/setup.cfg +0 -0
- {file_query_text-0.1.9 → file_query_text-0.1.11}/tests/test_main.py +0 -0
@@ -86,7 +86,7 @@ def main():
|
|
86
86
|
if args.debug:
|
87
87
|
# Print all attributes in debug mode
|
88
88
|
attrs = get_file_attributes(file_path)
|
89
|
-
print(f"{attrs['extension']:<15} {attrs['name']:<30} {attrs['size']:<10} {attrs['
|
89
|
+
print(f"{attrs['extension']:<15} {attrs['name']:<30} {attrs['size']:<10} {attrs['path']}")
|
90
90
|
else:
|
91
91
|
# Standard output
|
92
92
|
print(file_path)
|
@@ -97,6 +97,14 @@ def evaluate_conditions(file_path, condition):
|
|
97
97
|
if not condition:
|
98
98
|
return True
|
99
99
|
|
100
|
+
# Get the relative path for comparison
|
101
|
+
cwd = os.getcwd()
|
102
|
+
try:
|
103
|
+
relative_path = os.path.relpath(file_path, cwd)
|
104
|
+
except ValueError:
|
105
|
+
# Handle case when on different drives (Windows)
|
106
|
+
relative_path = file_path
|
107
|
+
|
100
108
|
def get_file_attr(attr_name):
|
101
109
|
if attr_name == "extension":
|
102
110
|
return os.path.splitext(file_path)[1][1:]
|
@@ -105,7 +113,7 @@ def evaluate_conditions(file_path, condition):
|
|
105
113
|
if attr_name == "size":
|
106
114
|
return os.path.getsize(file_path)
|
107
115
|
if attr_name == "path":
|
108
|
-
return
|
116
|
+
return relative_path # Use relative path instead of absolute
|
109
117
|
# Add more attributes as needed
|
110
118
|
return None
|
111
119
|
|
@@ -119,7 +127,8 @@ def evaluate_conditions(file_path, condition):
|
|
119
127
|
|
120
128
|
# 1. Basic condition: [attr, op, value]
|
121
129
|
if isinstance(expr[0], str) and isinstance(expr[1], str):
|
122
|
-
|
130
|
+
attr_name = expr[0]
|
131
|
+
attr_val = get_file_attr(attr_name)
|
123
132
|
op = expr[1]
|
124
133
|
val = expr[2].strip("'") if isinstance(expr[2], str) else expr[2] # Remove quotes if string
|
125
134
|
|
@@ -130,14 +139,7 @@ def evaluate_conditions(file_path, condition):
|
|
130
139
|
if op == ">": return attr_val is not None and int(attr_val) > int(val)
|
131
140
|
if op == ">=": return attr_val is not None and int(attr_val) >= int(val)
|
132
141
|
if op.upper() == "LIKE":
|
133
|
-
|
134
|
-
return False
|
135
|
-
# Convert SQL LIKE pattern (with % wildcards) to regex pattern
|
136
|
-
# Escape any regex special characters in the pattern except %
|
137
|
-
pattern = re.escape(val).replace('\\%', '%') # Unescape % after escaping everything else
|
138
|
-
pattern = pattern.replace("%", ".*")
|
139
|
-
pattern = f"^{pattern}$" # Anchor pattern to match whole string
|
140
|
-
return bool(re.search(pattern, str(attr_val), re.IGNORECASE))
|
142
|
+
return check_like_condition(attr_val, val)
|
141
143
|
|
142
144
|
# 2. Logical operations from infixNotation: [left, op, right]
|
143
145
|
elif expr[1] == "AND":
|
@@ -151,20 +153,28 @@ def evaluate_conditions(file_path, condition):
|
|
151
153
|
|
152
154
|
# 4. Special case for NOT LIKE: [attr, 'NOT', 'LIKE', value]
|
153
155
|
elif len(expr) == 4 and expr[1] == "NOT" and expr[2] == "LIKE":
|
154
|
-
|
156
|
+
attr_name = expr[0]
|
157
|
+
attr_val = get_file_attr(attr_name)
|
155
158
|
val = expr[3].strip("'") if isinstance(expr[3], str) else expr[3]
|
156
159
|
|
157
160
|
if attr_val is None:
|
158
161
|
return True # If attribute doesn't exist, NOT LIKE is True
|
159
162
|
|
160
|
-
|
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))
|
163
|
+
return not check_like_condition(attr_val, val)
|
165
164
|
|
166
165
|
return False
|
167
166
|
|
167
|
+
# Helper function to check LIKE conditions with proper pattern matching
|
168
|
+
def check_like_condition(attr_val, val):
|
169
|
+
if attr_val is None:
|
170
|
+
return False
|
171
|
+
# Convert SQL LIKE pattern (with % wildcards) to regex pattern
|
172
|
+
# Escape any regex special characters in the pattern except %
|
173
|
+
pattern = re.escape(val).replace('\\%', '%') # Unescape % after escaping everything else
|
174
|
+
pattern = pattern.replace("%", ".*")
|
175
|
+
pattern = f"^{pattern}$" # Anchor pattern to match whole string
|
176
|
+
return bool(re.search(pattern, str(attr_val), re.IGNORECASE))
|
177
|
+
|
168
178
|
return eval_expr(condition.asList())
|
169
179
|
|
170
180
|
# Function to get all attributes for a file
|
@@ -182,8 +192,7 @@ def get_file_attributes(file_path):
|
|
182
192
|
"extension": os.path.splitext(file_path)[1][1:],
|
183
193
|
"name": os.path.basename(file_path),
|
184
194
|
"size": os.path.getsize(file_path),
|
185
|
-
"path":
|
186
|
-
"relative_path": rel_path,
|
195
|
+
"path": rel_path, # Use relative path for consistency
|
187
196
|
}
|
188
197
|
return attributes
|
189
198
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{file_query_text-0.1.9 → file_query_text-0.1.11}/file_query_text.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|