Skip to content

Commit 23a4388

Browse files
author
Hugo Osvaldo Barrera
committed
Drop redundant code
1 parent 8980039 commit 23a4388

File tree

10 files changed

+26
-27
lines changed

10 files changed

+26
-27
lines changed

barcode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get(name, code=None, writer=None, options=None):
6262
barcode = __BARCODE_MAP[name.lower()]
6363
except KeyError:
6464
raise BarcodeNotFoundError(
65-
"The barcode {0!r} you requested is not known.".format(name)
65+
"The barcode {!r} you requested is not known.".format(name)
6666
)
6767

6868
if code is not None:

barcode/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from barcode.writer import SVGWriter
55

66

7-
class Barcode(object):
7+
class Barcode:
88

99
name = ""
1010

@@ -31,7 +31,7 @@ def to_ascii(self):
3131
return "\n".join(code)
3232

3333
def __repr__(self):
34-
return "<{0}({1!r})>".format(self.__class__.__name__, self.get_fullcode())
34+
return "<{}({!r})>".format(self.__class__.__name__, self.get_fullcode())
3535

3636
def build(self):
3737
raise NotImplementedError

barcode/codex.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ def __init__(self, pzn, writer=None):
9898
raise IllegalCharacterError("PZN can only contain numbers.")
9999
if len(pzn) != self.digits:
100100
raise NumberOfDigitsError(
101-
"PZN must have {0} digits, not {1}.".format(self.digits, len(pzn))
101+
"PZN must have {} digits, not {}.".format(self.digits, len(pzn))
102102
)
103103
self.pzn = pzn
104-
self.pzn = "{0}{1}".format(pzn, self.calculate_checksum())
105-
Code39.__init__(self, "PZN-{0}".format(self.pzn), writer, add_checksum=False)
104+
self.pzn = "{}{}".format(pzn, self.calculate_checksum())
105+
Code39.__init__(self, "PZN-{}".format(self.pzn), writer, add_checksum=False)
106106

107107
def get_fullcode(self):
108-
return "PZN-{0}".format(self.pzn)
108+
return "PZN-{}".format(self.pzn)
109109

110110
def calculate_checksum(self):
111111
sum_ = sum(int(x) * int(y) for x, y in enumerate(self.pzn, start=2))
@@ -271,10 +271,10 @@ class Gs1_128(Code128):
271271

272272
def __init__(self, code, writer=None):
273273
code = self.FNC1_CHAR + code
274-
super(Gs1_128, self).__init__(code, writer)
274+
super().__init__(code, writer)
275275

276276
def get_fullcode(self):
277-
return super(Gs1_128, self).get_fullcode()[1:]
277+
return super().get_fullcode()[1:]
278278

279279

280280
# For pre 0.8 compatibility

barcode/ean.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ def __init__(self, ean, writer=None, no_checksum=False):
5353
raise IllegalCharacterError("EAN code can only contain numbers.")
5454
if len(ean) != self.digits:
5555
raise NumberOfDigitsError(
56-
"EAN must have {0} digits, not {1}.".format(self.digits, len(ean),)
56+
"EAN must have {} digits, not {}.".format(self.digits, len(ean),)
5757
)
5858
self.ean = ean
5959
# If no checksum
6060
if no_checksum:
6161
# Add a thirteen char if given in parameter,
6262
# otherwise pad with zero
63-
self.ean = "{0}{1}".format(
63+
self.ean = "{}{}".format(
6464
ean, ean[self.digits] if len(ean) > self.digits else 0
6565
)
6666
else:
67-
self.ean = "{0}{1}".format(ean, self.calculate_checksum())
67+
self.ean = "{}{}".format(ean, self.calculate_checksum())
6868
self.writer = writer or Barcode.default_writer()
6969

7070
def __unicode__(self):

barcode/isxn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, isbn, writer=None):
7070
isbn = isbn.replace("-", "")
7171
isbn = isbn[: self.digits]
7272
self.isbn10 = isbn
73-
self.isbn10 = "{0}{1}".format(isbn, self._calculate_checksum())
73+
self.isbn10 = "{}{}".format(isbn, self._calculate_checksum())
7474
InternationalStandardBookNumber13.__init__(self, "978" + isbn, writer)
7575

7676
def _calculate_checksum(self):
@@ -105,7 +105,7 @@ def __init__(self, issn, writer=None):
105105
issn = issn.replace("-", "")
106106
issn = issn[: self.digits]
107107
self.issn = issn
108-
self.issn = "{0}{1}".format(issn, self._calculate_checksum())
108+
self.issn = "{}{}".format(issn, self._calculate_checksum())
109109
EuropeanArticleNumber13.__init__(self, self.make_ean(), writer)
110110

111111
def _calculate_checksum(self):
@@ -120,7 +120,7 @@ def _calculate_checksum(self):
120120
return tmp
121121

122122
def make_ean(self):
123-
return "977{0}00{1}".format(self.issn[:7], self._calculate_checksum())
123+
return "977{}00{}".format(self.issn[:7], self._calculate_checksum())
124124

125125
def __unicode__(self):
126126
return self.issn

barcode/pybarcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def create_barcode(args, parser):
5757
writer = SVGWriter()
5858
out = os.path.normpath(os.path.abspath(args.output))
5959
name = barcode.generate(args.barcode, args.code, writer, out, opts, args.text)
60-
print("New barcode saved as {0}.".format(name))
60+
print("New barcode saved as {}.".format(name))
6161

6262

6363
def main():

barcode/upc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, upc, writer=None, make_ean=False):
3737
raise IllegalCharacterError("UPC code can only contain numbers.")
3838
if len(upc) != self.digits:
3939
raise NumberOfDigitsError(
40-
"UPC must have {0} digits, not {1}.".format(self.digits, len(upc))
40+
"UPC must have {} digits, not {}.".format(self.digits, len(upc))
4141
)
4242
self.upc = upc
4343
self.upc = "{}{}".format(upc, self.calculate_checksum())

barcode/writer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def create_svg_object(with_doctype=False):
4747

4848

4949
SIZE = "{0:.3f}mm"
50-
COMMENT = "Autogenerated with python-barcode {0}".format(version)
50+
COMMENT = "Autogenerated with python-barcode {}".format(version)
5151
PATH = os.path.dirname(os.path.abspath(__file__))
5252

5353

54-
class BaseWriter(object):
54+
class BaseWriter:
5555
"""Baseclass for all writers.
5656
5757
Initializes the basic writer options. Childclasses can add more
@@ -259,7 +259,7 @@ def _init(self, code):
259259
attributes = {
260260
"width": "100%",
261261
"height": "100%",
262-
"style": "fill:{0}".format(self.background),
262+
"style": "fill:{}".format(self.background),
263263
}
264264
_set_attributes(background, **attributes)
265265
self._group.appendChild(background)
@@ -271,7 +271,7 @@ def _create_module(self, xpos, ypos, width, color):
271271
"y": SIZE.format(ypos),
272272
"width": SIZE.format(width),
273273
"height": SIZE.format(self.module_height),
274-
"style": "fill:{0};".format(color),
274+
"style": "fill:{};".format(color),
275275
}
276276
_set_attributes(element, **attributes)
277277
self._group.appendChild(element)
@@ -288,7 +288,7 @@ def _create_text(self, xpos, ypos):
288288
attributes = {
289289
"x": SIZE.format(xpos),
290290
"y": SIZE.format(ypos),
291-
"style": "fill:{0};font-size:{1}pt;text-anchor:middle;".format(
291+
"style": "fill:{};font-size:{}pt;text-anchor:middle;".format(
292292
self.foreground, self.font_size,
293293
),
294294
}
@@ -308,12 +308,12 @@ def _finish(self):
308308

309309
def save(self, filename, output):
310310
if self.compress:
311-
_filename = "{0}.svgz".format(filename)
311+
_filename = "{}.svgz".format(filename)
312312
f = gzip.open(_filename, "wb")
313313
f.write(output)
314314
f.close()
315315
else:
316-
_filename = "{0}.svg".format(filename)
316+
_filename = "{}.svg".format(filename)
317317
with open(_filename, "wb") as f:
318318
f.write(output)
319319
return _filename
@@ -364,6 +364,6 @@ def _finish(self):
364364
return self._image
365365

366366
def save(self, filename, output):
367-
filename = "{0}.{1}".format(filename, self.format.lower())
367+
filename = "{}.{}".format(filename, self.format.lower())
368368
output.save(filename, self.format.upper())
369369
return filename

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# pyBarcode documentation build configuration file, created by
43
# sphinx-quickstart on Fri Mar 12 13:29:48 2010.

tests/test_manually.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def append_img(x, y):
6666
options["center_text"] = True
6767
filename = bcode.save(os.path.join(TESTPATH, codename), options=options)
6868
print(
69-
"Code: {0}, Input: {1}, Output: {2}".format(
69+
"Code: {}, Input: {}, Output: {}".format(
7070
bcode.name, code, bcode.get_fullcode()
7171
)
7272
)

0 commit comments

Comments
 (0)