File: compiler.py

package info (click to toggle)
xeus-python 0.17.2%2B~0.6.3-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,752 kB
  • sloc: cpp: 4,890; python: 369; makefile: 18; javascript: 14
file content (20 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from IPython.core.compilerop import CachingCompiler


class XCachingCompiler(CachingCompiler):
    def __init__(self, *args, **kwargs):
        super(XCachingCompiler, self).__init__(*args, **kwargs)

        self.filename_mapper = None
        self.get_filename = None

    def get_code_name(self, raw_code, code, number):
        if self.get_filename is not None:
            filename = self.get_filename(raw_code)
        else:
            filename = "<string>"

        if self.filename_mapper is not None:
            self.filename_mapper(filename, number)

        return filename