Collection of mostly command line tools / PHP scripts. Somewhat out of date.

⌈⌋ ⎇ branch:  scripts + snippets


Check-in [4c1a26da5e]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fix generator for inx
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4c1a26da5edd7d4750e73188e63823e032b98e99
User & Date: mario 2025-06-16 00:27:51
Context
2025-06-16
00:28
updated description without utf-8 symbols check-in: fd98f78747 user: mario tags: trunk
00:27
fix generator for inx check-in: 4c1a26da5e user: mario tags: trunk
00:20
fix unicode and deprecated flags check-in: 8f32b150fe user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to inkscape/pmd2inks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3
# encoding: utf-8
# api: python
##type: cli
# category: convert
# title: plugin meta to .inx
# description: Convert plugin description to Inkscape .inx
# license: PD
# version: 0.7
# state: beta
# depends: pluginconf (>= 0.7.6)
# config: -
# pylint: disable=missing-docstring, invalid-name, no-else-return
# doc: https://gitlab.com/inkscape/extensions/-/blob/master/inkscape.extension.rng
#
# Quickly converts a PMD comment block to .inx descriptor.
# Mapping some types and modes.
#








|

|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3
# encoding: utf-8
# api: python
##type: cli
# category: convert
# title: plugin meta to .inx
# description: Convert plugin description to Inkscape .inx
# license: PD
# version: 0.8
# state: beta
# depends: pluginconf (== 0.7.6)
# config: -
# pylint: disable=missing-docstring, invalid-name, no-else-return
# doc: https://gitlab.com/inkscape/extensions/-/blob/master/inkscape.extension.rng
#
# Quickly converts a PMD comment block to .inx descriptor.
# Mapping some types and modes.
#
︙︙
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pluginconf


meta = {}
xml_template = """<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
    <name>{name}</name>
    <description>{desc}</description>
    <!--<schema:softwareVersion xmlns:schema="https://schema.org/">{version}</schema:softwareVersion>-->
    <category>{submenu}</category>
    <id>{id}</id>
    <dependency type="executable" location="inx">{fn}</dependency>
    <label appearance="header">{header}</label>
    {params}
    <effect needs-live-preview="false">
        <object-type>all</object-type>
        <effects-menu>







|

|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pluginconf


meta = {}
xml_template = """<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
    <name>{name}</name>
    <!--description>{desc}</description-->
    <!--<schema:softwareVersion xmlns:schema="https://schema.org/">{version}</schema:softwareVersion>-->
    <!--category>{submenu}</category-->
    <id>{id}</id>
    <dependency type="executable" location="inx">{fn}</dependency>
    <label appearance="header">{header}</label>
    {params}
    <effect needs-live-preview="false">
        <object-type>all</object-type>
        <effects-menu>
︙︙
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
        "text": "string",
        "tab": "notebook",
        "group": "optiongroup",
        "label": "label",
        "notebook": "notebook",
    },
    "mode": {
        "bool": "checkbox",
        "color": "color",
        "range": "slider",
        "float": "float",
    },
    "appearance": {
        "text": "multiline",
        "range": "full",
        "enum": "combo",
        "select": "combo",
    },







|
|

|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
        "text": "string",
        "tab": "notebook",
        "group": "optiongroup",
        "label": "label",
        "notebook": "notebook",
    },
    "mode": {
        #"bool": "checkbox",
        #"color": "color",
        "range": "slider",
        #"float": "float",
    },
    "appearance": {
        "text": "multiline",
        "range": "full",
        "enum": "combo",
        "select": "combo",
    },
︙︙
181
182
183
184
185
186
187
188




189
190
191
192
193
194
195
            </param>
        """
    elif _type == "notebook":
        notebook = new_notebook(_name, o)
        yield f"""
            <param name="{_name}" type="{_type}" {_add} gui-text="{_desc}">
        """
    elif _type in ("int", "float"):




        yield f"""
            <param name="{_name}" type="{_type}" min="{o.get("min",0)}" max="{o.get("max",100)}" precision="{o.get("precision",1)}" {_add} gui-text="{_desc}">{_val}</param>
        """
    else:
        yield f"""
            <param name="{_name}" type="{_type}" {_add} gui-text="{_desc}">{_val}</param>
        """







|
>
>
>
>







181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
            </param>
        """
    elif _type == "notebook":
        notebook = new_notebook(_name, o)
        yield f"""
            <param name="{_name}" type="{_type}" {_add} gui-text="{_desc}">
        """
    elif _type in ("int"):
        yield f"""
            <param name="{_name}" type="{_type}" min="{o.get("min",0)}" max="{o.get("max",100)}" {_add} gui-text="{_desc}">{_val}</param>
        """
    elif _type in ("float"):
        yield f"""
            <param name="{_name}" type="{_type}" min="{o.get("min",0)}" max="{o.get("max",100)}" precision="{o.get("precision",1)}" {_add} gui-text="{_desc}">{_val}</param>
        """
    else:
        yield f"""
            <param name="{_name}" type="{_type}" {_add} gui-text="{_desc}">{_val}</param>
        """
︙︙
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

def generate_inx(m):
    """ roughly convert builtin plugin description to .inx """
    params = []
    for o in m["config"]:
        for line in param(o):
            params.append(line)
    if notebook.curr:
        params = params + list(notebook.end("", True))
    args = list(
        filter(
            None,
            [add_arg(o) for o in m["config"] if o["type"] != "label"]
        )
    )







|







227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

def generate_inx(m):
    """ roughly convert builtin plugin description to .inx """
    params = []
    for o in m["config"]:
        for line in param(o):
            params.append(line)
    if notebook and notebook.curr:
        params = params + list(notebook.end("", True))
    args = list(
        filter(
            None,
            [add_arg(o) for o in m["config"] if o["type"] != "label"]
        )
    )
︙︙
246
247
248
249
250
251
252

253

254
255
256
257
258
259
260
        export=inx_export(m),
        fn=re.sub(".+/", "", m["fn"]),
        args="\n".join(args)
    )


if len(sys.argv) == 2:

    meta = pluginconf.plugin_meta(fn=sys.argv[1], max_length=8192)

    print(
        generate_inx(
            meta
        )
    )
else:
    print("Syntax: pmd2inx script.py")







>
|
>







250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
        export=inx_export(m),
        fn=re.sub(".+/", "", m["fn"]),
        args="\n".join(args)
    )


if len(sys.argv) == 2:
    #print(sys.argv)
    meta = pluginconf.plugin_meta(fn=sys.argv[1], max_length=20486)
    #print(meta)
    print(
        generate_inx(
            meta
        )
    )
else:
    print("Syntax: pmd2inx script.py")