INNER CODE UNIT · Python

get_line_pos

bsilverthorn/maccarone · src/maccarone/preprocessor.py:39

    def get_line_pos(self, raw_source: str) -> Tuple[int, int]:
        start_line = raw_source.count('\n', 0, self.start) + 1
        end_line = raw_source.count('\n', 0, self.end) + 1

        return (start_line, end_line)

    def complete(self, replacement: Optional[str]) -> str:
        (indent, guidance) = (self.indent, self.guidance)

        if "\n" in guidance:
            guidance_lines = "\n"
            guidance_lines += "\n".join(f"{indent}#{line}" for line in guidance.splitlines())
            guidance_lines += f"\n{indent}#"
        else:
            guidance_lines = guidance

        source = f"{indent}#<<{guidance_lines}>>\n"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…