@@ -35,7 +35,7 @@ def get_python_type(schema: Dict[str, Any]) -> str:
3535
3636def create_manual_tools () -> List [Dict [str , Any ]]:
3737 """Create tool definitions based on the specification documentation.
38-
38+
3939 Since the Nutrient API uses a build endpoint with actions rather than
4040 individual tool endpoints, we'll create convenience methods that wrap
4141 the build API.
@@ -90,7 +90,10 @@ def create_manual_tools() -> List[Dict[str, Any]]:
9090 "page_indexes" : {
9191 "type" : "List[int]" ,
9292 "required" : False ,
93- "description" : "List of page indexes to rotate (0-based). If not specified, all pages are rotated." ,
93+ "description" : (
94+ "List of page indexes to rotate (0-based). "
95+ "If not specified, all pages are rotated."
96+ ),
9497 },
9598 },
9699 },
@@ -245,10 +248,7 @@ def generate_method_code(tool_info: Dict[str, Any]) -> str:
245248 if not param_info ["required" ]:
246249 param_type = param_info ["type" ]
247250 # Handle List types
248- if param_type .startswith ("List[" ):
249- base_type = param_type
250- else :
251- base_type = param_type
251+ base_type = param_type
252252
253253 default = param_info .get ("default" )
254254 if default is None :
@@ -263,7 +263,9 @@ def generate_method_code(tool_info: Dict[str, Any]) -> str:
263263 # Build method signature
264264 if len (param_list ) > 3 : # Multiple parameters
265265 params_str = ",\n " .join (param_list )
266- method_signature = f" def { method_name } (\n { params_str } ,\n ) -> Optional[bytes]:"
266+ method_signature = (
267+ f" def { method_name } (\n { params_str } ,\n ) -> Optional[bytes]:"
268+ )
267269 else :
268270 params_str = ", " .join (param_list )
269271 method_signature = f" def { method_name } ({ params_str } ) -> Optional[bytes]:"
@@ -274,48 +276,56 @@ def generate_method_code(tool_info: Dict[str, Any]) -> str:
274276 docstring_lines .append ("" )
275277 docstring_lines .append (f" { description } " )
276278
277- docstring_lines .extend ([
278- "" ,
279- " Args:" ,
280- " input_file: Input file (path, bytes, or file-like object)." ,
281- ])
279+ docstring_lines .extend (
280+ [
281+ "" ,
282+ " Args:" ,
283+ " input_file: Input file (path, bytes, or file-like object)." ,
284+ ]
285+ )
282286
283287 if param_docs :
284288 docstring_lines .extend (param_docs )
285289
286- docstring_lines .extend ([
287- " output_path: Optional path to save the output file." ,
288- "" ,
289- " Returns:" ,
290- " Processed file as bytes, or None if output_path is provided." ,
291- "" ,
292- " Raises:" ,
293- " AuthenticationError: If API key is missing or invalid." ,
294- " APIError: For other API errors." ,
295- ' """' ,
296- ])
290+ docstring_lines .extend (
291+ [
292+ " output_path: Optional path to save the output file." ,
293+ "" ,
294+ " Returns:" ,
295+ " Processed file as bytes, or None if output_path is provided." ,
296+ "" ,
297+ " Raises:" ,
298+ " AuthenticationError: If API key is missing or invalid." ,
299+ " APIError: For other API errors." ,
300+ ' """' ,
301+ ]
302+ )
297303
298304 # Build method body
299305 method_body = []
300306
301307 # Collect kwargs
302- kwargs_params = [
303- f"{ name } ={ name } "
304- for name in parameters .keys ()
305- ]
308+ kwargs_params = [f"{ name } ={ name } " for name in parameters ]
306309
307310 if kwargs_params :
308311 kwargs_str = ", " .join (kwargs_params )
309- method_body .append (f' return self._process_file("{ tool_name } ", input_file, output_path, { kwargs_str } )' )
312+ method_body .append (
313+ f' return self._process_file("{ tool_name } ", input_file, '
314+ f"output_path, { kwargs_str } )"
315+ )
310316 else :
311- method_body .append (f' return self._process_file("{ tool_name } ", input_file, output_path)' )
317+ method_body .append (
318+ f' return self._process_file("{ tool_name } ", input_file, output_path)'
319+ )
312320
313321 # Combine all parts
314- return "\n " .join ([
315- method_signature ,
316- "\n " .join (docstring_lines ),
317- "\n " .join (method_body ),
318- ])
322+ return "\n " .join (
323+ [
324+ method_signature ,
325+ "\n " .join (docstring_lines ),
326+ "\n " .join (method_body ),
327+ ]
328+ )
319329
320330
321331def generate_api_methods (spec_path : Path , output_path : Path ) -> None :
@@ -330,23 +340,23 @@ def generate_api_methods(spec_path: Path, output_path: Path) -> None:
330340 # Generate code
331341 code_lines = [
332342 '"""Direct API methods for individual document processing tools.' ,
333- '' ,
334- ' This file provides convenient methods that wrap the Nutrient Build API' ,
335- ' for common document processing operations.' ,
343+ "" ,
344+ " This file provides convenient methods that wrap the Nutrient Build API" ,
345+ " for common document processing operations." ,
336346 '"""' ,
337- '' ,
338- ' from typing import List, Optional' ,
339- '' ,
340- ' from nutrient_dws.file_handler import FileInput' ,
341- '' ,
342- '' ,
343- ' class DirectAPIMixin:' ,
347+ "" ,
348+ " from typing import List, Optional" ,
349+ "" ,
350+ " from nutrient_dws.file_handler import FileInput" ,
351+ "" ,
352+ "" ,
353+ " class DirectAPIMixin:" ,
344354 ' """Mixin class containing Direct API methods.' ,
345- ' ' ,
346- ' These methods provide a simplified interface to common document' ,
347- ' processing operations. They internally use the Build API.' ,
355+ " " ,
356+ " These methods provide a simplified interface to common document" ,
357+ " processing operations. They internally use the Build API." ,
348358 ' """' ,
349- '' ,
359+ "" ,
350360 ]
351361
352362 # Add methods
0 commit comments