diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-03-04 18:40:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-04 18:40:53 +0100 |
| commit | e84a86d4ac0caf29d6074728376ff0a594243fec (patch) | |
| tree | 888c79ed0094ba2916a1d329861a85515959913c /lib/utils | |
| parent | b39575a50191307b3b56eab6455626398eec6397 (diff) | |
Update for Inkscape 1.0 (#880)
* update for inkscape 1.0
* add about extension
* Build improvements for the inkscape1.0 branch (#985)
* zip: export real svg not stitch plan
* #411 and #726
* Tools for Font Creators (#1018)
* ignore very small holes in fills
* remove embroider (#1026)
* auto_fill: ignore shrink_or_grow if result is empty (#589)
* break apart: do not ignore small fills
Co-authored-by: Hagen Fritsch <rumpeltux-github@irgendwo.org>
Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/utils')
| -rw-r--r-- | lib/utils/dotdict.py | 2 | ||||
| -rw-r--r-- | lib/utils/geometry.py | 6 | ||||
| -rw-r--r-- | lib/utils/inkscape.py | 4 | ||||
| -rw-r--r-- | lib/utils/io.py | 22 | ||||
| -rw-r--r-- | lib/utils/version.py | 17 |
5 files changed, 33 insertions, 18 deletions
diff --git a/lib/utils/dotdict.py b/lib/utils/dotdict.py index 76f23697..e946ecd4 100644 --- a/lib/utils/dotdict.py +++ b/lib/utils/dotdict.py @@ -13,7 +13,7 @@ class DotDict(dict): self.dotdictify() def _dotdictify(self): - for k, v in self.iteritems(): + for k, v in self.items(): if isinstance(v, dict): self[k] = DotDict(v) diff --git a/lib/utils/geometry.py b/lib/utils/geometry.py index bae32c32..f7b49407 100644 --- a/lib/utils/geometry.py +++ b/lib/utils/geometry.py @@ -1,6 +1,7 @@ import math -from shapely.geometry import LineString, Point as ShapelyPoint +from shapely.geometry import LineString +from shapely.geometry import Point as ShapelyPoint def cut(line, distance, normalized=False): @@ -123,9 +124,6 @@ class Point: def as_tuple(self): return (self.x, self.y) - def __cmp__(self, other): - return cmp(self.as_tuple(), other.as_tuple()) - def __getitem__(self, item): return self.as_tuple()[item] diff --git a/lib/utils/inkscape.py b/lib/utils/inkscape.py index a650da69..f89ea447 100644 --- a/lib/utils/inkscape.py +++ b/lib/utils/inkscape.py @@ -1,10 +1,10 @@ -from os.path import realpath, expanduser, join as path_join import sys +from os.path import expanduser, realpath def guess_inkscape_config_path(): if getattr(sys, 'frozen', None): - path = realpath(path_join(sys._MEIPASS, "..", "..", "..")) + path = realpath(sys._MEIPASS.split('extensions', 1)[0]) if sys.platform == "win32": import win32api diff --git a/lib/utils/io.py b/lib/utils/io.py index f51f629c..239585f4 100644 --- a/lib/utils/io.py +++ b/lib/utils/io.py @@ -1,15 +1,15 @@ import os import sys -from cStringIO import StringIO +from io import StringIO def save_stderr(): # GTK likes to spam stderr, which inkscape will show in a dialog. - null = open(os.devnull, 'w') - sys.stderr_dup = os.dup(sys.stderr.fileno()) - sys.real_stderr = os.fdopen(sys.stderr_dup, 'w') - os.dup2(null.fileno(), 2) - sys.stderr = StringIO() + with open(os.devnull, 'w') as null: + sys.stderr_dup = os.dup(sys.stderr.fileno()) + sys.real_stderr = os.fdopen(sys.stderr_dup, 'w', encoding='utf-8') + os.dup2(null.fileno(), 2) + sys.stderr = StringIO() def restore_stderr(): @@ -22,11 +22,11 @@ def restore_stderr(): def save_stdout(): - null = open(os.devnull, 'w') - sys.stdout_dup = os.dup(sys.stdout.fileno()) - sys.real_stdout = os.fdopen(sys.stdout_dup, 'w') - os.dup2(null.fileno(), 1) - sys.stdout = StringIO() + with open(os.devnull, 'w') as null: + sys.stdout_dup = os.dup(sys.stdout.fileno()) + sys.real_stdout = os.fdopen(sys.stdout_dup, 'w') + os.dup2(null.fileno(), 1) + sys.stdout = StringIO() def restore_stdout(): diff --git a/lib/utils/version.py b/lib/utils/version.py new file mode 100644 index 00000000..02eb388b --- /dev/null +++ b/lib/utils/version.py @@ -0,0 +1,17 @@ +import sys +from os.path import isfile, join, realpath + +from ..i18n import _ + + +def get_inkstitch_version(): + if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + version = realpath(join(sys._MEIPASS, "..", "VERSION")) + else: + version = realpath(join(realpath(__file__), "..", "..", "..", 'VERSION')) + if isfile(version): + with open(version, 'r') as v: + inkstitch_version = _("Ink/Stitch Version: %s") % v.readline() + else: + inkstitch_version = _("Ink/Stitch Version: unkown") + return inkstitch_version |
