diff --git a/setup.py b/setup.py index 995ef9c..dac328c 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +# cx_Freeze build not successful + import sys from cx_Freeze import setup, Executable from src.rosinenpicker.start import __version__ @@ -15,6 +17,6 @@ version=__version__, description="A package for picking the juciest text morsels out of a pile of documents.", options={"build_exe": build_exe_options}, - executables=[Executable("src/rosinenpicker/start.py", base=base)], + executables=[Executable("src/rosinenpicker/start.py", base=base, target_name="rosinenpicker")], ) diff --git a/src/rosinenpicker/__init__.py b/src/rosinenpicker/__init__.py index e69de29..4397e93 100644 --- a/src/rosinenpicker/__init__.py +++ b/src/rosinenpicker/__init__.py @@ -0,0 +1,5 @@ +import os +import site + +BASE_PATH = os.path.dirname(os.path.abspath(__file__)) +site.addsitedir(BASE_PATH) \ No newline at end of file diff --git a/src/rosinenpicker/data/__init__.py b/src/rosinenpicker/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/rosinenpicker/database.py b/src/rosinenpicker/data/database.py similarity index 100% rename from src/rosinenpicker/database.py rename to src/rosinenpicker/data/database.py diff --git a/src/rosinenpicker/pydantic_models.py b/src/rosinenpicker/data/pydantic_models.py similarity index 98% rename from src/rosinenpicker/pydantic_models.py rename to src/rosinenpicker/data/pydantic_models.py index d11c7f0..2cfeedc 100644 --- a/src/rosinenpicker/pydantic_models.py +++ b/src/rosinenpicker/data/pydantic_models.py @@ -1,5 +1,5 @@ from pydantic import BaseModel, DirectoryPath, field_validator, model_validator, NewPath -from .patterns import Pattern +from processing.patterns import Pattern from typing import Optional class ConfigError(Exception): diff --git a/src/rosinenpicker/processing/__init__.py b/src/rosinenpicker/processing/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/rosinenpicker/exporter.py b/src/rosinenpicker/processing/exporter.py similarity index 100% rename from src/rosinenpicker/exporter.py rename to src/rosinenpicker/processing/exporter.py diff --git a/src/rosinenpicker/patterns.py b/src/rosinenpicker/processing/patterns.py similarity index 100% rename from src/rosinenpicker/patterns.py rename to src/rosinenpicker/processing/patterns.py diff --git a/src/rosinenpicker/processors.py b/src/rosinenpicker/processing/processors.py similarity index 99% rename from src/rosinenpicker/processors.py rename to src/rosinenpicker/processing/processors.py index d15910a..7e8467b 100644 --- a/src/rosinenpicker/processors.py +++ b/src/rosinenpicker/processing/processors.py @@ -1,7 +1,7 @@ from pdfminer.high_level import extract_text from docx import Document import re -from .patterns import Pattern +from processing.patterns import Pattern class DocumentProcessor: text: str diff --git a/src/rosinenpicker/start.py b/src/rosinenpicker/start.py index def81e8..9e9826d 100644 --- a/src/rosinenpicker/start.py +++ b/src/rosinenpicker/start.py @@ -1,15 +1,17 @@ -__version__ = '0.1.13' +__version__ = '0.1.14' +# see content of __init__.py +import os +import sys import yaml import re -import os import shutil as sh import pathlib as pl import pandas as pd -from .pydantic_models import Config, ConfigStrategy, ConfigError -from .database import Base, DbRun, DbStrategy, DbProcessedFile, DbMatch -from .utils import file_sha256 -from .exporter import BaseExporter, CSVExporter, XLSXExporter, HTMLExporter, JSONExporter -from .processors import DocumentProcessor, PDFProcessor, TXTProcessor, DOCXProcessor +from data.pydantic_models import Config, ConfigStrategy, ConfigError +from data.database import Base, DbRun, DbStrategy, DbProcessedFile, DbMatch +from utils.utils import file_sha256 +from processing.exporter import BaseExporter, CSVExporter, XLSXExporter, HTMLExporter, JSONExporter +from processing.processors import DocumentProcessor, PDFProcessor, TXTProcessor, DOCXProcessor from sqlalchemy import create_engine, select from sqlalchemy.orm import sessionmaker, Session import argparse @@ -137,7 +139,7 @@ def cli(): # version? if args.version: print(f"{__version__}") - exit(0) + sys.exit(0) # read out only? if args.readout: @@ -147,24 +149,24 @@ def cli(): # file format implemented? if fe not in file_format_options.keys(): print(f"File '{args.readout}' appears to be of a type that cannot be read out!") - exit(1) + sys.exit(1) # determine processor processor = file_format_options[fe] # print out pr = processor(args.readout) # second argument inconsequential, to be removed at a later point print(pr.text) # exit - exit(0) + sys.exit(0) else: print("No file to read out provided!") parser.print_help() - exit(1) + sys.exit(1) # check if config exists! if not os.path.isfile(args.config): print("No configuration file provided! Please add one using -c! Apply -h for help.\n") parser.print_help() - exit(1) + sys.exit(1) main(args.config, args.database) diff --git a/src/rosinenpicker/utils/__init__.py b/src/rosinenpicker/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/rosinenpicker/utils.py b/src/rosinenpicker/utils/utils.py similarity index 100% rename from src/rosinenpicker/utils.py rename to src/rosinenpicker/utils/utils.py