File: run-local

package info (click to toggle)
calibre 5.12.0%2Bdfsg-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 391,928 kB
  • sloc: python: 402,208; ansic: 77,519; javascript: 56,085; cpp: 14,321; xml: 1,749; sh: 828; sql: 629; objc: 456; makefile: 54; sed: 3
file content (26 lines) | stat: -rwxr-xr-x 778 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/env python
import importlib
import os
import sys


sys.run_local = os.path.abspath(__file__)
base = os.path.dirname(sys.run_local)
src = os.path.join(base, 'src')
if src not in sys.path:
    sys.path.insert(0, src)
sys.resources_location = os.path.join(base, 'resources')
sys.extensions_location = os.path.join(src, 'calibre', 'plugins')
entry_point = sys.argv[1]
del sys.argv[1]
del src
del base

for ep in importlib.import_module('calibre.linux').entry_points.values():
    for line in ep:
        q, spec = (x.strip() for x in line.split('='))
        if q == entry_point:
            mod, func = spec.split(':')
            m = importlib.import_module(mod)
            sys.exit(getattr(m, func)())
raise SystemExit('No entry point named: {}'.format(entry_point))