Skip to content

Commit

Permalink
working on values - product and permutations
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Jan 10, 2025
1 parent 18310ae commit 7c90827
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 6 deletions.
37 changes: 31 additions & 6 deletions build/data/styles/baseline_positions.py
Original file line number Diff line number Diff line change
@@ -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
# <baseline-position> =
# [ first | last ]? &&
Expand Down
8 changes: 8 additions & 0 deletions build/data/styles/overflow_positions.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 8 additions & 0 deletions build/data/styles/self_positions.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
37 changes: 37 additions & 0 deletions build/values.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7c90827

Please sign in to comment.