Skip to content

Commit

Permalink
[IMP] openupgrade_160: add some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
duong77476-viindoo committed Aug 25, 2023
1 parent 40c07f4 commit 5905ca7
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions openupgradelib/openupgrade_160.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ def migrate_translations_to_jsonb(env, fields_spec):
"rounded",
)

_MARGIN_PADDING_ELEMENT_REPLACEMENT = (
("pl", "ps"),
("ml", "ms"),
("pr", "pr"),
("mr", "me"),
)

_MARGIN_PADDING_SIZE = (
"0", "1", "2", "3", "4", "5", "auto"
)

_MARGIN_PADDING = (
"sm", "lg"
)

# These replacements are from standard Bootstrap 4 to 5
_BS5_REPLACEMENTS = (
# Grid stuff
Expand All @@ -105,13 +120,29 @@ def migrate_translations_to_jsonb(env, fields_spec):
_r("pr", "pe"),
_r("ml", "ms"),
_r("mr", "me"),
# For stub like pl-0 -> ps-0
*(
_r("%s-%s" % (t4, size), "%s-%s" % (t5, size))
for (t4, t5), size in product(
_MARGIN_PADDING_ELEMENT_REPLACEMENT, _MARGIN_PADDING_SIZE
)
),
# For stub like ml-sm-1 -> ms-sm-1
*(
_r("%s-%s-%s" % (t4, context, size), "%s-%s-%s" % (t5, context, size))
for (t4, t5), context, size in product(
_MARGIN_PADDING_ELEMENT_REPLACEMENT, _MARGIN_PADDING,_MARGIN_PADDING_SIZE
)
),
# Forms
_r("custom-control", "form-control"),
_r("custom-check", "form-check"),
_r("custom-checkbox", "form-check"),
_r("custom-control-input", "form-check-input"),
_r("custom-control-label", "form-check-label"),
_r("custom-switch", "form-switch"),
_r("custom-select", "form-select"),
_r("custom-select-sm", "form-select-sm"),
_r("custom-select-lg", "form-select-lg"),
_r("custom-range", "form-range"),
_r("form-control-file", "form-control"),
_r("form-control-range", "form-control"),
Expand Down Expand Up @@ -148,8 +179,8 @@ def migrate_translations_to_jsonb(env, fields_spec):
_r("font-weight-normal", "fw-normal"),
_r("font-italic", "fst-italic"),
_r("font-normal", "fst-normal"),
_r("rounded-sm", "rounded-0"),
_r("rounded-lg", "rounded-1"),
_r("rounded-sm", "rounded-1"),
_r("rounded-lg", "rounded-3"),
# Helpers
_r(selector="embed-responsive-item", class_rm="embed-responsive-item"),
_r("sr-only", "visually-hidden"),
Expand Down Expand Up @@ -235,20 +266,15 @@ def migrate_translations_to_jsonb(env, fields_spec):
selector_mode="xpath",
attr_rp={"data-focus": "data-bs-focus"},
),
_attr_replace(
selector="//*[@data-parent]",
selector_mode="xpath",
attr_rp={"data-parent": "data-bs-parent"},
),
_attr_replace(
selector="//*[@data-content]",
selector_mode="xpath",
attr_rp={"data-content": "data-bs-content"},
),
_attr_replace(
selector="//*[@data-parent]",
selector="//*[@data-placement]",
selector_mode="xpath",
attr_rp={"data-parent": "data-bs-parent"},
attr_rp={"data-placement": "data-bs-placement"},
),
)

Expand Down

0 comments on commit 5905ca7

Please sign in to comment.