Unverified Commit 5fa31932 authored by Вячеслав Марцинкевич's avatar Вячеслав Марцинкевич Committed by GitHub
Browse files

Merge pull request #26 from normcontrol/CommonClasses

[Feat]Added the dataclasses functionality to the main unified classes.
Showing with 581 additions and 172 deletions
+581 -172
from enum import Enum
class AlignmentEnum(Enum):
LEFT = 'left'
Right = 'right'
CENTER = 'center'
JUSTIFY = 'juctify'
\ No newline at end of file
def pt_to_sm(value: float):
"""
Converts topographical points to centimeters
:param value: Conventional value
:return: The resulting value in centimeters
"""
return value / 28.346
def dm_to_sm(value: float):
"""
Converts inches to centimeters
:param value: Conventional value
:return: The resulting value in centimeters
"""
return value * 2.54
\ No newline at end of file
File deleted
import json
import re
from src.Class.Table import Table
from src.PDF.Table import PDFTable
from src.classes.Paragraph import Paragraph
class DocumentClass:
"""
Description: a unified class representing a text document, its properties and content
Parameters:
----------
__owner - attribute specifies the owner of a document,
__time - attribute specifies document creation time,
__content - attribute specifies the conten of a document
_owner: str
The attribute specifies the owner of a document
_time: datetime
The attribute specifies document creation time
_content: dictionary
The attribute specifies the conten of a document
Methods
Methods:
----------
add_content(id, paragraph)
Adds a paragraph to the content list
pt_to_sm(value)
Converts topographical points to centimeters
dm_to_sm(value)
Converts inches to centimeters
create_json_to_clasifier(listOfAttr)
Creates and returns a json string, which will later be sent to the classifier
......@@ -38,53 +32,27 @@ class DocumentClass:
Generates csv file based on content
"""
def __init__(self, owner, time):
self.__owner = owner
self.__time = time
self.__content = {}
self._owner = owner
self._time = time
self._content = {}
def add_content(self, paragraph_id, paragraph):
def add_content(self, element_id, element):
"""
Adds a paragraph to the content list
:param paragraph_id: Paragraph number to be added
:param paragraph: The paragraph to be added as a Paragraph class
:param element_id: Paragraph number to be added
:param element: The paragraph to be added as a Paragraph class
"""
self.content[paragraph_id] = paragraph
## Пункт в сантиметры
@classmethod
def pt_to_sm(cls, value):
"""
Converts topographical points to centimeters
:param value: Conventional value
:return: The resulting value in centimeters
self.content[element_id] = element
"""
return value/28.346
## Дюйм в сантиметры
@classmethod
def dm_to_sm(cls, value):
"""
Converts inches to centimeters
:param value: Conventional value
:return: The resulting value in centimeters
"""
return value * 2.54
def create_json_to_clasifier(self, list_of_attr = ["countn_of_sp_sbl","count_sbl","lowercase","uppercase","last_sbl",
"firstkey","prev_el","cur_el","next_el","bold","italics",
"keep_lines_together","keep_with_next", "outline_level",
"page_breake_before"]
):
def create_json_to_clasifier(self, list_of_attr=["countn_of_sp_sbl", "count_sbl", "lowercase", "uppercase",
"last_sbl", "first_key", "bold", "italics", "keep_lines_together",
"keep_with_next", "outline_level", "page_breake_before"]
):
"""
Creates and returns a json string, which will later be sent to the classifier
......@@ -95,26 +63,26 @@ class DocumentClass:
"""
s ="{"
json_string = "{"
for attribute in dir(self):
if attribute == "time" or attribute == "owner":
s = s + "\"" + attribute + "\": \"" + str(getattr(self,attribute)) + "\", "
s = s + "\"paragraphs\": {"
json_string = json_string + "\"" + attribute + "\": \"" + str(getattr(self, attribute)) + "\", "
json_string = json_string + "\"paragraphs\": {"
for i, p in self.content.items():
if p.__class__ != PDFTable :
s = s + "\"" + str(i) + "\": {\""
if p.__class__ == Paragraph:
json_string = json_string + "\"" + str(i) + "\": {\""
for attribute in dir(p):
if not attribute.startswith('_') and attribute in list_of_attr:
s = s + attribute + "\": \"" + str(getattr(p,attribute)) + "\",\""
l = len(s)
s = s[:l - 2] + "}, "
l = len(s)
s = s[:l - 2] + "}}"
json_text = json.loads(s)
json_string = json_string + attribute + "\": \"" + str(getattr(p, attribute)) + "\",\""
length = len(json_string)
json_string = json_string[:length - 2] + "}, "
length = len(json_string)
json_string = json_string[:length - 2] + "}}"
json_text = json.loads(json_string)
return json_text
@classmethod
def request_to_clasify(cls, json_text, api = "http://127.0.0.1:8001/clasify"):
def request_to_clasify(cls, json_text, api="http://127.0.0.1:8001/clasify"):
"""
Sends a request to the classification module
......@@ -127,10 +95,10 @@ class DocumentClass:
"""
import requests
response = requests.post(api, json= json_text)
response = requests.post(api, json=json_text)
return response
def write_CSV(self, path = 'pdftocsv.csv'):
def write_CSV(self, path='pdftocsv.csv'):
"""
......@@ -143,40 +111,37 @@ class DocumentClass:
import csv
with open(path, 'w', newline='', encoding="utf-8") as csvfile:
filewriter = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
filewriter.writerow(["text","countn_of_sp_sbl","count_sbl","uppercase", "lowercase","font_name","last_sbl",
"firstkey","indent","line_spasing","text_size"])
filewriter.writerow(["text", "countn_of_sp_sbl", "count_sbl", "uppercase", "lowercase", "font_name",
"last_sbl", "first_key", "indent", "line_spasing", "text_size"])
for key in self.content.keys():
if type(self.content.get(key))!= PDFTable:
filewriter.writerow([self.content.get(key).text, self.content.get(key).countn_of_sp_sbl,
self.content.get(key).count_sbl,self.content.get(key).uppercase,
if type(self.content.get(key)) == Paragraph:
filewriter.writerow([self.content.get(key).text, self.content.get(key).count_of_sp_sbl,
self.content.get(key).count_sbl, self.content.get(key).uppercase,
self.content.get(key).lowercase, self.content.get(key).font_name,
self.content.get(key).last_sbl,self.content.get(key).firstkey,
self.content.get(key).indent, self.content.get(key).line_spasing,
self.content.get(key).last_sbl, self.content.get(key).first_key,
self.content.get(key).indent, self.content.get(key).line_spacing,
self.content.get(key).text_size])
else:
filewriter.writerow([self.content.get(key).text])
@property
def content(self):
return self.__content
return self._content
@property
def time(self):
return self.__time
return self._time
@property
def owner(self):
return self.__owner
return self._owner
@owner.setter
def owner(self, owner):
self.__owner = owner
self._owner = owner
@time.setter
def time(self, time):
self.__time = time
self._time = time
@content.setter
def content(self, content):
self.__content = content
\ No newline at end of file
self._content = content
......@@ -20,8 +20,9 @@ class DrawFrame:
to the ending resource.
"""
def __init__(self, frame_style_name, frame_name, frame_anchor_type, frame_x, frame_y, frame_width, frame_height,
frame_rel_width, frame_rel_height, image_href, image_type, image_show, image_actuate):
def __init__(self, frame_style_name: str, frame_name: str, frame_anchor_type: str, frame_x: float, frame_y: float,
frame_width: float, frame_height: float, frame_rel_width: str, frame_rel_height: str, image_href: str,
image_type: str, image_show: str, image_actuate: str):
self._frame_style_name = frame_style_name
self._frame_name = frame_name
self._frame_anchor_type = frame_anchor_type
......
import re
from dataclasses import dataclass, field
from src.helpers.enums import AlignmentEnum
@dataclass
class Paragraph:
"""
Description: a inified class representing a text paragraph, its properties? styles and content
Parameters:
----------
_text - attribute specifies paragraph text
_countn_of_sp_sbl - attribute specifies number of special characters in a paragraph
_count_sbl - attribute specifies number of characters in a paragraph
_lowercase - attribute specifies lowercase text in the entire paragraph
_uppercase - attribute specifies uppercase text in the entire paragraph
_last_sbl - attribute specifies last paragraph character
_first_key - attribute specifies first paragraph character
_prev_el - attribute specifies the class of the previous structural element
_cur_el - attribute specifies the class of the current structural element
_next_el - attribute specifies the class of the next structural element
_alignment - attribute specifies text alignment
_indent - attribute specifies indent from the red line
_mrgrg - attribute specifies indent from the right side of the page
_mrglf - attribute specifies indent from the left side of the page
_line_spasing - attribute specifies paragraph line spacing
_mrgtop - attribute specifies attribute specifies indent from the top side of the page
_mrgbtm - attribute specifies attribute specifies indent from the bottom side of the page
_font_name - attribute specifies paragraph font
_bold - attribute specifies paragraph text boldness
_italics - attribute specifies paragraph text italics
_underlining - attribute specifies paragraph text underlining
_sub_text - attribute specifies
_super_text - attribute specifies
_text_size - attribute specifies text size
_color_text - attribute specifies text color
_page_breake_before - attribute specifies start of a new page
_keep_lines_together - attribute specifies keeping the line style together
_keep_with_next - attribute specifies keeping paragraphs together
_outline_level - attribute specifies paragraph type
_no_space_between_paragraphs_of_same_style - attribute specifies no extra space between paragraphs of the same style
_no_change_fontname - attribute specifies no change in text font inside a paragraph
_no_change_text_size - attribute specifies no change in text size inside a paragraph
Methods
_text: str
The attribute specifies paragraph text
_countn_of_sp_sbl: int
The attribute specifies number of special characters in a paragraph
_count_sbl: int
The attribute specifies number of characters in a paragraph
_lowercase: bool
The attribute specifies lowercase text in the entire paragraph
_uppercase: bool
The attribute specifies uppercase text in the entire paragraph
_last_sbl: str
The attribute specifies last paragraph character
_first_key: str
The attribute specifies first paragraph character
_alignment: AlignmentEnum
The attribute specifies text alignment
_indent: float
The attribute specifies indent from the red line
_mrgrg: float
The attribute specifies indent from the right side of the page
_mrglf: float
The attribute specifies indent from the left side of the page
_line_spacing: float
The attribute specifies paragraph line spacing
_mrgtop: float
The attribute specifies attribute specifies indent from the top side of the page
_mrgbtm: float
The attribute specifies attribute specifies indent from the bottom side of the page
_font_name: str
The attribute specifies paragraph font
_bold: bool
The attribute specifies paragraph text boldness
_italics: bool
The attribute specifies paragraph text italics
_underlining: bool
The attribute specifies paragraph text underlining
_sub_text: bool
The attribute specifies sub position of text
_super_text: bool
The attribute specifies super position of text
_text_size: float
The attribute specifies text size
_color_text: str
The attribute specifies text color in HEX
_page_breake_before: bool
The attribute specifies start of a new page
_keep_lines_together: bool
The attribute specifies keeping the line style together
_keep_with_next: bool
The attribute specifies keeping paragraphs together
_outline_level: str
The attribute specifies paragraph type
_no_change_fontname: bool
The attribute specifies no change in text font inside a paragraph
_no_change_text_size: bool
The attribute specifies no change in text size inside a paragraph
Methods:
----------
get_countn_of_sp_sbl(cls, text)
Counts and returns the number of special characters in a text
......@@ -61,43 +89,43 @@ class Paragraph:
Calculates the type of the first character of a paragraph
"""
def __init__(self, text, indent, line_spasing, font_name, text_size, no_change_fontname, no_change_text_size,
alignment=None, mrgrg=None, mrglf=None, mrgtop=None, mrgbtm=None, bold=None, italics=None,
underlining=None, sub_text=None, super_text=None, color_text="White",
keep_lines_together=None, keep_with_next=None, outline_level=None,
no_space_between_paragraphs_of_same_style=None, page_breake_before=None):
self._text = text
self._countn_of_sp_sbl = Paragraph.get_countn_of_sp_sbl(text)
self._count_sbl = Paragraph.get_count_sbl(text)
self._lowercase = Paragraph.get_lowercase(text)
self._uppercase = Paragraph.get_uppercase(text)
self._last_sbl = Paragraph.get_last_sbl(text)
self._first_key = Paragraph.get_first_key(text)
self._prev_el = None
self._cur_el = None
self._next_el = None
self._alignment = alignment
self._indent = indent
self._mrgrg = mrgrg
self._mrglf = mrglf
self._line_spasing = line_spasing
self._mrgtop = mrgtop
self._mrgbtm = mrgbtm
self._font_name = font_name
self._bold = bold
self._italics = italics
self._underlining = underlining
self._sub_text = sub_text
self._super_text = super_text
self._text_size = text_size
self._color_text = color_text
self._page_breake_before = page_breake_before
self._keep_lines_together = keep_lines_together
self._keep_with_next = keep_with_next
self._outline_level = outline_level
self._no_space_between_paragraphs_of_same_style = no_space_between_paragraphs_of_same_style
self._no_change_fontname = no_change_fontname
self._no_change_text_size = no_change_text_size
_line_spacing: float
_text: str
_count_of_sp_sbl: int = field(init=False)
_count_sbl: int = field(init=False)
_lowercase: bool = field(init=False)
_uppercase: bool = field(init=False)
_last_sbl: str = field(init=False)
_first_key: str = field(init=False)
_indent: float
_font_name: str
_text_size: float
_alignment: AlignmentEnum = None
_mrgrg: float = None
_mrglf: float = None
_mrgtop: float = None
_mrgbtm: float = None
_bold: bool = None
_italics: bool = None
_underlining: bool = None
_sub_text: bool = None
_super_text: bool = None
_color_text: str = None
_page_breake_before: bool = None
_keep_lines_together: bool = None
_keep_with_next: bool = None
_outline_level: str = None
_no_change_fontname: bool = None
_no_change_text_size: bool = None
def __post_init__(self):
self.count_of_sp_sbl = Paragraph.get_countn_of_sp_sbl(self.text)
self.count_sbl = Paragraph.get_count_sbl(self.text)
self.lowercase = Paragraph.get_lowercase(self.text)
self.uppercase = Paragraph.get_uppercase(self.text)
self.last_sbl = Paragraph.get_last_sbl(self.text)
self.first_key = Paragraph.get_first_key(self.text)
@classmethod
def get_countn_of_sp_sbl(cls, text):
......@@ -195,33 +223,13 @@ class Paragraph:
return ''
@property
def prev_el(self):
return self._prev_el
@prev_el.setter
def prev_el(self, prev_el):
self._prev_el = prev_el
@property
def cur_el(self):
return self._cur_el
@cur_el.setter
def cur_el(self, cur_el):
self._cur_el = cur_el
@property
def next_el(self):
return self._next_el
@next_el.setter
def font_name(self, next_el):
self._next_el = next_el
@property
def text(self):
return self._text
@text.setter
def text(self, text):
self._text = text
@property
def keep_lines_together(self):
return self._keep_lines_together
......@@ -229,6 +237,7 @@ class Paragraph:
@keep_lines_together.setter
def keep_lines_together(self, keep_lines_together):
self._keep_lines_together = keep_lines_together
@property
def outline_level(self):
return self._outline_level
......@@ -238,61 +247,60 @@ class Paragraph:
self._outline_level = outline_level
@property
def no_space_between_paragraphs_of_same_style(self):
return self._no_space_between_paragraphs_of_same_style
@no_space_between_paragraphs_of_same_style.setter
def no_space_between_paragraphs_of_same_style(self, no_space_between_paragraphs_of_same_style):
self._no_space_between_paragraphs_of_same_style = no_space_between_paragraphs_of_same_style
@property
def keep_with_next(self):
return self._keep_with_next
@keep_with_next.setter
def keep_with_next(self, keep_with_next):
self._keep_with_next = keep_with_next
@property
def indent(self):
return self._indent
@indent.setter
def indent(self, indent):
self._indent = indent
self._indent = indent
@property
def mrgrg(self):
return self._mrgrg
@mrgrg.setter
def mrgrg(self, mrgrg):
self._mrgrg = mrgrg
self._mrgrg = mrgrg
@property
def mrglf(self):
return self._mrglf
@mrglf.setter
def mrglf(self, mrglf):
self._mrglf = mrglf
self._mrglf = mrglf
@property
def mrgtop(self):
return self._mrgtop
@mrgtop.setter
def mrgtop(self, mrgtop):
self._mrgtop = mrgtop
self._mrgtop = mrgtop
@property
def mrgbtm(self):
return self._mrgbtm
@mrgbtm.setter
def mrgbtm(self, mrgbtm):
self._mrgbtm = mrgbtm
self._mrgbtm = mrgbtm
@property
def font_name(self):
return self._font_name
@font_name.setter
def font_name(self, font_name):
self._font_name= font_name
self._font_name = font_name
@property
def color_text(self):
......@@ -300,16 +308,16 @@ class Paragraph:
@color_text.setter
def color_text(self, color_text):
self._color_text= color_text
self._color_text = color_text
@property
def line_spasing(self):
return self._line_spasing
def line_spacing(self):
return self._line_spacing
@line_spasing.setter
def line_spasing(self, value):
@line_spacing.setter
def line_spacing(self, value):
if value >= 0:
self._line_spasing = value
self._line_spacing = value
else:
raise ValueError
......@@ -318,9 +326,9 @@ class Paragraph:
return self._bold
@bold.setter
def bold(self, b):
if b is True or b is False:
self._bold = b
def bold(self, bold):
if isinstance(bold, bool):
self._bold = bold
else:
raise ValueError
......@@ -329,9 +337,9 @@ class Paragraph:
return self._italics
@italics.setter
def italics(self, i):
if i is True or i is False:
self._italics = i
def italics(self, italics):
if isinstance(italics, bool):
self._italics = italics
else:
raise ValueError
......@@ -341,7 +349,7 @@ class Paragraph:
@underlining.setter
def underlining(self, underlining):
if underlining is True or underlining is False:
if isinstance(underlining, bool):
self._underlining = underlining
else:
raise ValueError
......@@ -351,9 +359,9 @@ class Paragraph:
return self._sub_text
@sub_text.setter
def sub_text(self, s):
if s is True or s is False:
self._sub_text = s
def sub_text(self, sub_text):
if isinstance(sub_text, bool):
self._sub_text = sub_text
else:
raise ValueError
......@@ -362,9 +370,9 @@ class Paragraph:
return self._super_text
@super_text.setter
def super_text(self, s):
if s is True or s is False:
self._super_text = s
def super_text(self, super_text):
if isinstance(super_text, bool):
self._super_text = super_text
else:
raise ValueError
......@@ -380,12 +388,12 @@ class Paragraph:
raise ValueError
@property
def countn_of_sp_sbl(self):
return self._countn_of_sp_sbl
def count_of_sp_sbl(self):
return self._count_of_sp_sbl
@countn_of_sp_sbl.setter
def countn_of_sp_sbl(self, countn_of_sp_sbl):
self._countn_of_sp_sbl = countn_of_sp_sbl
@count_of_sp_sbl.setter
def count_of_sp_sbl(self, count_of_sp_sbl):
self._count_of_sp_sbl = count_of_sp_sbl
@property
def count_sbl(self):
......@@ -394,6 +402,7 @@ class Paragraph:
@count_sbl.setter
def count_sbl(self, count_sbl):
self._count_sbl = count_sbl
@property
def lowercase(self):
return self._lowercase
......@@ -401,6 +410,7 @@ class Paragraph:
@lowercase.setter
def lowercase(self, lowercase):
self._lowercase = lowercase
@property
def uppercase(self):
return self._uppercase
......@@ -408,6 +418,7 @@ class Paragraph:
@uppercase.setter
def uppercase(self, uppercase):
self._uppercase = uppercase
@property
def last_sbl(self):
return self._last_sbl
......@@ -415,6 +426,7 @@ class Paragraph:
@last_sbl.setter
def last_sbl(self, last_sbl):
self._last_sbl = last_sbl
@property
def first_key(self):
return self._first_key
......@@ -422,24 +434,3 @@ class Paragraph:
@first_key.setter
def first_key(self, first_key):
self._first_key = first_key
@property
def prev_el(self):
return self._prev_el
@prev_el.setter
def prev_el(self, prev_el):
self._prev_el = prev_el
@property
def cur_el(self):
return self._cur_el
@cur_el.setter
def cur_el(self, cur_el):
self._cur_el = cur_el
@property
def next_el(self):
return self._next_el
@next_el.setter
def next_el(self, next_el):
self._next_el = next_el
\ No newline at end of file
......@@ -13,8 +13,8 @@ class Table:
_table_properties_align - attribute specifies the horizontal alignment of a table (table:align).
"""
def __init__(self, table_name, table_family, table_master_page_name, table_properties_width,
table_properties_margin_left, table_properties_align):
def __init__(self, table_name: str, table_family: str, table_master_page_name: str, table_properties_width: float,
table_properties_margin_left: float, table_properties_align: str):
self._table_name = table_name
self._table_family = table_family
self._table_master_page_name = table_master_page_name
......
......@@ -20,9 +20,9 @@ class TableCell:
or inline-area.
"""
def __init__(self, cell_name, cell_family, cell_properties_border, cell_properties_writing_mode,
cell_properties_padding_top, cell_properties_padding_left,
cell_properties_padding_bottom, cell_properties_padding_right):
def __init__(self, cell_name: str, cell_family: str, cell_properties_border: float, cell_properties_writing_mode: str,
cell_properties_padding_top: float, cell_properties_padding_left: float,
cell_properties_padding_bottom: float, cell_properties_padding_right: float):
self._cell_name = cell_name
self._cell_family = cell_family
self._cell_properties_border = cell_properties_border
......
......@@ -10,8 +10,8 @@ class TableColumn:
automatically if content in the column changes.
"""
def __init__(self, column_name, column_family, column_properties_column_width,
column_properties_use_optimal_column_width):
def __init__(self, column_name: str, column_family: str, column_properties_column_width: float,
column_properties_use_optimal_column_width: float):
self._column_name = column_name
self._column_family = column_family
self._column_properties_column_width = column_properties_column_width
......
......@@ -11,7 +11,7 @@ class TableRow:
automatically if content in the row changes.
"""
def __init__(self, row_name, row_family, row_properties_min_row_height, row_properties_use_optimal_row_height):
def __init__(self, row_name:str, row_family:str, row_properties_min_row_height:float, row_properties_use_optimal_row_height:float):
self._row_name = row_name
self._row_family = row_family
self._row_properties_min_row_height = row_properties_min_row_height
......
from dataclasses import dataclass
@dataclass
class Line:
"""
Description: A class is a text string and its attributes
----------
Parameters:
x0: The attribute describes the upper horizontal position of the symbol
y0: The attribute describes the upper vertical position of the symbol
x1: The attribute describes the lower horizontal position of the symbol
y1: The attribute describes the lower vertical position of the symbol
text: The attribute describes line text
fontname: The attribute describes line Font
size: The attribute describes line size
no_change_font_name: Attribute describing that the font of the string has not changed
no_change_text_size: Attribute describing that the size of the string has not changed
page: The attribute describes the page on which the line is located
chars: The attribute list of characters that make up the string
----------
_x0: float
The attribute describes the upper horizontal position of the symbol
_y0: float
The attribute describes the upper vertical position of the symbol
_x1: float
The attribute describes the lower horizontal position of the symbol
_y1: float
The attribute describes the lower vertical position of the symbol
_text: str
The attribute describes line text
_font_names: list
The attribute describes line Fonts
_sizes: list
The attribute describes line sizes
_no_change_font_name: bool
The attribute describing that the font of the string has not changed
_no_change_text_size: bool
The attribute describing that the size of the string has not changed
_page: int
The attribute describes the page on which the line is located
_chars: list
The attribute list of characters that make up the string
"""
def __init__(self,x0,y0,x1,y1,text,fontname,size,no_change_font_name,no_change_text_size,page,chars):
self.x0 = x0
self.x1 = x1
self.y0 = y0
self.y1 = y1
self.text = text
self.fontname = fontname
self.size = size
self.no_change_font_name = no_change_font_name
self.no_change_text_size = no_change_text_size
self.page = page
self.chars = chars
_x0: float
_x1: float
_y0: float
_y1: float
_text: str
_font_names: list
_text_sizes: list
_no_change_font_name: bool
_no_change_text_size: bool
_number_of_page: int
_chars: list
@property
def x0(self):
......@@ -57,12 +71,12 @@ class Line:
return self._text
@property
def fontname(self):
return self._fontname
def font_names(self):
return self._font_names
@property
def size(self):
return self._size
def text_sizes(self):
return self._text_sizes
@property
def no_change_font_name(self):
......@@ -73,8 +87,8 @@ class Line:
return self._no_change_text_size
@property
def page(self):
return self._page
def number_of_page(self):
return self._number_of_page
@property
def chars(self):
......@@ -96,13 +110,13 @@ class Line:
def text(self, value):
self._text = value
@fontname.setter
def fontname(self, value):
self._fontname = value
@font_names.setter
def font_names(self, value):
self._font_names = value
@size.setter
def size(self, value):
self._size = value
@text_sizes.setter
def text_sizes(self, value):
self._text_sizes = value
@no_change_font_name.setter
def no_change_font_name(self, value):
......@@ -112,10 +126,10 @@ class Line:
def no_change_text_size(self, value):
self._no_change_text_size = value
@page.setter
def page(self, value):
self._page = value
@number_of_page.setter
def number_of_page(self, value):
self._number_of_page = value
@chars.setter
def chars(self, value):
self._chars = value
\ No newline at end of file
self._chars = value
from dataclasses import dataclass, field
from src.pdf.pdfclasses.Line import Line
@dataclass()
class PdfParagraph:
"""
Description: A class is a pdf paragraph and its attributes
----------
Parameters:
lines: The attribute describes list of all paragraph lines
indent: The attribute describes indent from the red line of the paragraph
spaces: The attribute describes list of line spacing of all paragraph lines
line_spacing: The attribute describes line spacing in a paragraph
fontname: The attribute describes paragraph Font
text_size: The attribute describes paragraph size
nochangeFontName: Attribute describing that the font of the paragraph has not changed
nochangeSize: Attribute describing that the size of the paragraph has not changed
----------
_lines: list
The attribute describes list of all paragraph lines
_indent: float
The attribute describes indent from the red line of the paragraph
_spaces: list
The attribute describes list of line spacing of all paragraph lines
_line_spacing: float
The attribute describes line spacing in a paragraph
_font_name: str
The attribute describes paragraph Font
_text_size: float
The attribute describes paragraph size
_no_change_font_name: bool
Attribute describing that the font of the paragraph has not changed
_no_change_text_size: bool
Attribute describing that the size of the paragraph has not changed
"""
def __init__(self):
self.lines = []
self.indent = 0
self.spaces = []
self.line_spacing = 0
self.fontname = None
self.text_size = 0
self.no_change_font_name = True
self.no_change_text_size = True
_indent: float = None
_line_spacing: float = None
_font_name: str = None
_text_size: float = None
_no_change_font_name: bool = None
_no_change_text_size: bool = None
_spaces: list = field(default_factory=list)
_lines: list[Line] = field(default_factory=list)
@property
def lines(self):
......@@ -42,8 +56,8 @@ class PdfParagraph:
return self._line_spacing
@property
def fontname(self):
return self._fontname
def font_name(self):
return self._font_name
@property
def text_size(self):
......@@ -73,9 +87,9 @@ class PdfParagraph:
def line_spacing(self, value):
self._line_spacing = value
@fontname.setter
def fontname(self, value):
self._fontname = value
@font_name.setter
def font_name(self, value):
self._font_name = value
@text_size.setter
def text_size(self, value):
......@@ -87,4 +101,4 @@ class PdfParagraph:
@no_change_text_size.setter
def no_change_text_size(self, value):
self._no_change_text_size = value
self._no_change_text_size = value
\ No newline at end of file
......@@ -5,33 +5,33 @@ class PDFTable():
"""
Description: The class is a pdf table and its text
----------
Parameters:
__table - attribute represents the table itself and its attributes
__text - attribute representing tabular text
----------
_table - attribute represents the table itself and its attributes
_text - attribute representing tabular text
"""
def __init__(self, table):
self.__table = table
self.__text = []
self._table = table
self._text = []
def addText(self, text):
self.text.append(text)
@property
def table(self):
return self.__table
return self._table
@table.setter
def table(self, table):
self.__table = table
self._table = table
@property
def text(self):
return self.__text
return self._text
@text.setter
def text(self, text):
self.__text = text
self._text = text
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment