Skip to content

Commit

Permalink
Merge branch 'v0.1.0' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul4732saini committed Jul 13, 2024
2 parents 22373f4 + 6ead23f commit 8cf5b80
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions fise/query/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def _get_field(field: Field | Size, file: File) -> Any:

if isinstance(field, Size):
# Extracts the size in bytes and converts into the parsed size unit.
return round(
getattr(file, "size") / constants.SIZE_CONVERSION_MAP.get(field.unit), 5
)
return round(file.size / constants.SIZE_CONVERSION_MAP.get(field.unit), 5)

return getattr(file, field.field)

Expand Down Expand Up @@ -87,10 +85,6 @@ def get_dataframe(
columns=columns,
)

# Renames the column `size` -> `size[<size_unit>]` to also include
# the storage unit if not specified explicitly in the field name.
records.rename(columns={"size": "size[B]"}, inplace=True)

return records

def remove_files(self, condition: Callable[[File], bool], skip_err: bool) -> None:
Expand Down Expand Up @@ -120,22 +114,17 @@ def remove_files(self, condition: Callable[[File], bool], skip_err: bool) -> Non
skipped += 1
continue

raise OperationError(
f"Permission Error: Cannot delete '{file.absolute()}'"
)
raise OperationError(f"Permission Error: Cannot delete '{file}'")

else:
ctr += 1

# Extracts the absolute path to the directory and stores it locally.
directory: Path = self._directory.absolute()

Message(f"Successfully removed {ctr} files from '{directory}'.")
Message(f"Successfully removed {ctr} files from '{self._directory}'.")

# Prints the skipped files message only is `skipped` is not 0.
if skipped:
Alert(
f"Skipped {skipped} files from '{directory}' due to permission errors."
f"Skipped {skipped} files from '{self._directory}' due to permission errors."
)


Expand Down Expand Up @@ -329,20 +318,15 @@ def remove_directories(
skipped += 1
continue

raise OperationError(
f"Permission Error: Cannot delete '{subdir.absolute()}'"
)
raise OperationError(f"Permission Error: Cannot delete '{subdir}'")

else:
ctr += 1

# Extracts the absolute path to the directory and stores it locally.
directory: Path = self._directory.absolute()

Message(f"Successfully removed {ctr} directories from '{directory}'.")
Message(f"Successfully removed {ctr} directories from '{self._directory}'.")

# Prints the skipped files message only is `skipped` is not 0.
if skipped:
Alert(
f"Skipped {skipped} directories from '{directory}' due to permission errors."
f"Skipped {skipped} directories from '{self._directory}' due to permission errors."
)

0 comments on commit 8cf5b80

Please sign in to comment.