Exemple #1
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)
Exemple #2
0
    def _contact(self):
        contact = self._toml['contact']
        assert isinstance(contact, dict)

        with tr() as row:
            label = contact['label']
            assert isinstance(label, str)
            td(label, rowspan=2, colspan=1, class_name='label')

            contact_points = contact['value']
            assert isinstance(contact_points, dict)

            email = contact_points['email']
            assert isinstance(email, str)
            with td(colspan=3, class_name='value'):
                a(email, href=f'mailto:{email}', target='_blank')

        yield row

        with tr() as row:
            url = contact_points['url']
            assert isinstance(url, str)
            with td(colspan=3, class_name='value'):
                a(url, href=url, target='_blank')

        yield row
Exemple #3
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)
                            )
Exemple #4
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)
Exemple #5
0
def table(
        data: List[List[str]],
        header: Optional[List[str]] = None,
        green_value: Optional[str] = None,
        red_value: Optional[str] = None,
        red_predicate: Optional[Callable] = None
) -> None:
    """
    Print table to HTML output
    :param data: List of lines, each containing list of cell data
    :param header: optional list of header cells, no header if None or empty
    :param green_value: cell value content to highlight in green
    :param red_value: cell value content to highlight in red
    :param red_predicate: predicate on line to highlight in red
    """

    with tags.table():

        if header:
            with tags.tr():
                for cell in header:
                    tags.th(cell)

        for line in data:
            with tags.tr():
                for cell in line:
                    color = "var(--main-color)"
                    if green_value and green_value in cell:
                        color = "var(--green-color)"
                    if red_value and red_value in cell:
                        color = "var(--red-color)"
                    if red_predicate and red_predicate(line):
                        color = "var(--red-color)"
                    tags.td(cell, style="color:" + color)
Exemple #6
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),
        )
Exemple #7
0
    def format(trait, objs, *args, **kwargs) -> Htmlish:
        # TODO would be nice to have spinboard imported here for type checking..
        res = T.div(cls='pinboard')

        title = trait.title(objs)
        link = trait.link(objs)
        res.add(T.div(T.a(title, href=link)))

        with adhoc_html('pinboard', cb=lambda children: res.add(*children)):
            with T.table():
                for _, obj in objs:
                    if not isempty(obj.description):
                        with T.tr():
                            with T.td(colspan=3):
                                T.span(obj.description, cls='description')
                    with T.tr():
                        # TODO wtf is min??
                        with T.td(cls='min'):
                            T.a(f'{fdate(obj.when)}',
                                href=obj.blink,
                                cls='permalink timestamp')
                        with T.td(cls='min'):
                            text('by ')
                            trait.user_link(user=obj.user)
                        with T.td():
                            for t in obj.ntags:
                                trait.tag_link(tag=t, user=obj.user)
        # TODO userstats
        return res
Exemple #8
0
    def populate(self, pages):
        self.data = [[
            'Title', 'Rating', {
                'role': 'tooltip',
                'p': {
                    'html': 'true'
                }
            }, {
                'role': 'style'
            }
        ]]

        for p in pages:
            if 'scp' in p.tags:
                color = 'color: #db4437'
            elif 'tale' in p.tags:
                color = 'color: #4285f4'
            else:
                color = 'color: #f4b400'

            date = p.metadata[self.user].date[:10] or '-'

            tooltip = dt.table(dt.tr(dt.td(p.title, colspan=2)),
                               dt.tr(dt.td('Rating:'), dt.td(p.rating)),
                               dt.tr(dt.td('Created:'), dt.td(date)),
                               cls='articles_chart_tooltip')

            self.data.append(
                [p.title, p.rating,
                 tooltip.render(pretty=False), color])
Exemple #9
0
    def populate(self, pages):
        self.data = [[
            'Title',
            'Rating',
            {'role': 'tooltip', 'p': {'html': 'true'}},
            {'role': 'style'}]]

        for p in pages:
            if 'scp' in p.tags:
                color = 'color: #db4437'
            elif 'tale' in p.tags:
                color = 'color: #4285f4'
            else:
                color = 'color: #f4b400'

            date = p.metadata[self.user].date[:10] or '-'

            tooltip = dt.table(
                dt.tr(dt.td(p.title, colspan=2)),
                dt.tr(dt.td('Rating:'), dt.td(p.rating)),
                dt.tr(dt.td('Created:'), dt.td(date)),
                cls='articles_chart_tooltip')

            self.data.append([
                p.title,
                p.rating,
                tooltip.render(pretty=False),
                color])
    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)
Exemple #11
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
Exemple #12
0
    def add_header(self, text):
        """Insert a header to the HTML file

        Parameters:
            text (str) -- the header text
        """
        with self.doc:
            td(text)
Exemple #13
0
    def _person(self):
        person = self._toml['person']
        assert isinstance(person, dict)

        label = person['label']
        assert isinstance(label, str)
        td(label, colspan=1, class_name='label')

        td(SHARED.info.person_name, colspan=3, class_name='value')
def make_table_row(decorated_issue):
    r = tr()
    with r:
        td(a(decorated_issue.issue.number,
             href=decorated_issue.issue.html_url))
        td(decorated_issue.issue.title, width='200')
        td(raw(decorated_issue.assignees), width='200')
        td(raw(decorated_issue.priority), width='100')
        td(raw(decorated_issue.last_comment))
def list_test1(hits, url):
    table = t.table()
    with table:
        for hit in hits:
            with t.tr():
                t.td(t.a(hit['name'], href='%s/%d' % (url, hit['id'])))
        if len(hits) >= 9:
            t.tr(t.td('... (type in search bar to narrow list)'))
    return table.render()
Exemple #16
0
    def set_header(self, *args, **kwargs):
        self.header = self.parse_args(*args, **kwargs)

        with self.t:
            for k in self.header:
                table_row = tr()
                self.table_rows.append(table_row)
                with table_row:
                    td(k)
        return self
Exemple #17
0
    def as_rows(self):
        engineer = self._toml['engineer']
        designer = self._toml['designer']

        with tr() as row:
            td(engineer['title'], colspan=2, class_name='title')
            td(designer['title'], colspan=2, class_name='title')

        yield row

        yield from DisciplinesSideBySide(engineer, designer).as_rows()
Exemple #18
0
def _report_links(tests):
    if not tests:
        i("None!")
        return
    with table(border=1):
        with tr():
            th("Link to report")
        for test in sorted(tests):
            with tr():
                path = test.relative_to(REPORTS_PATH)
                td(a(test.name, href=path))
Exemple #19
0
    def _period_and_faculty(self):
        period = self._toml['period']
        assert isinstance(period, str)
        td(raw(period),
           colspan=1,
           rowspan=self._height_in_rows(),
           class_name='label')

        faculty = self._toml['faculty']
        assert isinstance(faculty, str)
        td(faculty, colspan=3, class_name='value emphasised')
Exemple #20
0
    def _period_and_title(self):
        period = self._toml['period']
        assert isinstance(period, str)
        td(raw(period),
           colspan=1,
           rowspan=self._height_in_rows(),
           class_name='label')

        title = self._toml['title']
        assert isinstance(title, str)
        td(title, colspan=3, class_name='value emphasised')
Exemple #21
0
def filter_user_list(results, url):  # TODO: GENERALIZE for other lists!
    table = t.table()
    with table:
        for result in results:
            with t.tr():
                t.td(
                    t.a(result['username'],
                        href='%s/%d' % (url, result['id'])))
        if len(results) >= 9:
            t.tr(t.td('... (type in search bar to narrow list)'))
    return table.render()
Exemple #22
0
    def build_footer(row, l_cols, cls):

        html_foot = tfoot(cls=cls)
        with html_foot:
            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_foot
def mount_ballots_to_table(cmpcvr_df: pd.DataFrame) -> tuple:
    cmpcvr_df.dropna(subset=['disagreed_info'], inplace=True)
    index = 1
    for _, row in cmpcvr_df.iterrows():
        head_row = tr(cls='',
                      data_toggle='collapse',
                      data_target=f'#collapse{index}')
        head_row += th(index), td(row['ballot_id']), td(row['style'])
        collapse_row = tr(id=f'collapse{index}', cls='collapse')
        collapse_row += td(), get_ballot_details_td(row)
        index += 1
        yield head_row, collapse_row
Exemple #24
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))
Exemple #25
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
Exemple #26
0
def report_links(tests, reports_path, actual_hashes=None):
    if actual_hashes is None:
        actual_hashes = {}

    if not tests:
        i("None!")
        return
    with table(border=1):
        with tr():
            th("Link to report")
        for test in sorted(tests):
            with tr(data_actual_hash=actual_hashes.get(test.stem, "")):
                path = test.relative_to(reports_path)
                td(a(test.name, href=path))
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
    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 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)
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
Exemple #31
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)
def diff(master_screens_path, current_screens_path, test_name, master_hash,
         current_hash):
    doc = dominate.document(title=test_name)
    master_screens = sorted(master_screens_path.iterdir())
    current_screens = sorted(current_screens_path.iterdir())

    with doc:
        h1(test_name)
        p("This UI test differs from master.",
          style="color: grey; font-weight: bold;")
        with table():
            with tr():
                td("Master:")
                td(master_hash, style="color: red;")
            with tr():
                td("Current:")
                td(current_hash, style="color: green;")
        hr()

        with table(border=1, width=600):
            with tr():
                th("Master")
                th("Current branch")

            html.diff_table(master_screens, current_screens)

    return html.write(REPORTS_PATH / "diff", doc, test_name + ".html")
    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)
Exemple #34
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)
Exemple #35
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)
Exemple #36
0
    def get_html(self, pretty=True):
        """Generates html code for displaying data for this metadata element"""

        field_infor_tr = tr(cls='row')
        with field_infor_tr:
            td(self.fieldName)
            td(self.fieldType)
            td(self.fieldWidth)
            td(self.fieldPrecision)
        if pretty:
            return field_infor_tr.render(pretty=pretty)
        return field_infor_tr
Exemple #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)
Exemple #38
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))
 def get_student_grades_html(self):
     import dominate
     from dominate import tags
     page = dominate.document(title='Final Grades')
     with page:
         with tags.table(border="1"):
             number_of_assignments = self.get_number_of_assignments()
             with tags.tr():
                 tags.th("First Name")
                 tags.th("Last Name")
                 tags.th("Overall Average")
                 tags.th("Letter Grade")
                 tags.th("Scores", colspan=str(number_of_assignments))
             for student in self.sorted_students():
                 with tags.tr():
                     grade_average = student.grade_average(number_of_assignments)
                     tags.td(student.name.first)
                     tags.td(student.name.last)
                     tags.td(grade_average)
                     tags.td(self._grade_tiers.letter(grade_average))
                     for score in student.sorted_scores():
                         tags.td(score)
     return str(page)
Exemple #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)
Exemple #41
0
    def add(self, *items):
        """ Adds items to the table row, items are wrapped in a <td> tag if self.header is
            False, else they are wrapped in a <th> tag.
        """
        added = []
        items = parse_into_single_tuple(items)
        for item in items:
            if isinstance(item, th) or isinstance(item, td):
                added.append(super().add(item))
            elif self.header is True:
                added.append(super().add(th(item)))
            else:
                added.append(super().add(td(item)))

        if len(added) == 1:
            return added[0]
        else:
            return added
Exemple #42
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))
Exemple #43
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)
Exemple #44
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)
    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