summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/extensions/apply_threadlist.py4
-rw-r--r--lib/extensions/batch_lettering.py4
-rw-r--r--lib/extensions/zip.py4
-rwxr-xr-xlib/inx/extensions.py12
-rwxr-xr-xlib/inx/inputs.py8
-rw-r--r--lib/inx/outputs.py8
-rw-r--r--lib/output.py32
-rw-r--r--lib/stitch_plan/generate_stitch_plan.py12
-rw-r--r--lib/stitch_plan/read_file.py8
-rw-r--r--lib/threads/color.py4
10 files changed, 48 insertions, 48 deletions
diff --git a/lib/extensions/apply_threadlist.py b/lib/extensions/apply_threadlist.py
index 5b831ff5..d01bd8e2 100644
--- a/lib/extensions/apply_threadlist.py
+++ b/lib/extensions/apply_threadlist.py
@@ -10,7 +10,7 @@ from typing import List, Optional
import inkex
-import pyembroidery
+import pystitch
from ..i18n import _
from ..svg.tags import INKSTITCH_ATTRIBS
@@ -105,7 +105,7 @@ class ApplyThreadlist(InkstitchExtension):
def parse_color_format(self, path: str) -> List[List[Optional[str]]]:
colors = []
- threads = pyembroidery.read(path).threadlist
+ threads = pystitch.read(path).threadlist
for color in threads:
if color.description is not None and color.description.startswith("Cut"):
# there is a maximum of 4 needles, we can simply take the last element from the description string
diff --git a/lib/extensions/batch_lettering.py b/lib/extensions/batch_lettering.py
index 70beaaf7..c0581e76 100644
--- a/lib/extensions/batch_lettering.py
+++ b/lib/extensions/batch_lettering.py
@@ -14,7 +14,7 @@ from zipfile import ZipFile
from inkex import Boolean, Group, errormsg
from lxml import etree
-import pyembroidery
+import pystitch
from ..extensions.lettering_along_path import TextAlongPath
from ..i18n import _
@@ -69,7 +69,7 @@ class BatchLettering(InkstitchExtension):
if not self.options.formats:
errormsg(_("Please specify at least one output file format"))
return
- available_formats = [file_format['extension'] for file_format in pyembroidery.supported_formats()] + ['svg']
+ available_formats = [file_format['extension'] for file_format in pystitch.supported_formats()] + ['svg']
file_formats = self.options.formats.split(',')
file_formats = [file_format.strip().lower() for file_format in file_formats if file_format.strip().lower() in available_formats]
if not file_formats:
diff --git a/lib/extensions/zip.py b/lib/extensions/zip.py
index 13cae7bd..2cee5f04 100644
--- a/lib/extensions/zip.py
+++ b/lib/extensions/zip.py
@@ -13,7 +13,7 @@ from inkex import Boolean, errormsg
from inkex.units import convert_unit
from lxml import etree
-import pyembroidery
+import pystitch
from ..i18n import _
from ..output import write_embroidery_file
@@ -35,7 +35,7 @@ class Zip(InkstitchExtension):
# it's kind of obnoxious that I have to do this...
self.formats = []
- for format in pyembroidery.supported_formats():
+ for format in pystitch.supported_formats():
if 'writer' in format and format['category'] in ['embroidery', 'color', 'image', 'stitch', 'quilting']:
extension = format['extension']
self.arg_parser.add_argument('--format-%s' % extension, type=Boolean, default=False, dest=extension)
diff --git a/lib/inx/extensions.py b/lib/inx/extensions.py
index d69f0d75..cab1ece6 100755
--- a/lib/inx/extensions.py
+++ b/lib/inx/extensions.py
@@ -5,14 +5,14 @@
import os
-import pyembroidery
+import pystitch
from ..commands import (COMMANDS, GLOBAL_COMMANDS, LAYER_COMMANDS,
OBJECT_COMMANDS)
from ..extensions import Input, Output, extensions
from ..lettering.categories import FONT_CATEGORIES
from ..threads import ThreadCatalog
-from .outputs import pyembroidery_output_formats
+from .outputs import pystitch_output_formats
from .utils import build_environment, write_inx_file
@@ -31,8 +31,8 @@ def object_commands():
return [(command, COMMANDS[command]) for command in OBJECT_COMMANDS]
-def pyembroidery_debug_formats():
- for format in pyembroidery.supported_formats():
+def pystitch_debug_formats():
+ for format in pystitch.supported_formats():
if 'writer' in format and format['category'] not in ['embroidery', 'image', 'color', 'stitch']:
yield format['extension'], format['description']
@@ -55,8 +55,8 @@ def generate_extension_inx_files(alter_data):
name = extension.name()
template = env.get_template(f'{name}.xml')
write_inx_file(name, template.render(alter_data,
- formats=pyembroidery_output_formats(),
- debug_formats=pyembroidery_debug_formats(),
+ formats=pystitch_output_formats(),
+ debug_formats=pystitch_debug_formats(),
threadcatalog=threadcatalog(),
font_categories=FONT_CATEGORIES,
layer_commands=layer_commands(),
diff --git a/lib/inx/inputs.py b/lib/inx/inputs.py
index cd8b57bd..667f71c9 100755
--- a/lib/inx/inputs.py
+++ b/lib/inx/inputs.py
@@ -3,13 +3,13 @@
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
-import pyembroidery
+import pystitch
from .utils import build_environment, write_inx_file
-def pyembroidery_input_formats():
- for format in pyembroidery.supported_formats():
+def pystitch_input_formats():
+ for format in pystitch.supported_formats():
if 'reader' in format and format['category'] in ['embroidery', 'color', 'stitch', 'quilting', 'debug']:
yield format['extension'], format['description']
@@ -18,6 +18,6 @@ def generate_input_inx_files(alter_data):
env = build_environment()
template = env.get_template('input.xml')
- for format, description in pyembroidery_input_formats():
+ for format, description in pystitch_input_formats():
name = f"input_{format.upper()}"
write_inx_file(name, template.render(alter_data, format=format, description=description))
diff --git a/lib/inx/outputs.py b/lib/inx/outputs.py
index 0cf9ac84..51907f79 100644
--- a/lib/inx/outputs.py
+++ b/lib/inx/outputs.py
@@ -3,13 +3,13 @@
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
-import pyembroidery
+import pystitch
from .utils import build_environment, write_inx_file
-def pyembroidery_output_formats():
- for format in pyembroidery.supported_formats():
+def pystitch_output_formats():
+ for format in pystitch.supported_formats():
if 'writer' in format:
description = format['description']
if format['category'] == "color":
@@ -30,6 +30,6 @@ def generate_output_inx_files(alter_data):
env = build_environment()
template = env.get_template('output.xml')
- for format, description, mimetype, category in pyembroidery_output_formats():
+ for format, description, mimetype, category in pystitch_output_formats():
name = f"output_{format.upper()}"
write_inx_file(name, template.render(alter_data, format=format, mimetype=mimetype, description=description))
diff --git a/lib/output.py b/lib/output.py
index 1b9c62a4..ff187165 100644
--- a/lib/output.py
+++ b/lib/output.py
@@ -8,9 +8,9 @@ import re
import sys
import inkex
-from pyembroidery.exceptions import TooManyColorChangesError
+from pystitch.exceptions import TooManyColorChangesError
-import pyembroidery
+import pystitch
from .commands import global_command
from .i18n import _
@@ -21,15 +21,15 @@ from .utils import Point
def get_command(stitch):
if stitch.jump:
- return pyembroidery.JUMP
+ return pystitch.JUMP
elif stitch.trim:
- return pyembroidery.TRIM
+ return pystitch.TRIM
elif stitch.color_change:
- return pyembroidery.COLOR_CHANGE
+ return pystitch.COLOR_CHANGE
elif stitch.stop:
- return pyembroidery.STOP
+ return pystitch.STOP
else:
- return pyembroidery.NEEDLE_AT
+ return pystitch.NEEDLE_AT
def get_origin(svg, bounding_box):
@@ -47,18 +47,18 @@ def get_origin(svg, bounding_box):
def jump_to_stop_point(pattern, svg):
stop_position = global_command(svg, "stop_position")
if stop_position:
- pattern.add_stitch_absolute(pyembroidery.JUMP, stop_position.point.x, stop_position.point.y)
+ pattern.add_stitch_absolute(pystitch.JUMP, stop_position.point.x, stop_position.point.y)
def write_embroidery_file(file_path, stitch_plan, svg, settings={}):
# convert from pixels to millimeters
- # also multiply by 10 to get tenths of a millimeter as required by pyembroidery
+ # also multiply by 10 to get tenths of a millimeter as required by pystitch
scale = 10 / PIXELS_PER_MM
origin = get_origin(svg, stitch_plan.bounding_box)
# origin = origin * scale
- pattern = pyembroidery.EmbPattern()
+ pattern = pystitch.EmbPattern()
# For later use when writing .dst header title field.
pattern.extras['name'] = os.path.splitext(svg.name)[0]
@@ -66,7 +66,7 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}):
stitch = Stitch(0, 0)
for color_block in stitch_plan:
- pattern.add_thread(color_block.color.pyembroidery_thread)
+ pattern.add_thread(color_block.color.pystitch_thread)
for stitch in color_block:
if stitch.stop:
@@ -74,21 +74,21 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}):
command = get_command(stitch)
pattern.add_stitch_absolute(command, stitch.x, stitch.y)
- pattern.add_stitch_absolute(pyembroidery.END, stitch.x, stitch.y)
+ pattern.add_stitch_absolute(pystitch.END, stitch.x, stitch.y)
settings.update({
# correct for the origin
"translate": -origin,
# convert from pixels to millimeters
- # also multiply by 10 to get tenths of a millimeter as required by pyembroidery
+ # also multiply by 10 to get tenths of a millimeter as required by pystitch
"scale": (scale, scale),
# This forces a jump at the start of the design and after each trim,
# even if we're close enough not to need one.
"full_jump": True,
- # defaults to False in pyembroidery (see https://github.com/EmbroidePy/pyembroidery/issues/188)
+ # defaults to False in pystitch (see https://github.com/EmbroidePy/pyembroidery/issues/188)
"trims": True,
})
@@ -96,7 +96,7 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}):
settings['encode'] = True
if file_path.endswith('.csv'):
- # Special treatment for CSV: instruct pyembroidery not to do any post-
+ # Special treatment for CSV: instruct pystitch not to do any post-
# processing. This will allow the user to match up stitch numbers seen
# in the simulator with commands in the CSV.
settings['max_stitch'] = float('inf')
@@ -104,7 +104,7 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}):
settings['explicit_trim'] = False
try:
- pyembroidery.write(pattern, file_path, settings)
+ pystitch.write(pattern, file_path, settings)
except IOError as e:
# L10N low-level file error. %(error)s is (hopefully?) translated by
# the user's system automatically.
diff --git a/lib/stitch_plan/generate_stitch_plan.py b/lib/stitch_plan/generate_stitch_plan.py
index cdd66d9e..c9faff4f 100644
--- a/lib/stitch_plan/generate_stitch_plan.py
+++ b/lib/stitch_plan/generate_stitch_plan.py
@@ -9,7 +9,7 @@ from html import escape
import inkex
-import pyembroidery
+import pystitch
from ..i18n import _
from ..svg import PIXELS_PER_MM, render_stitch_plan
@@ -20,23 +20,23 @@ from .stitch_plan import StitchPlan
def generate_stitch_plan(embroidery_file, import_commands="symbols"): # noqa: C901
validate_file_path(embroidery_file)
- pattern = pyembroidery.read(embroidery_file)
+ pattern = pystitch.read(embroidery_file)
stitch_plan = StitchPlan()
color_block = None
for raw_stitches, thread in pattern.get_as_colorblocks():
color_block = stitch_plan.new_color_block(thread)
for x, y, command in raw_stitches:
- if command == pyembroidery.STITCH:
+ if command == pystitch.STITCH:
color_block.add_stitch(Stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0))
if len(color_block) > 0:
- if import_commands == "none" and command in [pyembroidery.TRIM, pyembroidery.STOP]:
+ if import_commands == "none" and command in [pystitch.TRIM, pystitch.STOP]:
# Importing commands is not wanted:
# start a new color block without inserting the command
color_block = stitch_plan.new_color_block(thread)
- elif command == pyembroidery.TRIM:
+ elif command == pystitch.TRIM:
color_block.add_stitch(trim=True)
- elif command == pyembroidery.STOP:
+ elif command == pystitch.STOP:
color_block.add_stitch(stop=True)
color_block = stitch_plan.new_color_block(thread)
diff --git a/lib/stitch_plan/read_file.py b/lib/stitch_plan/read_file.py
index 56567f36..ada87958 100644
--- a/lib/stitch_plan/read_file.py
+++ b/lib/stitch_plan/read_file.py
@@ -3,7 +3,7 @@
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
-import pyembroidery
+import pystitch
from .stitch_plan import StitchPlan
from ..svg import PIXELS_PER_MM
@@ -11,7 +11,7 @@ from ..svg import PIXELS_PER_MM
def stitch_plan_from_file(embroidery_file):
"""Read a machine embroidery file in any supported format and return a stitch plan."""
- pattern = pyembroidery.read(embroidery_file)
+ pattern = pystitch.read(embroidery_file)
stitch_plan = StitchPlan()
color_block = None
@@ -20,7 +20,7 @@ def stitch_plan_from_file(embroidery_file):
color_block = stitch_plan.new_color_block(thread)
for x, y, command in raw_stitches:
color_block.add_stitch(x * PIXELS_PER_MM / 10.0, y * PIXELS_PER_MM / 10.0,
- jump=(command == pyembroidery.JUMP),
- trim=(command == pyembroidery.TRIM))
+ jump=(command == pystitch.JUMP),
+ trim=(command == pystitch.TRIM))
return stitch_plan
diff --git a/lib/threads/color.py b/lib/threads/color.py
index 335dc32b..6644e5ec 100644
--- a/lib/threads/color.py
+++ b/lib/threads/color.py
@@ -7,7 +7,7 @@ import colorsys
from inkex import Color, ColorError
-from pyembroidery.EmbThread import EmbThread
+from pystitch.EmbThread import EmbThread
class ThreadColor(object):
@@ -89,7 +89,7 @@ class ThreadColor(object):
return "#%s" % self.hex_digits
@property
- def pyembroidery_thread(self):
+ def pystitch_thread(self):
return {
"name": self.name,
"id": self.number,