appyter.profiles.default.fields package¶
Submodules¶
appyter.profiles.default.fields.AutocompleteField module¶
-
class
appyter.profiles.default.fields.AutocompleteField.
AutocompleteField
(constraint='.*', hint=None, **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a field that accepts a string with autocomplete. Auto complete will use
choices
or alternativelyfile_path
– a url to load the choices as an array.Be careful with this field, consider defining a constraint regex. Note that it is equivalent to a string field, and still accepts choices not being autocompleted.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
constraint – A regular expression for validating the file name.
hint – A hint to put in the field prior to content.
file_path – (Optional[str]) A remote url to download the autocomplete list. Should resolve to a json list of terms.
choices – (Union[List[str], Dict[str, str]]) A set of choices that are available for this field or lookup table mapping from choice label to resulting value
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (str) A default value as an example and for use during prototyping
examples – (Optional[Union[List[str], Dict[str, str]]]) Named strings to provide as clickable examples
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Additional keyword arguments used by other fields
appyter.profiles.default.fields.BoolField module¶
-
class
appyter.profiles.default.fields.BoolField.
BoolField
(**kwargs)[source]¶ Bases:
appyter.fields.Field
Represing a true or false value with a checkbox.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (bool) A default value as an example and for use during prototyping
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
yes_label – (Optional[str]) The text instead of “Yes”
no_label – (Optional[str]) The text instead of “No”
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Additional keyword arguments used by other fields
-
property
choices
¶ Potential values to choose from
-
property
raw_value
¶ (UNSAFE) Raw value of the field
appyter.profiles.default.fields.ChoiceField module¶
-
class
appyter.profiles.default.fields.ChoiceField.
ChoiceField
(**kwargs)[source]¶ Bases:
appyter.fields.Field
Represing a choice of string values with a combo box.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
required – (Optional[bool]) Whether or not this field is required (defaults to false)
choices – (Union[List[str], Dict[str, str]]) A set of choices that are available for this field or lookup table mapping from choice label to resulting value
default – (str) A default value as an example and for use during prototyping
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Additional keyword arguments used by other fields
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
safe_value
¶ (SAFE) Effective safe value for use in code, we use
repr
to escape values as necessary
appyter.profiles.default.fields.DescriptionField module¶
-
class
appyter.profiles.default.fields.DescriptionField.
DescriptionField
(**kwargs)[source]¶ Bases:
appyter.fields.Field
Representing text between fields
Usage:
{% do DescriptionField( name='my_fieldname', text='My Description', ) %}
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
text – (str) A human readable, HTML parsable text
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
**kwargs –
Additional keyword arguments used by other fields
-
property
raw_value
¶ (UNSAFE) Raw value of the field
appyter.profiles.default.fields.FileField module¶
-
class
appyter.profiles.default.fields.FileField.
FileField
(default=None, constraint='.*', **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a File URL.
The field ends up being a string of the file path, which will be relative to the appyter notebook.
import pandas as pd df = pd.read_csv({{ FileField(name='my-csv', label='My CSV') }})
Importantly, a FileField ultimately resolves to a URL supporting several schemes. Appyters ensure that url is available as an actual file when the appyter executes.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
constraint – A regular expression for validating the file name.
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (str) A default value as an example and for use during prototyping
storage – (Optional[str]) A storage prefix for browsing
examples – (Optional[Dict[str, str]]) Named url paths to example files to upload
paths can be relative i.e.
{ "my_file.txt": url_for('static', filename='my_file.txt') }
, or a remote url. :param section: (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField :param value: (INTERNAL Any) The raw value of the field (from the form for instance) :param **kwargs: Remaining arguments passed down to :class:appyter.fields.Field
’s constructor.-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
public_url
¶
-
property
raw_value
¶ (UNSAFE) Raw value of the field
-
property
uri
¶
-
property
value
¶ (SEMI-SAFE) Effective raw value of the field when parsed and constraints are asserted. When instantiating code, you should use safe_value.
appyter.profiles.default.fields.FloatField module¶
-
class
appyter.profiles.default.fields.FloatField.
FloatField
(**kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a field that accepts a floating point value
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (float) A default value as an example and for use during prototyping
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Additional keyword arguments used by other fields
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
raw_value
¶ (UNSAFE) Raw value of the field
appyter.profiles.default.fields.IntField module¶
-
class
appyter.profiles.default.fields.IntField.
IntField
(min=None, max=None, step=None, **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a field that accepts an integer
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
min – (Optional[int]) the minimum valid value that the field can take on
max – (Optional[int]) the maximum valid value that the field can take on
step – (Optional[int]) the interval for which values are incremented or decremented
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (float) A default value as an example and for use during prototyping
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Remaining arguments passed down to :class:
appyter.fields.Field
’s constructor.
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
raw_value
¶ (UNSAFE) Raw value of the field
appyter.profiles.default.fields.MultiCheckboxField module¶
-
class
appyter.profiles.default.fields.MultiCheckboxField.
MultiCheckboxField
(**kwargs)[source]¶ Bases:
appyter.fields.Field
Represing a set of independently selectable check boxes. Like
appyter.profiles.default.fields.MultiChoiceField
, but witha different rendering (check boxes instead of select)
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form to appear as a tooltip
descriptions – (Optional[Dict[str, str]]) A long human readable description for each choice to appear as a tooltip
choices – (Union[List[str], Dict[str, str]]) A set of choices that are available for this field or lookup table mapping from choice label to resulting value
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (float) A default value as an example and for use during prototyping
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Remaining arguments passed down to :class:
appyter.fields.Field
’s constructor.
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
raw_value
¶ (UNSAFE) Raw value of the field
-
property
value
¶ (SEMI-SAFE) Effective raw value of the field when parsed and constraints are asserted. When instantiating code, you should use safe_value.
appyter.profiles.default.fields.MultiChoiceField module¶
-
class
appyter.profiles.default.fields.MultiChoiceField.
MultiChoiceField
(**kwargs)[source]¶ Bases:
appyter.fields.Field
Represing a multi-selectable combo box. The resulting selection is represented with a list of strings that were chosen.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
choices – (Union[List[str], Dict[str, str]]) A set of choices that are available for this field or lookup table mapping from choice label to resulting value
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (float) A default value as an example and for use during prototyping
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Remaining arguments passed down to :class:
appyter.fields.Field
’s constructor.
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
raw_value
¶ (UNSAFE) Raw value of the field
-
property
value
¶ (SEMI-SAFE) Effective raw value of the field when parsed and constraints are asserted. When instantiating code, you should use safe_value.
appyter.profiles.default.fields.MultiFileField module¶
-
class
appyter.profiles.default.fields.MultiFileField.
MultiFileField
(multiple=True, **kwargs)[source]¶ Bases:
appyter.profiles.default.fields.FileField.FileField
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
public_url
¶
-
property
public_urls
¶
-
property
raw_value
¶ (UNSAFE) Raw value of the field
-
property
uri
¶
-
property
uris
¶
-
property
value
¶ (SEMI-SAFE) Effective raw value of the field when parsed and constraints are asserted. When instantiating code, you should use safe_value.
-
appyter.profiles.default.fields.SectionField module¶
-
class
appyter.profiles.default.fields.SectionField.
SectionField
(icon='cogs', **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing section header which other fields can be a part of
%%appyter hide_code {% do SectionField(name='section1', title='My Section', subtitle='is awesome') %} {% set x = IntField(name='int1', label='My Int', section='section1') %}
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
title – (str) A human readable title for the section
subtitle – (str) A human readable subtitle for the section
img – (str) The path to an image used in the field relative to the static folder
icon – (str) A font-awesome icon identifier, used if img is not provided
**kwargs –
Additional keyword arguments used by other fields
-
property
raw_value
¶ (UNSAFE) Raw value of the field
appyter.profiles.default.fields.StringField module¶
-
class
appyter.profiles.default.fields.StringField.
StringField
(constraint=None, hint=None, required=None, **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a field that accepts a string
Be careful with this field, consider defining a constraint regex.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
constraint – A regular expression for validating the file name.
hint – (Optional[str]) A hint to put in the field prior to content.
feedback – (Optional[str]) Text to provide user feedback if the regex fails.
choices – (Union[List[str], Dict[str, str]]) A set of choices that are available for this field or lookup table mapping from choice label to resulting value
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (str) A default value as an example and for use during prototyping
examples – (Optional[Union[List[str], Dict[str, str]]]) Named strings to provide as clickable examples
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Additional keyword arguments used by other fields
appyter.profiles.default.fields.TabField module¶
-
class
appyter.profiles.default.fields.TabField.
TabField
(choices={}, **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a tab field which contains inner fields to choose from.
%%appyter hide_code {% myfield = TabField( name='my_field', choices={ "A": [ StringField( name="my_field_A", default="a" ), ], "B": [ StringField( name="my_field_B", default="b" ) ] } ) %} :param name: (str) A name that will be used to refer to the object as a variable and in the HTML form. :param label: (str) A human readable label for the field for the HTML form :param description: (Optional[str]) A long human readable description for the field for the HTML form :param \**kwargs: Additional keyword arguments used by other fields
appyter.profiles.default.fields.TextField module¶
-
class
appyter.profiles.default.fields.TextField.
TextField
(constraint=None, hint=None, required=None, **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a field that accepts a multi-line string
Be careful with this field, consider defining a constraint regex.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
constraint – (Regex[str]) A regular expression for validating the file name.
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (str) A default value as an example and for use during prototyping
examples – (Optional[Union[List[str], Dict[str, str]]]) Named strings to provide as clickable examples
hint – (Optional[str]) A hint to put in the field prior to content.
rows – (Optional[int]) The number of rows (lines) in the textarea
cols – (Optional[int]) The number of cols (horizontal characters) in the textarea
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Remaining arguments passed down to :class:
appyter.fields.Field
’s constructor.
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
safe_value
¶ (SAFE) Effective safe value for use in code, we use
repr
to escape values as necessary
appyter.profiles.default.fields.TextListField module¶
-
class
appyter.profiles.default.fields.TextListField.
TextListField
(constraint='[^\\n]*', hint=None, **kwargs)[source]¶ Bases:
appyter.fields.Field
Representing a field that accepts a set of strings separated by newlines
Be careful with this field, consider defining a constraint regex. Unlike
appyter.profiles.default.fields.TextField
, this class will returna list and potentially render differently.
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
choices – (Union[List[str], Dict[str, str]]) A set of choices that are available for this field or lookup table mapping from choice label to resulting value
constraint – (Regex[str]) A regular expression for validating the file name.
required – (Optional[bool]) Whether or not this field is required (defaults to false)
default – (List[str]) A default value as an example and for use during prototyping
examples – (Optional[Dict[str, List[str]]]) Named lists to provide as clickable examples
hint – (Optional[str]) A hint to put in the field prior to content.
rows – (Optional[int]) The number of rows (lines) in the textarea
cols – (Optional[int]) The number of cols (horizontal characters) in the textarea
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Remaining arguments passed down to :class:
appyter.fields.Field
’s constructor.
-
constraint
()[source]¶ Return true if the received args.value satisfies constraints. Should be overridden by subclasses.
-
property
raw_value
¶ (UNSAFE) Raw value of the field
-
property
value
¶ (SEMI-SAFE) Effective raw value of the field when parsed and constraints are asserted. When instantiating code, you should use safe_value.
appyter.profiles.default.fields.VariableField module¶
-
class
appyter.profiles.default.fields.VariableField.
VariableField
(field=None, **kwargs)[source]¶ Bases:
appyter.fields.Field
Represing a variable number of instances of a given Field Usage:
{{ VariableField( nane='files' label='Files', field=FileField( name='file', label='File', default='file.txt', ), default=['file.txt'], min=0, max=10, ) }}
- Parameters:
name – (str) A name that will be used to refer to the object as a variable and in the HTML form.
label – (str) A human readable label for the field for the HTML form
description – (Optional[str]) A long human readable description for the field for the HTML form
default – (list) A default value as an example and for use during prototyping
min – (int) The minimum number of fields that can be specified
max – (int) The maximum number of fields that can be specified
section – (Optional[str]) The name of a SectionField for which to nest this field under, defaults to a root SectionField
value – (INTERNAL Any) The raw value of the field (from the form for instance)
**kwargs –
Remaining arguments passed down to :class:
appyter.fields.Field
’s constructor.
-
constraint
()[source]¶ Number of values should satisfy bounded constraints and all values should satisfy the field constraints.
-
prepare
(req)[source]¶ Typically, you’ll just provide a list of values satisfying the Field type, for forms we support json pointer refs for compatibility with older form fields – these pointers are resolved during prepare. Basically:
{ "variablefield": [{"$ref":"#/singlefield0"},{"$ref":"#/singlefield1"}], "singlefield0": "a", "singlefield1": "b" } ```json Will resolve to ```json {"variablefield": ["a", "b"]}
Letting us construct the form as before but permitting us to reference form fields generated on the fly that end up in the form request.
-
property
raw_value
¶ (UNSAFE) Raw value of the field
-
property
value
¶ (SEMI-SAFE) Effective raw value of the field when parsed and constraints are asserted. When instantiating code, you should use safe_value.
Module contents¶
- Filters represent classes derived from
appyters.fields.Field
implementing more specific field types and are rendered in
appyters.profiles.default.templates
. The various other profiles can be used to extend or override those definitions.