This post will be to keep track of a small project and get thoughts from others. It's probably very simple and doesn't require any major thought but I wanted to present the idea and see what others think.
So with PSPX9, we now have the ability to export history log but it's not meant to be used as a script but rather as a guide for tutorials and what settings were used. Which is just fine. For a single editing session it's very easy to export a script of the whole session if you want to, you aren't forced to use the log to export your editing history. However, if you didn't bother to make a script and late decide you wanted to, or if you did a lot of adjustments over multiple sessions that you want recorded then you're forced to rely on the edit history found in the Image Information dialog. And this only works for images like JPG and PSPImage files.
So If you exported a history and suddenly want it to be a script, or if you wanted to make a full multi-session a script you have to convert this history log or remember to save the full history as a script before closing the image
Luckily they seem to have used a lot of the same code for simplicity ( a common Corel method of adding new features) and the formatting is largely similar to a Python script. With very little editing the log can be parsed into a script manually, so I was wanting to do the same thing with the log.
What I want to do is make a script that can do three things. 1) Parse a history log file into scripting syntax, 2) Export the history from the Image Info dialog as a script for multi-session edits and 3) Run a log as a script.
Now, this may or may not be possible it depends on how everything is formatted. But I think we should be fine. Given that they keep most of the python-esque formatting of the parameter details. In fact it even keeps the proper spacing.
As I see it the rules are simple:
1) Each command is indented 1 tab - distinguishing a tab character is easy
2) The name of the command is always written with a # (comment in Python) - to know what command to use, just strip the "# " (hash and leading space) from the text and use that as the command name
3) Add a new blank line, tab in 1 space, and add "App.Do( Environment, 'CommandName', {" to the line. CommandName is taken from the previously grabbed name
4) Each new indentation is a new dictionary or list (maybe tuples as well), lists start with "[" and dictionaries with "{" it seems that only dictionaries need to have the beginning and ending symbols added. So test if the last character (after white space has been trimmed) is a "[" or ":" when the next line introduces an extra indentation to know what symbol to use.
5) If the next line is only a single indentation short of the current indentation count end the current block. If it's a list, do nothing. If it's a dictionary then add "}" to the end of the current line
6) If the next line is a single indentation and starts with a "#" then add a new line above the next line and add "})" to finish off the command.
And that should be most of it. With these simple rules it should be easy to implement a simple history log to script parser.
History Log to Script - WIP
Moderator: Kathy_9
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
History Log to Script - WIP
https://levifiction.wordpress.com/
