Created
November 9, 2021 22:30
-
-
Save cdracars/33399d76996317af6a6da4d00bdb7492 to your computer and use it in GitHub Desktop.
Very basic python script to update form_state from Drupal 7 to Drupal 9.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
filename = 'fsp_competitive_cross_reference.cut_n_paste.inc' | |
# Read in the file | |
with open(filename, 'r') as file: | |
filedata = file.read() | |
# print(filedata) | |
values = re.findall("\$form_state\['values'\].*\]", filedata) | |
temp = re.sub(r"(\$form_state\['values'\]\[)('.*')(\])", r'$form_state->getValue(\2)', filedata) | |
print(temp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
damn thing pulled my astericks.... I should have probably used somthing that indicated this was code....
regex is a bit greedy - so on line 12 your closing .*\] would consume all characters until the LAST ] and not the first ] (if there was more than one....) that is why I used, (in the vim description) '[^']*'