Skip to content

Commit 620778c

Browse files
author
Hugo Osvaldo Barrera
authored
Merge pull request #66 from heuer/feature/upc_docs
Added docs for make_ean, fixed Sphinx docs
2 parents cdf70a2 + 36bc0bb commit 620778c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

barcode/upc.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,27 @@
88

99
from barcode.base import Barcode
1010
from barcode.charsets import upc as _upc
11-
from barcode.errors import (
12-
IllegalCharacterError,
13-
NumberOfDigitsError,
14-
)
11+
from barcode.errors import IllegalCharacterError, NumberOfDigitsError
1512

1613

1714
class UniversalProductCodeA(Barcode):
18-
"""Initializes new UPC-A barcode.
19-
20-
:parameters:
21-
upc : String
22-
The upc number as string.
23-
writer : barcode.writer Instance
24-
The writer to render the barcode (default: SVGWriter).
25-
make_ean: boolean
26-
"""
15+
"""Universal Product Code (UPC) barcode.
2716
17+
UPC-A consists of 12 numeric digits.
18+
"""
2819
name = 'UPC-A'
2920

3021
digits = 11
3122

3223
def __init__(self, upc, writer=None, make_ean=False):
24+
"""Initializes new UPC-A barcode.
25+
26+
:param str upc: The upc number as string.
27+
:param writer: barcode.writer instance. The writer to render the barcode
28+
(default: SVGWriter).
29+
:param bool make_ean: Indicates if a leading zero should be added to the
30+
barcode. This converts the UPC into a valid European Article Number (EAN).
31+
"""
3332
self.ean = make_ean
3433
upc = upc[:self.digits]
3534
if not upc.isdigit():
@@ -61,7 +60,7 @@ def calculate_checksum(self):
6160
"""Calculates the checksum for UPCA/UPC codes
6261
6362
:return: The checksum for 'self.upc'
64-
:rtype: Integer
63+
:rtype: int
6564
"""
6665
def sum_(x, y):
6766
return int(x) + int(y)
@@ -79,7 +78,7 @@ def build(self):
7978
"""Builds the barcode pattern from 'self.upc'
8079
8180
:return: The pattern as string
82-
:rtype: String
81+
:rtype: str
8382
"""
8483
code = _upc.EDGE[:]
8584

@@ -98,7 +97,7 @@ def build(self):
9897
def to_ascii(self):
9998
"""Returns an ascii representation of the barcode.
10099
101-
:rtype: String
100+
:rtype: str
102101
"""
103102

104103
code = self.build()

0 commit comments

Comments
 (0)