Skip to main content

A simple Python plugin framework

Project description

uPM - a micro project manager

This neat tool wants to help you organizing project and file templates. It can create complete file structures in one simple command line and is easily extensible

Installation

To install uPM just create a virtual environment and use pip to install uPM directly into your project

python -m venv env
source env/bin/activate
python -m pip install upm
upm init -p projectname=myproject python-project .

This creates a simple python project with name myproject. Any occourance of the pattern projectname in filenames will be replaced by the given value myproject. Inside files, the pattern {{projectname}} will be replaced by the given value myproject

You can set your own parameters in a json based config file named ~/.upm/config. Additionally, uPM looks in the current directory for a configuration file named .upm which will overlay the current configuration.

Configuration

user setup

To setup uPM properly you should follow these steps. First, create a config structure for your uPM templates

$ mkdir -p ~/.upm/templates
$ vi ~/.upm/config

A minimal config file could look like this:

{
    "pattern" : {
        "author" : "YourName"
    },
    "template_path" : "~/.upm/templates"
}

You are now ready to create templates and any template that contains the pattern {{author}} will automagically get your name set

project setup

Additionally you can, in your base directory (from where you have to call uPM), create a file .upm which may contain additional information:

{
    "pattern" : {
        "projectname" : "MyTinyProject",
        "project-email" : "admin@mytiny-project.com"
    }
}

You also could set your own template_path for this particular project in the same mannor as in user setup

pre-created templates

Since nobody wants a templating engine without templates, I started to create some for my projects. These are also available at gitlab. Using the upper config file one can use them this way.

~$ mkdir ~/.upm && cd $_
.upm$ git clone git@gitlab.com:rapp.jens/upm-templates.git templates

Patterns which are always set

There are some (at least one) pattern which are automatically set by the program. Prevent using their name inside your pattern config

current_date

Any occourance of the word current_date in filenames or {{current_date}} will be replaced by the current date

creating your own templates

To create your own templates, just create a file or file structure like this one:

$ mkdir -p python-project/projectname
$ vi python-project/projectname/projectname.py

with its content

#!/usr/bin/env python
##############################################################################
# author       # {{author}}
# date         # {{current_date}}
# ---------------------------------------------------------------------------
# description  #
#              #
#              #
##############################################################################
import sys

def main():
    pass


if __name__ == '__main__':
    sys.exit(main())

Now you can simply scan your template into your template folder

$ upm scan python-project > ~/.upm/templates/python-project.tmpl

Creating this project is done by using

$ mkdir project && cd $_
$ upm init -pprojectname=MyProject python-project .

This creates a project directory like

└── MyProject
    └── MyProject.py

Currently, your scan base must be a directory. If you want to scan a single file, this must be the only file in the given directory. Here is an example for creating a single python file template.

pyfile/
└── name

scanning this using the command

$ upm scan pyfile python-main > ~/.upm/templates/python-main.tmpl

creates a template which can be used to create a single file using upm

$ upm init -pname=main.py python-main .

That's all for now. Have fun.

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

upm - micro project manager-0.1.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

upm_micro_project_manager-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file upm - micro project manager-0.1.1.tar.gz.

File metadata

File hashes

Hashes for upm - micro project manager-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f0e094898eec5f4b41995ba50bf4f829700f36e81b81c24726c44974eb8a6c4e
MD5 694bed202e25f1922423f8144b791843
BLAKE2b-256 27c6fca3caf1973aab54de456a06dc3d858c10f10b9b3baf2f6228211d77b2a9

See more details on using hashes here.

File details

Details for the file upm_micro_project_manager-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for upm_micro_project_manager-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb9a90c0b9b857e4fdfd97178a6d45be51f2c0d1ce7327dd01a1be5c50735e1e
MD5 6deaec794d559564b272699ada56cb4f
BLAKE2b-256 419899608df8d9802f9a769e8cafc1d6b5570dbe02d065ccf9fa5eb89a4b7ab9

See more details on using hashes here.

Supported by

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