Skip to content

Commit

Permalink
TLDR-369 review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NastyBoget committed Aug 1, 2023
1 parent 1fc0371 commit 84b35aa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions dedoc/data_structures/parsed_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def __init__(self,
self.metadata = metadata
self.content = content
self.attachments = [] if attachments is None else attachments
self.version = dedoc.__version__
self.warnings = warnings if warnings is not None else []

def add_attachments(self, new_attachment: List["ParsedDocument"]) -> None:
Expand All @@ -40,7 +39,7 @@ def set_metadata(self, metadata: DocumentMetadata) -> None:

def to_dict(self, depth: int = 0) -> dict:
res = OrderedDict()
res["version"] = self.version
res["version"] = dedoc.__version__
res["warnings"] = self.warnings
res["content"] = self.content.to_dict() if self.content is not None else []
res["metadata"] = self.metadata.to_dict()
Expand All @@ -54,7 +53,7 @@ def get_api_dict(api: Api, depth: int = 0, name: str = 'ParsedDocument') -> Mode
return api.model(name, {
'content': fields.Nested(DocumentContent.get_api_dict(api), description='Document content structure'),
'metadata': fields.Nested(DocumentMetadata.get_api_dict(api), allow_null=False, skip_none=True, description='Document meta information'),
'version': fields.String(description='the version of the program that parsed this document', example="2020.07.11"),
'version': fields.String(description='the version of the program that parsed this document', example="0.9.1"),
'warnings': fields.List(fields.String(description='list of warnings and possible errors', example="DOCX: seems that document corrupted")),
'attachments': fields.List(fields.Nested(api.model('others_ParsedDocument', {})), description='structure of attachments', required=False)
if depth == 10 # TODO delete this
Expand Down
3 changes: 1 addition & 2 deletions dedoc/dedoc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ def parse(self, file_path: str, parameters: Optional[Dict[str, str]] = None) ->
"""
parameters = {} if parameters is None else parameters

file_dir, file_name = os.path.split(file_path)
try:
return self.__parse_no_error_handling(file_path=file_path, parameters=parameters)
except DedocException as e:
e.filename = file_name
file_dir, file_name = os.path.split(file_path)
e.filename = file_name
e.metadata = BaseMetadataExtractor._get_base_meta_information(directory=file_dir, filename=file_name, name_actual=file_name)
raise e

Expand Down
4 changes: 2 additions & 2 deletions dedoc/manager_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"""MANAGER SETTINGS"""


def _get_manager_config(config: dict) -> dict:
def get_manager_config(config: dict) -> dict:
converters = [
DocxConverter(config=config),
ExcelConverter(config=config),
Expand Down Expand Up @@ -125,7 +125,7 @@ def getInstance(cls: "ConfigurationManager") -> "ConfigurationManager":

def initConfig(self, config: dict, new_config: dict = None) -> None:
if new_config is None:
self.__config = _get_manager_config(config)
self.__config = get_manager_config(config)
else:
self.__config = new_config

Expand Down
2 changes: 1 addition & 1 deletion docs/source/dedoc_api_usage/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Api parameters description
Use `true` value to enable this behaviour.

* - attachments_dir
- any string with a valid path
- optional string with a valid path
- None
- The path to the directory where document's attached files can be saved instead of a temporary directory.

Expand Down

0 comments on commit 84b35aa

Please sign in to comment.