Skip to main content

Module export

Module export 

Source
Expand description

Export to Computer: copying originals out of the library into a folder the user picked.

A Plan is worked out first (where each original goes, which directories to make), so the app can warn about files it would replace before anything is written, and run the copy on another thread. Names follow Eagle’s export: an item keeps <name>.<ext>; names that clash within one directory (ignoring case, as the Mac’s file system does) are numbered <name>-1.<ext>, <name>-2.<ext>, with the number padded to the width of the largest one.

Structs§

Convert
How to convert each image.
Plan
Everything an export will write.
Step
One original to copy.

Enums§

Collision
What to do when a file of the same name is already in the destination.
Format
An image format to export to.

Constants§

CSV_HEADER
The CSV columns, in Eagle’s order: id, name, extension, width, height, duration, source URL, notes, comments, tags, folders, size, rating, import time, modification time and the original’s path. The header text is falcon’s own.

Functions§

convert_bytes
Decodes an original (SVG rendered at its natural size), scales it down to longest if needed, and encodes it as convert asks.
convertible
Whether an item’s original can be converted: raster images falcon decodes, and SVG.
copy_file
Copies one original, keeping its modification time, as Eagle does. The copy is written beside its destination and renamed into place, so a failed copy never leaves half a file under the real name.
csv
The CSV text for ids (unknown ids skipped): a header and one row per item, lines joined with \n, preceded by a UTF-8 byte order mark so spreadsheet apps read it as UTF-8, as Eagle writes it.
csv_field
One CSV field: quoted, with quotes doubled, when it holds a comma, a quote or a line break; as it is otherwise.
csv_row
The CSV row for one item.
data_url
Copy Base64: a data: URL of the item’s original when it is a JPEG, PNG, WebP or GIF, else of its thumbnail (whose real format is sniffed: Eagle’s thumbnails are WebP inside a .png name). None when there is neither.
file_name
An item’s file name, <name>.<ext>, with any / (which no file name can hold) turned into a space.
folder_dir_name
The directory name for a folder, cleaned up as Eagle does on the Mac: tabs and runs of spaces become one space, : / and \\ become spaces, the ends are trimmed and a trailing dot is dropped. A name left empty becomes “Untitled”.
folder_paths_text
Lines for Copy Folder Path: each item’s <id>.info folder with a trailing slash, as Eagle copies them.
name_files
Chooses the names for files copied into one directory that already holds existing (lower-cased). Names are compared ignoring case. A name used once, and free, is kept. Otherwise every file of that name is numbered, as Eagle does: a.png twice becomes a-1.png and a-2.png; with KeepBoth, an a.png already there counts as the first, so a new one becomes a-2.png. A numbered name that is taken is skipped.
paths_text
Lines for Copy File Path: each item’s original, one per line, as Eagle copies them.
plan_converted
Plans exporting ids converted to format into dest: each file is named <name>.<format ext>, clashes handled as in plan_items. Items that can’t be converted are left out; see convertible.
plan_folder
Plans exporting the folder id as a directory tree under dest: a directory per folder and subfolder, each holding the originals of the live items filed directly in it (an item in two folders is copied into both). Items in any folder of hidden (locked ones) are left out, as are hidden subfolders. Sibling folders whose names clean up to the same directory share it. None if there is no such folder.
plan_items
Plans copying the originals of ids (in order, each once) straight into dest. Unknown ids are skipped.
plan_smart
Plans exporting the smart folder id as one flat directory under dest holding the originals of its items (Eagle exports a smart folder without its subfolders). Items in hidden folders are left out. None if there is no such smart folder.
run
Runs plan, calling on_step after each copy with whether it worked, and returns the paths written. A step that fails is skipped; the rest still run. Once cancel is set the run stops before the next file; the files already written stay (each is written whole or not at all).
run_converted
Runs a plan_converted plan: each step’s original is converted and written beside its destination, then renamed into place. cancel stops it between files, as in run.
thumbnail_image
Copy Thumbnail: the item’s thumbnail decoded, or, for an item without one, its original if that is an image.
write_csv
Writes csv to dest (through a temporary file) and returns the number of rows.