parsers.models¶
Defines a Parser mixin for obtaining matches for regular expressions.
-
class
parsers.models.FieldParser(*args, **kwargs)[source]¶ Bases:
parsers.models.ParserA FieldParser is a Parser designed to parse objects that contain fields accessible through dictionary keys. It extends the Parser class with the source_fields attribute:
- Attribute:
- source_fields: comma-separated field names from a dictionary that will
- be used to assemble a value for a field in a custom object (defined by a DataField). For example, ‘user.screen_name,id_str’ may be used to construct a link to a tweet.
-
get_method_display(**morekwargs)¶
-
source_fields¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
class
parsers.models.Parser(*args, **kwargs)[source]¶ Bases:
django.db.models.base.ModelAn abstract base class for parsing a value from an object, such as a string or dictionary.
-
formatter¶ a template that will be used to format the parsed value, For example, ‘https://twitter.com/{}/’ may be used to construct a link to a Twitter profile.
-
regex¶ a string representing a pattern to be compiled as a regular expression
-
method¶ a string specifying the form of a result to be obtained from a regex search, e.g., the number of matches, presence/absence of a match, or the value of a substring from the first match
-
METHOD_CHOICES= (('COPY', 'Copy'), ('COUNT', 'Number of Occurrences'), ('DATE', 'Date from string'), ('P/A', 'Presence/Absence'), ('SUBSTRING', 'Substring'))¶
-
clean()[source]¶ Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
-
formatter A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_method_display(**morekwargs)¶
-
method A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
name¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
regex A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
-
class
parsers.models.StringParser(*args, **kwargs)[source]¶ Bases:
parsers.models.ParserA StringParser provides proper validation for parsing and formatting strings.
-
get_method_display(**morekwargs)¶
-
