コード例 #1
0
	def KeyToPckgNode(key):
		try:
			packageNode = Main.dictKeyToPckg[ key ]
		except KeyError:
			packageNode = package.MakeUri( key )
			Main.dictKeyToPckg[ key ] = packageNode
		return packageNode
コード例 #2
0
 def key_to_pckg_node(key):
     try:
         package_node = Main.dictKeyToPckg[key]
     except KeyError:
         package_node = package.MakeUri(key)
         Main.dictKeyToPckg[ key ] = package_node
     return package_node
コード例 #3
0
def Main():
    paramkeyMaxDepth = "Maximum depth"
    paramkeyDispPackages = "Display packages"
    paramkeyDispFiles = "Display files"

    cgiEnv = lib_common.CgiEnv({
        paramkeyMaxDepth: 1,
        paramkeyDispPackages: True,
        paramkeyDispFiles: False
    })

    packageNam = cgiEnv.GetId()

    maxDepth = cgiEnv.GetParameters(paramkeyMaxDepth)
    dispPackages = cgiEnv.GetParameters(paramkeyDispPackages)
    dispFiles = cgiEnv.GetParameters(paramkeyDispFiles)

    packageNode = survol_python_package.MakeUri(packageNam)

    sys.stderr.write("packageNam=%s\n" % packageNam)

    grph = cgiEnv.GetGraph()

    tmpPyFil = lib_common.TmpFile("py_package_deps", "py")
    tmpPyFilName = tmpPyFil.Name

    # This creates a temporary file which imports the package.
    tmpFd = open(tmpPyFilName, "w")
    tmpFd.write("import %s\n" % packageNam)
    tmpFd.close()

    survol_python_package.AddImportedModules(grph, packageNode, tmpPyFilName,
                                             maxDepth, dispPackages, dispFiles)

    try:
        the_module = importlib.import_module(packageNam)
    except:
        exc = sys.exc_info()[0]
        lib_common.ErrorMessageHtml("Package:%s Unexpected error:%s" %
                                    (packageNam, str(exc)))

    try:
        initFilNam = the_module.__file__
        filNode = lib_common.gUriGen.FileUri(initFilNam)
        grph.add(
            (packageNode, survol_python_package.propPythonPackage, filNode))

        try:
            survol_python.AddAssociatedFiles(grph, filNode, initFilNam)
        except:
            exc = sys.exc_info()[0]
            lib_common.ErrorMessageHtml("File:%s Unexpected error:%s" %
                                        (initFilNam, str(exc)))
    except AttributeError:
        pass

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")
コード例 #4
0
def Main():
    paramkey_max_depth = "Maximum depth"
    paramkey_disp_packages = "Display packages"
    paramkey_disp_files = "Display files"

    cgiEnv = lib_common.ScriptEnvironment(
            {paramkey_max_depth: 1, paramkey_disp_packages: True, paramkey_disp_files: False})

    package_nam = cgiEnv.GetId()

    max_depth = cgiEnv.get_parameters(paramkey_max_depth)
    disp_packages= cgiEnv.get_parameters(paramkey_disp_packages)
    disp_files = cgiEnv.get_parameters(paramkey_disp_files)

    package_node = survol_python_package.MakeUri(package_nam)

    logging.debug("package_nam=%s", package_nam)

    grph = cgiEnv.GetGraph()

    tmp_py_fil = lib_util.TmpFile("py_package_deps", "py")
    tmp_py_fil_name = tmp_py_fil.Name

    # This creates a temporary file which imports the package.
    tmp_fd = open(tmp_py_fil_name, "w")
    tmp_fd.write("import %s\n" % package_nam)
    tmp_fd.close()

    survol_python_package.AddImportedModules(grph, package_node, tmp_py_fil_name, max_depth, disp_packages, disp_files)

    try:
        the_module = importlib.import_module(package_nam)
    except Exception as exc:
        lib_common.ErrorMessageHtml("Package:%s Unexpected error:%s" % (package_nam, str(exc)))

    try:
        init_fil_nam = the_module.__file__
        fil_node = lib_uris.gUriGen.FileUri(init_fil_nam)
        grph.add((package_node, survol_python_package.prop_python_package, fil_node))

        try:
            survol_python.AddAssociatedFiles(grph,fil_node, init_fil_nam)
        except Exception as exc:
            lib_common.ErrorMessageHtml("File:%s Unexpected error:%s" % (init_fil_nam, str(exc)))
    except AttributeError:
        pass

    cgiEnv.OutCgiRdf("LAYOUT_SPLINE")