Esempio n. 1
0
def main():
    """Main function for the program
    """
    config_contents = config.load_config("/github/workspace")
    table_lines = table.generate_table(config_contents)
    with open("README.md") as readme_file:
        readme_orig_lines = readme_file.readlines()
    if "<!-- START OF PROFILE STACK, DO NOT REMOVE -->\n" not in readme_orig_lines:
        with open("README.md", "a") as readme_file:
            readme_file.write(
                "<!-- START OF PROFILE STACK, DO NOT REMOVE -->\n")
            for table_line in table_lines:
                if table_line.endswith("\n"):
                    readme_file.write(table_line)
                else:
                    readme_file.write(table_line + "\n")
            readme_file.write("<!-- END OF PROFILE STACK, DO NOT REMOVE -->")
            logger.success("Wrote table to README.md file")
    else:
        with open("README.md", "w") as readme_file:
            readme_file.write("")
        with open("README.md", "a") as readme_file:
            write_line = True
            for line in readme_orig_lines:
                if line == "<!-- END OF PROFILE STACK, DO NOT REMOVE -->\n":
                    write_line = True
                if line == "<!-- START OF PROFILE STACK, DO NOT REMOVE -->\n":
                    readme_file.write(
                        "<!-- START OF PROFILE STACK, DO NOT REMOVE -->\n")
                    for table_line in table_lines:
                        readme_file.write(table_line + "\n")
                    write_line = False
                    logger.success("Wrote table to README.md file")
                if write_line:
                    if line.endswith("\n"):
                        readme_file.write(line)
                    else:
                        readme_file.write(line + "\n")
    commands.run_commands(
        [
            'git config --global user.email "*****@*****.**"',
            'git config --global user.name "Publishing Bot"',
            "git add .",
            'git commit -m "Update profile stack"',
            "git push",
        ],
        "Failed to push changes",
    )

    logger.success("⬆️ Pushed changes! ⬆️")
Esempio n. 2
0
def test_generate_table():
    os.environ["INPUT_TECHNOLOGY_EMOJI"] = "💻"
    os.environ["INPUT_PROJECT_EMOJI"] = "🚀"
    os.environ["INPUT_PATH"] = "../tests/example_config.yml"
    os.environ["INPUT_BADGES"] = "true"
    config_contents = config.load_config(".")

    result = table.generate_table(config_contents)
    assert result == [
        "| 💻 **Technology** | 🚀 **Projects** |",
        "|-|-|",
        "| [![Dart](https://img.shields.io/static/v1?label=&message=Dart&color=52C0F2&logo=dart&logoColor=white)](https://dart.dev/) | [![import_sorter](https://img.shields.io/static/v1?label=&message=import_sorter&color=000605&logo=github&logoColor=white&labelColor=000605)](https://github.com/fluttercommunity/import_sorter) [![Personal-Site](https://img.shields.io/static/v1?label=&message=Personal-Site&color=000605&logo=github&logoColor=white&labelColor=000605)](https://github.com/Matt-Gleich/Personal-Site) [![auralite-mobile](https://img.shields.io/static/v1?label=&message=auralite-mobile%20%28WIP%29&color=000605&logo=github&logoColor=white&labelColor=000605)](https://github.com/Matt-Gleich/auralite-mobile) |",
        "| [![Flutter](https://img.shields.io/static/v1?label=&message=Flutter&color=52C0F2&logo=flutter&logoColor=white)](https://flutter.dev/) | [![Personal-Site](https://img.shields.io/static/v1?label=&message=Personal-Site&color=000605&logo=github&logoColor=white&labelColor=000605)](https://github.com/Matt-Gleich/Personal-Site) [![auralite-mobile](https://img.shields.io/static/v1?label=&message=auralite-mobile%20%28WIP%29&color=000605&logo=github&logoColor=white&labelColor=000605)](https://github.com/Matt-Gleich/auralite-mobile) |",
    ]
Esempio n. 3
0
def vendor(import_code):
    # Error handling on bad url or b64
    try:
        if import_code.startswith("https://pastebin.com/"):
            build = pobapi.from_url(import_code)
        else:
            build = pobapi.from_import_code(import_code)
    except ValueError:
        form = ImportForm()
        form["import_code"].errors = ["Not a valid pastebin.com URL or import code."]
        return render_template("index.html", form=form)

    store = parse(build, quest_data, skill_data)
    tables = generate_table(store)

    return render_template("vendor.html", tables=tables)
Esempio n. 4
0
def main():
    """Main function for the program
    """
    config_contents = config.load_config('/github/workspace')
    table_lines = table.generate_table(config_contents)
    with open('README.md') as readme_file:
        readme_orig_lines = readme_file.readlines()
    if '<!-- START OF PROFILE STACK, DO NOT REMOVE -->\n' not in readme_orig_lines:
        with open('README.md', 'a') as readme_file:
            readme_file.write(
                '\n<!-- START OF PROFILE STACK, DO NOT REMOVE -->\n')
            for table_line in table_lines:
                readme_file.write(table_line + '\n')
            readme_file.write('<!-- END OF PROFILE STACK, DO NOT REMOVE -->\n')
            logger.success('Wrote table to README.md file')
    else:
        with open('README.md', 'w') as readme_file:
            readme_file.write('')
        with open('README.md', 'a') as readme_file:
            write_line = True
            for line in readme_orig_lines:
                if line == '\n<!-- END OF PROFILE STACK, DO NOT REMOVE -->\n':
                    write_line = True
                if write_line:
                    readme_file.write(line + '\n')
                if line == '<!-- START OF PROFILE STACK, DO NOT REMOVE -->\n':
                    for table_line in table_lines:
                        readme_file.write(table_line + '\n')
                    write_line = False
                logger.success('Wrote table to README.md file')
    os.system('git config --global user.email "*****@*****.**"')
    os.system('git config --global user.name "Publishing Bot"')
    os.system('git add .')
    os.system('git commit -m "Update profile stack"')
    os.system('git push')
    logger.success('Pushed changes!')
Esempio n. 5
0
import re

from table import (names, aliases, points, awake,
                   SEPARATOR, generate_table)

# cast to list in case of generator
table1 = list(generate_table(names))
table2 = list(generate_table(names, aliases))
table3 = list(generate_table(names, aliases, points))
table4 = list(generate_table(names, aliases, points, awake))


def test_generate_table():
    assert len(table1) == len(table2) == len(table3) == len(table4) == 6

    assert table1[0].count(SEPARATOR) == 0
    assert table2[0].count(SEPARATOR) == 1
    assert table3[0].count(SEPARATOR) == 2
    assert table4[0].count(SEPARATOR) == 3

    assert table1[1].split(SEPARATOR)[0] == 'Bob'
    assert table2[1].split(SEPARATOR)[1] == 'Nerd'
    assert re.match(r'\d+', table3[2].split(SEPARATOR)[2])
    assert table4[2].split(SEPARATOR)[3]