zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils module¶
SVG arrow detection and elongation utilities.
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils._load_svg_tree(svg_input)[source]¶
Load SVG XML tree from either file path or cache hash.
- Parameters:
svg_input – Either a file path or cache hash (starting with
'svg_')- Returns:
ElementTree object
- Raises:
FileNotFoundError – If file doesn’t exist
ValueError – If cache hash not found
ET.ParseError – If XML parsing fails
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils.is_straight_arrow_svg(svg_input)[source]¶
Check if SVG is a straight arrow (up, down, left, right).
- Parameters:
svg_input – Either a file path or cache hash (starting with
'svg_')- Returns:
True if SVG matches straight arrow pattern, False otherwise
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils.get_arrow_direction(svg_path)[source]¶
Determine arrow direction: ‘right’, ‘left’, ‘up’, or ‘down’.
- Returns:
Direction string or None if not a straight arrow
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils.is_diagonal_arrow_svg(svg_path)[source]¶
Check if SVG is a 45° diagonal arrow (upright, upleft, downright, downleft).
- Returns:
True if SVG matches 45° diagonal arrow pattern, False otherwise
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils.get_diagonal_arrow_direction(svg_path)[source]¶
Determine diagonal arrow direction: ‘upright’, ‘upleft’, ‘downright’, or ‘downleft’.
- Returns:
Direction string or None if not a 45° diagonal arrow
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils.is_arrow_svg(svg_path)[source]¶
Check if SVG is any arrow (straight or 45° diagonal).
- Returns:
True if SVG matches any arrow pattern, False otherwise
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils._create_backup(svg_path)[source]¶
Create a backup copy of the SVG file.
- Returns:
Path to backup file or None on failure
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils._restore_from_backup(svg_path, backup_path)[source]¶
Restore SVG file from backup.
- Returns:
True if successful, False otherwise
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils._cleanup_backup(backup_path)[source]¶
Remove backup file if it exists.
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils.elongate_straight_arrow(svg_path, scale_factor)[source]¶
Elongate straight arrow SVG.
Stores modified SVG in cache and returns cache hash.
- Parameters:
svg_path – Path to SVG file (will be read but not modified)
scale_factor – Multiplier for arrow length (minimum 0.2)
- Returns:
svg_{8_char_hex})
- Return type:
Cache hash of modified SVG (format
- Raises:
ValueError – If scale_factor < 0.2
Exception – If SVG parsing or modification fails
- zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgarrowutils.elongate_diagonal_arrow(svg_path, scale_factor)[source]¶
Elongate 45° diagonal arrow SVG.
Stores modified SVG in cache and returns cache hash.
- Parameters:
svg_path – Path to SVG file (will be read but not modified)
scale_factor – Multiplier for arrow length (minimum 0.2)
- Returns:
svg_{8_char_hex})
- Return type:
Cache hash of modified SVG (format
- Raises:
ValueError – If scale_factor < 0.2
Exception – If SVG parsing or modification fails
See Also¶
zooui/objects/mediaobjects/svgmediaobject - SVGMediaObject class
zooui/objects/mediaobjects/mediaobjectsutils/svg/svgcache/svgcache - SVG caching system