Skip to content

Commit

Permalink
Changes for Python 3. Now version v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dcjud committed Mar 10, 2023
1 parent 9f20dcf commit c483d06
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 677 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*~
*.pyc
deleteme
foo.*
foo

2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# bookland.py - generate EAN-13 bar codes, including ISBN and ISMN
#
# Copyright (C) 1999-2007 Judah Milgram
# Copyright (C) 1999-2023 Judah Milgram
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down
11 changes: 11 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


2023-03-09

Release v2.0.0
Mods to allow running with Python 3. Still runs with Python 2.7.


2023-03-08

Moving to github, starting with v1.4.1
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

bookland.py - generate EAN-13 bar codes, including ISBN and ISMN

Copyright (C) 1999-2007 Judah Milgram
Copyright (C) 1999-2023 Judah Milgram

This is free software and comes with NO WARRANTY. See file COPYING for
license.
Expand Down
13 changes: 13 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Don't print numbers with %s... specify the format. Facilitates
comparisons between versions.

Switch to argparse

Write unit tests

Documentation: sphinx

README -> README.md


34 changes: 17 additions & 17 deletions bookland
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/python
#!/bin/env python3

MYNAME="bookland"
MYVERSION="1.4.1 Beta"
COPYRIGHT="(C) 1999-2011 J. Milgram"
VERSIONDATE = "July 2011"
MYVERSION="2.0.0"
COPYRIGHT="(C) 1999-2023 J. Milgram"
VERSIONDATE = "March 2023"
MAINTAINER = "[email protected]"

# Copyright (C) 1999-2011 Judah Milgram
# Copyright (C) 1999-2023 Judah Milgram
#
# bookland - generate EAN-13 bar codes, including ISBN and ISMN.
#
Expand Down Expand Up @@ -159,7 +159,7 @@ class Postscript:
if max(cmyk)>1 or min(cmyk)<0:
raise PostscriptError("cmyk value out of range")

bbox = map(int,self.bb)
bbox = [ int(corner) for corner in self.bb ]
# int truncates towards zero.
for i in range(len(bbox)):
if bbox[i] > 0:
Expand Down Expand Up @@ -214,7 +214,7 @@ class Bars(Postscript):
"gsave",
"%s %s translate 0 0 moveto" % (x0,y0),
"/moduleHeight { %s } def" % moduleHeight,
"/moduleWidth { %s } def" % moduleWidth,
"/moduleWidth { %0.3f } def" % moduleWidth,
"/barWidthReduction { %s } def" % barWidthReduction]
currentVal = None
n = None
Expand Down Expand Up @@ -473,7 +473,7 @@ def doTheRightThing(s,font,price,moduleHeight,
else:
upc5=None

commandLine = string.join(sys.argv)
commandLine = ' '.join(sys.argv)
epsComment = "%% Command line: %s" % commandLine
creator = "%s %s" % (MYNAME,MYVERSION)
title = str(productCode)
Expand Down Expand Up @@ -576,13 +576,13 @@ Usage: %s [-h|--help] [-V|--version] [-f|--font=fontname] [-q]
elif opt in ("-a","--autofile"):
outfile="auto"
elif opt in ("--cmyk"):
cmyk = tuple(map(float,val.split(",")))
if len(cmyk)!=4:
printUsage()
sys.exit(1)
cmyk = [float(x) for x in val.split(",")]
if len(cmyk)!=4:
printUsage()
sys.exit(1)
elif opt in ("--rgb"):
rgb = map(float,val.split(","))
if len(rgb)!=3:
if len(rgb)!=3:
printUsage()
sys.exit(1)
cmyk = rgbtocmyk(rgb)
Expand Down Expand Up @@ -611,18 +611,18 @@ Usage: %s [-h|--help] [-V|--version] [-f|--font=fontname] [-q]

if checkonly:
productCode = makeProductCode(s,forceISBN13=True)
print "%s understood as %s" % (s,productCode)
print('%s understood as %s' % (s,productCode))
if productCode.type in [ "ISBN10", "ISMN" ]:
print "13-digit version: %s" % productCode.as13()
print('13-digit version: %s' % productCode.as13())
sys.exit(0)

try:
epslines,filename = doTheRightThing(s,font,priceCode,heightScale*72,
barWidthReduction,zone,cmyk,
labelScale,
padding)
except ProductCodeError,e:
for msg in e.msgs: print msg
except ProductCodeError as e:
for msg in e.msgs: print(msg)
printUsage()
sys.exit(1)

Expand Down
Loading

0 comments on commit c483d06

Please sign in to comment.