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

Method write_code

scripts/openapi.py:2085–2096  ·  view source on GitHub ↗
(orig_code: str, updated_code: str, filename: str, dry_run: bool)

Source from the content-addressed store, hash-verified

2083
2084 @staticmethod
2085 def write_code(orig_code: str, updated_code: str, filename: str, dry_run: bool) -> bool:
2086 if dry_run:
2087 diff = difflib.unified_diff(orig_code.splitlines(1), updated_code.splitlines(1))
2088 changes = "".join(diff)
2089 print("Diff:")
2090 print(changes)
2091 return len(changes) > 0
2092 else:
2093 if updated_code != orig_code:
2094 with open(filename, "w") as w:
2095 w.write(updated_code)
2096 return True
2097
2098 def apply(
2099 self,

Callers 4

applyMethod · 0.95
create_classMethod · 0.95
create_methodMethod · 0.95
add_schema_to_classMethod · 0.80

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected