MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / run_file

Function run_file

tools/cython_imports.py:37–60  ·  view source on GitHub ↗
(cmd: code_writer_cmd, file: Path)

Source from the content-addressed store, hash-verified

35
36
37def run_file(cmd: code_writer_cmd, file: Path):
38 content = file.read_text("utf-8")
39 count = 0
40
41 def repl_fn(match):
42 nonlocal count
43 count += 1
44 return code
45
46 content = section_re.sub(repl_fn, content)
47 if count == 0:
48 if content:
49 raise ValueError(
50 "Expected to find comment '# START GENERATED CYTHON IMPORT' "
51 f"in cython file {file}, but none found and the file is not "
52 "empty"
53 )
54 content = code
55 if count > 1:
56 raise ValueError(
57 "Expected to find a single comment '# START GENERATED CYTHON "
58 f"IMPORT' in cython file {file}, but {count} found"
59 )
60 cmd.write_output_file_from_text(content, file)
61
62
63def run(cmd: code_writer_cmd):

Callers 1

runFunction · 0.70

Calls 2

subMethod · 0.80

Tested by

no test coverage detected