Skip to content

Commit f9355c7

Browse files
Refactor query/parsers.py
Removed redundant references to the `is_absolute` variable in multiple methods throughout `query/parsers.py` as the mechanism for the same has been removed in the recent commits.
1 parent f154539 commit f9355c7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

fise/query/parsers.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from shared import DeleteQuery, SearchQuery, Directory, DataLine, Field, File, Size
1616

1717

18-
def _parse_path(subquery: list[str]) -> tuple[bool, Path, int]:
18+
def _parse_path(subquery: list[str]) -> tuple[Path, int]:
1919
"""
2020
Parses the file/directory path and its type from the specified sub-query.
2121
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]:
3131
if path_type == "absolute":
3232
path = path.resolve()
3333

34-
return path_type == "absolute", path, 1
34+
return path, 1
3535

3636
# 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
3838

3939

4040
def _get_from_keyword_index(subquery: list[str]) -> int:
@@ -135,16 +135,16 @@ def _parse_fields(
135135

136136
return fields, columns
137137

138-
def _parse_directory(self) -> tuple[Path, bool, int]:
138+
def _parse_directory(self) -> tuple[Path, int]:
139139
"""
140140
Parses the directory path and its metadata.
141141
"""
142-
is_absolute, path, index = _parse_path(self._query[self._from_index + 1 :])
142+
path, index = _parse_path(self._query[self._from_index + 1 :])
143143

144144
if not path.is_dir():
145145
raise QueryParseError("The specified path for lookup must be a directory.")
146146

147-
return path, is_absolute, index
147+
return path, index
148148

149149
def _parse_remove_query(self) -> DeleteQuery:
150150
"""
@@ -154,7 +154,7 @@ def _parse_remove_query(self) -> DeleteQuery:
154154
if self._from_index != 0:
155155
raise QueryParseError("Invalid query syntax.")
156156

157-
path, is_absolute, index = self._parse_directory()
157+
path, index = self._parse_directory()
158158

159159
# Extracts the function for filtering file records.
160160
condition: Callable[[File | DataLine | Directory], bool] = (
@@ -171,7 +171,7 @@ def _parse_search_query(self) -> SearchQuery:
171171
"""
172172

173173
fields, columns = self._parse_fields(self._query[: self._from_index])
174-
path, is_absolute, index = self._parse_directory()
174+
path, index = self._parse_directory()
175175

176176
# Extracts the function for filtering file records.
177177
condition: Callable[[File | DataLine | Directory], bool] = (
@@ -241,27 +241,27 @@ def _parse_fields(self, attrs: list[str] | str) -> tuple[list[Field], list[str]]
241241

242242
return fields, columns
243243

244-
def _parse_path(self) -> tuple[Path, bool, int]:
244+
def _parse_path(self) -> tuple[Path, int]:
245245
"""
246246
Parses the file/directory path and its metadata.
247247
"""
248248

249-
is_absolute, path, index = _parse_path(self._query[self._from_index + 1 :])
249+
path, index = _parse_path(self._query[self._from_index + 1 :])
250250

251251
if not (path.is_dir() or path.is_file()):
252252
raise QueryParseError(
253253
"The specified path for lookup must be a file or directory."
254254
)
255255

256-
return path, is_absolute, index
256+
return path, index
257257

258258
def parse_query(self) -> SearchQuery:
259259
"""
260260
Parses the file data search query.
261261
"""
262262

263263
fields, columns = self._parse_fields(self._query[: self._from_index])
264-
path, is_absolute, index = self._parse_path()
264+
path, index = self._parse_path()
265265

266266
# Extracts the function for filtering file records.
267267
condition: Callable[[File | DataLine | Directory], bool] = (
@@ -317,7 +317,7 @@ def _parse_search_query(self) -> SearchQuery:
317317
"""
318318

319319
fields, columns = self._parse_fields(self._query[: self._from_index])
320-
path, is_absolute, index = self._parse_directory()
320+
path, index = self._parse_directory()
321321

322322
# Extracts the function for filtering file records.
323323
condition: Callable[[File | DataLine | Directory], bool] = (

0 commit comments

Comments
 (0)