2021-03-12 04:17:19 +00:00
|
|
|
# Authors: see git history
|
|
|
|
#
|
|
|
|
# Copyright (c) 2010 Authors
|
|
|
|
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
|
|
|
|
|
2018-08-20 02:14:10 +00:00
|
|
|
import pyembroidery
|
|
|
|
|
2021-03-04 17:40:53 +00:00
|
|
|
from ..commands import (COMMANDS, GLOBAL_COMMANDS, LAYER_COMMANDS,
|
|
|
|
OBJECT_COMMANDS)
|
|
|
|
from ..extensions import Input, Output, extensions
|
2023-07-12 16:28:07 +00:00
|
|
|
from ..lettering.categories import FONT_CATEGORIES
|
2020-04-25 12:24:01 +00:00
|
|
|
from ..threads import ThreadCatalog
|
2021-03-04 17:40:53 +00:00
|
|
|
from .outputs import pyembroidery_output_formats
|
|
|
|
from .utils import build_environment, write_inx_file
|
2018-08-23 02:54:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def layer_commands():
|
|
|
|
# We purposefully avoid using commands.get_command_description() here. We
|
|
|
|
# want to call _() on the description inside the actual template so that
|
|
|
|
# we use the translation language selected in build_environment().
|
|
|
|
return [(command, COMMANDS[command]) for command in LAYER_COMMANDS]
|
|
|
|
|
|
|
|
|
2018-08-24 20:29:13 +00:00
|
|
|
def global_commands():
|
|
|
|
return [(command, COMMANDS[command]) for command in GLOBAL_COMMANDS]
|
|
|
|
|
|
|
|
|
2018-08-23 02:54:15 +00:00
|
|
|
def object_commands():
|
|
|
|
return [(command, COMMANDS[command]) for command in OBJECT_COMMANDS]
|
2018-08-20 02:14:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
def pyembroidery_debug_formats():
|
|
|
|
for format in pyembroidery.supported_formats():
|
2022-06-24 15:11:52 +00:00
|
|
|
if 'writer' in format and format['category'] not in ['embroidery', 'image', 'color', 'stitch']:
|
2018-08-20 02:14:10 +00:00
|
|
|
yield format['extension'], format['description']
|
|
|
|
|
|
|
|
|
2020-04-25 12:24:01 +00:00
|
|
|
def threadcatalog():
|
|
|
|
threadcatalog = ThreadCatalog().palette_names()
|
|
|
|
return threadcatalog
|
|
|
|
|
|
|
|
|
2024-02-07 20:03:57 +00:00
|
|
|
def generate_extension_inx_files(alter_data):
|
2018-08-20 02:14:10 +00:00
|
|
|
env = build_environment()
|
|
|
|
|
|
|
|
for extension in extensions:
|
2018-08-20 19:49:19 +00:00
|
|
|
if extension is Input or extension is Output:
|
|
|
|
continue
|
|
|
|
|
2018-08-20 02:14:10 +00:00
|
|
|
name = extension.name()
|
2024-02-07 20:03:57 +00:00
|
|
|
template = env.get_template(f'{name}.xml')
|
|
|
|
write_inx_file(name, template.render(alter_data,
|
|
|
|
formats=pyembroidery_output_formats(),
|
2018-08-23 02:54:15 +00:00
|
|
|
debug_formats=pyembroidery_debug_formats(),
|
2020-04-25 12:24:01 +00:00
|
|
|
threadcatalog=threadcatalog(),
|
2023-07-12 16:28:07 +00:00
|
|
|
font_categories=FONT_CATEGORIES,
|
2018-08-23 02:54:15 +00:00
|
|
|
layer_commands=layer_commands(),
|
2018-08-24 20:29:13 +00:00
|
|
|
object_commands=object_commands(),
|
|
|
|
global_commands=global_commands()))
|