Exemple #1
0
def write_ext_md(tuples_ext):
    # Split out ones with improperly formatted entry_point names
    ok_tups = [t for t in tuples_ext if P_ERRCODE.match(t.ep)]
    bad_tups = [t for t in tuples_ext if not P_ERRCODE.match(t.ep)]

    PKG_SORT_PATH.write_text(
        PKG_SORT_TEMPLATE.render(
            table=markdown_table.render(
                ("Package", "Entry Point"),
                ((md_pypi_link(p), e)
                 for p, e in sorted(ok_tups, key=(lambda t: t.pkg))),
            ),
            date=DATE,
        ))
    EC_SORT_PATH.write_text(
        EC_SORT_TEMPLATE.render(
            table=markdown_table.render(
                ("Entry Point", "Package"),
                ((e, md_pypi_link(p))
                 for p, e in sorted(ok_tups, key=(lambda t: t.ep))),
            ),
            date=DATE,
        ))

    BAD_CODE_PATH.write_text(
        BAD_TEMPLATE.render(
            table=markdown_table.render(
                ("Package", "Entry Point"),
                ((md_pypi_link(p), e) for p, e in bad_tups)),
            date=DATE,
        ))
Exemple #2
0
def write_report_md(tuples_rep):
    table_pkg = markdown_table.render(
        ("Package", "Entry Point"),
        ((md_pypi_link(p), e) for p, e in tuples_rep))
    table_ep = markdown_table.render(
        ("Entry Point", "Package"),
        ((e, md_pypi_link(p))
         for p, e in sorted(tuples_rep, key=(lambda t: t.ep))),
    )
    REP_PATH.write_text(
        REP_TEMPLATE.render(table_pkg=table_pkg, table_ep=table_ep, date=DATE))
Exemple #3
0
 def details_table(self):
     matrix = []
     name = self.yaml.get("name", os.path.basename(os.getcwd()))
     matrix = [['name', name]]
     description = self.yaml.get("description", "").strip()
     if len(description) > 1:
         matrix.append(['description', description])
     return markdown_table.render(["key", "value"], matrix)
Exemple #4
0
def main():

    data = get_data()

    results = []
    for state in data.keys():
        results.append([state, str(ii(data, state)), str(iii(data, state))])

    print(markdown_table.render(["Results", "Max", "Average"], results) + "\n")
Exemple #5
0
 def resources_table(self):
     resources = self.yaml.get("resources", [])
     if not resources:
         return ""
     matrix = []
     for url in resources:
         left = "`%s`" % os.path.basename(url)
         right = "[%s](%s)" % (url, url)
         matrix.append([left, right])
     return markdown_table.render(["filename", "url"], matrix)
Exemple #6
0
            s = f.read()
            crop = yaml.safe_load(s)

        common_name_key = crop['common_name_key']
        common_name_dict = localizable_strings[common_name_key]
        title = common_name_dict['en'][0].title()

        template_path = child_path.with_suffix('.md')
        out_filename = Path(template_path.name)
        out_md_path = out_dir_path.joinpath(out_filename)
        print('Writing ' + str(out_md_path))
        with out_md_path.open('w') as outfile:
            headers = ['Language', 'String']
            matrix = [[f'`{k}`', ', '.join(v)]
                      for k, v in common_name_dict.items()]
            common_names_md_table = markdown_table.render(headers, matrix)
            del (crop['common_name_key'])

            headers = ['Key', 'Value']
            matrix = [[f'`{k}`', str(v)] for k, v in crop.items()
                      if not k == 'title' and v]
            crop_md_table = markdown_table.render(headers, matrix)

            try:
                with template_path.open() as template_file:
                    s = template_file.read()
            except FileNotFoundError as e:
                s = ''
            s = f'# {title}\n\n## Common Names\n\n{common_names_md_table}\n\n\n## Data\n\n{crop_md_table}\n\n\n{s}'

            outfile.write(s)