File: reg_qtres_importer.py

package info (click to toggle)
radare2-cutter 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,768 kB
  • sloc: cpp: 38,432; python: 507; sh: 505; xml: 115; makefile: 89; ansic: 10; javascript: 3
file content (30 lines) | stat: -rw-r--r-- 741 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
import importlib
import _qtres

class QtResLoader:
    @classmethod
    def get_code(cls, name):
        return _qtres.get_code(name)

    @classmethod
    def create_module(cls, spec):
        return None

    @classmethod
    def exec_module(cls, module):
        code = cls.get_code(module.__name__)
        if code is None:
            raise ImportError("get_code() failed")
        exec(code, module.__dict__)

class QtResFinder:
    @classmethod
    def find_spec(cls, fullname, path=None, target=None):
        if path or target:
            return None
        if not _qtres.exists(fullname):
            return None
        return importlib._bootstrap.ModuleSpec(fullname, QtResLoader)

sys.meta_path.append(QtResFinder)