Skip to main content

softshell

Turn hard-coded variables into dynamic ones without refactoring.

This module allows you to run a script where you replace hard-coded variable assignments with a list of values. For example, suppose we have some script (add.py) that looks like this:

PARAM=2

def add(x, y=2):
    return x + y

print("Adding {} to 2".format(PARAM))
print(add(PARAM))

Without changing anything in add.py, you just create some configuration (config.yml) file like the following:

---
path: add.py
configurations:
    - line_number: 1
      variable: PARAM
      value: [1, 2, 3]

And then run this:

$ softshell -f config.yml python add.py

[{'configurations': [{'line_number': 1,
                      'value': [1, 2, 3],
                      'variable': 'PARAM'}],
  'path': 'add.py'}]
Going through edit 1/3
Configuration is: [('add.py', [(1, 'PARAM', 1)])]
Logs can be found here: /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmp7sr_umua
Going through edit 2/3
Configuration is: [('add.py', [(1, 'PARAM', 2)])]
Logs can be found here: /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpn5y4b48c
Going through edit 3/3
Configuration is: [('add.py', [(1, 'PARAM', 3)])]
Logs can be found here: /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpo4vlz7e3

You will see three separate log files, each showing the result where we set PARAM to 1, 2, 3, respectively:

$ cat /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmp7sr_umua
Configuration is: [('add.py', [(1, 'PARAM', 1)])]
Adding 1 to 2
3
$ cat /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpn5y4b48c
Configuration is: [('add.py', [(1, 'PARAM', 2)])]
Adding 2 to 2
4
$ cat /var/folders/km/41mjphdd6553jdjjf32y9jkh0000gn/T/tmpo4vlz7e3
Configuration is: [('add.py', [(1, 'PARAM', 3)])]
Adding 3 to 2
5

More examples can be found in the examples directory

Installation

$ pip install softshell

Metadata

Release files for softshell 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for softshell 0.1
File Size Uploaded
softshell-0.1.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for softshell 0.1
File Interpreter ABI Platform
softshell-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / softshell-0.1.tar.gz

Download URL softshell-0.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5c49fac530c7ff290d1f9b255b7e4b9409c84faeb9dfe7debc43f74af08e94f8
BLAKE2b-256 checksum
How to use checksums
d19a01a2a02f8065a83e2a6fea4abc295032bebbec022dde7208d3cb88155d4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

Release files / softshell-0.1-py3-none-any.whl

Download URL softshell-0.1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30e73829b5b02081137a8b51c152d66668c7e5a5f57b49829abbafd58589b137
BLAKE2b-256 checksum
How to use checksums
0e26b785d1bccb90d79e73e163a2807c5b60058ee10eb175bece679974b5eac7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page