diff --git a/weasyprint/css/__init__.py b/weasyprint/css/__init__.py index c49426958..e2df8750b 100644 --- a/weasyprint/css/__init__.py +++ b/weasyprint/css/__init__.py @@ -23,14 +23,14 @@ import cssselect2 import tinycss2 +from .. import CSS +from ..logger import LOGGER, PROGRESS_LOGGER +from ..urls import URLFetchingError, get_url_attribute, url_join from . import computed_values from .properties import INHERITED, INITIAL_NOT_COMPUTED, INITIAL_VALUES from .utils import remove_whitespace, split_on_comma from .validation import preprocess_declarations from .validation.descriptors import preprocess_descriptors -from .. import CSS -from ..logger import LOGGER, PROGRESS_LOGGER -from ..urls import URLFetchingError, get_url_attribute, url_join # Reject anything not in here: PSEUDO_ELEMENTS = (None, 'before', 'after', 'first-line', 'first-letter') diff --git a/weasyprint/css/computed_values.py b/weasyprint/css/computed_values.py index 5faf75d4c..6c5476e9b 100644 --- a/weasyprint/css/computed_values.py +++ b/weasyprint/css/computed_values.py @@ -14,12 +14,12 @@ from tinycss2.color3 import parse_color -from .properties import INITIAL_VALUES, Dimension -from .utils import ( - ANGLE_TO_RADIANS, LENGTH_UNITS, LENGTHS_TO_PIXELS, safe_urljoin) from .. import text from ..logger import LOGGER from ..urls import get_link_attribute +from .properties import INITIAL_VALUES, Dimension +from .utils import ( + ANGLE_TO_RADIANS, LENGTH_UNITS, LENGTHS_TO_PIXELS, safe_urljoin) ZERO_PIXELS = Dimension(0, 'px') diff --git a/weasyprint/css/utils.py b/weasyprint/css/utils.py index e652193ff..a8ea5a726 100644 --- a/weasyprint/css/utils.py +++ b/weasyprint/css/utils.py @@ -16,10 +16,10 @@ from tinycss2.color3 import parse_color -from .properties import Dimension from ..formatting_structure import counters from ..images import LinearGradient, RadialGradient from ..urls import iri_to_uri, url_is_absolute +from .properties import Dimension # http://dev.w3.org/csswg/css3-values/#angles # 1 is this many radians. diff --git a/weasyprint/css/validation/__init__.py b/weasyprint/css/validation/__init__.py index 618e60fbf..450a02eff 100644 --- a/weasyprint/css/validation/__init__.py +++ b/weasyprint/css/validation/__init__.py @@ -12,10 +12,10 @@ from tinycss2 import serialize +from ... import LOGGER +from ..utils import InvalidValues, remove_whitespace from .expanders import EXPANDERS from .properties import PREFIX, PROPRIETARY, UNSTABLE, validate_non_shorthand -from ..utils import InvalidValues, remove_whitespace -from ... import LOGGER # Not applicable to the print media NOT_PRINT_MEDIA = { diff --git a/weasyprint/css/validation/descriptors.py b/weasyprint/css/validation/descriptors.py index ed7728111..765bddea3 100644 --- a/weasyprint/css/validation/descriptors.py +++ b/weasyprint/css/validation/descriptors.py @@ -12,11 +12,11 @@ import tinycss2 -from . import properties +from ...logger import LOGGER from ..utils import ( InvalidValues, comma_separated_list, get_keyword, get_single_keyword, get_url, remove_whitespace, single_keyword, single_token) -from ...logger import LOGGER +from . import properties DESCRIPTORS = {} diff --git a/weasyprint/css/validation/expanders.py b/weasyprint/css/validation/expanders.py index c5651dcb7..42ccd70a3 100644 --- a/weasyprint/css/validation/expanders.py +++ b/weasyprint/css/validation/expanders.py @@ -13,6 +13,9 @@ from tinycss2.color3 import parse_color +from ..properties import INITIAL_VALUES, Dimension +from ..utils import ( + InvalidValues, get_keyword, get_single_keyword, split_on_comma) from .descriptors import expand_font_variant from .properties import ( background_attachment, background_image, background_position, @@ -21,9 +24,6 @@ flex_wrap, font_family, font_size, font_stretch, font_style, font_weight, line_height, list_style_image, list_style_position, list_style_type, other_colors, overflow_wrap, validate_non_shorthand) -from ..properties import INITIAL_VALUES, Dimension -from ..utils import ( - InvalidValues, get_keyword, get_single_keyword, split_on_comma) EXPANDERS = {} diff --git a/weasyprint/css/validation/properties.py b/weasyprint/css/validation/properties.py index 3179d4bb4..17bce1a7e 100644 --- a/weasyprint/css/validation/properties.py +++ b/weasyprint/css/validation/properties.py @@ -12,6 +12,7 @@ from tinycss2.color3 import parse_color +from ...formatting_structure import counters from .. import computed_values from ..properties import KNOWN_PROPERTIES, Dimension from ..utils import ( @@ -19,7 +20,6 @@ get_content_list_token, get_image, get_keyword, get_length, get_resolution, get_single_keyword, get_url, parse_2d_position, parse_background_position, parse_function, single_keyword, single_token) -from ...formatting_structure import counters PREFIX = '-weasy-' PROPRIETARY = set() diff --git a/weasyprint/formatting_structure/build.py b/weasyprint/formatting_structure/build.py index cb357a011..0b57d352e 100644 --- a/weasyprint/formatting_structure/build.py +++ b/weasyprint/formatting_structure/build.py @@ -19,10 +19,10 @@ import tinycss2.color3 -from . import boxes, counters from .. import html from ..css import properties from ..logger import LOGGER +from . import boxes, counters # Maps values of the ``display`` CSS property to box types. BOX_TYPE_FROM_DISPLAY = { diff --git a/weasyprint/layout/__init__.py b/weasyprint/layout/__init__.py index 429ab1c3c..24df36d8d 100644 --- a/weasyprint/layout/__init__.py +++ b/weasyprint/layout/__init__.py @@ -20,11 +20,11 @@ from collections import defaultdict +from ..formatting_structure import boxes +from ..logger import PROGRESS_LOGGER from .absolute import absolute_box_layout, absolute_layout from .backgrounds import layout_backgrounds from .pages import make_all_pages, make_margin_boxes -from ..formatting_structure import boxes -from ..logger import PROGRESS_LOGGER def initialize_page_maker(context, root_box): diff --git a/weasyprint/layout/absolute.py b/weasyprint/layout/absolute.py index ad7b962f8..0b36d33b2 100644 --- a/weasyprint/layout/absolute.py +++ b/weasyprint/layout/absolute.py @@ -7,12 +7,12 @@ """ +from ..formatting_structure import boxes from .markers import list_marker_layout from .min_max import handle_min_max_width from .percentages import resolve_percentages, resolve_position_percentages from .preferred import shrink_to_fit from .tables import table_wrapper_width -from ..formatting_structure import boxes class AbsolutePlaceholder(object): diff --git a/weasyprint/layout/backgrounds.py b/weasyprint/layout/backgrounds.py index 307605edf..556ebfa02 100644 --- a/weasyprint/layout/backgrounds.py +++ b/weasyprint/layout/backgrounds.py @@ -10,9 +10,9 @@ from collections import namedtuple from itertools import cycle +from ..formatting_structure import boxes from . import replaced from .percentages import resolve_radii_percentages -from ..formatting_structure import boxes Background = namedtuple('Background', 'color, layers, image_rendering') BackgroundLayer = namedtuple( diff --git a/weasyprint/layout/blocks.py b/weasyprint/layout/blocks.py index 282b3a37a..899ca821d 100644 --- a/weasyprint/layout/blocks.py +++ b/weasyprint/layout/blocks.py @@ -9,6 +9,7 @@ """ +from ..formatting_structure import boxes from .absolute import AbsolutePlaceholder, absolute_layout from .columns import columns_layout from .flex import flex_layout @@ -20,7 +21,6 @@ from .min_max import handle_min_max_width from .percentages import resolve_percentages, resolve_position_percentages from .tables import table_layout, table_wrapper_width -from ..formatting_structure import boxes def block_level_layout(context, box, max_position_y, skip_stack, diff --git a/weasyprint/layout/columns.py b/weasyprint/layout/columns.py index 0d63858f2..20db8e0e1 100644 --- a/weasyprint/layout/columns.py +++ b/weasyprint/layout/columns.py @@ -11,9 +11,9 @@ from math import floor +from ..formatting_structure import boxes from .absolute import absolute_layout from .percentages import resolve_percentages -from ..formatting_structure import boxes def columns_layout(context, box, max_position_y, skip_stack, containing_block, diff --git a/weasyprint/layout/flex.py b/weasyprint/layout/flex.py index da33ffc56..36edfef28 100644 --- a/weasyprint/layout/flex.py +++ b/weasyprint/layout/flex.py @@ -12,12 +12,12 @@ import sys from math import log10 +from ..css.properties import Dimension +from ..formatting_structure import boxes from .markers import list_marker_layout from .percentages import resolve_one_percentage, resolve_percentages from .preferred import max_content_width, min_content_width from .tables import find_in_flow_baseline -from ..css.properties import Dimension -from ..formatting_structure import boxes class FlexLine(list): diff --git a/weasyprint/layout/float.py b/weasyprint/layout/float.py index f823ae592..949b2260c 100644 --- a/weasyprint/layout/float.py +++ b/weasyprint/layout/float.py @@ -9,12 +9,12 @@ """ +from ..formatting_structure import boxes from .markers import list_marker_layout from .min_max import handle_min_max_width from .percentages import resolve_percentages, resolve_position_percentages from .preferred import shrink_to_fit from .tables import table_wrapper_width -from ..formatting_structure import boxes @handle_min_max_width diff --git a/weasyprint/layout/inlines.py b/weasyprint/layout/inlines.py index f827ad502..2a367489a 100644 --- a/weasyprint/layout/inlines.py +++ b/weasyprint/layout/inlines.py @@ -11,6 +11,10 @@ import unicodedata +from ..css import computed_from_cascaded +from ..css.computed_values import ex_ratio, strut_layout +from ..formatting_structure import boxes +from ..text import can_break_text, split_first_line from .absolute import AbsolutePlaceholder, absolute_layout from .flex import flex_layout from .float import avoid_collisions, float_layout @@ -20,10 +24,6 @@ inline_min_content_width, shrink_to_fit, trailing_whitespace_size) from .replaced import image_marker_layout from .tables import find_in_flow_baseline, table_wrapper_width -from ..css import computed_from_cascaded -from ..css.computed_values import ex_ratio, strut_layout -from ..formatting_structure import boxes -from ..text import can_break_text, split_first_line def iter_line_boxes(context, box, position_y, skip_stack, containing_block, diff --git a/weasyprint/layout/markers.py b/weasyprint/layout/markers.py index 7a1f62601..8ef62c263 100644 --- a/weasyprint/layout/markers.py +++ b/weasyprint/layout/markers.py @@ -9,11 +9,11 @@ """ +from ..formatting_structure import boxes +from ..text import split_first_line from .percentages import resolve_percentages from .replaced import image_marker_layout from .tables import find_in_flow_baseline -from ..formatting_structure import boxes -from ..text import split_first_line def list_marker_layout(context, box): diff --git a/weasyprint/layout/pages.py b/weasyprint/layout/pages.py index 7f15fcecd..8fdc4b4cc 100644 --- a/weasyprint/layout/pages.py +++ b/weasyprint/layout/pages.py @@ -11,15 +11,15 @@ import copy +from ..css import ( + PageType, computed_from_cascaded, matching_page_types, set_computed_styles) +from ..formatting_structure import boxes, build +from ..logger import PROGRESS_LOGGER from .absolute import absolute_layout from .blocks import block_container_layout, block_level_layout from .min_max import handle_min_max_height, handle_min_max_width from .percentages import resolve_percentages from .preferred import max_content_width, min_content_width -from ..css import ( - PageType, computed_from_cascaded, matching_page_types, set_computed_styles) -from ..formatting_structure import boxes, build -from ..logger import PROGRESS_LOGGER class OrientedBox(object): diff --git a/weasyprint/layout/preferred.py b/weasyprint/layout/preferred.py index 55871fd44..97ec265a9 100644 --- a/weasyprint/layout/preferred.py +++ b/weasyprint/layout/preferred.py @@ -15,9 +15,9 @@ import sys -from .replaced import default_image_sizing from .. import text from ..formatting_structure import boxes +from .replaced import default_image_sizing def shrink_to_fit(context, box, available_width): diff --git a/weasyprint/layout/tables.py b/weasyprint/layout/tables.py index 3be98d6b5..ee8e5d4ee 100644 --- a/weasyprint/layout/tables.py +++ b/weasyprint/layout/tables.py @@ -9,10 +9,10 @@ """ -from .percentages import resolve_one_percentage, resolve_percentages -from .preferred import max_content_width, table_and_columns_preferred_widths from ..formatting_structure import boxes from ..logger import LOGGER +from .percentages import resolve_one_percentage, resolve_percentages +from .preferred import max_content_width, table_and_columns_preferred_widths def table_layout(context, table, max_position_y, skip_stack, diff --git a/weasyprint/tests/test_acid2.py b/weasyprint/tests/test_acid2.py index 1c42ae83e..a523440a6 100644 --- a/weasyprint/tests/test_acid2.py +++ b/weasyprint/tests/test_acid2.py @@ -9,10 +9,10 @@ """ +from .. import HTML from .test_draw import assert_pixels_equal, image_to_pixels from .testing_utils import ( assert_no_logs, capture_logs, requires, resource_filename) -from .. import HTML @assert_no_logs diff --git a/weasyprint/tests/test_api.py b/weasyprint/tests/test_api.py index 5fcf64c61..b3869a2e4 100644 --- a/weasyprint/tests/test_api.py +++ b/weasyprint/tests/test_api.py @@ -23,11 +23,11 @@ import py import pytest +from .. import CSS, HTML, __main__, default_url_fetcher +from ..urls import path2url from .test_draw import B, _, assert_pixels_equal, image_to_pixels, r from .testing_utils import ( FakeHTML, assert_no_logs, capture_logs, http_server, resource_filename) -from .. import CSS, HTML, __main__, default_url_fetcher -from ..urls import path2url def _test_resource(class_, basename, check, **kwargs): diff --git a/weasyprint/tests/test_boxes.py b/weasyprint/tests/test_boxes.py index 4a277e42d..e917bff8e 100644 --- a/weasyprint/tests/test_boxes.py +++ b/weasyprint/tests/test_boxes.py @@ -13,12 +13,12 @@ import pytest -from .testing_utils import BASE_URL, FakeHTML, assert_no_logs, capture_logs from .. import images from ..css import PageType, get_all_computed_styles from ..css.targets import TargetCollector from ..formatting_structure import boxes, build, counters from ..layout.pages import set_page_type_computed_styles +from .testing_utils import BASE_URL, FakeHTML, assert_no_logs, capture_logs PROPER_CHILDREN = dict((key, tuple(map(tuple, value))) for key, value in { # Children can be of *any* type in *one* of the lists. diff --git a/weasyprint/tests/test_css.py b/weasyprint/tests/test_css.py index 4ccca0ffb..86b04875e 100644 --- a/weasyprint/tests/test_css.py +++ b/weasyprint/tests/test_css.py @@ -12,13 +12,13 @@ import pytest import tinycss2 -from .testing_utils import ( - BASE_URL, FakeHTML, assert_no_logs, capture_logs, resource_filename) from .. import CSS, css, default_url_fetcher from ..css import PageType, get_all_computed_styles, parse_page_selectors from ..css.computed_values import strut_layout from ..layout.pages import set_page_type_computed_styles from ..urls import path2url +from .testing_utils import ( + BASE_URL, FakeHTML, assert_no_logs, capture_logs, resource_filename) @assert_no_logs diff --git a/weasyprint/tests/test_css_descriptors.py b/weasyprint/tests/test_css_descriptors.py index 1ea25410e..569c2cb7e 100644 --- a/weasyprint/tests/test_css_descriptors.py +++ b/weasyprint/tests/test_css_descriptors.py @@ -11,9 +11,9 @@ import tinycss2 -from .testing_utils import assert_no_logs, capture_logs from ..css import preprocess_stylesheet from ..css.validation.descriptors import preprocess_descriptors +from .testing_utils import assert_no_logs, capture_logs @assert_no_logs diff --git a/weasyprint/tests/test_css_validation.py b/weasyprint/tests/test_css_validation.py index ec4b9e554..2bc4b9855 100644 --- a/weasyprint/tests/test_css_validation.py +++ b/weasyprint/tests/test_css_validation.py @@ -14,11 +14,11 @@ import pytest import tinycss2 -from .testing_utils import assert_no_logs, capture_logs from ..css import preprocess_declarations from ..css.computed_values import ZERO_PIXELS from ..css.properties import INITIAL_VALUES, Dimension from ..images import LinearGradient, RadialGradient +from .testing_utils import assert_no_logs, capture_logs def expand_to_dict(css, expected_error=None): diff --git a/weasyprint/tests/test_draw/test_background.py b/weasyprint/tests/test_draw/test_background.py index 3c444e128..984667590 100644 --- a/weasyprint/tests/test_draw/test_background.py +++ b/weasyprint/tests/test_draw/test_background.py @@ -11,8 +11,8 @@ import pytest -from . import B, G, _, assert_pixels, r from ..testing_utils import assert_no_logs +from . import B, G, _, assert_pixels, r @assert_no_logs diff --git a/weasyprint/tests/test_draw/test_before_after.py b/weasyprint/tests/test_draw/test_before_after.py index 9c7893c0b..6e1313425 100644 --- a/weasyprint/tests/test_draw/test_before_after.py +++ b/weasyprint/tests/test_draw/test_before_after.py @@ -9,8 +9,8 @@ """ -from . import assert_same_rendering from ..testing_utils import assert_no_logs +from . import assert_same_rendering @assert_no_logs diff --git a/weasyprint/tests/test_draw/test_box.py b/weasyprint/tests/test_draw/test_box.py index f57973810..52cd2d91a 100644 --- a/weasyprint/tests/test_draw/test_box.py +++ b/weasyprint/tests/test_draw/test_box.py @@ -11,9 +11,9 @@ import itertools -from . import B, G, R, _, assert_different_renderings, assert_pixels, b, g -from ..testing_utils import assert_no_logs from ... import HTML +from ..testing_utils import assert_no_logs +from . import B, G, R, _, assert_different_renderings, assert_pixels, b, g @assert_no_logs diff --git a/weasyprint/tests/test_draw/test_column.py b/weasyprint/tests/test_draw/test_column.py index ddf6d2df6..7ae9369f6 100644 --- a/weasyprint/tests/test_draw/test_column.py +++ b/weasyprint/tests/test_draw/test_column.py @@ -9,8 +9,8 @@ """ -from . import _, a, assert_pixels, r from ..testing_utils import assert_no_logs, requires +from . import _, a, assert_pixels, r @assert_no_logs diff --git a/weasyprint/tests/test_draw/test_current_color.py b/weasyprint/tests/test_draw/test_current_color.py index e83f95044..35dc0e556 100644 --- a/weasyprint/tests/test_draw/test_current_color.py +++ b/weasyprint/tests/test_draw/test_current_color.py @@ -9,8 +9,8 @@ """ -from . import G, assert_pixels from ..testing_utils import assert_no_logs +from . import G, assert_pixels @assert_no_logs diff --git a/weasyprint/tests/test_draw/test_gradient.py b/weasyprint/tests/test_draw/test_gradient.py index 4deaa31e3..12bb197f0 100644 --- a/weasyprint/tests/test_draw/test_gradient.py +++ b/weasyprint/tests/test_draw/test_gradient.py @@ -9,8 +9,8 @@ """ -from . import B, V, _, assert_pixels, html_to_pixels, r, v from ..testing_utils import assert_no_logs, requires +from . import B, V, _, assert_pixels, html_to_pixels, r, v @assert_no_logs diff --git a/weasyprint/tests/test_draw/test_image.py b/weasyprint/tests/test_draw/test_image.py index 98d1cd2a7..c503c052a 100644 --- a/weasyprint/tests/test_draw/test_image.py +++ b/weasyprint/tests/test_draw/test_image.py @@ -11,8 +11,8 @@ import pytest -from . import B, _, a, assert_pixels, assert_same_rendering, r from ..testing_utils import assert_no_logs, capture_logs +from . import B, _, a, assert_pixels, assert_same_rendering, r centered_image = [ _ + _ + _ + _ + _ + _ + _ + _, diff --git a/weasyprint/tests/test_draw/test_list.py b/weasyprint/tests/test_draw/test_list.py index c4956473e..0bfce7c29 100644 --- a/weasyprint/tests/test_draw/test_list.py +++ b/weasyprint/tests/test_draw/test_list.py @@ -11,8 +11,8 @@ import pytest -from . import B, _, assert_pixels, r from ..testing_utils import SANS_FONTS, assert_no_logs +from . import B, _, assert_pixels, r @assert_no_logs diff --git a/weasyprint/tests/test_draw/test_opacity.py b/weasyprint/tests/test_draw/test_opacity.py index 6772bfb4d..c3eb720d6 100644 --- a/weasyprint/tests/test_draw/test_opacity.py +++ b/weasyprint/tests/test_draw/test_opacity.py @@ -9,8 +9,8 @@ """ -from . import assert_same_rendering from ..testing_utils import assert_no_logs +from . import assert_same_rendering opacity_source = '''