file_query_text 0.1.3__tar.gz → 0.1.5__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.3 → file_query_text-0.1.5}/PKG-INFO +2 -2
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text/__init__.py +1 -1
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text/cli.py +7 -1
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text/main.py +13 -1
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text.egg-info/PKG-INFO +2 -2
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text.egg-info/requires.txt +1 -1
- {file_query_text-0.1.3 → file_query_text-0.1.5}/pyproject.toml +7 -2
- {file_query_text-0.1.3 → file_query_text-0.1.5}/tests/test_main.py +63 -5
- {file_query_text-0.1.3 → file_query_text-0.1.5}/README.md +0 -0
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text/grammar.py +0 -0
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text.egg-info/SOURCES.txt +0 -0
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text.egg-info/dependency_links.txt +0 -0
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text.egg-info/entry_points.txt +0 -0
- {file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text.egg-info/top_level.txt +0 -0
- {file_query_text-0.1.3 → file_query_text-0.1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: file_query_text
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
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
|
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.12
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
Requires-Dist: pyparsing>=3.2.3
|
14
|
-
Requires-Dist:
|
14
|
+
Requires-Dist: gitignore-parser>=0.1.12
|
15
15
|
Provides-Extra: dev
|
16
16
|
Requires-Dist: pytest>=8.3.5; extra == "dev"
|
17
17
|
|
@@ -25,6 +25,11 @@ def main():
|
|
25
25
|
action="store_true",
|
26
26
|
help="Don't respect .gitignore files (show ignored files)"
|
27
27
|
)
|
28
|
+
parser.add_argument(
|
29
|
+
"--show-hidden", "-s",
|
30
|
+
action="store_true",
|
31
|
+
help="Show hidden files (starting with a dot)"
|
32
|
+
)
|
28
33
|
args = parser.parse_args()
|
29
34
|
|
30
35
|
# Get current working directory for the query
|
@@ -54,7 +59,8 @@ def main():
|
|
54
59
|
visitor.select,
|
55
60
|
visitor.from_dirs,
|
56
61
|
visitor.where,
|
57
|
-
respect_gitignore=not args.no_gitignore
|
62
|
+
respect_gitignore=not args.no_gitignore,
|
63
|
+
show_hidden=args.show_hidden
|
58
64
|
)
|
59
65
|
|
60
66
|
# Display results
|
@@ -31,7 +31,7 @@ class QueryVisitor:
|
|
31
31
|
self.from_dirs = parsed_query.get("from_dirs", [])
|
32
32
|
self.where = parsed_query.get("where", None)
|
33
33
|
|
34
|
-
def execute_query(select, from_dirs, where_conditions, respect_gitignore=True):
|
34
|
+
def execute_query(select, from_dirs, where_conditions, respect_gitignore=True, show_hidden=False):
|
35
35
|
matched_files = []
|
36
36
|
|
37
37
|
# Set up gitignore matching if requested
|
@@ -63,6 +63,18 @@ def execute_query(select, from_dirs, where_conditions, respect_gitignore=True):
|
|
63
63
|
for filename in files:
|
64
64
|
file_path = os.path.join(root, filename)
|
65
65
|
|
66
|
+
# Skip hidden files or files in hidden directories unless explicitly requested
|
67
|
+
if not show_hidden:
|
68
|
+
# Check if file name starts with dot
|
69
|
+
if os.path.basename(file_path).startswith('.'):
|
70
|
+
continue
|
71
|
+
|
72
|
+
# Check if any parent directory starts with dot
|
73
|
+
rel_path = os.path.relpath(file_path, directory)
|
74
|
+
path_parts = rel_path.split(os.sep)
|
75
|
+
if any(part.startswith('.') for part in path_parts[:-1]): # Check all except the filename
|
76
|
+
continue
|
77
|
+
|
66
78
|
# Check if file is ignored by gitignore rules
|
67
79
|
if respect_gitignore:
|
68
80
|
# Find which repo this file belongs to
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: file_query_text
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
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
|
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.12
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
Requires-Dist: pyparsing>=3.2.3
|
14
|
-
Requires-Dist:
|
14
|
+
Requires-Dist: gitignore-parser>=0.1.12
|
15
15
|
Provides-Extra: dev
|
16
16
|
Requires-Dist: pytest>=8.3.5; extra == "dev"
|
17
17
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "file_query_text"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.5"
|
8
8
|
description = "SQL-like interface for querying files in your filesystem"
|
9
9
|
readme = "README.md"
|
10
10
|
requires-python = ">=3.12"
|
@@ -18,7 +18,7 @@ classifiers = [
|
|
18
18
|
]
|
19
19
|
dependencies = [
|
20
20
|
"pyparsing>=3.2.3",
|
21
|
-
"
|
21
|
+
"gitignore-parser>=0.1.12",
|
22
22
|
]
|
23
23
|
|
24
24
|
[project.urls]
|
@@ -41,3 +41,8 @@ name = "testpypi"
|
|
41
41
|
url = "https://test.pypi.org/simple/"
|
42
42
|
publish-url = "https://test.pypi.org/legacy/"
|
43
43
|
explicit = true
|
44
|
+
|
45
|
+
[dependency-groups]
|
46
|
+
dev = [
|
47
|
+
"pytest>=8.3.5",
|
48
|
+
]
|
@@ -21,6 +21,9 @@ def temp_dir():
|
|
21
21
|
f.write("Test TXT")
|
22
22
|
with open(root_path / "downloads/image.jpg", "w") as f:
|
23
23
|
f.write("Test JPG")
|
24
|
+
# Add a hidden file
|
25
|
+
with open(root_path / "docs/.hidden.txt", "w") as f:
|
26
|
+
f.write("Hidden file")
|
24
27
|
|
25
28
|
yield root_path # Provide the path to the test
|
26
29
|
|
@@ -196,10 +199,10 @@ def test_not_conditions(temp_dir):
|
|
196
199
|
visitor.where
|
197
200
|
)
|
198
201
|
|
199
|
-
# Query should return all non-PDF files
|
202
|
+
# Query should return all non-PDF files (except hidden ones since show_hidden=False by default)
|
200
203
|
all_non_pdf_files = []
|
201
204
|
for path in (temp_dir / "docs").glob("*"):
|
202
|
-
if path.suffix != ".pdf":
|
205
|
+
if path.is_file() and path.suffix != ".pdf" and not path.name.startswith('.'):
|
203
206
|
all_non_pdf_files.append(str(path))
|
204
207
|
|
205
208
|
# Normalize paths for comparison
|
@@ -296,7 +299,8 @@ def test_query_without_where_clause(temp_dir):
|
|
296
299
|
results = execute_query(
|
297
300
|
visitor.select,
|
298
301
|
visitor.from_dirs,
|
299
|
-
visitor.where
|
302
|
+
visitor.where,
|
303
|
+
show_hidden=True # Show all files including hidden ones
|
300
304
|
)
|
301
305
|
|
302
306
|
# All files in the docs directory should be returned
|
@@ -325,7 +329,8 @@ def test_empty_query(temp_dir):
|
|
325
329
|
results = execute_query(
|
326
330
|
visitor.select,
|
327
331
|
visitor.from_dirs,
|
328
|
-
visitor.where
|
332
|
+
visitor.where,
|
333
|
+
show_hidden=True # Show all files including hidden ones
|
329
334
|
)
|
330
335
|
|
331
336
|
# Count all files in all subdirectories
|
@@ -358,7 +363,8 @@ def test_no_argument_query(temp_dir):
|
|
358
363
|
results = execute_query(
|
359
364
|
visitor.select,
|
360
365
|
visitor.from_dirs,
|
361
|
-
visitor.where
|
366
|
+
visitor.where,
|
367
|
+
show_hidden=True # Show all files including hidden ones
|
362
368
|
)
|
363
369
|
|
364
370
|
# Count all files in all subdirectories
|
@@ -374,3 +380,55 @@ def test_no_argument_query(temp_dir):
|
|
374
380
|
# Ensure we're getting more than just one file type
|
375
381
|
extensions = {os.path.splitext(p)[1] for p in actual}
|
376
382
|
assert len(extensions) > 1, "Query with no argument should return files with different extensions"
|
383
|
+
|
384
|
+
# Add a specific test for hidden file behavior
|
385
|
+
def test_hidden_files(temp_dir):
|
386
|
+
"""Test hidden files are excluded by default but included when show_hidden=True."""
|
387
|
+
# Create a hidden file
|
388
|
+
with open(temp_dir / "docs/.config.json", "w") as f:
|
389
|
+
f.write('{"setting": "value"}')
|
390
|
+
|
391
|
+
query_str = f"SELECT * FROM '{temp_dir}/docs'"
|
392
|
+
|
393
|
+
parsed = parse_query(query_str)
|
394
|
+
visitor = QueryVisitor()
|
395
|
+
visitor.visit(parsed)
|
396
|
+
|
397
|
+
# Without show_hidden
|
398
|
+
results_default = execute_query(
|
399
|
+
visitor.select,
|
400
|
+
visitor.from_dirs,
|
401
|
+
visitor.where
|
402
|
+
)
|
403
|
+
|
404
|
+
# With show_hidden=True
|
405
|
+
results_with_hidden = execute_query(
|
406
|
+
visitor.select,
|
407
|
+
visitor.from_dirs,
|
408
|
+
visitor.where,
|
409
|
+
show_hidden=True
|
410
|
+
)
|
411
|
+
|
412
|
+
# Check hidden files are not in default results
|
413
|
+
hidden_files = [str(p) for p in (temp_dir / "docs").glob(".*") if p.is_file()]
|
414
|
+
default_files = [str(p) for p in results_default]
|
415
|
+
|
416
|
+
for hidden_file in hidden_files:
|
417
|
+
assert hidden_file not in default_files, f"Hidden file {hidden_file} should not be in default results"
|
418
|
+
|
419
|
+
# Check hidden files are in results with show_hidden=True
|
420
|
+
with_hidden_files = [str(p) for p in results_with_hidden]
|
421
|
+
|
422
|
+
# Get all visible files
|
423
|
+
visible_files = [str(p) for p in (temp_dir / "docs").glob("*") if p.is_file()]
|
424
|
+
|
425
|
+
# Combine visible and hidden files to get all files
|
426
|
+
all_files = visible_files + hidden_files
|
427
|
+
|
428
|
+
# Create a more specific test that checks if every hidden file is in results
|
429
|
+
for hidden_file in hidden_files:
|
430
|
+
assert hidden_file in with_hidden_files, f"Hidden file {hidden_file} missing from results"
|
431
|
+
|
432
|
+
# Also check if every visible file is in results
|
433
|
+
for visible_file in visible_files:
|
434
|
+
assert visible_file in with_hidden_files, f"Visible file {visible_file} missing from results"
|
File without changes
|
File without changes
|
File without changes
|
{file_query_text-0.1.3 → file_query_text-0.1.5}/file_query_text.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|