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.
This commit is contained in:
Brett Smith 2021-01-09 10:49:04 -05:00
parent 188063cbb7
commit 6a3d64ff22
3 changed files with 10 additions and 11 deletions

View file

@ -53,14 +53,13 @@ class FieldFlags(enum.IntFlag):
class FieldType(enum.Enum): class FieldType(enum.Enum):
Btn = 'Btn' Btn = 'Btn'
BUTTON = Btn Button = Btn
Ch = 'Ch' Ch = 'Ch'
CHOICE = Ch Choice = Ch
Sig = 'Sig' Sig = 'Sig'
SIG = Sig Signature = Sig
SIGNATURE = Sig
Tx = 'Tx' Tx = 'Tx'
TEXT = Tx Text = Tx
class FormField: class FormField:
@ -87,14 +86,14 @@ class FormField:
except ValueError: except ValueError:
return retval return retval
flags = retval.flags() flags = retval.flags()
if field_type is FieldType.BUTTON: if field_type is FieldType.Button:
if flags & FieldFlags.Radio: if flags & FieldFlags.Radio:
pass pass
elif flags & FieldFlags.Pushbutton: elif flags & FieldFlags.Pushbutton:
pass pass
else: else:
retval.__class__ = CheckboxField retval.__class__ = CheckboxField
elif field_type is FieldType.TEXT: elif field_type is FieldType.Text:
retval.__class__ = TextField retval.__class__ = TextField
return retval return retval

View file

@ -5,7 +5,7 @@ from setuptools import setup
setup( setup(
name='conservancy_beancount', name='conservancy_beancount',
description="Plugin, library, and reports for reading Conservancy's books", description="Plugin, library, and reports for reading Conservancy's books",
version='1.15.0', version='1.15.1',
author='Software Freedom Conservancy', author='Software Freedom Conservancy',
author_email='info@sfconservancy.org', author_email='info@sfconservancy.org',
license='GNU AGPLv3+', license='GNU AGPLv3+',

View file

@ -65,7 +65,7 @@ def test_empty_field():
def test_text_field_base(): def test_text_field_base():
source = field_source(b's', b'string of text', 'Tx') source = field_source(b's', b'string of text', 'Tx')
field = fieldsmod.FormField(source) 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.name() == 's'
assert field.value() == b'string of text' assert field.value() == b'string of text'
@ -73,7 +73,7 @@ def test_text_field_base():
def test_checkbox_field_base(value): def test_checkbox_field_base(value):
source = field_source(b'cb', value, 'Btn', literal=True) source = field_source(b'cb', value, 'Btn', literal=True)
field = fieldsmod.FormField(source) 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.name() == 'cb'
assert field.value().name == value assert field.value().name == value
@ -114,7 +114,7 @@ def test_inheritance():
assert not parent.is_terminal() assert not parent.is_terminal()
assert field.is_terminal() assert field.is_terminal()
assert field.name() == 'kid' 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.value() == 'parent value'
assert field.flags() == 17 assert field.flags() == 17
assert not list(field.kids()) assert not list(field.kids())