Unverified Commit d745abc0 authored by Tereshchenko Vlad's avatar Tereshchenko Vlad Committed by GitHub
Browse files

Merge pull request #30 from algormx/fix/unified_classes

[Fix]: wrapped unified classes with @dataclass
1 merge request!27[Feat]: updating the architecture of the ODT document parsing module
Showing with 65 additions and 88 deletions
+65 -88
from dataclasses import dataclass
@dataclass
class DrawFrame:
"""
Description: Draw frame class for ODT document.
Parameters:
Attributes:
_frame_style_name - attribute specifies the style of current frame,
_frame_name - attribute specifies the name of current frame,
_frame_anchor_type - attribute specifies how a frame is bound to a text document,
......@@ -20,22 +25,19 @@ class DrawFrame:
to the ending resource.
"""
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
self._frame_x = frame_x
self._frame_y = frame_y
self._frame_width = frame_width
self._frame_height = frame_height
self._frame_rel_width = frame_rel_width
self._frame_rel_height = frame_rel_height
self._image_href = image_href
self._image_type = image_type
self._image_show = image_show
self._image_actuate = image_actuate
_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
@property
def frame_style_name(self):
......@@ -140,12 +142,3 @@ class DrawFrame:
@image_actuate.setter
def image_actuate(self, value):
self._image_actuate = value
def __repr__(self):
return str('{_frame_style_name: ' + self._frame_style_name + '; _frame_name: ' + self._frame_name +
'; _frame_anchor_type: ' + self._frame_anchor_type + '; _frame_x: ' + str(self._frame_x) +
'; _frame_y: ' + str(self._frame_y) + '; _frame_width: ' + str(self._frame_width) +
'; _frame_height: ' + str(self._frame_height) + '; _frame_rel_width: ' + self._frame_rel_width +
'; _frame_rel_height: ' + self._frame_rel_height + '; _image_href: ' + self._image_href +
'; _image_type: ' + self._image_type + '; _image_show: ' + self._image_show + '; _image_actuate: ' +
self._image_actuate + '}')
\ No newline at end of file
from dataclasses import dataclass
@dataclass
class Table:
"""
Description: Table class for ODT document.
Parameters:
Attributes:
_table_name - attribute specifies the name of a table,
_table_family - attribute specifies the family of a style (style:family),
_table_master_page_name - attribute specifies the name of element that contains the content
......@@ -13,14 +18,12 @@ class Table:
_table_properties_align - attribute specifies the horizontal alignment of a table (table: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
self._table_properties_width = table_properties_width
self._table_properties_margin_left = table_properties_margin_left
self._table_properties_align = table_properties_align
_table_name: str
_table_family: str
_table_master_page_name: str
_table_properties_width: float
_table_properties_margin_left: float
_table_properties_align: str
@property
def table_name(self):
......@@ -69,10 +72,3 @@ class Table:
@table_properties_align.setter
def table_properties_align(self, value):
self._table_properties_align = value
def __repr__(self):
return str('{_table_name: ' + self._table_name + '; _table_family: ' + self._table_family +
'; _table_master_page_name: ' + self._table_master_page_name + '; _table_properties_width: ' +
str(self._table_properties_width) + '; _table_properties_margin_left: ' +
str(self._table_properties_margin_left) + '; _table_properties_align: ' +
self._table_properties_align + '}')
\ No newline at end of file
from dataclasses import dataclass
@dataclass
class TableCell:
"""
Description: Table cell class for ODT document.
Parameters:
Attributes:
_cell_name - attribute specifies the name of a cell,
_cell_family - attribute specifies the family of a style (style:family),
_cell_properties_border - attribute specifies the property for setting the same width, color, and style for
......@@ -20,17 +25,14 @@ class TableCell:
or inline-area.
"""
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
self._cell_properties_writing_mode = cell_properties_writing_mode
self._cell_properties_padding_top = cell_properties_padding_top
self._cell_properties_padding_left = cell_properties_padding_left
self._cell_properties_padding_bottom = cell_properties_padding_bottom
self._cell_properties_padding_right = cell_properties_padding_right
_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
@property
def cell_name(self):
......@@ -95,12 +97,3 @@ class TableCell:
@cell_properties_padding_right.setter
def cell_properties_padding_right(self, value):
self._cell_properties_padding_right = value
def __repr__(self):
return str('{_cell_name: ' + self._cell_name + '; _cell_family: ' + self._cell_family +
'; _cell_properties_border: ' + str(self._cell_properties_border) +
'; _cell_properties_writing_mode: ' + self._cell_properties_writing_mode +
'; _cell_properties_padding_top: ' + str(self._cell_properties_padding_top) +
'; _cell_properties_padding_left: ' + str(self._cell_properties_padding_left) +
'; _cell_properties_padding_bottom: ' + str(self._cell_properties_padding_bottom) +
'; _cell_properties_padding_right: ' + str(self._cell_properties_padding_right) + '}')
\ No newline at end of file
from dataclasses import dataclass
@dataclass
class TableColumn:
"""
Description: Table column class for ODT document.
Parameters:
Attributes:
_column_name - attribute specifies the name of a column,
_column_family - attribute specifies the family of a style (style:family),
_column_properties_column_width - attribute specifies a fixed width for a column (style:table-column-properties),
......@@ -10,12 +15,10 @@ class TableColumn:
automatically if content in the column changes.
"""
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
self._column_properties_use_optimal_column_width = column_properties_use_optimal_column_width
_column_name: str
_column_family: str
_column_properties_column_width: float
_column_properties_use_optimal_column_width: float
@property
def column_name(self):
......@@ -48,9 +51,3 @@ class TableColumn:
@column_properties_use_optimal_column_width.setter
def column_properties_use_optimal_column_width(self, value):
self._column_properties_use_optimal_column_width = value
def __repr__(self):
return str('{_column_name: ' + self._column_name + '; _column_family: ' + self._column_family +
'; _column_properties_column_width: ' + str(self._column_properties_column_width) +
'; _column_properties_use_optimal_column_width: ' +
str(self._column_properties_use_optimal_column_width) + '}')
\ No newline at end of file
from dataclasses import dataclass
@dataclass
class TableRow:
"""
Description: Table row class for ODT document.
Parameters:
Attributes:
_row_name - attribute specifies the name of a row,
_row_family - attribute specifies the family of a style (style:family),
_row_properties_min_row_height - attribute specifies a fixed minimum height for a row
......@@ -11,11 +16,10 @@ class TableRow:
automatically if content in the row changes.
"""
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
self._row_properties_use_optimal_row_height = row_properties_use_optimal_row_height
_row_name:str
_row_family:str
_row_properties_min_row_height:float
_row_properties_use_optimal_row_height:float
@property
def row_name(self):
......@@ -48,9 +52,3 @@ class TableRow:
@row_properties_use_optimal_row_height.setter
def row_properties_use_optimal_row_height(self, value):
self._row_properties_use_optimal_row_height = value
def __repr__(self):
return str('{_row_name: ' + self._row_name + '; _row_family: ' + self._row_family +
'; _row_properties_min_row_height: ' + str(self._row_properties_min_row_height) +
'; _row_properties_use_optimal_row_height: ' +
str(self._row_properties_use_optimal_row_height) + '}')
\ No newline at end of file
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