openconvert 1.0.0__py3-none-any.whl → 1.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
openconvert/__init__.py CHANGED
@@ -9,13 +9,13 @@ import asyncio
9
9
  from pathlib import Path
10
10
  from typing import Optional, List
11
11
 
12
- __version__ = "1.0.0"
12
+ __version__ = "1.1.1"
13
13
  __author__ = "OpenAgents Team"
14
14
  __email__ = "team@openagents.com"
15
15
 
16
16
  # Import the async convert function
17
17
  try:
18
- from .openconvert_cli import convert as _async_convert
18
+ from openconvert.openconvert_cli import convert as _async_convert
19
19
  except ImportError:
20
20
  from openconvert_cli import convert as _async_convert
21
21
 
@@ -23,90 +23,78 @@ except ImportError:
23
23
  def convert(
24
24
  input_files: List[Path],
25
25
  output_path: Path,
26
- from_format: Optional[str] = None,
27
- to_format: Optional[str] = None,
28
- prompt: Optional[str] = None,
29
26
  host: str = "network.openconvert.ai",
30
- port: int = 8765
27
+ port: int = 8765,
31
28
  ) -> bool:
32
- """Convert files using the OpenConvert network.
33
-
34
- This is a synchronous wrapper around the async convert function.
29
+ """
30
+ Convert files using the OpenConvert network.
35
31
 
36
32
  Args:
37
- input_files: List of input file paths
38
- output_path: Output file or directory path
39
- from_format: Source MIME type (optional, will be detected)
40
- to_format: Target MIME type (optional, will be detected from output extension)
41
- prompt: Optional conversion prompt
42
- host: Network host to connect to
43
- port: Network port to connect to
33
+ input_files: List of input file paths to convert
34
+ output_path: Output file path
35
+ host: OpenConvert network host (default: network.openconvert.ai)
36
+ port: OpenConvert network port (default: 8765)
44
37
 
45
38
  Returns:
46
- bool: True if conversion succeeded
47
-
48
- Example:
49
- >>> from openconvert import convert
50
- >>> from pathlib import Path
51
- >>> success = convert(
52
- ... input_files=[Path("document.txt")],
53
- ... output_path=Path("document.pdf")
54
- ... )
39
+ bool: True if conversion successful, False otherwise
55
40
  """
56
- return asyncio.run(_async_convert(
57
- input_files=input_files,
58
- output_path=output_path,
59
- from_format=from_format,
60
- to_format=to_format,
61
- prompt=prompt,
62
- host=host,
63
- port=port
64
- ))
41
+ try:
42
+ result = asyncio.run(_async_convert(
43
+ input_files=input_files,
44
+ output_path=output_path,
45
+ host=host,
46
+ port=port
47
+ ))
48
+ return result
49
+ except Exception as e:
50
+ print(f"Conversion failed: {e}")
51
+ return False
65
52
 
66
53
 
67
54
  def convert_file(
68
- input_file: str,
69
- output_file: str,
70
- from_format: Optional[str] = None,
71
- to_format: Optional[str] = None,
72
- prompt: Optional[str] = None,
55
+ input_path: str,
56
+ output_path: str,
73
57
  host: str = "network.openconvert.ai",
74
58
  port: int = 8765
75
59
  ) -> bool:
76
- """Convert a single file using the OpenConvert network.
77
-
78
- Convenience function for single file conversions with string paths.
60
+ """
61
+ Convert a single file using the OpenConvert network.
79
62
 
80
63
  Args:
81
- input_file: Input file path (string)
82
- output_file: Output file path (string)
83
- from_format: Source MIME type (optional, will be detected)
84
- to_format: Target MIME type (optional, will be detected from output extension)
85
- prompt: Optional conversion prompt
86
- host: Network host to connect to
87
- port: Network port to connect to
64
+ input_path: Path to input file
65
+ output_path: Path for output file
66
+ host: OpenConvert network host (default: network.openconvert.ai)
67
+ port: OpenConvert network port (default: 8765)
88
68
 
89
69
  Returns:
90
- bool: True if conversion succeeded
70
+ bool: True if conversion successful, False otherwise
91
71
 
92
72
  Example:
93
73
  >>> from openconvert import convert_file
94
74
  >>> success = convert_file("document.txt", "document.pdf")
95
- >>> success = convert_file(
96
- ... "data.csv",
97
- ... "report.pdf",
98
- ... prompt="Create a professional report"
99
- ... )
75
+ >>> if success:
76
+ ... print("Conversion completed!")
100
77
  """
101
- return convert(
102
- input_files=[Path(input_file)],
103
- output_path=Path(output_file),
104
- from_format=from_format,
105
- to_format=to_format,
106
- prompt=prompt,
107
- host=host,
108
- port=port
109
- )
78
+ try:
79
+ input_files = [Path(input_path)]
80
+ output_file = Path(output_path)
81
+
82
+ return convert(
83
+ input_files=input_files,
84
+ output_path=output_file,
85
+ host=host,
86
+ port=port
87
+ )
88
+ except Exception as e:
89
+ print(f"File conversion failed: {e}")
90
+ return False
110
91
 
111
92
 
112
- __all__ = ["convert", "convert_file"]
93
+ # Export main functions
94
+ __all__ = [
95
+ "convert",
96
+ "convert_file",
97
+ "__version__",
98
+ "__author__",
99
+ "__email__",
100
+ ]
openconvert/__main__.py CHANGED
@@ -7,7 +7,7 @@ Allows running the OpenConvert CLI as a module:
7
7
  """
8
8
 
9
9
  import sys
10
- from .openconvert_cli import main
10
+ from openconvert.openconvert_cli import main
11
11
 
12
12
  if __name__ == "__main__":
13
13
  sys.exit(main())
@@ -25,10 +25,7 @@ current_dir = Path(__file__).resolve().parent
25
25
  openagents_root = current_dir.parent.parent
26
26
  sys.path.insert(0, str(openagents_root / "src"))
27
27
 
28
- try:
29
- from .client import OpenConvertClient
30
- except ImportError:
31
- from client import OpenConvertClient
28
+ from openconvert.client import OpenConvertClient
32
29
 
33
30
  # Set up logging
34
31
  logging.basicConfig(
@@ -89,7 +86,9 @@ def validate_args(args: argparse.Namespace) -> bool:
89
86
  """
90
87
  # For conversion operations, input and output are required
91
88
  if not args.input or not args.output:
92
- logger.error("Input (-i) and output (-o) arguments are required for conversion")
89
+ logger.error("Input and output are required for conversion")
90
+ logger.error("Usage: openconvert <input> <output>")
91
+ logger.error(" or: openconvert -i <input> -o <output>")
93
92
  return False
94
93
 
95
94
  # Check input exists
@@ -105,10 +104,17 @@ def validate_args(args: argparse.Namespace) -> bool:
105
104
  logger.error(f"Output directory does not exist: {output_dir}")
106
105
  return False
107
106
 
108
- # If input is a directory, require --from and --to
107
+ # If input is a directory, require --from and --to (positional args don't support directory conversion)
109
108
  if input_path.is_dir():
110
109
  if not args.from_format or not args.to_format:
111
110
  logger.error("When input is a directory, --from and --to formats must be specified")
111
+ logger.error("Example: openconvert -i docs/ -o converted/ --from text/plain --to application/pdf")
112
+ return False
113
+
114
+ # For directory conversion, must use flag arguments
115
+ if hasattr(args, 'input_file') and (args.input_file or args.output_file):
116
+ logger.error("Directory conversion requires -i and -o flags, not positional arguments")
117
+ logger.error("Example: openconvert -i docs/ -o converted/ --from text/plain --to application/pdf")
112
118
  return False
113
119
 
114
120
  return True
@@ -391,24 +397,36 @@ def main() -> int:
391
397
  """Main CLI entry point.
392
398
 
393
399
  Returns:
394
- int: Exit code (0 = success, 1 = error)
400
+ int: Exit code (0 for success, 1 for error)
395
401
  """
396
402
  parser = argparse.ArgumentParser(
397
- description="OpenConvert CLI - Connect to OpenAgents network for file conversion",
403
+ prog="openconvert",
404
+ description="Connect to OpenConvert OpenAgents network for file conversions",
398
405
  formatter_class=argparse.RawDescriptionHelpFormatter,
399
- epilog="""
406
+ epilog=f"""
400
407
  Examples:
401
- # Convert single file (formats auto-detected)
402
- openconvert -i document.txt -o document.pdf
408
+ # Simple file conversion (positional arguments)
409
+ openconvert input.txt output.pdf
410
+ openconvert image.png image.jpg
411
+
412
+ # Using flags (traditional way)
413
+ openconvert -i input.txt -o output.pdf
414
+ openconvert -i image.png -o image.jpg
403
415
 
404
- # Convert directory with specific formats
405
- openconvert -i images/ -o converted/ --from image/png --to application/pdf
416
+ # Directory conversion (requires format specification)
417
+ openconvert -i docs/ -o converted/ --from text/plain --to application/pdf
418
+
419
+ # Convert with format specification
420
+ openconvert input.data output.pdf --from text/csv --to application/pdf
406
421
 
407
422
  # Convert with custom prompt
408
- openconvert -i data.csv -o report.pdf --prompt "Create a formatted report with charts"
423
+ openconvert data.csv report.pdf --prompt "Create a formatted report with charts"
409
424
 
410
425
  # Specify network connection
411
- openconvert -i file.doc -o file.md --host remote.server.com --port 8765
426
+ openconvert file.doc file.md --host remote.server.com --port 8765
427
+
428
+ # List available formats
429
+ openconvert --list-formats
412
430
 
413
431
  Supported formats include:
414
432
  Documents: txt, pdf, docx, html, md, rtf, csv, xlsx
@@ -421,7 +439,19 @@ Supported formats include:
421
439
  """
422
440
  )
423
441
 
424
- # Arguments (required for conversion, optional for discovery)
442
+ # Positional arguments (optional)
443
+ parser.add_argument(
444
+ "input_file",
445
+ nargs="?",
446
+ help="Input file path (alternative to -i/--input)"
447
+ )
448
+ parser.add_argument(
449
+ "output_file",
450
+ nargs="?",
451
+ help="Output file path (alternative to -o/--output)"
452
+ )
453
+
454
+ # Traditional flag arguments (for backward compatibility and directory operations)
425
455
  parser.add_argument(
426
456
  "-i", "--input",
427
457
  help="Input file or directory path"
@@ -482,6 +512,12 @@ Supported formats include:
482
512
  # Parse arguments
483
513
  args = parser.parse_args()
484
514
 
515
+ # Merge positional and flag arguments (positional takes precedence)
516
+ if args.input_file:
517
+ args.input = args.input_file
518
+ if args.output_file:
519
+ args.output = args.output_file
520
+
485
521
  # Configure logging level
486
522
  if args.quiet:
487
523
  logging.getLogger().setLevel(logging.ERROR)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openconvert
3
- Version: 1.0.0
3
+ Version: 1.1.1
4
4
  Summary: CLI tool for connecting to OpenConvert OpenAgents network for file conversion
5
5
  Home-page: https://github.com/acenta-ai/openconvert
6
6
  Author: OpenAgents Team
@@ -35,7 +35,7 @@ Requires-Python: >=3.8
35
35
  Description-Content-Type: text/markdown
36
36
  License-File: LICENSE
37
37
  Requires-Dist: pyyaml>=5.4.0
38
- Requires-Dist: openagents>=0.5.0
38
+ Requires-Dist: openagents>=0.5.1
39
39
  Provides-Extra: dev
40
40
  Requires-Dist: pytest>=6.0.0; extra == "dev"
41
41
  Requires-Dist: pytest-asyncio>=0.18.0; extra == "dev"
@@ -0,0 +1,10 @@
1
+ openconvert/__init__.py,sha256=TTh9NZJNnWc9GDxhmBkSjUS5t7QR_9ozMW7TS011dMg,2555
2
+ openconvert/__main__.py,sha256=IApP1DLv-K00aTUTB_yrNOnakkvq-6O1ackzJ25xbcQ,274
3
+ openconvert/client.py,sha256=qqidLnLDwF-4f5-WPutrZkNV-CGzFfm4C741NbKOIcE,14954
4
+ openconvert/openconvert_cli.py,sha256=JFHkM8cpAsJLsw60Wls_og0SxlUDrvNOnE1I69zN1WM,19655
5
+ openconvert-1.1.1.dist-info/licenses/LICENSE,sha256=dHQW0DXhwJm5PhaWpJsZmcrC2OgU1sPDO66nVLmL8Ek,1072
6
+ openconvert-1.1.1.dist-info/METADATA,sha256=NhrOF_UtZ3nc38w-ZnU2pUSVaBZ2t0iYSB0Wx-6ZQL4,15307
7
+ openconvert-1.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ openconvert-1.1.1.dist-info/entry_points.txt,sha256=Jhi6MBetmmpMK_CpeEkzx44KFHPsuTBCZ0UzUrGZ5dM,65
9
+ openconvert-1.1.1.dist-info/top_level.txt,sha256=BQWm5PHwGlf1DRAcesIki9gKa0D27YCXJLeqj9DQ-es,12
10
+ openconvert-1.1.1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- openconvert/__init__.py,sha256=jGaXnKh8u4eq3Ycq5d6G--AwYfs5PSw-MJbI1cPLw1U,3253
2
- openconvert/__main__.py,sha256=9bqNhW4-s5yWNZGkvnUy6UCb8eaZiQAFfgeuNghDdxg,263
3
- openconvert/client.py,sha256=qqidLnLDwF-4f5-WPutrZkNV-CGzFfm4C741NbKOIcE,14954
4
- openconvert/openconvert_cli.py,sha256=HvWUc76dvzuoXcMWMLnh8LEXrMcT4pJCqY5bLvXaGuc,18179
5
- openconvert-1.0.0.dist-info/licenses/LICENSE,sha256=dHQW0DXhwJm5PhaWpJsZmcrC2OgU1sPDO66nVLmL8Ek,1072
6
- openconvert-1.0.0.dist-info/METADATA,sha256=HySK5XSYrR3EzQKvG_oTV7_TQiE9Ckt7G7kuLSUjZsk,15307
7
- openconvert-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- openconvert-1.0.0.dist-info/entry_points.txt,sha256=Jhi6MBetmmpMK_CpeEkzx44KFHPsuTBCZ0UzUrGZ5dM,65
9
- openconvert-1.0.0.dist-info/top_level.txt,sha256=BQWm5PHwGlf1DRAcesIki9gKa0D27YCXJLeqj9DQ-es,12
10
- openconvert-1.0.0.dist-info/RECORD,,