Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion beangulp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ def _extract(
log(" ...", nl=False)

# Extract entries.
entries = extract.extract_from_file(importer, filename, existing_entries)
entries = extract.extract_from_file(
importer,
filename,
existing_entries,
reverse=reverse,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think passing reverse as a keyword argument is necessary here. Using a regular argument should make the function call fit on a single line and avoid the ugly black indentation style.

account = importer.account(filename)

extracted.append((filename, entries, account, importer))
Expand Down
8 changes: 6 additions & 2 deletions beangulp/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@


def extract_from_file(
importer: "Importer", filename: str, existing_entries: "data.Directives"
importer: "Importer",
filename: str,
existing_entries: "data.Directives",
reverse: bool = False,
) -> data.Entries:
"""Import entries from a document.

Args:
importer: The importer instance to handle the document.
filename: Filesystem path to the document.
existing_entries: Existing entries.
reverse: Sort extracted entries in descending order.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reverse: Sort extracted entries in descending order.
reverse: Sort extracted entries in reverse order.

Whether the order is ascending or descending and which filed is used for sorting depends entirely on the importer implementation.


Returns:
The list of imported entries.
Expand All @@ -52,7 +56,7 @@ def extract_from_file(
return []

# Sort the newly imported entries.
importer.sort(entries)
importer.sort(entries, reverse=reverse)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
importer.sort(entries, reverse=reverse)
importer.sort(entries, reverse)


# Ensure that the entries are typed correctly.
for entry in entries:
Expand Down