Skip to content

Commit

Permalink
changed all but 1 info logs to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ibm committed Nov 28, 2024
1 parent 0918824 commit 0e29c1e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/boxtodocx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 22 additions & 22 deletions src/boxtodocx/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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'

Expand All @@ -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}")



Expand Down Expand Up @@ -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()

Expand All @@ -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'

Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/boxtodocx/mappers/html_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0e29c1e

Please sign in to comment.