示例#1
0
    def treat_file(
        self,
        filename: str,
        dict_test: Optional[Dict[str,
                                 Union[Tuple[str, int, int], Tuple[str, float,
                                                                   float],
                                       Tuple[str, Angle, Angle], ], ]] = None,
        dict_default_values: Optional[Dict[str, Union[int, float, Tuple[int,
                                                                        int],
                                                      Angle]]] = None,
        debug: Optional[DebugImage] = None,
    ) -> None:
        if debug is None:
            debug = DebugImage(DebugImage.Level.OFF)

        if dict_default_values is None:
            dict_default_values = {}

        if self.__fuzzing:
            dict_default_values["UnskewPageHoughLinesScale"] = random.uniform(
                0.30, 1.0)
            dict_default_values[
                "SplitTwoWavesHoughLinesScale"] = random.uniform(0.30, 1.0)
            print(filename, dict_default_values)

        super().treat_file(filename, dict_test, dict_default_values, debug)
示例#2
0
def execute(filename: str) -> None:
    try:
        diptych.script.SeparatePage().treat_file(filename,
                                                 debug=DebugImage(
                                                     DebugImage.Level.DEBUG,
                                                     filename))
    except NotMyException as err:
        print("Failure with image : {0}, reason: {1}".format(filename, err))
    except Exception as err:  # pylint: disable=broad-except
        print("Failed : {0}, reason: {1}".format(filename, err))
示例#3
0
def test_disabled_enable_debug() -> None:
    """Check that enable_debug=False works."""
    tc.assertTrue(
        is_file_exists(get_absolute_from_current_path(__file__, "0001.png"))
    )
    copy_file(
        get_absolute_from_current_path(__file__, "0001.png"),
        get_absolute_from_current_path(__file__, "0001_debug.png"),
    )
    SeparatePage().treat_file(
        get_absolute_from_current_path(__file__, "0001_debug.png"),
        debug=DebugImage(DebugImage.Level.OFF),
    )
    delete_file(get_absolute_from_current_path(__file__, "0001_debug.png"))
示例#4
0
def test_mock_stop_at_5() -> None:
    """Check that stop_at 5 works."""
    tc.assertTrue(
        is_file_exists(get_absolute_from_current_path(__file__, "0001.png"))
    )
    copy_file(
        get_absolute_from_current_path(__file__, "0001.png"),
        get_absolute_from_current_path(__file__, "0001_5.png"),
    )
    del_pattern(extract_path(__file__), "0001_5.png_*")
    MockDisableSeparatePage(5).treat_file(
        get_absolute_from_current_path(__file__, "0001_5.png"),
        debug=DebugImage(DebugImage.Level.TOP),
    )
    delete_file(get_absolute_from_current_path(__file__, "0001_5.png"))
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_1_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_2_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_3_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_3_2.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_4_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_5_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_6_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_6_2.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_7_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_7_2.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_page_1.png")
        )
    )
    tc.assertTrue(
        is_file_exists(
            get_absolute_from_current_path(__file__, "0001_5.png_page_2.png")
        )
    )