SILICON
Loading...
Searching...
No Matches
normalize Namespace Reference

Classes

class  SVGTreeBuilder

Functions

ET.Element parse_svg (bytes data)
dict load_palette (Path path=PALETTE_PATH)
bool sanitize_svg (ET.Element root)
bytes serialize (ET.Element root)
dict import_svg (bytes data, Path config=DEFAULT_CONFIG)
None resolve_palette (ET.Element root, dict colors)
bytes optimize (bytes source, Path config)
ET.Element optimize_svg (ET.Element root, Path config)
bytes export_svg (bytes source, dict palette)
None process_file (Path source, Path destination, Path config)
str export_name (str source, set used, bool overwrite=False, reserved=None)
bytes export_archive (list files, dict palette, bool overwrite=False)
 make_server (list[dict] sources, dict palette, Path config, int port=0)
int main ()

Variables

str SVG_NS = "http://www.w3.org/2000/svg"
 SCRIPT_DIR = Path(__file__).resolve().parent
str PALETTE_PATH = SCRIPT_DIR.parents[1] / "resources/app/palette.json"
str DEFAULT_CONFIG = SCRIPT_DIR / "svgo.config.mjs"
int MAX_SVG_BYTES = 10 * 1024 * 1024
int MAX_REQUEST_BYTES = MAX_SVG_BYTES * 6 + 1024

Detailed Description

Select SVG elements and assign Silicon palette colors in a local browser.

Function Documentation

◆ export_archive()

bytes export_archive ( list files,
dict palette,
bool overwrite = False )

Definition at line 194 of file normalize.py.

◆ export_name()

str export_name ( str source,
set used,
bool overwrite = False,
reserved = None )
Match browser naming, keeping archive paths and duplicate names out.

Definition at line 178 of file normalize.py.

◆ export_svg()

bytes export_svg ( bytes source,
dict palette )
Serialize edits to an already optimized document without running SVGO.

Definition at line 164 of file normalize.py.

◆ import_svg()

dict import_svg ( bytes data,
Path config = DEFAULT_CONFIG )

Definition at line 90 of file normalize.py.

◆ load_palette()

dict load_palette ( Path path = PALETTE_PATH)

Definition at line 47 of file normalize.py.

◆ main()

int main ( )

Definition at line 300 of file normalize.py.

◆ make_server()

make_server ( list[dict] sources,
dict palette,
Path config,
int port = 0 )

Definition at line 217 of file normalize.py.

◆ optimize()

bytes optimize ( bytes source,
Path config )

Definition at line 115 of file normalize.py.

◆ optimize_svg()

ET.Element optimize_svg ( ET.Element root,
Path config )

Definition at line 138 of file normalize.py.

◆ parse_svg()

ET.Element parse_svg ( bytes data)

Definition at line 36 of file normalize.py.

◆ process_file()

None process_file ( Path source,
Path destination,
Path config )
Noninteractive helper; writes only after successful optimization.

Definition at line 172 of file normalize.py.

◆ resolve_palette()

None resolve_palette ( ET.Element root,
dict colors )
Resolve annotations with the same inline-style precedence as Silicon.

Definition at line 98 of file normalize.py.

◆ sanitize_svg()

bool sanitize_svg ( ET.Element root)
Keep static SVG; the preview additionally blocks network loads with CSP.

Definition at line 64 of file normalize.py.

◆ serialize()

bytes serialize ( ET.Element root)

Definition at line 86 of file normalize.py.

Variable Documentation

◆ DEFAULT_CONFIG

str DEFAULT_CONFIG = SCRIPT_DIR / "svgo.config.mjs"

Definition at line 23 of file normalize.py.

◆ MAX_REQUEST_BYTES

int MAX_REQUEST_BYTES = MAX_SVG_BYTES * 6 + 1024

Definition at line 25 of file normalize.py.

◆ MAX_SVG_BYTES

int MAX_SVG_BYTES = 10 * 1024 * 1024

Definition at line 24 of file normalize.py.

◆ PALETTE_PATH

str PALETTE_PATH = SCRIPT_DIR.parents[1] / "resources/app/palette.json"

Definition at line 22 of file normalize.py.

◆ SCRIPT_DIR

SCRIPT_DIR = Path(__file__).resolve().parent

Definition at line 21 of file normalize.py.

◆ SVG_NS

str SVG_NS = "http://www.w3.org/2000/svg"

Definition at line 20 of file normalize.py.