From 6a3d64ff2250043bc8c764bd4cfbfaf9f29e6f95 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Sat, 9 Jan 2021 10:49:04 -0500 Subject: [PATCH] fields: Change FieldType capitalization. This is friendlier to the YAML input and consistent with FieldFlags. Less consistent with the rest of the codebase, but local consistency matters more IMO. --- conservancy_beancount/pdfforms/fields.py | 13 ++++++------- setup.py | 2 +- tests/test_pdfforms_fields.py | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/conservancy_beancount/pdfforms/fields.py b/conservancy_beancount/pdfforms/fields.py index e8786e4..444255b 100644 --- a/conservancy_beancount/pdfforms/fields.py +++ b/conservancy_beancount/pdfforms/fields.py @@ -53,14 +53,13 @@ class FieldFlags(enum.IntFlag): class FieldType(enum.Enum): Btn = 'Btn' - BUTTON = Btn + Button = Btn Ch = 'Ch' - CHOICE = Ch + Choice = Ch Sig = 'Sig' - SIG = Sig - SIGNATURE = Sig + Signature = Sig Tx = 'Tx' - TEXT = Tx + Text = Tx class FormField: @@ -87,14 +86,14 @@ class FormField: except ValueError: return retval flags = retval.flags() - if field_type is FieldType.BUTTON: + if field_type is FieldType.Button: if flags & FieldFlags.Radio: pass elif flags & FieldFlags.Pushbutton: pass else: retval.__class__ = CheckboxField - elif field_type is FieldType.TEXT: + elif field_type is FieldType.Text: retval.__class__ = TextField return retval diff --git a/setup.py b/setup.py index 9b070f9..bfef667 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='conservancy_beancount', description="Plugin, library, and reports for reading Conservancy's books", - version='1.15.0', + version='1.15.1', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+', diff --git a/tests/test_pdfforms_fields.py b/tests/test_pdfforms_fields.py index 5ff3475..1cd72ee 100644 --- a/tests/test_pdfforms_fields.py +++ b/tests/test_pdfforms_fields.py @@ -65,7 +65,7 @@ def test_empty_field(): def test_text_field_base(): source = field_source(b's', b'string of text', 'Tx') field = fieldsmod.FormField(source) - assert field.field_type() is fieldsmod.FieldType.TEXT + assert field.field_type() is fieldsmod.FieldType.Text assert field.name() == 's' assert field.value() == b'string of text' @@ -73,7 +73,7 @@ def test_text_field_base(): def test_checkbox_field_base(value): source = field_source(b'cb', value, 'Btn', literal=True) field = fieldsmod.FormField(source) - assert field.field_type() is fieldsmod.FieldType.BUTTON + assert field.field_type() is fieldsmod.FieldType.Button assert field.name() == 'cb' assert field.value().name == value @@ -114,7 +114,7 @@ def test_inheritance(): assert not parent.is_terminal() assert field.is_terminal() assert field.name() == 'kid' - assert field.field_type() is fieldsmod.FieldType.TEXT + assert field.field_type() is fieldsmod.FieldType.Text assert field.value() == 'parent value' assert field.flags() == 17 assert not list(field.kids())