Python scripts for easily handling variables and outputs #320
Replies: 3 comments 1 reply
-
Wow! 😎 Looks a pretty cool thing to me! 🌞 I didn't try to run it yet, but I looked at the Python code. I'll need to explore it more at a better time 🙂. Does it support custom variables? I.e. variables starting with P.S. I noticed the following "special" variables there: OUTPUT = Variable("output")
PASSTHROUGH = Variable("passthrough")
Maybe these two could be taken out, or put a remark on them in the code? 👍 Thank you for this! I appreciate it! 🥇 I'll try it out and come back when I have some more feedback. 🙂 |
Beta Was this translation helpful? Give feedback.
-
Pondering: Query variables from Obsidian in realtime?Your work made me start pondering a question: What if we could skip reading variables in the shell command part altogether? E.g. Benefits:
This requires me to explore what possibilities Node.js's |
Beta Was this translation helpful? Give feedback.
-
What a coincidence, I came up with exactly the same idea yesterday! From a Linux user's perspective, I can use stdout/stdin, unnamed pipes, named pipes (FIFO) or sockets for communication. Actually, a stdout/stdin pair should be enough General Workflow
Pros & Cons+ No need to worry about how to escape and when to escape strings - When the script grows to some extent, it might be better to write a new extension Putting the growing code in a separate file blurs the boundary between write a Shell Command and writing a new Obsidian extension. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I found it better to put lengthy command in some files, and forward the variables using arguments.
Being able to store the configurations and logs elsewhere is another plus.
Although it is an overkill for customizing PDF export command, these facilitating Python scripts may be the help of someone with similar needs. > Codes here <
I will make this a pypi package for easier access if people think it useful :-)
The variable names are stored as string constants and can be concatenated with arguments.
These scripts can also generate a handy usage message like this
usage: md2pdf.py [-h] --sourcepath {{file_path:absolute}} --sourcetitle {{title}} --sourcefolder {{folder_path:absolute}}
,so the argument list can be directly pasted in Shellcommand configuration.
Such arguments are parsed and stored in a typed way like a dataclass.
There is also a function to setup a logger suitable for Shellcommands which prints
ERROR
andCRITICAL
tostderr
, andINFO
tostdout
and other debug information elsewhere.Beta Was this translation helpful? Give feedback.
All reactions