Skip to content

Commit

Permalink
more docs to intrinsicmodal
Browse files Browse the repository at this point in the history
  • Loading branch information
ACea15 committed Sep 11, 2024
1 parent 0aa3ec4 commit 1f761b2
Show file tree
Hide file tree
Showing 2 changed files with 656 additions and 385 deletions.
25 changes: 25 additions & 0 deletions feniax/preprocessor/containers/fieldformatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import re

# Sample input string for demonstration purposes.
input_data = """
@dataclass
class MyClass:
field1: int = dfield("int", default=0)
field2: str = dfield("str", default="")
"""

# Regular expression pattern to match the specific format in data class fields
pattern = re.compile(r'(\w+): (\w+|\[.*?\]|".*?"|\'.*?\') = dfield\(".*?", (.*?)\)')

# Function to perform the substitution
def replace_dfield(match):
field_name = match.group(1)
field_type = match.group(2)
remaining_args = match.group(3)
return f'{field_name}: {field_type} = dfield("{field_name}", {remaining_args})'

# Perform the replacement using the sub method
output_data = re.sub(pattern, replace_dfield, input_data)

# Print result
print(output_data)
Loading

0 comments on commit 1f761b2

Please sign in to comment.