Module src.line

Expand source code
from flask_restful import Resource
import globals
from src import auth
from webargs.flaskparser import use_kwargs
from webargs import fields
from marshmallow import Schema
from bson import json_util, ObjectId


class lineSchema(Schema):
    size = fields.Str()
    font = fields.Str()
    color = fields.Str()
    text = fields.Str()
    bbox = fields.List(fields.Integer())
    bboxScaled = fields.List(fields.Integer())
    pageId = fields.Str()
    fileId = fields.Str()
    current = fields.Integer()
    ocr = fields.Str()
    parent = fields.Str()
    cursor = fields.Integer()


dictionary = {
    "size": fields.Str(required=True),
    "font": fields.Str(required=True),
    "color": fields.Str(required=True),
    "text": fields.Str(required=True),
    "bbox": fields.List(fields.Integer(required=True)),
    "bboxScaled": fields.List(fields.Integer(required=True)),
    "pageId": fields.Str(required=True),
    "fileId": fields.Str(required=True),
    "current": fields.Integer(required=True),
    "ocr": fields.Str(required=True),
    "parent": fields.Str(required=True),
    "PROB": fields.Str(required=True),
    "letterSpacing": fields.Str(required=True),
    "wordSpacing": fields.Str(required=True),
    "textRotate": fields.Number(required=True),
    "lineHeight": fields.Str(required=True),
    "pageLineIndex": fields.Integer(required=True),
    "fontWeight": fields.Str(required=True),
    "cursor": fields.Integer(required=True),
    "fontStyle": fields.Str(required=True),
    "textDecoration": fields.Str(required=True),
    "customCSS": fields.Str(required=True),
    "whiteSpace": fields.Str(required=False, dump_default="pre", load_default="pre")

}

linesDB = globals.linesDB
auth_args = {"Authorization": fields.Str(required=True)}


# It takes in a bunch of arguments, checks if the user is authorized, and then inserts the arguments
# into a MongoDB database
class NewLine(Resource):
    parent_args = dictionary

    @use_kwargs(auth_args, location="headers")
    @use_kwargs(parent_args)
    def post(self, Authorization, size, font, color, text, bbox, customCSS, fontStyle, textDecoration, bboxScaled,
             pageId, fileId, lineHeight, textRotate, current, ocr, parent, PROB, letterSpacing, wordSpacing,
             pageLineIndex, fontWeight, cursor, whiteSpace):
        """
                I'm trying to insert a document into a MongoDB collection, and I'm getting a "TypeError: Object
                of type 'ObjectId' is not JSON serializable" error

                :param Authorization: The token that is generated when the user logs in
                :param size: font size
                :param font: font-family
                :param color: the color of the text
                :param text: the text of the line
                :param bbox: [x, y, width, height]
                :param customCSS: This is the CSS that is applied to the line
                :param fontStyle: normal, italic, oblique
                :param textDecoration: "underline"
                :param bboxScaled: [x, y, width, height]
                :param pageId: the id of the page the line is on
                :param fileId: The id of the file that the line belongs to
                :param lineHeight: the height of the line
                :param textRotate: 0
                :param current: boolean
                :param ocr: the text that was extracted from the image
                :param parent: the id of the parent line
                :param PROB: Probability of the line being a header
                :param letterSpacing: 0
                :param wordSpacing: 0
                :param pageLineIndex: the index of the line in the page
                :param fontWeight: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900
                :param cursor: the cursor position of the line
                :param whiteSpace: normal
                :return: The id of the inserted document.
                """
        if auth.verify(str(Authorization).split(" ")[1]):
            id = str(linesDB.insert_one({
                "size": size, "font": font, "color": color, "text": text, "bbox": bbox,
                "bboxScaled": bboxScaled, "pageId": pageId, "fileId": fileId,
                "current": current, "ocr": ocr, "parent": parent, "PROB": PROB,
                "textRotate": textRotate, "lineHeight": lineHeight, "letterSpacing": letterSpacing,
                "wordSpacing": wordSpacing, "pageLineIndex": pageLineIndex, "fontWeight": fontWeight,
                "cursor": cursor, "fontStyle": fontStyle, "textDecoration": textDecoration, "customCSS": customCSS,
                "whiteSpace": whiteSpace
            }).inserted_id)
            return {"msg": id}, 200
        else:
            return {"msg": "Unauthorized! Access Denied"}, 401


# This class is used to update a line in the database
class UpdateLine(Resource):
    parent_args = dictionary
    parent_args["_id"] = fields.Str(required=True)

    @use_kwargs(auth_args, location="headers")
    @use_kwargs(parent_args)
    def put(self, Authorization, _id, size, font, color, text, bbox, fontStyle, customCSS, textDecoration, textRotate,
            lineHeight, bboxScaled, pageId, fileId, current, ocr, parent, PROB, letterSpacing, wordSpacing,
            pageLineIndex, fontWeight, cursor, whiteSpace):
        """
        I'm trying to update a document in a MongoDB collection using the update_one() function

        :param Authorization: The token that is generated when the user logs in
        :param _id: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f")
        :param size: font size
        :param font: "Times New Roman"
        :param color: "#000000"
        :param text: the text of the line
        :param bbox: [x, y, width, height]
        :param fontStyle: normal, italic, oblique
        :param customCSS: {
        :param textDecoration: "underline"
        :param textRotate: 0
        :param lineHeight: line height
        :param bboxScaled: [x, y, width, height]
        :param pageId: ObjectId("5e8d8f8f8b9c8a0f9c8b9c8a")
        :param fileId: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f")
        :param current: boolean
        :param ocr: the text of the line
        :param parent: the parent line of the line
        :param PROB: Probability of the line being a header
        :param letterSpacing: 0
        :param wordSpacing: 0
        :param pageLineIndex: the index of the line in the page
        :param fontWeight: normal
        :param cursor: {
        :param whiteSpace: "normal"
        :return: The return value is a tuple of the form (response, status, headers)
        """
        if auth.verify(str(Authorization).split(" ")[1]):
            count = linesDB.update_one({
                "_id": ObjectId(_id)
            },
                {
                    "$set": {
                        "size": size,
                        "font": font,
                        "color": color,
                        "text": text,
                        "bbox": bbox,
                        "bboxScaled": bboxScaled,
                        "pageId": pageId,
                        "fileId": fileId,
                        "current": current,
                        "ocr": ocr,
                        "parent": parent,
                        "PROB": PROB,
                        "letterSpacing": letterSpacing,
                        "wordSpacing": wordSpacing,
                        "pageLineIndex": pageLineIndex,
                        "fontWeight": fontWeight,
                        "lineHeight": lineHeight,
                        "textRotate": textRotate,
                        "cursor": cursor,
                        "fontStyle": fontStyle,
                        "textDecoration": textDecoration,
                        "customCSS": customCSS
                    }
            }).modified_count
            return {"msg": count}, 200
        else:
            return {"msg": "Unauthorized! Access Denied"}, 401


# This class is used to delete a line from the database
class DeleteLine(Resource):
    fileid = {"id": fields.Str(required=True)}

    @use_kwargs(fileid, location="query")
    @use_kwargs(auth_args, location="headers")
    def delete(self, Authorization, id):
        """
        If the user is authorized, delete the document with the given id, otherwise return an error
        message.

        :param Authorization: This is the token that is generated when the user logs in
        :param id: The id of the document to be deleted
        :return: The return value is a tuple.
        """
        if auth.verify(str(Authorization).split(" ")[1]):
            linesDB.delete_one({"_id": ObjectId(id)})
            return {"msg": "Deleted Successfully"}
        else:
            return {"msg": "Unauthorized! Access Denied"}, 401

Classes

class DeleteLine

Represents an abstract RESTful resource. Concrete resources should extend from this class and expose methods for each supported HTTP method. If a resource is invoked with an unsupported HTTP method, the API will return a response with status 405 Method Not Allowed. Otherwise the appropriate method is called and passed all arguments from the url rule used when adding the resource to an Api instance. See :meth:~flask_restful.Api.add_resource for details.

Expand source code
class DeleteLine(Resource):
    fileid = {"id": fields.Str(required=True)}

    @use_kwargs(fileid, location="query")
    @use_kwargs(auth_args, location="headers")
    def delete(self, Authorization, id):
        """
        If the user is authorized, delete the document with the given id, otherwise return an error
        message.

        :param Authorization: This is the token that is generated when the user logs in
        :param id: The id of the document to be deleted
        :return: The return value is a tuple.
        """
        if auth.verify(str(Authorization).split(" ")[1]):
            linesDB.delete_one({"_id": ObjectId(id)})
            return {"msg": "Deleted Successfully"}
        else:
            return {"msg": "Unauthorized! Access Denied"}, 401

Ancestors

  • flask_restful.Resource
  • flask.views.MethodView
  • flask.views.View

Class variables

var fileid
var methods : Optional[List[str]]

Methods

def delete(self, Authorization, id)

If the user is authorized, delete the document with the given id, otherwise return an error message.

:param Authorization: This is the token that is generated when the user logs in :param id: The id of the document to be deleted :return: The return value is a tuple.

Expand source code
@use_kwargs(fileid, location="query")
@use_kwargs(auth_args, location="headers")
def delete(self, Authorization, id):
    """
    If the user is authorized, delete the document with the given id, otherwise return an error
    message.

    :param Authorization: This is the token that is generated when the user logs in
    :param id: The id of the document to be deleted
    :return: The return value is a tuple.
    """
    if auth.verify(str(Authorization).split(" ")[1]):
        linesDB.delete_one({"_id": ObjectId(id)})
        return {"msg": "Deleted Successfully"}
    else:
        return {"msg": "Unauthorized! Access Denied"}, 401
class NewLine

Represents an abstract RESTful resource. Concrete resources should extend from this class and expose methods for each supported HTTP method. If a resource is invoked with an unsupported HTTP method, the API will return a response with status 405 Method Not Allowed. Otherwise the appropriate method is called and passed all arguments from the url rule used when adding the resource to an Api instance. See :meth:~flask_restful.Api.add_resource for details.

Expand source code
class NewLine(Resource):
    parent_args = dictionary

    @use_kwargs(auth_args, location="headers")
    @use_kwargs(parent_args)
    def post(self, Authorization, size, font, color, text, bbox, customCSS, fontStyle, textDecoration, bboxScaled,
             pageId, fileId, lineHeight, textRotate, current, ocr, parent, PROB, letterSpacing, wordSpacing,
             pageLineIndex, fontWeight, cursor, whiteSpace):
        """
                I'm trying to insert a document into a MongoDB collection, and I'm getting a "TypeError: Object
                of type 'ObjectId' is not JSON serializable" error

                :param Authorization: The token that is generated when the user logs in
                :param size: font size
                :param font: font-family
                :param color: the color of the text
                :param text: the text of the line
                :param bbox: [x, y, width, height]
                :param customCSS: This is the CSS that is applied to the line
                :param fontStyle: normal, italic, oblique
                :param textDecoration: "underline"
                :param bboxScaled: [x, y, width, height]
                :param pageId: the id of the page the line is on
                :param fileId: The id of the file that the line belongs to
                :param lineHeight: the height of the line
                :param textRotate: 0
                :param current: boolean
                :param ocr: the text that was extracted from the image
                :param parent: the id of the parent line
                :param PROB: Probability of the line being a header
                :param letterSpacing: 0
                :param wordSpacing: 0
                :param pageLineIndex: the index of the line in the page
                :param fontWeight: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900
                :param cursor: the cursor position of the line
                :param whiteSpace: normal
                :return: The id of the inserted document.
                """
        if auth.verify(str(Authorization).split(" ")[1]):
            id = str(linesDB.insert_one({
                "size": size, "font": font, "color": color, "text": text, "bbox": bbox,
                "bboxScaled": bboxScaled, "pageId": pageId, "fileId": fileId,
                "current": current, "ocr": ocr, "parent": parent, "PROB": PROB,
                "textRotate": textRotate, "lineHeight": lineHeight, "letterSpacing": letterSpacing,
                "wordSpacing": wordSpacing, "pageLineIndex": pageLineIndex, "fontWeight": fontWeight,
                "cursor": cursor, "fontStyle": fontStyle, "textDecoration": textDecoration, "customCSS": customCSS,
                "whiteSpace": whiteSpace
            }).inserted_id)
            return {"msg": id}, 200
        else:
            return {"msg": "Unauthorized! Access Denied"}, 401

Ancestors

  • flask_restful.Resource
  • flask.views.MethodView
  • flask.views.View

Class variables

var methods : Optional[List[str]]
var parent_args

Methods

def post(self, Authorization, size, font, color, text, bbox, customCSS, fontStyle, textDecoration, bboxScaled, pageId, fileId, lineHeight, textRotate, current, ocr, parent, PROB, letterSpacing, wordSpacing, pageLineIndex, fontWeight, cursor, whiteSpace)

I'm trying to insert a document into a MongoDB collection, and I'm getting a "TypeError: Object of type 'ObjectId' is not JSON serializable" error

:param Authorization: The token that is generated when the user logs in :param size: font size :param font: font-family :param color: the color of the text :param text: the text of the line :param bbox: [x, y, width, height] :param customCSS: This is the CSS that is applied to the line :param fontStyle: normal, italic, oblique :param textDecoration: "underline" :param bboxScaled: [x, y, width, height] :param pageId: the id of the page the line is on :param fileId: The id of the file that the line belongs to :param lineHeight: the height of the line :param textRotate: 0 :param current: boolean :param ocr: the text that was extracted from the image :param parent: the id of the parent line :param PROB: Probability of the line being a header :param letterSpacing: 0 :param wordSpacing: 0 :param pageLineIndex: the index of the line in the page :param fontWeight: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900 :param cursor: the cursor position of the line :param whiteSpace: normal :return: The id of the inserted document.

Expand source code
@use_kwargs(auth_args, location="headers")
@use_kwargs(parent_args)
def post(self, Authorization, size, font, color, text, bbox, customCSS, fontStyle, textDecoration, bboxScaled,
         pageId, fileId, lineHeight, textRotate, current, ocr, parent, PROB, letterSpacing, wordSpacing,
         pageLineIndex, fontWeight, cursor, whiteSpace):
    """
            I'm trying to insert a document into a MongoDB collection, and I'm getting a "TypeError: Object
            of type 'ObjectId' is not JSON serializable" error

            :param Authorization: The token that is generated when the user logs in
            :param size: font size
            :param font: font-family
            :param color: the color of the text
            :param text: the text of the line
            :param bbox: [x, y, width, height]
            :param customCSS: This is the CSS that is applied to the line
            :param fontStyle: normal, italic, oblique
            :param textDecoration: "underline"
            :param bboxScaled: [x, y, width, height]
            :param pageId: the id of the page the line is on
            :param fileId: The id of the file that the line belongs to
            :param lineHeight: the height of the line
            :param textRotate: 0
            :param current: boolean
            :param ocr: the text that was extracted from the image
            :param parent: the id of the parent line
            :param PROB: Probability of the line being a header
            :param letterSpacing: 0
            :param wordSpacing: 0
            :param pageLineIndex: the index of the line in the page
            :param fontWeight: normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900
            :param cursor: the cursor position of the line
            :param whiteSpace: normal
            :return: The id of the inserted document.
            """
    if auth.verify(str(Authorization).split(" ")[1]):
        id = str(linesDB.insert_one({
            "size": size, "font": font, "color": color, "text": text, "bbox": bbox,
            "bboxScaled": bboxScaled, "pageId": pageId, "fileId": fileId,
            "current": current, "ocr": ocr, "parent": parent, "PROB": PROB,
            "textRotate": textRotate, "lineHeight": lineHeight, "letterSpacing": letterSpacing,
            "wordSpacing": wordSpacing, "pageLineIndex": pageLineIndex, "fontWeight": fontWeight,
            "cursor": cursor, "fontStyle": fontStyle, "textDecoration": textDecoration, "customCSS": customCSS,
            "whiteSpace": whiteSpace
        }).inserted_id)
        return {"msg": id}, 200
    else:
        return {"msg": "Unauthorized! Access Denied"}, 401
class UpdateLine

Represents an abstract RESTful resource. Concrete resources should extend from this class and expose methods for each supported HTTP method. If a resource is invoked with an unsupported HTTP method, the API will return a response with status 405 Method Not Allowed. Otherwise the appropriate method is called and passed all arguments from the url rule used when adding the resource to an Api instance. See :meth:~flask_restful.Api.add_resource for details.

Expand source code
class UpdateLine(Resource):
    parent_args = dictionary
    parent_args["_id"] = fields.Str(required=True)

    @use_kwargs(auth_args, location="headers")
    @use_kwargs(parent_args)
    def put(self, Authorization, _id, size, font, color, text, bbox, fontStyle, customCSS, textDecoration, textRotate,
            lineHeight, bboxScaled, pageId, fileId, current, ocr, parent, PROB, letterSpacing, wordSpacing,
            pageLineIndex, fontWeight, cursor, whiteSpace):
        """
        I'm trying to update a document in a MongoDB collection using the update_one() function

        :param Authorization: The token that is generated when the user logs in
        :param _id: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f")
        :param size: font size
        :param font: "Times New Roman"
        :param color: "#000000"
        :param text: the text of the line
        :param bbox: [x, y, width, height]
        :param fontStyle: normal, italic, oblique
        :param customCSS: {
        :param textDecoration: "underline"
        :param textRotate: 0
        :param lineHeight: line height
        :param bboxScaled: [x, y, width, height]
        :param pageId: ObjectId("5e8d8f8f8b9c8a0f9c8b9c8a")
        :param fileId: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f")
        :param current: boolean
        :param ocr: the text of the line
        :param parent: the parent line of the line
        :param PROB: Probability of the line being a header
        :param letterSpacing: 0
        :param wordSpacing: 0
        :param pageLineIndex: the index of the line in the page
        :param fontWeight: normal
        :param cursor: {
        :param whiteSpace: "normal"
        :return: The return value is a tuple of the form (response, status, headers)
        """
        if auth.verify(str(Authorization).split(" ")[1]):
            count = linesDB.update_one({
                "_id": ObjectId(_id)
            },
                {
                    "$set": {
                        "size": size,
                        "font": font,
                        "color": color,
                        "text": text,
                        "bbox": bbox,
                        "bboxScaled": bboxScaled,
                        "pageId": pageId,
                        "fileId": fileId,
                        "current": current,
                        "ocr": ocr,
                        "parent": parent,
                        "PROB": PROB,
                        "letterSpacing": letterSpacing,
                        "wordSpacing": wordSpacing,
                        "pageLineIndex": pageLineIndex,
                        "fontWeight": fontWeight,
                        "lineHeight": lineHeight,
                        "textRotate": textRotate,
                        "cursor": cursor,
                        "fontStyle": fontStyle,
                        "textDecoration": textDecoration,
                        "customCSS": customCSS
                    }
            }).modified_count
            return {"msg": count}, 200
        else:
            return {"msg": "Unauthorized! Access Denied"}, 401

Ancestors

  • flask_restful.Resource
  • flask.views.MethodView
  • flask.views.View

Class variables

var methods : Optional[List[str]]
var parent_args

Methods

def put(self, Authorization, _id, size, font, color, text, bbox, fontStyle, customCSS, textDecoration, textRotate, lineHeight, bboxScaled, pageId, fileId, current, ocr, parent, PROB, letterSpacing, wordSpacing, pageLineIndex, fontWeight, cursor, whiteSpace)

I'm trying to update a document in a MongoDB collection using the update_one() function

:param Authorization: The token that is generated when the user logs in :param _id: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f") :param size: font size :param font: "Times New Roman" :param color: "#000000" :param text: the text of the line :param bbox: [x, y, width, height] :param fontStyle: normal, italic, oblique :param customCSS: { :param textDecoration: "underline" :param textRotate: 0 :param lineHeight: line height :param bboxScaled: [x, y, width, height] :param pageId: ObjectId("5e8d8f8f8b9c8a0f9c8b9c8a") :param fileId: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f") :param current: boolean :param ocr: the text of the line :param parent: the parent line of the line :param PROB: Probability of the line being a header :param letterSpacing: 0 :param wordSpacing: 0 :param pageLineIndex: the index of the line in the page :param fontWeight: normal :param cursor: { :param whiteSpace: "normal" :return: The return value is a tuple of the form (response, status, headers)

Expand source code
@use_kwargs(auth_args, location="headers")
@use_kwargs(parent_args)
def put(self, Authorization, _id, size, font, color, text, bbox, fontStyle, customCSS, textDecoration, textRotate,
        lineHeight, bboxScaled, pageId, fileId, current, ocr, parent, PROB, letterSpacing, wordSpacing,
        pageLineIndex, fontWeight, cursor, whiteSpace):
    """
    I'm trying to update a document in a MongoDB collection using the update_one() function

    :param Authorization: The token that is generated when the user logs in
    :param _id: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f")
    :param size: font size
    :param font: "Times New Roman"
    :param color: "#000000"
    :param text: the text of the line
    :param bbox: [x, y, width, height]
    :param fontStyle: normal, italic, oblique
    :param customCSS: {
    :param textDecoration: "underline"
    :param textRotate: 0
    :param lineHeight: line height
    :param bboxScaled: [x, y, width, height]
    :param pageId: ObjectId("5e8d8f8f8b9c8a0f9c8b9c8a")
    :param fileId: ObjectId("5e8d8f8f8f8f8f8f8f8f8f8f")
    :param current: boolean
    :param ocr: the text of the line
    :param parent: the parent line of the line
    :param PROB: Probability of the line being a header
    :param letterSpacing: 0
    :param wordSpacing: 0
    :param pageLineIndex: the index of the line in the page
    :param fontWeight: normal
    :param cursor: {
    :param whiteSpace: "normal"
    :return: The return value is a tuple of the form (response, status, headers)
    """
    if auth.verify(str(Authorization).split(" ")[1]):
        count = linesDB.update_one({
            "_id": ObjectId(_id)
        },
            {
                "$set": {
                    "size": size,
                    "font": font,
                    "color": color,
                    "text": text,
                    "bbox": bbox,
                    "bboxScaled": bboxScaled,
                    "pageId": pageId,
                    "fileId": fileId,
                    "current": current,
                    "ocr": ocr,
                    "parent": parent,
                    "PROB": PROB,
                    "letterSpacing": letterSpacing,
                    "wordSpacing": wordSpacing,
                    "pageLineIndex": pageLineIndex,
                    "fontWeight": fontWeight,
                    "lineHeight": lineHeight,
                    "textRotate": textRotate,
                    "cursor": cursor,
                    "fontStyle": fontStyle,
                    "textDecoration": textDecoration,
                    "customCSS": customCSS
                }
        }).modified_count
        return {"msg": count}, 200
    else:
        return {"msg": "Unauthorized! Access Denied"}, 401
class lineSchema (*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)

Base schema class with which to define custom schemas.

Example usage:

.. code-block:: python

import datetime as dt
from dataclasses import dataclass

from marshmallow import Schema, fields


@dataclass
class Album:
    title: str
    release_date: dt.date


class AlbumSchema(Schema):
    title = fields.Str()
    release_date = fields.Date()


album = Album("Beggars Banquet", dt.date(1968, 12, 6))
schema = AlbumSchema()
data = schema.dump(album)
data  # {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}

:param only: Whitelist of the declared fields to select when instantiating the Schema. If None, all fields are used. Nested fields can be represented with dot delimiters. :param exclude: Blacklist of the declared fields to exclude when instantiating the Schema. If a field appears in both only and exclude, it is not used. Nested fields can be represented with dot delimiters. :param many: Should be set to True if obj is a collection so that the object will be serialized to a list. :param context: Optional context passed to :class:fields.Method and :class:fields.Function fields. :param load_only: Fields to skip during serialization (write-only fields) :param dump_only: Fields to skip during deserialization (read-only fields) :param partial: Whether to ignore missing fields and not require any fields declared. Propagates down to Nested fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields. :param unknown: Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.

Changed in version: 3.0.0

prefix parameter removed.

Changed in version: 2.0.0

__validators__, __preprocessors__, and __data_handlers__ are removed in favor of marshmallow.decorators.validates_schema, marshmallow.decorators.pre_load and marshmallow.decorators.post_dump. __accessor__ and __error_handler__ are deprecated. Implement the handle_error and get_attribute methods instead.

Expand source code
class lineSchema(Schema):
    size = fields.Str()
    font = fields.Str()
    color = fields.Str()
    text = fields.Str()
    bbox = fields.List(fields.Integer())
    bboxScaled = fields.List(fields.Integer())
    pageId = fields.Str()
    fileId = fields.Str()
    current = fields.Integer()
    ocr = fields.Str()
    parent = fields.Str()
    cursor = fields.Integer()

Ancestors

  • marshmallow.schema.Schema
  • marshmallow.base.SchemaABC

Class variables

var opts