/usr/share/pyshared/jsb/utils/source.py is in jsonbot 0.84.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 | # jsb/utils/source.py
#
#
""" get the location of a source """
## basic imports
import os
import logging
import sys
## getsource function
def getsource(mod):
if not os.getcwd() in sys.path: sys.path.insert(0, os.getcwd())
source = None
splitted = mod.split(".")
if len(splitted) == 1: splitted.append("")
thedir = mod.replace(".", os.sep)
if os.path.isdir(thedir): source = thedir
if source and os.path.exists(source):
logging.info("datadir - source is %s" % source)
return source
if not source:
try:
import pkg_resources
source = pkg_resources.resource_filename(".".join(splitted[:len(splitted)-1]), splitted[-1])
except ImportError:
try:
import jsb.contrib.pkg_resources as pkg_resources
source = pkg_resources.resource_filename(".".join(splitted[:len(splitted)-1]), splitted[-1])
except ImportError: pass
logging.info("datadir - source is %s" % source)
return source
|