Skip to main content

A dynamic, multi-language project templating utility.

Project description

nusex

PyPi version PyPI - Status Downloads GitHub last commit License

CI Read the Docs Maintainability Test Coverage

A dynamic, multi-language project templating utility.

Features

  • An easy-to-use command-line interface
  • A powerful API for application developers
  • Smart templating to populate projects with relevant information
  • A profile system for those who maintain personal and organisation-owned projects
  • Premade templates to get started with
  • Minimal dependencies, unlike many other templating utilities
  • Support for CPython and PyPy 3.7 and up on all OSes

Installation

To install the latest stable version of nusex:

pip install nusex

To install the latest development version:

pip install git+https://github.com/nusex/nusex

You may need to prefix these commands with a call to the Python interpreter depending on your OS and Python configuration.

Using the CLI

The CLI provides a simple and user-friendly way to use nusex, and is ideal for those wishing to use nusex to enhance their own development experience. It abstracts a fair amount away from you, so you may wish to use the API if you want something more powerful.

The CLI is not available in version 2 yet.

Using the API

The API provides a more powerful interface to build templates and profiles with, and is ideal for those wishing to utilise nusex's capabilities in their own applications.

Building a basic template would look something like this:

from nusex.api import Template

template = Template("template_name")
files = template.find_files(".")
excludes = template.process_excludes(files, sources=[".gitignore"])
template.build(files - excludes, "Project Name", blueprint="generic")

From there, you can create a profile to deploy the template with:

from nusex.api import Profile

profile = Profile(
    "profile_name",
    author_name="Author Name",
    author_email="author@email.com",
    ...
)

Finally, you can deploy the template:

template.deploy("/path/to/deploy", project_name="New Project", profile=profile)

Have a look at the documentation to find out more.

What is "smart templating"?

When building templates, nusex replaces various parts of specific files with placeholder variables, which are then replaced with profile data when deployed. The files checked are dependent on the blueprint used, so for example, using the Python blueprint would give different results than using the Rust one.

It is important to note that the source files are not modified; the files are loaded into memory beforehand.

Consider the following file:

# mymodule/__init__.py

__productname__ = "My Module"
__version__ = "1.0.0"
__author__ = "Barney the Dinosaur"

nusex checks the main __init__.py file of the project, and looks out for specific dunder variables, such as the three above. Each dunder variable that has a suitable placeholder variable (things like __all__ do not have one, and so are left alone) has its value replaced. The above file would become this:

# mymodule/__init__.py

__productname__ = "$:project_name:"
__version__ = "$:starting_version:"
__author__ = "$:author_name:"

When deploying, nusex simply replaces these placeholder variables with data from the given profile, or data it infers from the current environment.

Contributing

Contributions are very much welcome! To get started:

License

The nusex module for Python is licensed under the BSD 3-Clause License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nusex-2.0.0a3.tar.gz (21.9 kB view hashes)

Uploaded Source

Built Distribution

nusex-2.0.0a3-py3-none-any.whl (33.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page