Unverified Commit 7c046c5c authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Update localized READMES when template is filled. (#18062)

parent 94ca7d2f
...@@ -133,6 +133,7 @@ def find_code_in_transformers(object_name): ...@@ -133,6 +133,7 @@ def find_code_in_transformers(object_name):
_re_copy_warning = re.compile(r"^(\s*)#\s*Copied from\s+transformers\.(\S+\.\S+)\s*($|\S.*$)") _re_copy_warning = re.compile(r"^(\s*)#\s*Copied from\s+transformers\.(\S+\.\S+)\s*($|\S.*$)")
_re_replace_pattern = re.compile(r"^\s*(\S+)->(\S+)(\s+.*|$)") _re_replace_pattern = re.compile(r"^\s*(\S+)->(\S+)(\s+.*|$)")
_re_fill_pattern = re.compile(r"<FILL\s+[^>]*>")
def get_indent(code): def get_indent(code):
...@@ -346,6 +347,11 @@ def convert_to_localized_md(model_list, localized_model_list, format_str): ...@@ -346,6 +347,11 @@ def convert_to_localized_md(model_list, localized_model_list, format_str):
# Add an anchor white space behind a model description string for regex. # Add an anchor white space behind a model description string for regex.
# If metadata cannot be captured, the English version will be directly copied. # If metadata cannot be captured, the English version will be directly copied.
localized_model_index[title] = _re_capture_meta.sub(_rep, model + " ") localized_model_index[title] = _re_capture_meta.sub(_rep, model + " ")
elif _re_fill_pattern.search(localized_model_index[title]) is not None:
update = _re_capture_meta.sub(_rep, model + " ")
if update != localized_model_index[title]:
readmes_match = False
localized_model_index[title] = update
else: else:
# Synchronize link # Synchronize link
localized_model_index[title] = _re_capture_title_link.sub( localized_model_index[title] = _re_capture_title_link.sub(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment