MCPcopy Index your code
hub / github.com/python/cpython / extract_from_snapshots

Function extract_from_snapshots

Lib/test/test_tools/test_i18n.py:595–629  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

593
594
595def extract_from_snapshots():
596 snapshots = {
597 'messages.py': (),
598 'fileloc.py': ('--docstrings',),
599 'docstrings.py': ('--docstrings',),
600 'comments.py': ('--add-comments=i18n:',),
601 'custom_keywords.py': ('--keyword=foo', '--keyword=nfoo:1,2',
602 '--keyword=pfoo:1c,2',
603 '--keyword=npfoo:1c,2,3', '--keyword=_:1,2'),
604 'multiple_keywords.py': ('--keyword=foo:1c,2,3', '--keyword=foo:1c,2',
605 '--keyword=foo:1,2',
606 # repeat a keyword to make sure it is extracted only once
607 '--keyword=foo', '--keyword=foo'),
608 # == Test character escaping
609 # Escape ascii and unicode:
610 'escapes.py': ('--escape', '--add-comments='),
611 # Escape only ascii and let unicode pass through:
612 ('escapes.py', 'ascii-escapes.pot'): ('--add-comments=',),
613 }
614
615 for filename, args in snapshots.items():
616 if isinstance(filename, tuple):
617 filename, output_file = filename
618 output_file = DATA_DIR / output_file
619 input_file = DATA_DIR / filename
620 else:
621 input_file = DATA_DIR / filename
622 output_file = input_file.with_suffix('.pot')
623 contents = input_file.read_bytes()
624 with temp_cwd(None):
625 Path(input_file.name).write_bytes(contents)
626 assert_python_ok('-Xutf8', Test_pygettext.script, *args,
627 input_file.name)
628 yield (input_file, output_file,
629 Path('messages.pot').read_text(encoding='utf-8'))
630
631
632def update_POT_snapshots():

Callers 2

test_pygettext_outputMethod · 0.85
update_POT_snapshotsFunction · 0.85

Calls 8

temp_cwdFunction · 0.90
PathClass · 0.90
assert_python_okFunction · 0.90
itemsMethod · 0.45
with_suffixMethod · 0.45
read_bytesMethod · 0.45
write_bytesMethod · 0.45
read_textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…