From 0e29c1e5ce5896f5039685f68a98353ff0ad65a2 Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar Date: Thu, 28 Nov 2024 16:11:21 +0530 Subject: [PATCH] changed all but 1 info logs to debug --- src/boxtodocx/cli.py | 4 +-- src/boxtodocx/converter.py | 44 ++++++++++++++-------------- src/boxtodocx/mappers/html_mapper.py | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/boxtodocx/cli.py b/src/boxtodocx/cli.py index 41bc6df..a8b5bad 100644 --- a/src/boxtodocx/cli.py +++ b/src/boxtodocx/cli.py @@ -43,14 +43,14 @@ def main(input_path: str, dir: Optional[str], token: Optional[str], # Process files if input_path.is_dir(): - logger.info(f"Processing directory: {input_path}") + logger.debug(f"Processing directory: {input_path}") converter.convert_folder(input_path) else: if not input_path.suffix == '.boxnote': logger.error(f"Input file must be a .boxnote file: {input_path}") return 1 - logger.info(f"Processing file: {input_path}") + logger.debug(f"Processing file: {input_path}") converter.convert_single_file(input_path, output_path) return 0 diff --git a/src/boxtodocx/converter.py b/src/boxtodocx/converter.py index 57e9e8a..4f65c17 100644 --- a/src/boxtodocx/converter.py +++ b/src/boxtodocx/converter.py @@ -52,7 +52,7 @@ def convert_single_file( temp_html = self.get_temp_html_path() # Read and parse content - logger.info(f"Reading input file: {input_file}") + logger.debug(f"Reading input file: {input_file}") with open(input_file, 'r', encoding='utf-8') as f: content = f.read() @@ -66,17 +66,17 @@ def convert_single_file( output_docx = output_docx.parent / f'{output_stem}.docx' # Parse BoxNote to HTML - logger.info("Converting BoxNote to HTML") + logger.debug("Converting BoxNote to HTML") parser = BoxNoteParser() html_content = parser.parse(content, clean_name, self.workdir, self.token, self.user_id) # Write temporary HTML - logger.info(f"Writing temporary HTML: {temp_html}") + logger.debug(f"Writing temporary HTML: {temp_html}") with open(temp_html, 'w', encoding='utf-8') as f: f.write(html_content) # Convert HTML to docx - logger.info(f"Converting to docx: {output_docx}") + logger.debug(f"Converting to docx: {output_docx}") docx_parser = HtmlToDocx(self.workdir) docx_parser.table_style = 'TableGrid' @@ -103,25 +103,25 @@ def convert_folder(self, input_path: Path) -> None: successful = 0 failed = 0 - logger.info(f"Found {total_files} BoxNote files in {input_path}") + logger.debug(f"Found {total_files} BoxNote files in {input_path}") for boxnote_file in boxnote_files: try: - logger.info(f"Processing: {boxnote_file.name}") + logger.debug(f"Processing: {boxnote_file.name}") output_docx = None # Let convert_single_file handle the output path self.convert_single_file(boxnote_file, output_docx) successful += 1 - logger.info(f"Successfully converted: {boxnote_file.name}") + logger.debug(f"Successfully converted: {boxnote_file.name}") except Exception as e: failed += 1 logger.error(f"Failed to convert {boxnote_file.name}: {str(e)}") continue # Print summary - logger.info("\nConversion Summary:") - logger.info(f"Total files: {total_files}") - logger.info(f"Successfully converted: {successful}") - logger.info(f"Failed: {failed}") + logger.debug("\nConversion Summary:") + logger.debug(f"Total files: {total_files}") + logger.debug(f"Successfully converted: {successful}") + logger.debug(f"Failed: {failed}") @@ -163,7 +163,7 @@ def convert_single_file( temp_html = self.get_temp_html_path(workdir) # Read and parse content - logger.info(f"Reading input file: {input_file}") + logger.debug(f"Reading input file: {input_file}") with open(input_file, 'r', encoding='utf-8') as f: content = f.read() @@ -178,16 +178,16 @@ def convert_single_file( # Parse BoxNote to HTML from html_parser import parse - logger.info("Converting BoxNote to HTML") + logger.debug("Converting BoxNote to HTML") html_content = parse(content, clean_name, workdir, token, user_id) # Write temporary HTML - logger.info(f"Writing temporary HTML: {temp_html}") + logger.debug(f"Writing temporary HTML: {temp_html}") with open(temp_html, 'w', encoding='utf-8') as f: f.write(html_content) # Convert HTML to docx - logger.info(f"Converting to docx: {output_docx}") + logger.debug(f"Converting to docx: {output_docx}") docx_parser = HtmlToDocx(workdir) docx_parser.table_style = 'TableGrid' @@ -218,25 +218,25 @@ def convert_folder( successful = 0 failed = 0 - logger.info(f"Found {total_files} BoxNote files in {input_path}") + logger.debug(f"Found {total_files} BoxNote files in {input_path}") for boxnote_file in boxnote_files: try: - logger.info(f"Processing: {boxnote_file.name}") + logger.debug(f"Processing: {boxnote_file.name}") output_docx = None # Let convert_single_file handle the output path self.convert_single_file(token, workdir, boxnote_file, output_docx, user_id) successful += 1 - logger.info(f"Successfully converted: {boxnote_file.name}") + logger.debug(f"Successfully converted: {boxnote_file.name}") except Exception as e: failed += 1 logger.error(f"Failed to convert {boxnote_file.name}: {str(e)}") continue # Print summary - logger.info("\nConversion Summary:") - logger.info(f"Total files: {total_files}") - logger.info(f"Successfully converted: {successful}") - logger.info(f"Failed: {failed}") + logger.debug("\nConversion Summary:") + logger.debug(f"Total files: {total_files}") + logger.debug(f"Successfully converted: {successful}") + logger.debug(f"Failed: {failed}") def main(): parser = argparse.ArgumentParser(description='Convert BoxNote files to docx format') diff --git a/src/boxtodocx/mappers/html_mapper.py b/src/boxtodocx/mappers/html_mapper.py index 6131fc6..afd5625 100644 --- a/src/boxtodocx/mappers/html_mapper.py +++ b/src/boxtodocx/mappers/html_mapper.py @@ -358,7 +358,7 @@ def download_image(box_file_id: str, file_name: str, workdir: Path, token: str, with open(file_path, 'wb') as f: f.write(response.content) - logger.info(f'Successfully downloaded image: {file_name}') + logger.debug(f'Successfully downloaded image: {file_name}') return file_path except requests.exceptions.RequestException as e: