
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Not worth it to refactor your script into a bunch of functions? This is a simple python library that lets you run your script as though you had, so you can
call results = callscript('myscript.py', x=3, y=4)
. Just add comments in your scirpt to show where the inputs and outputs are, and callscript
will
make the function work properly:
# myscript.py
x = 1 # input
y = 2 # input
w = x * y
v = x / y # output
z = x + y # output
print(z) # ignore
Why does this exist? Because sometimes you don't want to touch your old code or want to keep working with it using an interactive coding tool like Spyder, VSCode's interactive mode, or Jupyter, but you still want to be able to test your script using new parameters, or wrap it with a user interface.
Or maybe you're not sure how to go about changing the script's code to make it work in a new context and don't have a lot of time at the moment to work it out, or maybe you're collaborating with someone who isn't ready to refactor the script yet.
In any case, with callscript
, you can leave the original script alone and wrap it with your new functionality.
Install callscript
with PyPI
pip install callscript
If you label your script with the "input" or "output" comments, callscript
can call it!
# examples/script.py
x = 3 # input
y = 5 # input
z = x + y # output
Then from your other code, you can call it with the callscript()
function:
>>> from callscript import callscript
>>> callscript('examples/script.py', x=10, y=20)
{'z': 30}
Want to change your variable names? You can do that, too!
# examples/script2.py
x = 3 # input:FirstWeek
y = 5 # input:SecondWeek
z = x + y # output:sum
>>> callscript('examples/script2.py', FirstWeek=10, SecondWeek=20)
{'sum': 30}
Want some lines to be ignored when being called by callscript()
? Use the # ignore
tag!
# examples/script3.py
x = 3 # input
y = 5 # input
input('What is your name?') # ignore
z = x + y # output
z = 100000 # ignore
>>> callscript('examples/script3.py', x=10, y=20)
{'z': 30}
callscript()
will automatically use the original values of the inputs in the script as defaults.
# examples/script4.py
name = 'Nick' # input
greeting = 'Hello, ' # input
msg = greeting + name # output
>>> callscript('examples/script4.py', name='Emma')
{'msg': 'Hello, Emma'}
To run tests, run the following command
tox
Don't modify the CHANGELOG.rst
file directly! Instead, usescriv create
make a new entry for the changelog. After you've written a contribution, add the entry and write what you did into the template. When we are ready to make a release, we'll use the scriv collect
command to aggregate these fragments into a new changeelog entry.
FAQs
Makes scripts feel like functions.
We found that callscript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.