Skip to content

Commit

Permalink
Merge pull request #32 from xcodinas/master
Browse files Browse the repository at this point in the history
Pass writer options in get
  • Loading branch information
Hugo Osvaldo Barrera authored Apr 9, 2019
2 parents 2c3b785 + 7ab36c9 commit 0b23701
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions barcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@
PROVIDED_BARCODES.sort()


def get(name, code=None, writer=None):
def get(name, code=None, writer=None, options=None):
options = options or {}
try:
barcode = __BARCODE_MAP[name.lower()]
except KeyError:
raise BarcodeNotFoundError('The barcode {0!r} you requested is not '
'known.'.format(name))
if code is not None:
return barcode(code, writer)
return barcode(code, writer, **options)
else:
return barcode

Expand All @@ -68,7 +69,7 @@ def get_class(name):
def generate(name, code, writer=None, output=None, writer_options=None,
text=None, pil=False):
options = writer_options or {}
barcode = get(name, code, writer)
barcode = get(name, code, writer, options)
if pil:
return barcode.render(writer_options, text)
if isinstance(output, _strbase):
Expand Down

0 comments on commit 0b23701

Please sign in to comment.