Esempio n. 1
0
    def getLoadedDirname(self, mod):
        """ Returns the directory name that the indicated
        conventionally-loaded module must have been loaded from. """

        fullname = mod.__name__
        dirname = Filename.fromOsSpecific(mod.__file__).getDirname()

        parentname = None
        basename = fullname
        if '.' in fullname:
            parentname, basename = fullname.rsplit('.', 1)

        path = None
        if parentname:
            parent = sys.modules[parentname]
            path = parent.__path__
        if path is None:
            path = sys.path

        for dir in path:
            pdir = Filename.fromOsSpecific(dir).cStr()
            if pdir + '/' + basename == dirname:
                # We found it!
                return dir

        # Couldn't figure it out.
        return None
Esempio n. 2
0
    def getLoadedDirname(self, mod):
        """ Returns the directory name that the indicated
        conventionally-loaded module must have been loaded from. """

        fullname = mod.__name__
        dirname = Filename.fromOsSpecific(mod.__file__).getDirname()

        parentname = None
        basename = fullname
        if '.' in fullname:
            parentname, basename = fullname.rsplit('.', 1)

        path = None
        if parentname:
            parent = sys.modules[parentname]
            path = parent.__path__
        if path is None:
            path = sys.path

        for dir in path:
            pdir = Filename.fromOsSpecific(dir).cStr()
            if pdir + '/' + basename == dirname:
                # We found it!
                return dir

        # Couldn't figure it out.
        return None
Esempio n. 3
0
 def __init__(self, path):
     self.dir_path = Filename.fromOsSpecific(path)
Esempio n. 4
0
 def getdata(self, path):
     path = Filename(self.dir_path, Filename.fromOsSpecific(path))
     vfile = vfs.getFile(path)
     if not vfile:
         raise IOError
     return vfile.readFile(True)
Esempio n. 5
0
 def __init__(self, path):
     self.dir_path = Filename.fromOsSpecific(path)
Esempio n. 6
0
 def getdata(self, path):
     path = Filename(self.dir_path, Filename.fromOsSpecific(path))
     vfile = vfs.getFile(path)
     if not vfile:
         raise IOError
     return vfile.readFile(True)