Skip to main content

A powerful templating tool for your projects.

Project description

Proclip

PyPi version PyPI - Status Downloads GitHub last commit License

A powerful templating tool for your projects.

CPython versions 3.7 through 3.11-dev and PyPy versions 3.7 through 3.9 are officially supported.

Windows, MacOS, and Linux are all supported.

Installation

To install the latest stable version of Proclip, use the following command:

pip install proclip

You can also install the latest development version using the following command:

pip install git+https://github.com/parafoxia/proclip

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

Creating clips

You can create clips using the following command:

clip new <name> <file> [-o output-dir]

Use clip new --help for more information on what each option does.

To create a clip, first create a file, and code it how you want it to look. You can also include variables that Proclip can replace when you paste the clip. Variables use a slightly modified Jinja syntax, which additionally allows for default values to be provided.

Take the following example:

class {{ cls = MyClass }}:
    def __init__(self, n: int) -> None:
        self.{{ attr }} = n

    @property
    def number(self) -> int:
        return self.{{ attr }}

if __name__ == "__main__":
    c = {{ cls }}(5)
    print(c.number)

In this example, you have two distinct variables: cls, and attr. cls has a default value (MyClass), so when you paste the clip, that value will be used if you don't supply one. Note that only the first instance of cls needs a default value. Keep in mind that only one default value can be assigned per variable; others will be overwritten.

Pasting clips

You can paste clips using the following command:

clip paste <name> [-i input-dir] [-o output] [-v variables]

Use clip paste --help for more information on what each option does.

You can use the -v flag to insert values for variables when pasting. Variables that were not assigned default values when the clip was created need a value supplied to them. Default values can be overridden if you choose to do so.

Variables are passed as strings, where a value needs to be assigned to a key (for example, key=value). You can use commas to separate multiple variable assignments (key1=value1,key2=value2). In the above example, passing -v "attr=n" produces the following file:

class MyClass:
    def __init__(self, n: int) -> None:
        self.n = n

    @property
    def number(self) -> int:
        return self.n

if __name__ == "__main__":
    c = MyClass(5)
    print(c.number)

Contributing

Contributions are very much welcome! To get started:

License

The Proclip 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

proclip-0.2.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

proclip-0.2.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file proclip-0.2.0.tar.gz.

File metadata

  • Download URL: proclip-0.2.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for proclip-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d91a966a84e9410bf5797fb04730e7dd105b05c8f44a450ab8bd2c7dadcb5ecc
MD5 3134d6e2ec6756420c86d53689efc9ff
BLAKE2b-256 61b810d8707c4a8443334f1fc34360222a30a2875bd1b147593e6f4992045b74

See more details on using hashes here.

File details

Details for the file proclip-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: proclip-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for proclip-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c22389fd4cb341e303def5fc84c8997cab7045f25746264b1f204f002b591dba
MD5 dc05c82dabec5d0c7218db832ed73ccd
BLAKE2b-256 830763247a01da5fdd5344670409dccc2194db4cce7fde47473b6992630e1d17

See more details on using hashes here.

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