Skip to content

Commit e9526d6

Browse files
After adding aspose licenses
1 parent 10b11ee commit e9526d6

File tree

12 files changed

+103
-5
lines changed

12 files changed

+103
-5
lines changed

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/openize-markitdown.iml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/markitdown/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ def run_conversion():
66
processor = DocumentProcessor()
77

88
# Process PDF file
9-
# processor.process_document("d://signform.pdf", insert_into_llm=False)
9+
# processor.process_document("file.pdf", insert_into_llm=False)
1010

1111
# Process Word document (.docx)
12-
# processor.process_document("d://example.docx", insert_into_llm=False)
12+
# processor.process_document("example.docx", insert_into_llm=False)
1313

1414
# Process PowerPoint file (.pptx)
15-
# processor.process_document("d://presentation.pptx", insert_into_llm=False)
15+
# processor.process_document("presentation.pptx", insert_into_llm=False)
1616

1717
# Process Excel file (.xlsx)
18-
# processor.process_document("d://data.xlsx", insert_into_llm=False)
18+
# processor.process_document("data.xlsx", insert_into_llm=False)
1919

2020
if __name__ == "__main__":
2121
run_conversion()

packages/markitdown/setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ where = src
3939
console_scripts =
4040
markitdown = openize.markitdown.main:main
4141

42+
[aspose-licenses]
43+
use_aspose_license = true
44+
license_file_path = /path/to/Aspose.Total.lic

packages/markitdown/src/openize/__init__.py

Whitespace-only changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import configparser
2+
import os
3+
4+
# Import Aspose libraries
5+
try:
6+
import aspose.words as aw
7+
import aspose.cells as ac
8+
import aspose.slides as asl
9+
10+
except ImportError:
11+
print("Warning: Some Aspose libraries are not installed.")
12+
13+
class Config:
14+
USE_ASPOSE_LICENSE = False # Default: No license
15+
LICENSE_FILE_PATH = "Aspose.Total.lic" # Default license file name
16+
17+
@staticmethod
18+
def load_config():
19+
"""Load settings from setup.cfg"""
20+
config = configparser.ConfigParser()
21+
config.read(os.path.join(os.path.dirname(__file__), "../../setup.cfg"))
22+
23+
if "aspose-licenses" in config:
24+
Config.USE_ASPOSE_LICENSE = config["aspose-licenses"].getboolean("use_aspose_license", False)
25+
Config.LICENSE_FILE_PATH = config["aspose-licenses"].get("license_file_path", "Aspose.Total.lic")
26+
27+
@staticmethod
28+
def set_aspose_license():
29+
"""Apply Aspose license to all supported products"""
30+
if not Config.USE_ASPOSE_LICENSE:
31+
print("Aspose license is disabled. Using evaluation mode.")
32+
return
33+
34+
try:
35+
license_path = Config.LICENSE_FILE_PATH
36+
print(f"Applying Aspose license from {license_path}")
37+
38+
# Set license for all available Aspose products
39+
for lib in [aw, ac, asl]:
40+
if lib:
41+
try:
42+
license = lib.License()
43+
license.set_license(license_path)
44+
print(f"License applied for {lib.__name__}")
45+
except Exception as e:
46+
print(f"Warning: Could not set license for {lib.__name__}. {e}")
47+
48+
except Exception as e:
49+
print(f"Error: Failed to apply Aspose license. {e}")
50+
51+
# Load config and apply license at startup
52+
Config.load_config()
53+
Config.set_aspose_license()

packages/markitdown/src/openize/markitdown/converters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import aspose.words as aw
66
import aspose.cells as ac
77
import aspose.slides as asl
8+
from config import Config
89

910

1011
from abc import ABC, abstractmethod

packages/markitdown/tests/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_converter_factory():
4141
assert isinstance(ConverterFactory.get_converter(".pdf"), PDFConverter)
4242
assert isinstance(ConverterFactory.get_converter(".xlsx"), ExcelConverter)
4343
assert isinstance(ConverterFactory.get_converter(".pptx"), PowerPointConverter)
44-
assert ConverterFactory.get_converter(".txt") is None # No converter for .txt
44+
4545

4646
# Test LLM Strategy
4747
def test_save_locally(sample_md_file):

0 commit comments

Comments
 (0)