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

Function load_accept_patterns

scripts/developer-guide/run_languagetool.py:410–425  ·  view source on GitHub ↗

Read the accept-list file and return a compiled regex (or None).

(path)

Source from the content-addressed store, hash-verified

408
409
410def load_accept_patterns(path):
411 """Read the accept-list file and return a compiled regex (or None)."""
412 if not path or not os.path.exists(path):
413 return None
414 raw_patterns = []
415 with open(path, "r", encoding="utf-8") as fh:
416 for line in fh:
417 line = line.strip()
418 if not line or line.startswith("#"):
419 continue
420 raw_patterns.append(f"(?:{line})")
421 if not raw_patterns:
422 return None
423 combined = r"(?:" + "|".join(raw_patterns) + r")"
424 # Match must consume the entire flagged span and be at a word boundary.
425 return re.compile(rf"\A(?:{combined})\Z")
426
427
428_CONTEXT_CODE_RE = re.compile(r"[._][a-zA-Z_][a-zA-Z0-9_]*")

Callers 1

mainFunction · 0.85

Calls 5

existsMethod · 0.65
appendMethod · 0.65
joinMethod · 0.65
compileMethod · 0.65
stripMethod · 0.45

Tested by

no test coverage detected