Example #1
0
def test_default_value():
    with yield_input(""):
        val = prompt(
            "Enter optional string",
            default="default-answer",
        )
        assert val == "default-answer"
Example #2
0
def test_validate_str():
    with yield_input(["hello", "world", "scikit-something"]):
        val = prompt(
            "Input scikit name",
            validate=lambda x: x if x.startswith("scikit") else None,
        )
        assert val == "scikit-something"
Example #3
0
def test_validate_int():
    with yield_input(["foo", "1.5", 1]):
        val = prompt(
            "Please input integer",
            validate=lambda x: int(x),
        )
        assert val == 1
Example #4
0
def test_default_not_validated():
    with yield_input(""):
        val = prompt(
            "Enter a number",
            validate=lambda x: int(x),
            default="hello",
        )
        assert val == "hello"
Example #5
0
def test_default_value_after_bad_input():
    with yield_input(["asd", ""]):
        val = prompt(
            "Enter scikit name",
            validate=lambda x: x if x.startswith("scikit") else None,
            default="scikit-something",
        )
        assert val == "scikit-something"
Example #6
0
SPEC Quickstart
===============

Quickly setup stub for new SPEC proposal.
"""

from datetime import datetime

import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".tools"))
from tools import prompt

now = datetime.now()
author = prompt("Your Name")
email = prompt("Your Email Address")
number = prompt("SPEC number", validate=lambda x: int(x))
title = prompt("SPEC title")

filename = f"spec-{number:04d}.md"
text = f"""---
title: "SPEC {number} — {title}"
date: {now.strftime("%Y-%m-%d")}
draft: false
author:
  - "{author} <{email}>"
discussion: https://discuss.scientific-python.org/t/
endorsed-by:
---
Example #7
0
"""
Core Project Registration
=========================

Register your core project.
"""

import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../.tools"))
from tools import prompt

project = prompt("Project Name")
project_lower = project.lower()
logo = prompt("Project Logo (from your GitHub organization profile pic)")
default_home = f"https://{project_lower}.org"
homepage = prompt("Project Homepage", default=default_home)
repository = prompt(
    "Repository",
    default=f"https://github.com/{project_lower}/{project_lower}")
pypi = prompt("PyPI page", default=f"https://pypi.org/project/{project_lower}")
license = prompt("License URL",
                 default=f"{repository}/blob/master/LICENSE.txt")
license_type = prompt("License", default="3-clause BSD")
adopters = prompt("List the GitHub handles of developers who can adopt SPECs")

filename = f"{project.lower()}.md"
text = f"""---
title: "{project}"
draft: false
Example #8
0
===============

Quickly setup stub for new SPEC proposal.
"""

from datetime import datetime

import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".tools"))
from tools import prompt


now = datetime.now()
author = prompt("Your Name")
email = prompt("Your Email Address")
number = prompt("SPEC number", validate=lambda x: int(x))
title = prompt("SPEC title")
discussion = prompt("Discussion number", default="", validate=lambda x: int(x))

filename = f"spec-{number:04d}.md"
text = f"""---
title: "SPEC {number} — {title}"
date: {now.strftime("%Y-%m-%d")}
draft: false
author:
  - "{author} <{email}>"
discussion: {f'https://github.com/scientific-python/specs/discussions/{discussion}' if discussion else ''}
endorsed-by:
---
Example #9
0
"""
Steering Committee Registration
===============================

Register as a steering committee member.
"""

import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../.tools"))
from tools import prompt

name = prompt("Name")
github_handle = prompt("GitHub Handle")
avatar = prompt("Avatar")

filename = f"{name.lower().replace(' ', '_')}.md"
text = f"""---
title: {name}
repository: https://github.com/{github_handle}
avatar: {avatar}
---
"""

with open(filename, "w") as file:
    file.write(text)