Skip to content

Commit

Permalink
Make document-level renderer harmless
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Nov 24, 2023
1 parent 59dc178 commit 607ace6
Show file tree
Hide file tree
Showing 6 changed files with 270 additions and 183 deletions.
16 changes: 1 addition & 15 deletions src/pypdfium2/__main__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# SPDX-FileCopyrightText: 2023 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

import os
import sys
import logging
import argparse
import importlib
import pypdfium2._helpers as pdfium
import pypdfium2.internal as pdfium_i
from pypdfium2.version import PYPDFIUM_INFO, PDFIUM_INFO
# the * import in pypdfium2.raw loses underscore-prefixed members, so import from the direct origin
from pypdfium2_raw.bindings import _loader_info as loader_info
from pypdfium2._cli._parsers import setup_logging

SubCommands = {
"arrange": "rearrange/merge documents",
Expand Down Expand Up @@ -49,17 +46,6 @@ def get_parser():
return main_parser


def setup_logging():

pdfium_i.DEBUG_AUTOCLOSE.value = bool(int( os.environ.get("DEBUG_AUTOCLOSE", 0) ))

lib_logger = logging.getLogger("pypdfium2")
lib_logger.addHandler(logging.StreamHandler())
lib_logger.setLevel(logging.DEBUG)

pdfium.PdfUnspHandler().setup()


def api_main(raw_args=sys.argv[1:]):

parser = get_parser()
Expand Down
14 changes: 14 additions & 0 deletions src/pypdfium2/_cli/_parsers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
# SPDX-FileCopyrightText: 2023 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

import os
import logging
from pathlib import Path
import pypdfium2._helpers as pdfium
import pypdfium2.internal as pdfium_i


def setup_logging():

pdfium_i.DEBUG_AUTOCLOSE.value = bool(int( os.environ.get("DEBUG_AUTOCLOSE", 0) ))

lib_logger = logging.getLogger("pypdfium2")
lib_logger.addHandler(logging.StreamHandler())
lib_logger.setLevel(logging.DEBUG)

pdfium.PdfUnspHandler().setup()


def parse_numtext(numtext):
Expand Down
Loading

0 comments on commit 607ace6

Please sign in to comment.