This file is indexed.

/usr/share/inkscape/extensions/sozi_upgrade.py is in sozi 12.05-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import sys
import inkex

# Replaced automatically by the version number during the build process
SOZI_VERSION = "12.06-12110506"


def upgrade_or_install(context):
    upgrade_or_install_element(context, "script")
    upgrade_or_install_element(context, "style")
    upgrade_document(context)
    

def upgrade_or_install_element(context, tag):
    """
    Upgrade or install a script or a style sheet into the document.
        - tag: "script" or "style"
    Depending on the argument, the content of file "sozi.js" or "sozi.css"
    will be copied to the script or style element.
    """
    # Check version and remove older versions
    latest_version_found = False
    for elt in context.document.xpath("//svg:" + tag + "[@id='sozi-" + tag + "']", namespaces=inkex.NSS):
        version_attr = inkex.addNS("version", "sozi")
        if version_attr in elt.attrib:
            version = elt.attrib[version_attr]
        else:
            version = "0"
        if version == SOZI_VERSION:
            latest_version_found = True
        elif version < SOZI_VERSION:
            elt.getparent().remove(elt)
        else:
            sys.stderr.write("Document has been created using a higher version of Sozi. Please upgrade the Inkscape plugin.\n")
            exit()
  
    # Create new element if needed
    if not latest_version_found:
        ext = "js" if tag == "script" else "css"
        elt = inkex.etree.Element(inkex.addNS(tag, "svg"))
        elt.text = open(os.path.join(os.path.dirname(__file__), "sozi." + ext)).read()
        elt.set("id","sozi-" + tag)
        elt.set(inkex.addNS("version", "sozi"), SOZI_VERSION)
        context.document.getroot().append(elt)


def upgrade_document(context):
    """
    Upgrade the Sozi-specific elements of the document to follow the evolutions of the document format.
    """
    # Upgrade from 10.x

    SOZI_ATTR = ["title", "sequence", "hide", "clip", "timeout-enable", "timeout-ms",
                 "transition-duration-ms", "transition-zoom-percent", "transition-profile"]
                 
    # FIXME allow multiple classes in element
    for elt in context.document.xpath("//svg:*[@class='sozi-frame']", namespaces=inkex.NSS):
        del elt.attrib["class"]

        # Create a new frame element
        f = inkex.etree.Element(inkex.addNS("frame", "sozi"))
        f.set(inkex.addNS("refid", "sozi"), elt.attrib["id"]) # TODO check namespace for id?
        context.document.getroot().append(f)

        # Move all Sozi-specific attributes from the original element to the frame element
        for attr in SOZI_ATTR:
            ns_attr = inkex.addNS(attr, "sozi")
            if ns_attr in elt.attrib:
                f.set(ns_attr, elt.attrib[ns_attr])
                del elt.attrib[ns_attr]
  
    # Upgrade from 11.10
    sequence_attr = inkex.addNS("sequence", "sozi")
    for i, elt in enumerate(context.document.xpath("//sozi:frame", namespaces=inkex.NSS)):
        if sequence_attr not in elt.attrib:
            elt.set(sequence_attr, unicode(i + 1))
        if "id" not in elt.attrib:
            elt.set("id", context.uniqueId("frame" + elt.attrib[sequence_attr]))