MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / main

Function main

scripts/prepare-for-update-assertions.py:108–129  ·  view source on GitHub ↗
(filename: str, function: str, dry_run: bool)

Source from the content-addressed store, hash-verified

106
107
108def main(filename: str, function: str, dry_run: bool) -> bool:
109 with open(filename) as r:
110 code = "".join(r.readlines())
111
112 tree = cst.parse_module(code)
113 transformer = SingleLineStatementTransformer(function)
114 tree_updated = tree.visit(transformer)
115
116 if dry_run:
117 diff = "".join(difflib.unified_diff(code.splitlines(1), tree_updated.code.splitlines(1)))
118 if diff:
119 print(f"Diff of {filename}:")
120 print(diff)
121 print()
122 return True
123 else:
124 if not tree_updated.deep_equals(tree):
125 with open(filename, "w") as w:
126 w.write(tree_updated.code)
127 return True
128
129 return False
130
131
132def parse_args():

Calls 2

writeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…