From 1546a3e2ff7323815ee9b73138128c291a7a6480 Mon Sep 17 00:00:00 2001 From: Xavier Codinas Date: Tue, 9 Apr 2019 16:23:56 +0200 Subject: [PATCH 1/3] Pass writer options in get --- barcode/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/barcode/__init__.py b/barcode/__init__.py index 9b1768a..ac6b3b4 100755 --- a/barcode/__init__.py +++ b/barcode/__init__.py @@ -49,14 +49,14 @@ PROVIDED_BARCODES.sort() -def get(name, code=None, writer=None): +def get(name, code=None, writer=None, options=None): 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 @@ -68,7 +68,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): From ee3c5ee54edaa785a160e82c928502996238967d Mon Sep 17 00:00:00 2001 From: Xavier Codinas Date: Tue, 9 Apr 2019 16:28:48 +0200 Subject: [PATCH 2/3] Fix test error with mapping --- barcode/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barcode/__init__.py b/barcode/__init__.py index ac6b3b4..ee16e0d 100755 --- a/barcode/__init__.py +++ b/barcode/__init__.py @@ -49,7 +49,7 @@ PROVIDED_BARCODES.sort() -def get(name, code=None, writer=None, options=None): +def get(name, code=None, writer=None, options={}): try: barcode = __BARCODE_MAP[name.lower()] except KeyError: From 7ab36c945a5e78b4e61cbee9fb1f91f174c08d72 Mon Sep 17 00:00:00 2001 From: Xavier Codinas Date: Tue, 9 Apr 2019 16:35:54 +0200 Subject: [PATCH 3/3] Do not use a mutable argument by default --- barcode/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barcode/__init__.py b/barcode/__init__.py index ee16e0d..78b38a7 100755 --- a/barcode/__init__.py +++ b/barcode/__init__.py @@ -49,7 +49,8 @@ PROVIDED_BARCODES.sort() -def get(name, code=None, writer=None, options={}): +def get(name, code=None, writer=None, options=None): + options = options or {} try: barcode = __BARCODE_MAP[name.lower()] except KeyError: