adding setup, fixing package
parent
aa6c5b68fc
commit
f475a1b090
|
@ -1,2 +0,0 @@
|
||||||
from . import datamatrix
|
|
||||||
from datamatrix import *
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
pkgs.python3Packages.buildPythonPackage {
|
||||||
|
pname = "label-gen";
|
||||||
|
version = "1.0";
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
propagatedBuildInputs = with pkgs; [ inkscape python3Packages.pyyaml ];
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
import xml.dom.minidom as minidom
|
import xml.dom.minidom as minidom
|
||||||
from datamatrix import datamatrix
|
|
||||||
import uuid_gen
|
|
||||||
import random
|
import random
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
from . import uuid_gen
|
||||||
|
from . import datamatrix
|
||||||
|
|
||||||
|
|
||||||
class Label:
|
class Label:
|
||||||
def __init__(self, name, category, others, url):
|
def __init__(self, name, category, others, url):
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import labelgen
|
|
||||||
import argparse
|
import argparse
|
||||||
import yaml
|
import yaml
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from .generator import Label, Labelgen
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"labels", nargs="?", default=None, help="file with label definitions"
|
"labels", nargs="?", default=None, help="file with label definitions"
|
||||||
|
@ -19,31 +20,31 @@ parser.add_argument(
|
||||||
)
|
)
|
||||||
parser.add_argument("--empty", action="store_true", help="add empty labels")
|
parser.add_argument("--empty", action="store_true", help="add empty labels")
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if args.labels is not None:
|
def run():
|
||||||
with open(args.labels) as f:
|
args = parser.parse_args()
|
||||||
parts = yaml.safe_load(f)
|
|
||||||
else:
|
|
||||||
parts = []
|
|
||||||
|
|
||||||
l = labelgen.Labelgen(
|
if args.labels is not None:
|
||||||
y_offset=0.3, x_offset=-1.0, outline=args.outline, add_uuid=args.uuid
|
with open(args.labels) as f:
|
||||||
)
|
parts = yaml.safe_load(f)
|
||||||
|
else:
|
||||||
|
parts = []
|
||||||
|
|
||||||
for field in range(1 + args.skip, 25):
|
l = Labelgen(y_offset=0.3, x_offset=-1.0, outline=args.outline, add_uuid=args.uuid)
|
||||||
try:
|
|
||||||
part = parts[field]
|
|
||||||
l.set_label(field, labelgen.Label.from_dict(part))
|
|
||||||
except IndexError:
|
|
||||||
if args.empty:
|
|
||||||
l.set_label(field, labelgen.Label.empty())
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
except TypeError:
|
|
||||||
logging.exception(f"label generation failed for {field} {part}")
|
|
||||||
if args.empty:
|
|
||||||
l.set_label(field, labelgen.Label.empty())
|
|
||||||
|
|
||||||
l.gen_svg("out/montage.svg")
|
for field in range(1 + args.skip, 25):
|
||||||
subprocess.call("inkscape -f out/montage.svg -A out/montage.pdf".split(" "))
|
try:
|
||||||
|
part = parts[field]
|
||||||
|
l.set_label(field, Label.from_dict(part))
|
||||||
|
except IndexError:
|
||||||
|
if args.empty:
|
||||||
|
l.set_label(field, Label.empty())
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
except TypeError:
|
||||||
|
logging.exception(f"label generation failed for {field} {part}")
|
||||||
|
if args.empty:
|
||||||
|
l.set_label(field, Label.empty())
|
||||||
|
|
||||||
|
l.gen_svg("out/montage.svg")
|
||||||
|
subprocess.call("inkscape -f out/montage.svg -A out/montage.pdf".split(" "))
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
from datamatrix import datamatrix
|
|
||||||
import math
|
import math
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
import xml.dom.minidom as minidom
|
import xml.dom.minidom as minidom
|
||||||
|
|
||||||
|
from . import datamatrix
|
||||||
|
|
||||||
def encode_base256(b):
|
def encode_base256(b):
|
||||||
be = bytes()
|
be = bytes()
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="label-gen",
|
||||||
|
version="1.0",
|
||||||
|
description="labels for electronic parts inventory",
|
||||||
|
author="Jan Wiśniewski",
|
||||||
|
author_email="vuko@hackerspace.pl",
|
||||||
|
classifiers=[
|
||||||
|
"License :: OSI Approved :: zlib/libpng License",
|
||||||
|
"Programming Language :: Python :: 3.7",
|
||||||
|
],
|
||||||
|
packages=["label_gen"],
|
||||||
|
python_requires=">=3.6,",
|
||||||
|
install_requires=["pyyaml"],
|
||||||
|
entry_points={
|
||||||
|
"console_scripts": [
|
||||||
|
"label_gen=label_gen.run:run",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
)
|
Loading…
Reference in New Issue