kopia lustrzana https://github.com/EmbroidePy/pyembroidery
Porównaj commity
9 Commity
Autor | SHA1 | Data |
---|---|---|
tatarize | 1f8d3e9a53 | |
Tatarize | c36428075c | |
tatarize | 6fd941f4b2 | |
luz paz | a5982a43a1 | |
tatarize | 3d0db61e7a | |
Tatarize | 93601f80a0 | |
Aurish Hammad Hafeez | 830144a6c9 | |
tatarize | 06225f67dd | |
Tatarize | adaff94bfa |
|
@ -0,0 +1 @@
|
|||
github: [tatarize]
|
|
@ -0,0 +1,73 @@
|
|||
name: Unittest
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, dev]
|
||||
paths:
|
||||
- '**.py'
|
||||
- '.github/workflows/unittests.yml'
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths:
|
||||
- '**.py'
|
||||
- '.github/workflows/unittests.yml'
|
||||
|
||||
concurrency:
|
||||
group: unittests-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
unittests:
|
||||
|
||||
name: ${{ matrix.os }}+py${{ matrix.python-version }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 10
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-2019, macos-11]
|
||||
python-version: [3.11]
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout ${{ github.ref }}
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Identify precise Python version
|
||||
id: full-python-version
|
||||
shell: bash
|
||||
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
|
||||
|
||||
- name: Cache Python env for ${{ matrix.os }}-py${{ steps.full-python-version.outputs.version }}
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ env.pythonLocation }}
|
||||
key: new-${{ matrix.os }}-py${{ steps.full-python-version.outputs.version }}-${{ hashFiles('requirements.txt') }}
|
||||
|
||||
- name: List environment
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJSON(github) }}
|
||||
JOB_CONTEXT: ${{ toJSON(job) }}
|
||||
STEPS_CONTEXT: ${{ toJSON(steps) }}
|
||||
RUNNER_CONTEXT: ${{ toJSON(runner) }}
|
||||
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
|
||||
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
|
||||
run: |
|
||||
pip list
|
||||
env
|
||||
|
||||
- name: Run Unittests
|
||||
run: |
|
||||
python -m unittest discover test -v
|
||||
if ${{ matrix.experimental }} == true; then
|
||||
exit 0
|
||||
fi
|
10
README.md
10
README.md
|
@ -29,7 +29,7 @@ Pyembroidery fully meets and exceeds all of these requirements.
|
|||
* It supports all the core commands where that format can use said command as well as FAST and SLOW for .u01.
|
||||
* SEQUINS work in all supported formats (.dst) that are known to support sequins. Further it supports SEQUIN to JUMP operations on the other formats.
|
||||
|
||||
Though previously mandated support for Python 2.7, this support was dropped at the end of life for that version. It is highly recommended that you upgrade. A `python27` branch is availible but that branch was merely forked from when the version was supported.
|
||||
Though previously mandated support for Python 2.7, this support was dropped at the end of life for that version. It is highly recommended that you upgrade. A `python27` branch is available but that branch was merely forked from when the version was supported.
|
||||
|
||||
|
||||
## Philosophy
|
||||
|
@ -52,7 +52,7 @@ Other reasonable elements:
|
|||
## Overview
|
||||
Readers are sent a fileobject/stream, an EmbPattern and sometimes a settings dict. The reader parses the file, adding in metadata, threads, and stitches with as much valid information as the file contains.
|
||||
|
||||
EmbPattern objects contain all relevant data. You can iterate stitch blocks .get_as_stitchblocks() or access the raw-stitches, threads, or metadata.
|
||||
EmbPattern objects contain all relevant data. You can iterate stitch blocks .get_as_stitchblock() or access the raw-stitches, threads, or metadata.
|
||||
|
||||
Writers are called to save a pattern to disk. The writers save raw-stitch data to disk. This data may, however, not be formatted in a way the writer can utilize effectively. For this reason, writers (except lossless csv) utilize the encoder to ensure whatever the data is in the pattern will be presented to the writer in a manner coherent to the writer.
|
||||
|
||||
|
@ -202,7 +202,7 @@ Prints out a workable CSV file with the given data. Starting in 1.3 the csv patt
|
|||
|
||||
|
||||
#### Reading/Writing to JSON:
|
||||
Saves the pattern as a JSON object. This is intended to be useful as an interchange format since JSON is the most common data interchange format availible currently.
|
||||
Saves the pattern as a JSON object. This is intended to be useful as an interchange format since JSON is the most common data interchange format available currently.
|
||||
|
||||
|
||||
#### Writing to PNG:
|
||||
|
@ -533,7 +533,7 @@ The encoder will by default ignore any COLOR_BREAK that occurs before any stitch
|
|||
|
||||
You can expressly add any of the core commands to the patterns. These are generalized and try to play nice with other commands. When the patterns are written to disk, they call pattern.get_normalized_pattern() and save the normalized pattern. Saving to any format does not modify the pattern, ever. It writes the modified pattern out. It adds the max_jump and max_stitch to the encoding when it normalizes this to save. So each format can compile to a different set of stitches due to the max_jump etc. This is expressly an attempt to maintain as much data integrity as possible.
|
||||
|
||||
After a load, the pattern will be filled with raw basic stitch data, it's perfectly reasonable call .get_stable_pattern() on this which will make it into a series of stitches, color_breaks, sequence_breaks or get_pattern_interpolate_trim() which will allow you to introduce trim commands after a series of JUMP commands as specified and merge the untrimmed jumps. Or to iterate through the data with .get_as_stitchblocks() which is a generator that will produce stitch blocks from the raw loaded data. The stabilized pattern simply makes a new pattern, iterates through the current pattern by the stitchblocks and feeds that into add_stitch_block(). This results in a pattern without any jumps, trims, etc.
|
||||
After a load, the pattern will be filled with raw basic stitch data, it's perfectly reasonable call .get_stable_pattern() on this which will make it into a series of stitches, color_breaks, sequence_breaks or get_pattern_interpolate_trim() which will allow you to introduce trim commands after a series of JUMP commands as specified and merge the untrimmed jumps. Or to iterate through the data with .get_as_stitchblock() which is a generator that will produce stitch blocks from the raw loaded data. The stabilized pattern simply makes a new pattern, iterates through the current pattern by the stitchblocks and feeds that into add_stitch_block(). This results in a pattern without any jumps, trims, etc.
|
||||
|
||||
STITCH_BREAK
|
||||
|
||||
|
@ -566,7 +566,7 @@ While there's only NONE, and THREE_SMALL for contingencies currently, both the t
|
|||
|
||||
* The core units are 1/10th mm. This is what 1 refers to within most formats, and internally within pyembroidery itself. You are entirely permitted to use floating point numbers. When writing to a format, fractional values will be lost, but this shall happen in such a way to avoid the propagation of error. Relative stitches from position ( 0.0, 0.31 ) of (+5.4, +5.4), (+5.4, +5,4), (+5.4, +5,4) should encode as changes of 5,6 6,5 5,6. Taking the relative distance in the format as the integer change from the last integer position to the new one, maintaining a position as close to the absolute position as possible. All fractional values are considered significant.
|
||||
|
||||
In some read formats the formats themselves have a slightly different unit systems such as .PCD or .MIT these alternative units will be presented seemlessly as 1/10th mm units.
|
||||
In some read formats the formats themselves have a slightly different unit systems such as .PCD or .MIT these alternative units will be presented seamlessly as 1/10th mm units.
|
||||
|
||||
### Core Command Ordering
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ def process_header_info(out, prefix, value):
|
|||
out.metadata("copyright", value)
|
||||
elif prefix == "TC":
|
||||
values = [x.strip() for x in value.split(",")]
|
||||
out.add_thread({"hex": values[0], "description": value[1], "catalog": value[2]})
|
||||
out.add_thread({"hex": values[0], "description": values[1], "catalog": values[2]})
|
||||
else:
|
||||
out.metadata(prefix, value)
|
||||
|
||||
|
|
|
@ -670,7 +670,7 @@ class EmbPattern:
|
|||
self.stitches[last_change][2] = STOP
|
||||
else:
|
||||
thread_index += 1
|
||||
except IndexError: # Non-existant threads cannot double
|
||||
except IndexError: # Non-existent threads cannot double
|
||||
return
|
||||
init_color = False
|
||||
elif data == COLOR_CHANGE or data == COLOR_BREAK or data == NEEDLE_SET:
|
||||
|
|
|
@ -31,7 +31,7 @@ def get_thread_set():
|
|||
EmbThreadPec(246, 74, 138, "Deep Rose", "25"),
|
||||
EmbThreadPec(178, 118, 36, "Light Brown", "26"),
|
||||
EmbThreadPec(252, 187, 197, "Salmon Pink", "27"),
|
||||
EmbThreadPec(254, 55, 15, "Vermillion", "28"),
|
||||
EmbThreadPec(254, 55, 15, "Vermilion", "28"),
|
||||
EmbThreadPec(240, 240, 240, "White", "29"),
|
||||
EmbThreadPec(106, 28, 138, "Violet", "30"),
|
||||
EmbThreadPec(168, 221, 196, "Seacrest", "31"),
|
||||
|
@ -54,7 +54,7 @@ def get_thread_set():
|
|||
EmbThreadPec(247, 56, 102, "Carmine", "48"),
|
||||
EmbThreadPec(181, 75, 100, "Amber Red", "49"),
|
||||
EmbThreadPec(19, 43, 26, "Olive Green", "50"),
|
||||
EmbThreadPec(199, 1, 86, "Dark Fuschia", "51"),
|
||||
EmbThreadPec(199, 1, 86, "Dark Fuchsia", "51"),
|
||||
EmbThreadPec(254, 158, 50, "Tangerine", "52"),
|
||||
EmbThreadPec(168, 222, 235, "Light Blue", "53"),
|
||||
EmbThreadPec(0, 103, 62, "Emerald Green", "54"),
|
||||
|
|
|
@ -412,20 +412,13 @@ class GenericWriter:
|
|||
self.block_closing = True
|
||||
|
||||
def write(self):
|
||||
pattern = self.pattern
|
||||
f = self.f
|
||||
settings = self.settings
|
||||
|
||||
if settings is None:
|
||||
return
|
||||
|
||||
# DOCUMENT STATISTICS
|
||||
self.set_document_statistics()
|
||||
|
||||
self.open_pattern()
|
||||
if self.metadata_entry is not None:
|
||||
for i, key in enumerate(pattern.extras):
|
||||
value = pattern.extras[key]
|
||||
for i, key in enumerate(self.pattern.extras):
|
||||
value = self.pattern.extras[key]
|
||||
self.format_dictionary.update({
|
||||
"metadata_index": i,
|
||||
"metadata_key": str(key),
|
||||
|
@ -436,7 +429,7 @@ class GenericWriter:
|
|||
)
|
||||
|
||||
if self.thread_entry is not None:
|
||||
for i, thread in enumerate(pattern.threadlist):
|
||||
for i, thread in enumerate(self.pattern.threadlist):
|
||||
self.format_dictionary.update({
|
||||
"thread_index": i,
|
||||
"thread_color": thread.hex_color(),
|
||||
|
@ -453,7 +446,7 @@ class GenericWriter:
|
|||
write_string_utf8(
|
||||
self.f, self.thread_entry.format_map(self.format_dictionary)
|
||||
)
|
||||
for self.command_index in range(0, len(pattern.stitches)):
|
||||
for self.command_index in range(0, len(self.pattern.stitches)):
|
||||
self.update_command()
|
||||
write_segment = self.get_write_segment(self.cmd)
|
||||
|
||||
|
@ -462,7 +455,7 @@ class GenericWriter:
|
|||
if isinstance(write_segment, dict):
|
||||
key, default = write_segment[None]
|
||||
key = key.format_map(self.format_dictionary)
|
||||
write_segment = write_segment.get(key,default)
|
||||
write_segment = write_segment.get(key, default)
|
||||
self.update_positions(self.x, self.y, self.cmd)
|
||||
if self.cmd == SEQUIN_MODE:
|
||||
self.open_document()
|
||||
|
|
|
@ -7,6 +7,7 @@ from .EmbMatrix import EmbMatrix
|
|||
from .EmbPattern import EmbPattern
|
||||
from .EmbThread import EmbThread
|
||||
from .EmbCompress import compress, expand
|
||||
import pyembroidery.GenericWriter as GenericWriter
|
||||
|
||||
# items available in a sub-heirarchy (e.g. pyembroidery.PecGraphics.get_graphic_as_string)
|
||||
from .PecGraphics import get_graphic_as_string
|
||||
|
|
3
setup.py
3
setup.py
|
@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||
|
||||
setuptools.setup(
|
||||
name="pyembroidery",
|
||||
version="1.4.35",
|
||||
version="1.4.36",
|
||||
author="Tatarize",
|
||||
author_email="tatarize@gmail.com",
|
||||
description="Embroidery IO library",
|
||||
|
@ -21,6 +21,7 @@ setuptools.setup(
|
|||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
|
|
Ładowanie…
Reference in New Issue