Source API¶
Signatures and documentation are read from the current Python source during the build.
vexy_lines.parser
¶
Parse Vexy Lines .lines XML files into typed dataclasses.
A .lines file contains the full project: layer tree (groups, layers,
fills), document properties, and two optional embedded images.
Embedded image encodings:
- Source image: base64( 4-byte BE uint32 uncompressed-size + zlib(JPEG) )
- Preview image: base64( raw PNG )
The public API is three functions: :func:parse, :func:extract_source_image,
and :func:extract_preview_image.
extract_preview_image(path, output)
¶
Parse a .lines file and save its embedded preview image as PNG.
Args:
path: Path to the .lines file.
output: Destination path for the PNG file.
Returns:
The resolved output :class:~pathlib.Path.
Raises: FileNotFoundError: If path does not exist. ValueError: If no preview image is embedded in the file.
Source code in src/vexy_lines/parser.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | |
extract_source_image(path, output)
¶
Parse a .lines file and save its embedded source image as JPEG.
Args:
path: Path to the .lines file.
output: Destination path for the JPEG file.
Returns:
The resolved output :class:~pathlib.Path.
Raises: FileNotFoundError: If path does not exist. ValueError: If no source image is embedded in the file.
Source code in src/vexy_lines/parser.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | |
extract_source_images(path, output_dir)
¶
Extract all document and group source images from a .lines file.
Args:
path: Path to the .lines file.
output_dir: Directory where JPEG files will be written.
Returns: Output paths in extraction order. The document source is first when present, followed by group sources in XML traversal order.
Raises: FileNotFoundError: If path does not exist. ValueError: If no source images are embedded in the file.
Source code in src/vexy_lines/parser.py
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
parse(path)
¶
Parse a .lines file and return a :class:~vexy_lines.types.LinesDocument.
This is the main entry point for file-based parsing. The operation is
entirely offline: no network access, no Vexy Lines app, and no
platform-specific libraries are required. Corrupt or missing embedded
images (<SourcePict>, <PreviewDoc>) are handled gracefully — a
warning is logged and the corresponding field is set to None rather
than raising an exception.
Args:
path: Path to the .lines file (str or Path).
Returns:
Fully populated :class:~vexy_lines.types.LinesDocument.
Raises: FileNotFoundError: If path does not exist. ET.ParseError: If the file is not valid XML (e.g. truncated or corrupt at the XML level).
Source code in src/vexy_lines/parser.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | |
parse_string(xml)
¶
Parse a .lines XML string and return a :class:~vexy_lines.types.LinesDocument.
Use this when you already have the XML content in memory (e.g. from a network response or database) instead of a file path.
Args:
xml: Raw XML string from a .lines file.
Returns:
Fully populated :class:~vexy_lines.types.LinesDocument.
Raises: ET.ParseError: If xml is not valid XML.
Source code in src/vexy_lines/parser.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |