Abid Ali Awan commited on
Commit ·
d6d4d3a
1
Parent(s): 91ef89a
Enhance type hinting in app.py for convert_local_file and convert_from_url functions
Browse files- src/app.py +4 -3
src/app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
from pathlib import Path
|
|
|
|
| 3 |
from urllib.parse import urlparse
|
| 4 |
|
| 5 |
import convertapi
|
|
@@ -11,12 +12,12 @@ convertapi.api_credentials = os.getenv("CONVERTAPI_TOKEN")
|
|
| 11 |
|
| 12 |
|
| 13 |
# Function to convert a local file
|
| 14 |
-
def convert_local_file(local_file_path, output_format):
|
| 15 |
"""
|
| 16 |
Convert a local document to a different format.
|
| 17 |
|
| 18 |
Args:
|
| 19 |
-
local_file_path (str): The path to the input file.
|
| 20 |
output_format (str): The format to convert the file to.
|
| 21 |
|
| 22 |
Returns:
|
|
@@ -47,7 +48,7 @@ def convert_local_file(local_file_path, output_format):
|
|
| 47 |
|
| 48 |
|
| 49 |
# Function to convert a file from a URL
|
| 50 |
-
def convert_from_url(document_url, output_format):
|
| 51 |
"""
|
| 52 |
Convert a document from a URL to a different format.
|
| 53 |
|
|
|
|
| 1 |
import os
|
| 2 |
from pathlib import Path
|
| 3 |
+
from typing import *
|
| 4 |
from urllib.parse import urlparse
|
| 5 |
|
| 6 |
import convertapi
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
# Function to convert a local file
|
| 15 |
+
def convert_local_file(local_file_path: str, output_format: str) -> str:
|
| 16 |
"""
|
| 17 |
Convert a local document to a different format.
|
| 18 |
|
| 19 |
Args:
|
| 20 |
+
local_file_path (str): The path to the input file provided by Gradio.
|
| 21 |
output_format (str): The format to convert the file to.
|
| 22 |
|
| 23 |
Returns:
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
# Function to convert a file from a URL
|
| 51 |
+
def convert_from_url(document_url: str, output_format: str) -> str:
|
| 52 |
"""
|
| 53 |
Convert a document from a URL to a different format.
|
| 54 |
|