Code Repository
As our favorite app capability (so far), the Code Repository allows you to reuse code around your Post Functions, Listeners and Console.
Creating a Demonstrative file
Go to Easy for Jira → Code Repository (left menu).
You can create files that can be imported to other places, so let’s work one example, we want to centralize this sum function so we can call it on other scripts.
Name | Prettify Seconds |
---|---|
Filename |
|
Documentation | Function to receive an integer (seconds) as input and make it more humane. |
def prettify_seconds(seconds):
days = seconds // (24 * 3600)
seconds %= (24 * 3600)
hours = seconds // 3600
seconds %= 3600
minutes = seconds // 60
seconds %= 60
result = ""
if days > 0:
result += f"{days} day, " if days <= 1 else f"{days} days, "
if hours > 0:
result += f"{hours} hours, "
if minutes > 0:
result += f"{minutes} minutes, "
result += f"and {seconds} seconds"
return result
When you hit save , your file will be available to all scriptable modules of the app such as Post Functions, Listeners and Console.
Above the “Save File” button there’s the import declaration that you need to add to your files, so let’s suppose I want to use this sum function on my postfunction to sum 2 fields. I would go to Post Functions then in the beginning of my file I would add:
import seconds_prettify
Usage
When creating or updating your Post Functions or Listeners you can import your code as:
import seconds_prettify
seconds = 89219
string = prettify_seconds(seconds)
print(string)
# Output :: 1 day, 46 minutes, and 59 seconds
This is of course a very basic example, as you can build whatever you want and import it to other files.
Documentation
The documentation can be written in a markup format, and then put in a readonly format by clicking in the eye so it’s readable.
The final editor should look something like this:
Versions
Dealing with Versions is quite easy, below your editor you can see some arrows pointing backwards.
To load a version is simple, click the arrow. It should load only the version of the code.
Easy for Jira - Python Automations, 2023