15
15
from shared import DeleteQuery , SearchQuery , Directory , DataLine , Field , File , Size
16
16
17
17
18
- def _parse_path (subquery : list [str ]) -> tuple [bool , Path , int ]:
18
+ def _parse_path (subquery : list [str ]) -> tuple [Path , int ]:
19
19
"""
20
20
Parses the file/directory path and its type from the specified sub-query.
21
21
Also returns the index of the file/directory specification in the query
@@ -31,10 +31,10 @@ def _parse_path(subquery: list[str]) -> tuple[bool, Path, int]:
31
31
if path_type == "absolute" :
32
32
path = path .resolve ()
33
33
34
- return path_type == "absolute" , path , 1
34
+ return path , 1
35
35
36
36
# Returns `False` for a relative path type as not explicitly specified in query.
37
- return False , Path (subquery [0 ].strip ("'\" " )), 0
37
+ return Path (subquery [0 ].strip ("'\" " )), 0
38
38
39
39
40
40
def _get_from_keyword_index (subquery : list [str ]) -> int :
@@ -135,16 +135,16 @@ def _parse_fields(
135
135
136
136
return fields , columns
137
137
138
- def _parse_directory (self ) -> tuple [Path , bool , int ]:
138
+ def _parse_directory (self ) -> tuple [Path , int ]:
139
139
"""
140
140
Parses the directory path and its metadata.
141
141
"""
142
- is_absolute , path , index = _parse_path (self ._query [self ._from_index + 1 :])
142
+ path , index = _parse_path (self ._query [self ._from_index + 1 :])
143
143
144
144
if not path .is_dir ():
145
145
raise QueryParseError ("The specified path for lookup must be a directory." )
146
146
147
- return path , is_absolute , index
147
+ return path , index
148
148
149
149
def _parse_remove_query (self ) -> DeleteQuery :
150
150
"""
@@ -154,7 +154,7 @@ def _parse_remove_query(self) -> DeleteQuery:
154
154
if self ._from_index != 0 :
155
155
raise QueryParseError ("Invalid query syntax." )
156
156
157
- path , is_absolute , index = self ._parse_directory ()
157
+ path , index = self ._parse_directory ()
158
158
159
159
# Extracts the function for filtering file records.
160
160
condition : Callable [[File | DataLine | Directory ], bool ] = (
@@ -171,7 +171,7 @@ def _parse_search_query(self) -> SearchQuery:
171
171
"""
172
172
173
173
fields , columns = self ._parse_fields (self ._query [: self ._from_index ])
174
- path , is_absolute , index = self ._parse_directory ()
174
+ path , index = self ._parse_directory ()
175
175
176
176
# Extracts the function for filtering file records.
177
177
condition : Callable [[File | DataLine | Directory ], bool ] = (
@@ -241,27 +241,27 @@ def _parse_fields(self, attrs: list[str] | str) -> tuple[list[Field], list[str]]
241
241
242
242
return fields , columns
243
243
244
- def _parse_path (self ) -> tuple [Path , bool , int ]:
244
+ def _parse_path (self ) -> tuple [Path , int ]:
245
245
"""
246
246
Parses the file/directory path and its metadata.
247
247
"""
248
248
249
- is_absolute , path , index = _parse_path (self ._query [self ._from_index + 1 :])
249
+ path , index = _parse_path (self ._query [self ._from_index + 1 :])
250
250
251
251
if not (path .is_dir () or path .is_file ()):
252
252
raise QueryParseError (
253
253
"The specified path for lookup must be a file or directory."
254
254
)
255
255
256
- return path , is_absolute , index
256
+ return path , index
257
257
258
258
def parse_query (self ) -> SearchQuery :
259
259
"""
260
260
Parses the file data search query.
261
261
"""
262
262
263
263
fields , columns = self ._parse_fields (self ._query [: self ._from_index ])
264
- path , is_absolute , index = self ._parse_path ()
264
+ path , index = self ._parse_path ()
265
265
266
266
# Extracts the function for filtering file records.
267
267
condition : Callable [[File | DataLine | Directory ], bool ] = (
@@ -317,7 +317,7 @@ def _parse_search_query(self) -> SearchQuery:
317
317
"""
318
318
319
319
fields , columns = self ._parse_fields (self ._query [: self ._from_index ])
320
- path , is_absolute , index = self ._parse_directory ()
320
+ path , index = self ._parse_directory ()
321
321
322
322
# Extracts the function for filtering file records.
323
323
condition : Callable [[File | DataLine | Directory ], bool ] = (
0 commit comments