diff --git a/build/data/styles/baseline_positions.py b/build/data/styles/baseline_positions.py index 921f4a41..d9501518 100644 --- a/build/data/styles/baseline_positions.py +++ b/build/data/styles/baseline_positions.py @@ -1,15 +1,40 @@ +import os +import sys +from pathlib import Path + +parent_dir = Path(__file__).resolve().parent.parent.parent +sys.path.append(str(parent_dir)) +sys.path.append(os.path.join(parent_dir)) + from lang import Lang from value import Value +from values import Values -overflow_positions = [ - Value().set_generate_name("first baseline").add_text(Lang.EN, "first baseline").add_text(Lang.FA, "خط پایه اول"), - Value().set_generate_name("first baseline").add_text(Lang.EN, "baseline first").add_text(Lang.FA, "اول خط پایه"), - Value().set_generate_name("last baseline").add_text(Lang.EN, "last baseline").add_text(Lang.FA, "خط پایه آخر"), - Value().set_generate_name("last baseline").add_text(Lang.EN, "baseline last").add_text(Lang.FA, "آخر خط پایه"), - Value().set_generate_name("baseline").add_text(Lang.EN, "baseline").add_text(Lang.FA, "خط پایه"), +overflow_positions = Values.And( + [ + Value().set_generate_name("first").add_text(Lang.EN, "first").add_text(Lang.FA, "اول"), + Value().set_generate_name("last").add_text(Lang.EN, "last").add_text(Lang.FA, "آخر"), + ], + [ + Value().set_generate_name("baseline").add_text(Lang.EN, "baseline").add_text(Lang.FA, "خط پایه"), + ], +) +# Values.and() should generate the following: +# Value().set_generate_name("first baseline").add_text(Lang.EN, "first baseline").add_text(Lang.FA, "خط پایه اول"), +# Value().set_generate_name("first baseline").add_text(Lang.EN, "baseline first").add_text(Lang.FA, "اول خط پایه"), +# Value().set_generate_name("last baseline").add_text(Lang.EN, "last baseline").add_text(Lang.FA, "خط پایه آخر"), +# Value().set_generate_name("last baseline").add_text(Lang.EN, "baseline last").add_text(Lang.FA, "آخر خط پایه"), +# Value().set_generate_name("baseline").add_text(Lang.EN, "baseline").add_text(Lang.FA, "خط پایه"), + +print(overflow_positions) + +overflow_positions += [ + Value().set_generate_name("baseline").add_text(Lang.EN, "baseline").add_text(Lang.FA, "خط پایه"), ] +print(overflow_positions) + # https://developer.mozilla.org/en-US/docs/Web/CSS/align-items # = # [ first | last ]? && diff --git a/build/data/styles/overflow_positions.py b/build/data/styles/overflow_positions.py index 36e6aa2c..0999edb7 100644 --- a/build/data/styles/overflow_positions.py +++ b/build/data/styles/overflow_positions.py @@ -1,3 +1,11 @@ +import os +import sys +from pathlib import Path + +parent_dir = Path(__file__).resolve().parent.parent +sys.path.append(str(parent_dir)) +sys.path.append(os.path.join(parent_dir, "data", "styles")) + from lang import Lang from value import Value diff --git a/build/data/styles/self_positions.py b/build/data/styles/self_positions.py index f2fcccb7..3d370504 100644 --- a/build/data/styles/self_positions.py +++ b/build/data/styles/self_positions.py @@ -1,3 +1,11 @@ +import os +import sys +from pathlib import Path + +parent_dir = Path(__file__).resolve().parent.parent +sys.path.append(str(parent_dir)) +sys.path.append(os.path.join(parent_dir, "data", "styles")) + from lang import Lang from value import Value diff --git a/build/values.py b/build/values.py new file mode 100644 index 00000000..97f36c6a --- /dev/null +++ b/build/values.py @@ -0,0 +1,37 @@ +import itertools +from value import Value + +class Values: + @staticmethod + def And(*value_groups): + """ + Combines arrays of Value objects to generate new Value objects for all combinations. + + Args: + value_groups: Lists of Value objects to combine. + + Returns: + A list of Value objects representing all combinations. + """ + + combinations = itertools.product(*value_groups) + + result = [] + for combo in combinations: + permutations = itertools.permutations(combo) + + for perm in permutations: + combined_name = [] + for value in perm: + combined_name.append(value.generate_name) + + print(combined_name) + + print(combo) + combined_value = Value() + combined_value.set_generate_name(" ".join(combined_name)) + + print(combined_value.generate_name) + result.append(combined_value) + + return result \ No newline at end of file