コード例 #1
0
def _object_information_html_iterator(theCgi):
    if theCgi.m_entity_type:
        # WrtAsUtf('m_entity_id: %s<br>'%(theCgi.m_entity_id))

        entity_module = lib_util.GetEntityModule(theCgi.m_entity_type)
        entDoc = entity_module.__doc__
        if entDoc:
            entDoc = entDoc.strip()
        else:
            entDoc = ""

        urlClass = lib_util.EntityClassUrl(theCgi.m_entity_type)
        urlClass_with_mode = _url_in_html_mode(urlClass)

        yield ('<table class="table_script_information">')
        yield ("""
        <tr>
            <td><a href='%s'>%s</a></td>
            <td>%s</td>
        </tr>
        """ % (urlClass_with_mode, theCgi.m_entity_type, entDoc))

        for dict_property_value in theCgi.m_entity_id_dict.items():
            yield ("<tr><td>%s</td><td>%s</td></tr>" % dict_property_value)

        yield ('</table>')
コード例 #2
0
ファイル: lib_export_html.py プロジェクト: rchateauneu/survol
def _objects_triplets(dict_class_subj_prop_obj):
    """Group objects by class.
    Display list of classes with an index and a link to the class."""

    # No need to use natural sort, because these are no filenames or strings containing numbers.
    for entity_graphic_class in sorted(dict_class_subj_prop_obj):
        url_class = lib_util.EntityClassUrl(entity_graphic_class)
        url_class_with_mode = _url_in_html_mode(url_class)
        dict_subj_prop_obj = dict_class_subj_prop_obj[entity_graphic_class]

        array_graph_params = lib_patterns.TypeToGraphParams(
            entity_graphic_class)
        # "Graphic_shape","Graphic_colorfill","Graphic_colorbg","Graphic_border","Graphic_is_rounded"
        color_class = array_graph_params[1]

        yield url_class_with_mode, entity_graphic_class, color_class, dict_subj_prop_obj
コード例 #3
0
ファイル: lib_export_html.py プロジェクト: vchateauneu/survol
def WriteAllObjects(grph):
    """
		This displays all the objects returend by this scripts.
		Other scripts are not here, so we do not have to eliminate them.
		This is therefore simpler than in the SVG (Graphviz) output,
		where all objects are mixed together.
	"""

    # This groups data by subject, then predicate, then object.
    dictClassSubjPropObj = dict()

    # TODO: Group objects by type, then display the count, some info about each type etc...
    for aSubj, aPred, anObj in grph:
        # No point displaying some keys if there is no value.
        if aPred == pc.property_information:
            try:
                if str(anObj) == "":
                    continue
            # 'ascii' codec can't encode character u'\xf3' in position 17: ordinal not in range(128)
            # u'SDK de comprobaci\xf3n de Visual Studio 2012 - esn'
            except UnicodeEncodeError:
                exc = sys.exc_info()[1]
                sys.stderr.write("Exception %s\n" % str(exc))
                continue

        subj_str = str(aSubj)
        (subj_title, entity_graphic_class,
         entity_id) = lib_naming.ParseEntityUri(subj_str)

        try:
            dictSubjPropObj = dictClassSubjPropObj[entity_graphic_class]
            try:
                dictPred = dictSubjPropObj[aSubj]
                try:
                    dictPred[aPred].append(anObj)
                except KeyError:
                    # First time this object has this predicate.
                    dictPred[aPred] = [anObj]
            except KeyError:
                # First time we see this object.
                dictSubjPropObj[aSubj] = {aPred: [anObj]}
        except KeyError:
            # First object of this class.
            dictClassSubjPropObj[entity_graphic_class] = {
                aSubj: {
                    aPred: [anObj]
                }
            }

    # Group objects by class.
    # Display list of classes with an indexs and a link to the class.
    # "NO TITLE" is wrong

    # TODO: Create a "difference mode". Periodic display, of only the difference between successive data sets.
    # Ajouter mode "difference": On recalcule periodiquement et on affiche la difference.

    # No need to use natural sort, because these are no filenames or strings containing numbres.
    for entity_graphic_class in sorted(dictClassSubjPropObj):

        urlClass = lib_util.EntityClassUrl(entity_graphic_class)
        urlClass_with_mode = UrlInHtmlMode(urlClass)
        WrtAsUtf("<h3>Class <a href='%s'>%s</a></h3>" %
                 (urlClass_with_mode, entity_graphic_class))
        dictSubjPropObj = dictClassSubjPropObj[entity_graphic_class]

        DispClassObjects(dictSubjPropObj)
コード例 #4
0
ファイル: lib_export_html.py プロジェクト: vchateauneu/survol
def WriteScriptInformation(theCgi, gblCgiEnvList):
    """
		This displays general information about this script and the object if there is one.
	"""
    sys.stderr.write("WriteScriptInformation entity_type=%s\n" %
                     (theCgi.m_entity_type))

    # This is already called in lib_common, when creating CgiEnv.
    # It does not matter because this is very fast.
    callingUrl = lib_util.RequestUri()
    (entity_label, entity_graphic_class,
     entity_id) = lib_naming.ParseEntityUri(callingUrl, longDisplay=True)
    sys.stderr.write("entity_label=%s entity_graphic_class=%s entity_id=%s\n" %
                     (entity_label, entity_graphic_class, entity_id))

    # WrtAsUtf('<table class="list_of_merged_scripts">')
    WrtAsUtf('<table border="0">')
    if len(gblCgiEnvList):
        sys.stderr.write("gblCgiEnvList=%s\n" % str(gblCgiEnvList))
        # This step is dedicated to the merging of several scripts.

        WrtAsUtf(
            "<tr align=left><td colspan=2 align=left><h2>Fusion of data from %d scripts</h2></td></tr>"
            % len(gblCgiEnvList))
        for aCgiEnv in gblCgiEnvList:
            sys.stderr.write("aCgiEnv=%s\n" % str(aCgiEnv))
            sys.stderr.write("aCgiEnv.m_page_title=%s\n" %
                             str(aCgiEnv.m_page_title))
            sys.stderr.write("aCgiEnv.m_calling_url=%s\n" %
                             str(aCgiEnv.m_calling_url))
            (page_title_first, page_title_rest) = lib_util.SplitTextTitleRest(
                aCgiEnv.m_page_title)
            WrtAsUtf(
                "<tr><td><a href='%s'>%s</td><td><i>%s</i></td></tr>" %
                (aCgiEnv.m_calling_url, page_title_first, page_title_rest))

    else:
        (page_title_first,
         page_title_rest) = lib_util.SplitTextTitleRest(theCgi.m_page_title)
        WrtAsUtf("<tr><td colspan=2><h2>%s</h2></td></tr>" %
                 (page_title_first))
        if page_title_rest:
            WrtAsUtf("<tr><td colspan=2>%s</td></tr>" % (page_title_rest))

    WrtAsUtf('</table>')

    if theCgi.m_entity_type:
        # WrtAsUtf('m_entity_id: %s<br>'%(theCgi.m_entity_id))

        WrtAsUtf('<table class="table_script_information">')

        entity_module = lib_util.GetEntityModule(theCgi.m_entity_type)
        entDoc = entity_module.__doc__
        if not entDoc:
            entDoc = ""

        urlClass = lib_util.EntityClassUrl(theCgi.m_entity_type)
        urlClass_with_mode = UrlInHtmlMode(urlClass)
        WrtAsUtf("""
		<tr>
			<td><a href='%s'>%s</a></td>
			<td>%s</td>
		</tr>
		""" % (urlClass_with_mode, theCgi.m_entity_type, entDoc))

        for keyProp in theCgi.m_entity_id_dict:
            keyVal = theCgi.m_entity_id_dict[keyProp]

            WrtAsUtf("""
			<tr>
				<td>%s</td>
				<td>%s</td>
			</tr>
			""" % (keyProp, keyVal))

        WrtAsUtf('</table>')