MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / process_file

Function process_file

scripts/website/americanize_spelling.py:149–166  ·  view source on GitHub ↗
(path, write, counts, skipped)

Source from the content-addressed store, hash-verified

147
148
149def process_file(path, write, counts, skipped):
150 with open(path, "r", encoding="utf-8") as fh:
151 original = fh.read()
152 fm, body, _ = blog_text.split_front_matter(original)
153 if post_author(fm).lower() in SKIP_AUTHORS:
154 skipped.append(os.path.basename(path))
155 return False
156 cut = len(blog_text.author_body(body))
157 author_part, rest = body[:cut], body[cut:]
158 new_author = convert_body(author_part, counts)
159 if new_author == author_part:
160 return False
161 new_full = fm + new_author + rest
162 assert new_full.startswith(fm), f"front matter changed in {path}"
163 if write:
164 with open(path, "w", encoding="utf-8") as fh:
165 fh.write(new_full)
166 return True
167
168
169def expand(paths):

Callers 1

mainFunction · 0.70

Calls 6

post_authorFunction · 0.85
convert_bodyFunction · 0.85
readMethod · 0.65
lowerMethod · 0.65
appendMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected