diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70d35d6..1a328a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,13 +22,13 @@ All types of contributions are encouraged and valued. See the [Table of Contents ## Asking Questions -> If you want to ask a question, we assume that you have read the available [Documentation](https://potassco.org/fillname/). +> If you want to ask a question, we assume that you have read the available [Documentation](https://fillname.org/). -Before you ask a question, it is best to search for existing [issues](https://github.com/potassco/fillname/issues) or [messages](https://sourceforge.net/p/potassco/mailman/potassco-users/) in the archive of our mailing list. +Before you ask a question, it is best to search for existing [issues](https://fillname.org/issues) or [messages](https://sourceforge.net/p/potassco/mailman/potassco-users/) in the archive of our mailing list. If you then still feel the need to ask a question and need clarification, we recommend the following: -- [Subscribe](https://sourceforge.net/projects/potassco/lists/potassco-users) to our mailing list on SourceForge or open an [issue](https://github.com/potassco/fillname/issues/new) on GitHub. +- [Subscribe](https://sourceforge.net/projects/potassco/lists/potassco-users) to our mailing list on SourceForge or open an [issue](https://fillname.org/issues/new) on GitHub. - Provide as much context as you can about what you're running into. - We can best help you if you provide executable code showcasing your problem. @@ -53,7 +53,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform - Make sure that you are using the latest version. - Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions. If you are looking for support, you might want to check [this section](#i-have-a-question)). -- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/potassco/fillname/issues?q=label%3Abug). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://fillname.org/issues?q=label%3Abug). - Collect information about the bug - Python Version - Possibly your input and the output @@ -65,7 +65,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform We use GitHub issues to track bugs and errors. If you run into an issue with the project: -- Open an [Issue](https://github.com/potassco/fillname/issues/new). +- Open an [Issue](https://fillname.org/issues/new). - Explain the behavior you would expect and the actual behavior. - Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. - Provide the information you collected in the previous section. @@ -84,14 +84,14 @@ This section guides you through submitting an enhancement suggestion for fillnam #### Before Submitting an Enhancement - Make sure that you are using the latest version. -- Read the [documentation](https://potassco.org/fillname/) carefully and find out if the functionality is already covered, maybe by an individual configuration. -- Perform a [search](https://github.com/potassco/fillname/issues) to see if the enhancement has already been suggested. If it has, add a comment to an existing issue instead of opening a new one. +- Read the [documentation](https://fillname.org/) carefully and find out if the functionality is already covered, maybe by an individual configuration. +- Perform a [search](https://fillname.org/issues) to see if the enhancement has already been suggested. If it has, add a comment to an existing issue instead of opening a new one. - Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. <!-- omit in toc --> #### How Do I Submit a Good Enhancement Suggestion? -Enhancement suggestions are tracked as [GitHub issues](https://github.com/potassco/fillname/issues). +Enhancement suggestions are tracked as [GitHub issues](https://fillname.org/issues). - Use a **clear and descriptive title** for the issue to identify the suggestion. - Provide a **step-by-step description of the suggested enhancement** in as many details as possible. diff --git a/LICENSE b/LICENSE index 6357844..3759b39 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 <author> +Copyright (c) 2024 Mister Fillname Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/doc/content/installation.md b/doc/content/installation.md index d5cb677..d0a73f0 100644 --- a/doc/content/installation.md +++ b/doc/content/installation.md @@ -11,7 +11,7 @@ $ fillname -h ## Installing with pip -The python fillname package can be found [here](https://pypi.org/project/fillname/). +The python fillname package can be found [here](https://fillname.org/). ```console $ pip install fillname @@ -21,7 +21,7 @@ $ pip install fillname ### Installing from source -The project is hosted on [github](https://github.com/potassco/fillname) and can +The project is hosted on [github](https://fillname.org/) and can also be installed from source. ```{warning} @@ -35,7 +35,7 @@ The `setuptools` package is required to run the commands below. Execute the following command in the top level fillname directory: ```console -$ git clone https://github.com/potassco/fillname +$ git clone https://fillname.org/ $ cd fillname $ pip install -e .[all] ``` diff --git a/init.py b/init.py index ed4e4ae..1e0aa1e 100755 --- a/init.py +++ b/init.py @@ -5,34 +5,65 @@ import os import re +import subprocess -def read(prompt, regex): +def read(prompt, regex, default): """ Read a string from command line. The string has to match the given regular expression. """ + if default: + prompt += f" [{default}]" + prompt += ": " + while True: ret = input(prompt) + if not ret and default: + ret = default match = re.match(regex, ret) if match is not None: return ret print(f"the project name has to match the regular expression: {regex}") +def git_config_get(attr): + """ + Get a git config value. + """ + try: + return subprocess.check_output(["git", "config", "--get", attr]).decode().strip() + except subprocess.CalledProcessError: + return None + def main(): """ Rename the project. """ - project = read("project name: ", r"^[a-z][a-z0-9_]*$") - author = read("author: ", r".+") - email = read("email: ", r".+") + + author = git_config_get("user.name") + email = git_config_get("user.email") + origin = git_config_get("remote.origin.url") + url, project = None, None + + if origin is not None: + match = re.match(r"^.*[:/]([^:/]*)/([^/]*)(\.git)?$", origin) + if match is not None: + org, project = match.group(1), match.group(2) + url = f"https://github.com/{org}/{project}/" + project = project.replace("-", "_") + + project = read("project name", r"^[a-z][a-z0-9_]*$", project) + author = read("author", r".+", author) + email = read("email", r".+", email) + url = read("url", r".+", url) replacements = { - "fillname": project, "author@fillname.com": email, "Mister Fillname": author, + "https://fillname.org/": url, + "fillname": project, } def replace(filepath): @@ -48,8 +79,8 @@ def replace(filepath): ".pre-commit-config.yaml", "noxfile.py", "pyproject.toml", - "setup.cfg", "CONTRIBUTING.md", + "DEPLOYMENT.md", "DEVELOPMENT.md", "LICENSE", "README.md", diff --git a/pyproject.toml b/pyproject.toml index 0207c33..33ccba6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dynamic = [ "version" ] readme = "README.md" [project.urls] -Hompage = "https://potassco.org/" +Hompage = "https://fillname.org/" [project.optional-dependencies] format = [ "black", "isort", "autoflake" ]