예제 #1
0
    def get_html(self):
        """Generates html for displaying all metadata elements associated with this logical file.
        Subclass must override to include additional html for additional metadata it supports.
        """

        root_div = div()
        dataset_name_div = div()
        if self.logical_file.dataset_name:
            with dataset_name_div:
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            th("Title", cls="text-muted")
                            td(self.logical_file.dataset_name)
        keywords_div = div()
        if self.keywords:
            keywords_div = div(cls="col-sm-12 content-block")
            with keywords_div:
                legend('Keywords')
                with div(cls="tags"):
                    with ul(id="list-keywords-file-type",
                            cls="tag-list custom-well"):
                        for kw in self.keywords:
                            with li():
                                a(kw, cls="tag")

        extra_metadata_div = div()
        if self.extra_metadata:
            extra_metadata_div = div(cls="col-sm-12 content-block")
            with extra_metadata_div:
                legend('Extended Metadata')
                with table(cls="table table-striped funding-agencies-table",
                           style="width: 100%"):
                    with tbody():
                        with tr(cls="header-row"):
                            th("Key")
                            th("Value")
                        for k, v in self.extra_metadata.iteritems():
                            with tr(data_key=k):
                                td(k)
                                td(v)

        if self.logical_file.dataset_name:
            root_div.add(dataset_name_div)
        if self.keywords:
            root_div.add(keywords_div)
        if self.extra_metadata:
            root_div.add(extra_metadata_div)

        return root_div.render()
예제 #2
0
    def render(self):
        """Print unique values for a column."""
        rows: List[Row] = self.query(
            query_text=self.legend_query,
            column=self.iri,
        )

        table_rows = [
            tr(
                td(
                    raw(
                        render(
                            node=row['prov_value'],
                            octiron=self.octiron,
                            environments=[
                                TABLE.td,
                                IOLANTA.html,
                            ],
                        ) if row['prov_value'] is not None else '', ), ),
                td(*self.render_comment(row)),
                td(row['count']),
            ) for row in rows
        ]

        return table(
            thead(
                tr(
                    # These are hard coded, and I cannot change that. See the
                    # docstring for details.
                    th('Value'),
                    th('Description'),
                    th('Count'),
                ), ),
            tbody(*table_rows),
        )
예제 #3
0
    def get_html(self):
        """generates html code for viewing web service related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('URL')
                            td(self.url)
                        with tr():
                            get_th('Service Type')
                            td(self.service_type)
                        with tr():
                            get_th('Return Type')
                            td(self.return_type)
                        with tr():
                            get_th('Reference Type')
                            td(self.reference_type)

        return root_div.render(pretty=True)
def build_discrepancy_parent_report(discrepancy_reports):
    version = utils.show_version()
    doc = dominate.document(title='Audit Engine version: ' + version)
    report_head(doc)
    discrepancy_reports.sort(key=itemgetter('discrepancy', 'ballots'),
                             reverse=True)
    with doc:
        with div(cls='container'):
            report_headline(version)
            with table(cls='table table-striped'):
                with thead():
                    with tr():
                        th('#', scope="col")
                        th('Precinct', scope="col")
                        th('Ballots total', scope="col")
                        th('Discrepancy', scope="col")
                        th('Report', scope="col")
                with tbody():
                    for index, report in enumerate(discrepancy_reports):
                        with tr():
                            report_abs_path = os.path.abspath(
                                report.get('path'))
                            th(index + 1)
                            td(report.get('precinct'))
                            td(report.get('ballots'))
                            td(f"{report.get('discrepancy')}%")
                            td(
                                a(i(cls='far fa-file-alt'),
                                  href=report_abs_path,
                                  targer='_blank'))
    return doc
def get_summary_table(cmpcvr_df):
    ballots_processed = cmpcvr_df.shape[0]
    styles_detected = len(cmpcvr_df['style'].unique())
    matched_ballots = len(cmpcvr_df.loc[cmpcvr_df['agreed'] == 1])
    non_matched_ballots = len(cmpcvr_df.loc[cmpcvr_df['agreed'] == 0])
    blank_ballots = len(cmpcvr_df.loc[cmpcvr_df['blank'] == 1])
    overvoted_ballots = len(cmpcvr_df.loc[cmpcvr_df['overvotes'] > 0])
    with table(cls='table table-striped'):
        with tbody():
            with tr():
                th('Number of ballots processed')
                td(ballots_processed)
            with tr():
                th('Number of different ballot types')
                td(styles_detected)
            with tr():
                th('Number of ballots matching the CVR results')
                td(matched_ballots)
            with tr():
                th('Number of ballots not matching the CVR results')
                td(non_matched_ballots)
            with tr():
                th('Number of completely blank ballots')
                td(blank_ballots)
            with tr():
                th('Number of overvotes')
                td(overvoted_ballots)
예제 #6
0
def html_grid(grid, transpose=False):
    if transpose:
        grid = list(map(list, zip(*grid)))
    with dtags.table().add(dtags.tbody()):
        for row_idx, row in enumerate(grid):
            with dtags.tr():
                for cell_idx, cell in enumerate(row):
                    cell_type = cell["type"]
                    if cell_type == "txt":
                        if "text" not in cell:
                            raise ValueError(
                                "Expected grid cell of type 'txt'"
                                " to have field 'text'"
                            )
                        dtags.td().add(dtags.p(cell["text"]))
                    elif cell_type == "video":
                        if "path" not in cell:
                            raise ValueError(
                                "Expected grid cell of type 'video'"
                                " to have field 'path'"
                            )
                        video_path = cell["path"]
                        if str(video_path).lower().endswith("webm"):
                            vid_type = "video/webm"
                        if str(video_path).lower().endswith("mp4"):
                            vid_type = "video/mp4"
                        with dtags.td():
                            dtags.video(controls=True, autoplay=False).add(
                                dtags.source(src=video_path, type=vid_type)
                            )
def mount_discrepancy_table(contest: str, contest_disagreed_df: pd.DataFrame,
                            precinct_marks_df: pd.DataFrame) -> table:
    contest_marks_df = precinct_marks_df.loc[precinct_marks_df['contest'] ==
                                             contest]
    overvotes = contest_marks_df['overvotes'].sum()
    undervotes = contest_marks_df['undervotes'].sum()
    options = [
        o for o in contest_marks_df['option'].unique().tolist()
        if not o.startswith('#contest vote_for')
    ]
    with table(cls='table table-striped'):
        with thead():
            with tr():
                th('Candidate or Issue', scope="col")
                th('Audit System Adjudicated Votes', scope="col")
                th('Audit Indeterminate Votes', scope="col")
                th('Canvassing Board Adjustments', scope="col")
                th('Audit Total Votes', scope="col")
                th('Certified Results Total', scope="col")
                th('Difference', scope="col")
        with tbody():
            for option in options:
                mount_option_row(option, contest_disagreed_df,
                                 contest_marks_df)
            with tr():
                td('Number of overvotes')
                td(overvotes, colspan=6)
            with tr():
                td('Number of undervotes')
                td(undervotes, colspan=6)
예제 #8
0
    def _create_table(self, rows):
        columns = []
        for row in rows:
            for column in row.keys():
                if column in columns:
                    continue
                columns.append(column)

        # Create table
        table = tags.table()

        thead = tags.thead()
        tr = tags.tr()
        for column in columns:
            tr += tags.th(raw(column))
        thead += tr

        tbody = tags.tbody()
        for row in rows:
            tr = tags.tr()
            for column in columns:
                tr += tags.td(row.get(column, ''))
            tbody += tr

        table += thead
        table += tbody

        return table
예제 #9
0
def status_class(octiron: Octiron, iri: URIRef):
    """Visualize all available status values as a table."""
    choices = octiron.query('''
        SELECT
            ?status ?label ?symbol
            ?defined_by_iri ?defined_by_url ?defined_by_label
        WHERE {
            ?status a adr:Status .

            GRAPH ?defined_by_iri {
                ?status rdfs:label ?label .

                OPTIONAL {
                   ?status octa:symbol ?symbol .
                }
            }

            OPTIONAL {
                ?defined_by_iri octa:url ?defined_by_url .
            }

            OPTIONAL {
                ?defined_by_iri rdfs:label ?defined_by_label .
            }
        } ORDER BY ?label
        ''')

    rows = map(build_table_row, choices)

    return table(thead(tr(
        th('Code'),
        th('Label'),
        th('Defined By'),
    )), tbody(*rows))
예제 #10
0
    def get_html(self):
        """generates html code for viewing site related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('Name')
                            td(self.name)
                        with tr():
                            get_th('Code')
                            td(self.code)
                        with tr():
                            get_th('Latitude')
                            td(self.latitude)
                        with tr():
                            get_th('Longitude')
                            td(self.longitude)

        return root_div.render(pretty=True)
def getDescriptionPills(statistics):
    statistics = np.round(statistics, 1)

    statisticstable = table(cls='table')
    table_header_row = tr()
    table_header_row.appendChild(th('Measurements count'))
    table_header_row.appendChild(th('Mean error'))
    table_header_row.appendChild(th('Standard Error dev'))
    table_header_row.appendChild(th('Min error measured'))
    table_header_row.appendChild(th('First quartile (25%)'))
    table_header_row.appendChild(th('Median (50%)'))
    table_header_row.appendChild(th('Third quartile (75%)'))
    table_header_row.appendChild(th('Max error measured'))

    table_row = tr()
    table_row.appendChild(td(str(statistics[0])))
    table_row.appendChild(td(str(statistics[1])))
    table_row.appendChild(td(str(statistics[2])))
    table_row.appendChild(td(str(statistics[3])))
    table_row.appendChild(td(str(statistics[4])))
    table_row.appendChild(td(str(statistics[5])))
    table_row.appendChild(td(str(statistics[6])))
    table_row.appendChild(td(str(statistics[7])))

    statisticstable.appendChild(thead(table_header_row))
    statisticstable.appendChild(tbody(table_row))
    return statisticstable
예제 #12
0
    def _write_body(self, write_attr: bool) -> None:
        tags, raw = _get_tags_module()
        tbody_tag = tags.tbody()

        for row_idx, (values, value_dp_list) in enumerate(
                zip(self._table_value_matrix, self._table_value_dp_matrix)):
            tr_tag = tags.tr()
            for value, value_dp, column_dp in zip(values, value_dp_list,
                                                  self._column_dp_list):
                td_tag = tags.td(raw(MultiByteStrDecoder(value).unicode_str))

                default_style = self._get_col_style(column_dp.column_index)
                style = self._fetch_style_from_filter(row_idx, column_dp,
                                                      value_dp, default_style)

                if write_attr:
                    if style.align == Align.AUTO:
                        td_tag["align"] = value_dp.align.align_string
                    else:
                        td_tag["align"] = style.align.align_string

                    if style.vertical_align != VerticalAlign.BASELINE:
                        td_tag["valign"] = style.vertical_align.align_str

                    style_tag = self.__make_style_tag(style=style)
                    if style_tag:
                        td_tag["style"] = style_tag

                tr_tag += td_tag
            tbody_tag += tr_tag

        self._table_tag += tbody_tag
        self._write_line(self._table_tag.render(indent=self.indent_string))
예제 #13
0
def main(args=None):
    if args == None:
        args = arguments.Args()
        if len(args) < 4:
            print(
                'Returns Github Issues from the Github API based on the arguments and generates an HTML table.'
            )
            print(
                'Usage: python report.py <GITHUB_TOKEN> <GITHUB_REPO> <GITHUB_ORG> <GITHUB_ISSUE_LABEL> >report.html'
            )
            exit(1)
    token = args.get(0)
    repository = args.get(1)
    organization = args.get(2)
    label = args.get(3)
    if token is not None and repository is not None and organization is not None and label is not None:
        g = Github(token)
        repos = g.get_organization(organization).get_repos(repository)
    title = 'Github Issue Status'
    d = dominate.document(title=title)
    with d.body:
        h1(title)
        with table(border='1', width='1024', cellpadding='10').add(tbody()):
            make_table(repos, label)
    print(d)
예제 #14
0
    def get_html(self):
        """generates html code for viewing site related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('Name')
                            td(self.name)
                        with tr():
                            get_th('Code')
                            td(self.code)
                        with tr():
                            get_th('Latitude')
                            td(self.latitude)
                        with tr():
                            get_th('Longitude')
                            td(self.longitude)

        return root_div.render(pretty=True)
예제 #15
0
    def get_html(self):
        """generates html code for viewing web service related data"""

        root_div = div(cls="col-xs-12 pull-left", style="margin-top:10px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                # strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('URL')
                            td(self.url)
                        with tr():
                            get_th('Service Type')
                            td(self.service_type)
                        with tr():
                            get_th('Return Type')
                            td(self.return_type)
                        with tr():
                            get_th('Reference Type')
                            td(self.reference_type)

        return root_div.render(pretty=True)
예제 #16
0
    def writeContent(self):
        self.writeln('<h1>Using Webware with Dominate</h1>')
        self.writeln(
            '<p>Dominate is a Python library that can be used in Webware'
            ' applications to generate HTML programmatically.</p>')
        if not dominate:
            self.writeln(
                f'<p>Please install <a href="{self.homepage}">Dominate</a>'
                ' in order to view this demo.</p>')
            return

        content = div(id='content')
        with content:
            h2('Hello World!')
            with table(cls="NiceTable").add(tbody()):
                tr(th('Demo table', colspan=3))
                r = tr()
                r += td('One')
                r.add(td('Two'))
                with r:
                    td('Three')
            para = p(__pretty=False)
            with para:
                text('This content has been produced with ')
                a('Dominate', href=self.homepage)
                text(' programmatically.')
        self.write(content)
예제 #17
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="content-block")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            legend('Cell Information')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('Rows')
                        td(self.rows)
                    with tr():
                        get_th('Columns')
                        td(self.columns)
                    with tr():
                        get_th('Cell Size X Value')
                        td(self.cellSizeXValue)
                    with tr():
                        get_th('Cell Size Y Value')
                        td(self.cellSizeYValue)
                    with tr():
                        get_th('Cell Data Type')
                        td(self.cellDataType)

        return root_div.render(pretty=pretty)
예제 #18
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="content-block")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            legend('Cell Information')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('Rows')
                        td(self.rows)
                    with tr():
                        get_th('Columns')
                        td(self.columns)
                    with tr():
                        get_th('Cell Size X Value')
                        td(self.cellSizeXValue)
                    with tr():
                        get_th('Cell Size Y Value')
                        td(self.cellSizeYValue)
                    with tr():
                        get_th('Cell Data Type')
                        td(self.cellDataType)

        return root_div.render(pretty=pretty)
예제 #19
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="content-block")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            legend('Spatial Reference')
            div('Coordinate Reference System', cls='text-muted space-top')
            div(self.value.get('projection', ''))
            div('Coordinate Reference System Unit', cls='text-muted space-top')
            div(self.value['units'])
            div('Datum', cls='text-muted space-top')
            div(self.value.get('datum', ''))
            div('Coordinate String', cls='text-muted space-top')
            div(self.value.get('projection_string', ''), style="word-break: break-all;")
            h4('Extent', cls='space-top')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('North')
                        td(self.value['northlimit'])
                    with tr():
                        get_th('West')
                        td(self.value['westlimit'])
                    with tr():
                        get_th('South')
                        td(self.value['southlimit'])
                    with tr():
                        get_th('East')
                        td(self.value['eastlimit'])

        return root_div.render(pretty=pretty)
예제 #20
0
    def get_extra_metadata_html_form(self):
        def get_add_keyvalue_button():
            add_key_value_btn = a(cls="btn btn-success",
                                  type="button",
                                  data_toggle="modal",
                                  data_target="#add-keyvalue-filetype-modal",
                                  style="margin-bottom:20px;")
            with add_key_value_btn:
                with span(cls="glyphicon glyphicon-plus"):
                    span("Add Key/Value", cls="button-label")
            return add_key_value_btn

        if self.extra_metadata:
            root_div_extra = div(cls="col-xs-12", id="filetype-extra-metadata")
            with root_div_extra:
                legend('Extended Metadata')
                get_add_keyvalue_button()
                with table(cls="table table-striped funding-agencies-table",
                           style="width: 100%"):
                    with tbody():
                        with tr(cls="header-row"):
                            th("Key")
                            th("Value")
                            th("Edit/Remove")
                        counter = 0
                        for k, v in self.extra_metadata.iteritems():
                            counter += 1
                            with tr(data_key=k):
                                td(k)
                                td(v)
                                with td():
                                    a(data_toggle="modal",
                                      data_placement="auto",
                                      title="Edit",
                                      cls=
                                      "glyphicon glyphicon-pencil icon-button icon-blue",
                                      data_target="#edit-keyvalue-filetype-modal"
                                      "-{}".format(counter))
                                    a(data_toggle="modal",
                                      data_placement="auto",
                                      title="Remove",
                                      cls=
                                      "glyphicon glyphicon-trash icon-button btn-remove",
                                      data_target=
                                      "#delete-keyvalue-filetype-modal"
                                      "-{}".format(counter))

                self._get_add_key_value_modal_form()
                self._get_edit_key_value_modal_forms()
                self._get_delete_key_value_modal_forms()
            return root_div_extra
        else:
            root_div_extra = div(cls="row", id="filetype-extra-metadata")
            with root_div_extra:
                with div(cls="col-lg-12 content-block"):
                    legend('Extended Metadata')
                    get_add_keyvalue_button()
                    self._get_add_key_value_modal_form()
            return root_div_extra
예제 #21
0
def create_table(table_rows, *content):
    html_table = table(cellspacing="0",
                       cellpadding="5",
                       width="100%",
                       margin="0 auto",
                       border="1",
                       style="white-space:nowrap;")
    with html_table.add(thead()).add(tr()):
        for val in [
                "name", "purchase_price", "purchase_level", "min_price",
                "min_level", "min_profit", "min_percent", "relevant_price",
                "relevant_level", "relevant_profit", "relevant_percent"
        ]:
            th(val)
    with html_table:
        tbody(table_rows)
    return html(body(table(tr(td(html_table, *content)))))
예제 #22
0
def render_html_table(rows):
    h = html()
    with h.add(body()).add(div(id='content')):
        with table().add(tbody()):
            for row in rows:
                l = tr()
                for cell in row:
                    l.add(td(cell))
    return h.render()
예제 #23
0
파일: mannatags.py 프로젝트: bsync/Manna
 def __init__(self, *args, **kwargs):
     super().__init__(*args, id=f"{self.table_id}", style="width: 100%;")
     kwargs.setdefault('order', [[0, "desc"]])
     kwargs.setdefault('select', {"items": "row"})
     self.head = self.add(tags.thead())
     self.body = self.add(tags.tbody())
     #self.dtargs = 'order:[[0,"desc"]], select:{"items": "row"}, '  \
     self.dtargs = ",".join([f' {x}: {y}' for x, y in kwargs.items()])
     self.on_ready_scriptage = f"var {self.table_id} = $('#{self.table_id}').DataTable({{{self.dtargs}}});"
예제 #24
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="col-xs-6 col-sm-6", style="margin-bottom:40px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            legend('Spatial Reference')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('Coordinate Reference System')
                        td(self.value.get('projection', ''))
                    with tr():
                        get_th('Datum')
                        td(self.datum)
                    with tr():
                        get_th('Coordinate String Type')
                        td(self.projection_string_type)
                    with tr():
                        get_th('Coordinate String Text')
                        td(self.projection_string_text)
            h4('Extent')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('North')
                        td(self.value['northlimit'])
                    with tr():
                        get_th('West')
                        td(self.value['westlimit'])
                    with tr():
                        get_th('South')
                        td(self.value['southlimit'])
                    with tr():
                        get_th('East')
                        td(self.value['eastlimit'])
                    with tr():
                        get_th('Unit')
                        td(self.value['units'])

        return root_div.render(pretty=pretty)
예제 #25
0
    def render(self) -> table:
        """Render the table."""
        columns = list_columns(
            iri=self.uriref,
            octiron=self.octiron,
        )

        ordering = get_ordering(
            iri=self.uriref,
            octiron=self.octiron,
        )

        headers = construct_headers(
            octiron=self.octiron,
            table_iri=self.uriref,
            columns=columns,
        )

        instances = select_instances(
            iri=self.uriref,
            octiron=self.octiron,
        )

        rows = [
            construct_row(
                instance=instance,
                columns=columns,
                octiron=self.octiron,
            )
            for instance in instances
        ]

        rows = order_rows(
            rows=rows,
            ordering=ordering,
        )

        rows = [
            tr(
                *render_row(
                    row=row,
                    columns=columns,
                    octiron=self.octiron,
                ),
            )
            for row in rows
        ]

        return table(
            thead(
                tr(*headers),
            ),
            tbody(*rows),
        )
예제 #26
0
def add_table(table):
    with dtags.table().add(dtags.tbody()):
        for row in table:
            with dtags.tr():
                for col_idx, col_val in enumerate(row[1:]):
                    if col_idx == 0:
                        dtags.td().add(
                            dtags.a("{}".format(col_val), href=row[0]))
                    else:
                        if isinstance(col_val, float):
                            col_val = "{0:.5f}".format(col_val)
                        dtags.td().add("{}".format(col_val))
예제 #27
0
def make_email_body(issues):
    title = 'BETA:\nPlease update, close or change the priority of the following issues so your team knows what is going on.'
    d = dominate.document(title=title)
    with d.body:
        h3(title)
        with table(border='1', width='1024', cellpadding='10').add(tbody()):
            report.make_table_header()
            decorated_issues = report.build_decorated_issues(issues)
            decorated_issues.sort(key=lambda issue: issue.priority)
            for decorated_issue in decorated_issues:
                report.make_table_row(decorated_issue)
    return str(d)
예제 #28
0
    def _write_body(self):
        tbody_tag = tags.tbody()

        for value_list, value_prop_list in zip(self._value_matrix, self._value_prop_matrix):
            tr_tag = tags.tr()
            for value, value_prop in zip(value_list, value_prop_list):
                td_tag = tags.td(value)
                td_tag["align"] = value_prop.align.align_string
                tr_tag += td_tag
            tbody_tag += tr_tag

        self._table_tag += tbody_tag
        self._write_line(self._table_tag.render(indent=self.indent_string))
예제 #29
0
    def build_body(df, l_cols):

        html_body = tbody()
        with html_body:
            for index, row in df.iterrows():
                with tr():
                    for name in l_cols:
                        td(row[name] if isinstance(row[name],
                                                   (unicode,
                                                    str)) else str(row[name]),
                           cls="table-primary")

        return html_body
예제 #30
0
    def _write_body(self):
        tbody_tag = tags.tbody()

        for value_list, value_prop_list in zip(self._value_matrix,
                                               self._value_prop_matrix):
            tr_tag = tags.tr()
            for value, value_prop in zip(value_list, value_prop_list):
                td_tag = tags.td(value)
                td_tag["align"] = value_prop.align.align_string
                tr_tag += td_tag
            tbody_tag += tr_tag

        self._table_tag += tbody_tag
        self._write_line(self._table_tag.render(indent=self.indent_string))
예제 #31
0
    def _write_body(self):
        tbody_tag = tags.tbody()

        for value_list, value_dp_list in zip(self._table_value_matrix,
                                             self._table_value_dp_matrix):
            tr_tag = tags.tr()
            for value, value_dp in zip(value_list, value_dp_list):
                td_tag = tags.td(MultiByteStrDecoder(value).unicode_str)
                td_tag["align"] = value_dp.align.align_string
                tr_tag += td_tag
            tbody_tag += tr_tag

        self._table_tag += tbody_tag
        self._write_line(self._table_tag.render(indent=self.indent_string))
예제 #32
0
def create_market_mission_table(missions, offers):
    html_table = table(cellspacing="0",
                       cellpadding="5",
                       width="30%",
                       margin="0 auto",
                       border="1",
                       style="white-space:nowrap;")
    with html_table.add(thead()).add(tr()):
        for val in ["mission", "value"]:
            th(val)
    with html_table:
        if not offers:
            name_val = missions[0] if missions else "N/A"
            tbody(tr(td(name_val), td("N/A")))
        else:
            for mission in missions:
                try:
                    offer_price = offers[mission.name].get_min_price()
                except Exception as exception:
                    logging.error("Failed to tabulate %s", mission.name)
                    logging.error(str(exception))
                    offer_price = "N/A"
                tbody(tr(td(mission.name), td(offer_price)))
    return html_table
예제 #33
0
파일: ddpd.py 프로젝트: nicHoch/STIXCore
def mtable(columns, data, tclass):
    t = table(cls=tclass, style="width: 100%; table-layout:fixed;")
    _tr = tr()
    for c, style in columns:
        _tr.add(th(c, style=style))
    t.add(thead(_tr))
    tb = tbody()
    for r in data:
        _tr = tr()
        for i, c in enumerate(r):
            _tr.add(td(c, style=columns[i][1]))
        tb.add(_tr)

    t.add(tb)
    return t
예제 #34
0
    def _get_field_informations_html(self):
        root_div = div(cls="content-block")
        with root_div:
            legend('Field Information')
            with table(style="width: 100%;"):
                with tbody():
                    with tr(cls='row'):
                        th('Name')
                        th('Type')
                        th('Width')
                        th('Precision')

                    for field_info in self.fieldinformations.all():
                        field_info.get_html(pretty=False)

        return root_div.render()
예제 #35
0
    def _get_field_informations_html(self):
        root_div = div(cls="content-block")
        with root_div:
            legend('Field Information')
            with table(style="width: 100%;"):
                with tbody():
                    with tr(cls='row'):
                        th('Name')
                        th('Type')
                        th('Width')
                        th('Precision')

                    for field_info in self.fieldinformations.all():
                        field_info.get_html(pretty=False)

        return root_div.render()
    def _get_field_informations_html(self):
        root_div = div(cls="col-md-12 col-sm-12 pull-left",
                       style="margin-bottom:40px;")
        with root_div:
            legend('Field Information')
            with table(style="width: 100%;"):
                with tbody():
                    with tr(cls='row'):
                        th('Name')
                        th('Type')
                        th('Width')
                        th('Precision')

                    for field_info in self.fieldinformations.all():
                        field_info.get_html(pretty=False)

        return root_div.render()
예제 #37
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="content-block", style="margin-bottom:40px;")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            legend('Geometry Information')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('Geometry Type')
                        td(self.geometryType)
                    with tr():
                        get_th('Feature Count')
                        td(self.featureCount)
        return root_div.render(pretty=pretty)
예제 #38
0
    def _write_body(self):
        tags = _get_tags_module()
        tbody_tag = tags.tbody()

        for values, value_dp_list in zip(self._table_value_matrix, self._table_value_dp_matrix):
            tr_tag = tags.tr()
            for value, value_dp, styler in zip(values, value_dp_list, self._styler_list):
                td_tag = tags.td(MultiByteStrDecoder(value).unicode_str)
                td_tag["align"] = value_dp.align.align_string

                style_tag = self.__make_style_tag(styler)
                if style_tag:
                    td_tag["style"] = style_tag

                tr_tag += td_tag
            tbody_tag += tr_tag

        self._table_tag += tbody_tag
        self._write_line(self._table_tag.render(indent=self.indent_string))
예제 #39
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div()

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('Variable Name')
                            td(self.variableName)
                        with tr():
                            get_th('Variable Unit')
                            td(self.variableUnit)
                        if self.noDataValue:
                            with tr():
                                get_th('No Data Value')
                                td(self.noDataValue)
                        if self.maximumValue:
                            with tr():
                                get_th('Maximum Value')
                                td(self.maximumValue)
                        if self.minimumValue:
                            with tr():
                                get_th('Minimum Value')
                                td(self.minimumValue)
                        if self.method:
                            with tr():
                                get_th('Method')
                                td(self.method)
                        if self.comment:
                            with tr():
                                get_th('Comment')
                                td(self.comment)

        return root_div.render(pretty=pretty)
예제 #40
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="content-block")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            legend('Spatial Reference')
            div('Coordinate Reference System', cls='text-muted')
            div(self.projection_name)
            div('Datum', cls='text-muted space-top')
            div(self.datum)
            div('Coordinate String Text', cls='text-muted space-top')
            div(self.projection_string)
            h4('Extent', cls='space-top')
            with table(cls='custom-table'):
                with tbody():
                    with tr():
                        get_th('North')
                        td(self.northlimit)
                    with tr():
                        get_th('West')
                        td(self.westlimit)
                    with tr():
                        get_th('South')
                        td(self.southlimit)
                    with tr():
                        get_th('East')
                        td(self.eastlimit)
                    with tr():
                        get_th('Unit')
                        td(self.unit)

        return root_div.render(pretty=pretty)
예제 #41
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        root_div = div(cls="content-block")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="custom-well"):
                strong(self.name)
                with table(cls='custom-table'):
                    with tbody():
                        with tr():
                            get_th('Unit')
                            td(self.unit)
                        with tr():
                            get_th('Type')
                            td(self.type)
                        with tr():
                            get_th('Shape')
                            td(self.shape)
                        if self.descriptive_name:
                            with tr():
                                get_th('Long Name')
                                td(self.descriptive_name)
                        if self.missing_value:
                            with tr():
                                get_th('Missing Value')
                                td(self.missing_value)
                        if self.method:
                            with tr():
                                get_th('Comment')
                                td(self.method)

        return root_div.render(pretty=pretty)
예제 #42
0
    def get_html(self, site_number):
        """generates html code for viewing site related data"""

        root_div = div(cls="content-block")

        def get_th(heading_name):
            return th(heading_name, cls="text-muted")

        with root_div:
            with div(cls="panel panel-default"):
                with div(cls="panel-heading"):
                    with h4(cls="panel-title"):
                        site_name = "Site-{}".format(site_number)
                        if self.site_name:
                            site_name = self.site_name
                        a(site_name, data_toggle="collapse", data_parent="#accordion",
                          href="#collapse{}".format(site_number))
                with div(id="collapse{}".format(site_number), cls="panel-collapse collapse"):
                    with div(cls="panel-body"):
                        with table(cls='custom-table'):
                            with tbody():
                                with tr():
                                    get_th('Network Name')
                                    td(self.network_name)
                                with tr():
                                    get_th('Service Type')
                                    td(self.service_type)
                                with tr():
                                    get_th('Return Type')
                                    td(self.return_type)
                                with tr():
                                    get_th('Reference Type')
                                    td(self.reference_type)
                                with tr():
                                    get_th('URL')
                                    with td():
                                        a(self.url, href=self.url, target="_blank")
                                with tr():
                                    get_th('Site Name')
                                    if self.site_name:
                                        td(self.site_name)
                                    else:
                                        td("")
                                with tr():
                                    get_th('Site Code')
                                    td(self.site_code)
                                with tr():
                                    get_th('Latitude')
                                    td(self.latitude)
                                with tr():
                                    get_th('Longitude')
                                    td(self.longitude)
                                with tr():
                                    get_th('Variable Name')
                                    if self.variable_name:
                                        td(self.variable_name)
                                    else:
                                        td("")
                                with tr():
                                    get_th('Variable Code')
                                    td(self.variable_code)
                                with tr():
                                    get_th('Method Description')
                                    if self.method_description:
                                        td(self.method_description)
                                    else:
                                        td("")
                                with tr():
                                    get_th('Method Link')
                                    if self.method_link \
                                            and self.method_link.lower() != 'unknown':
                                        with td():
                                            a(self.method_link, href=self.method_link,
                                              target="_blank")
                                    elif self.method_link:
                                        td(self.method_link)
                                    else:
                                        td("")
                                with tr():
                                    get_th('Sample Medium')
                                    if self.sample_medium:
                                        td(self.sample_medium)
                                    else:
                                        td("")
                                with tr():
                                    get_th('Value Count')
                                    if self.value_count is not None:
                                        td(self.value_count)
                                    else:
                                        td("")
                                with tr():
                                    get_th('Begin Date')
                                    td(self.start_date)
                                with tr():
                                    get_th('End Date')
                                    td(self.end_date)

        return root_div
예제 #43
0
def landing_page(request, page):
    content_model = page.get_content_model()
    edit_resource = page_processors.check_resource_mode(request)

    if not edit_resource:  # non-edit mode
        # get the context from hs_core
        context = page_processors.get_page_context(page, request.user, resource_edit=edit_resource,
                                                   extended_metadata_layout=None, request=request)
        extended_metadata_exists = False

        if content_model.metadata.originalcoverage:
            extended_metadata_exists = True

        context['extended_metadata_exists'] = extended_metadata_exists

        # add the original coverage context
        geom_info_for_view = {}
        geom_info = content_model.metadata.geometryinformation
        if geom_info:
            geom_info_for_view['geometryType'] = geom_info.geometryType
            geom_info_for_view['featureCount'] = geom_info.featureCount
            context['geometry_information'] = geom_info_for_view

        ori_cov_dict = {}
        ori_cov_obj = content_model.metadata.originalcoverage
        if ori_cov_obj:
            ori_cov_dict['northlimit'] = ori_cov_obj.northlimit
            ori_cov_dict['eastlimit'] = ori_cov_obj.eastlimit
            ori_cov_dict['southlimit'] = ori_cov_obj.southlimit
            ori_cov_dict['westlimit'] = ori_cov_obj.westlimit
            ori_cov_dict['projection_string'] = ori_cov_obj.projection_string
            ori_cov_dict['projection_name'] = ori_cov_obj.projection_name
            ori_cov_dict['datum'] = ori_cov_obj.datum
            ori_cov_dict['unit'] = ori_cov_obj.unit
            context['original_coverage'] = ori_cov_dict

        field_info_list = content_model.metadata.fieldinformations.all()
        field_info_list_context = []
        for field_info in field_info_list:
            field_info_dict_item = {}
            field_info_dict_item["fieldName"] = field_info.fieldName
            field_info_dict_item["fieldType"] = field_info.fieldType
            field_info_dict_item["fieldTypeCode"] = field_info.fieldTypeCode
            field_info_dict_item["fieldWidth"] = field_info.fieldWidth
            field_info_dict_item["fieldPrecision"] = field_info.fieldPrecision
            field_info_list_context.append(field_info_dict_item)
        context['field_information'] = field_info_list_context

    else:  # editing mode
        # now editing is allowed for resource specific metadata
        geom_info_for_view = {}
        geom_info = content_model.metadata.geometryinformation
        if geom_info:
            geom_info_for_view['geometryType'] = geom_info.geometryType
            geom_info_for_view['featureCount'] = geom_info.featureCount

        geom_information_form = GeometryInformationForm(initial=geom_info_for_view,
                                                        res_short_id=content_model.short_id,
                                                        allow_edit=False,
                                                        element_id=geom_info.id
                                                        if geom_info else None)

        geom_information_layout = HTML('<div class="form-group col-lg-6 col-xs-12" '
                                       'id="geometryinformation">'
                                       '{% load crispy_forms_tags %}'
                                       '{% crispy geom_information_form %}'
                                       '</div>')

        # origina coverage_form
        ori_cov_obj = content_model.metadata.originalcoverage
        ori_coverage_data_dict = {}
        if ori_cov_obj:
            ori_coverage_data_dict['projection_string'] = ori_cov_obj.projection_string
            ori_coverage_data_dict['projection_name'] = ori_cov_obj.projection_name
            ori_coverage_data_dict['datum'] = ori_cov_obj.datum
            ori_coverage_data_dict['unit'] = ori_cov_obj.unit
            ori_coverage_data_dict['northlimit'] = ori_cov_obj.northlimit
            ori_coverage_data_dict['eastlimit'] = ori_cov_obj.eastlimit
            ori_coverage_data_dict['southlimit'] = ori_cov_obj.southlimit
            ori_coverage_data_dict['westlimit'] = ori_cov_obj.westlimit

        ori_coverage_form = OriginalCoverageForm(initial=ori_coverage_data_dict,
                                                 res_short_id=content_model.short_id,
                                                 allow_edit=False,
                                                 element_id=ori_cov_obj.id
                                                 if ori_cov_obj else None)
        ori_coverage_layout = HTML('<div class="form-group col-lg-6 '
                                   'col-xs-12" id="originalcoverage"> '
                                   '{% load crispy_forms_tags %} '
                                   '{% crispy ori_coverage_form %} '
                                   '</div>')
        root_div = div(cls="col-md-12 col-sm-12 pull-left", style="margin-bottom:40px;")
        with root_div:
            legend('Field Information')
            with table(style="width: 100%;"):
                with tbody():
                    with tr(cls='row'):
                        th('Name')
                        th('Type')
                        th('Width')
                        th('Precision')

                    for field_info in content_model.metadata.fieldinformations.all():
                        field_info.get_html(pretty=False)

        ext_md_layout = Layout(geom_information_layout,
                               ori_coverage_layout,
                               HTML(root_div.render()))

        context = page_processors.get_page_context(page,
                                                   request.user,
                                                   resource_edit=edit_resource,
                                                   extended_metadata_layout=ext_md_layout,
                                                   request=request)
        context['ori_coverage_form'] = ori_coverage_form
        context['geom_information_form'] = geom_information_form

    context['edit_mode'] = edit_resource
    hs_core_context = add_generic_context(request, page)
    context.update(hs_core_context)

    return context