• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Custom Journal Output

Minous

Well-known member
Is it possible to create a raw text file with the Journal contents for all characters in a portfolio?

When using the PDF output it uses new lines instead of wrapping the text automatically which makes getting titles on a single line not possible.
 
Can't be done from within HL that I know of.

HL portfolio files are zipped up XML files. It appears that HL embeds newlines inside text attributes in a way that isn't proper XML. They put the newline character into the attribute text as an ASCII <LF> and the XML spec says it should be the HTML newline entity instead. Every XML library I've tested for reading XML deletes the newlines from the attribute content. :(
 
Last edited:
Python3 solution

I have a workaround.

I have a working Python3 script now (written and tested on Python 3.4). It can be executed with a single filename and it will try to determine what kind of file it is and handle it appropriately. Each of these possibilities is tried, in order, until one succeeds.
  • Filename ends with .por or .zip: treated as a HeroLab portfolio file. The script will look inside and pull out the filenames of the heroes, then process each one in the same order that they appear in the portfolio.
  • Filename is equal to "portfolio.xml": treated as though the portfolio has already been extracted (as a ZIP file) and the script is being executed in the top-level directory where it was unpacked. It will search the current directory and the herolab/ subdirectory looking for portfolio.xml. if it finds it, it will look for the heroes listed within and process them the same as the previous choice.
  • Filename ends with .xml: treated as a simple data file that contains the information for a single hero. The journal will be extracted from only this file. The current directory will be searched and if the file is not found, the herolab/ subdirectory will also be searched.
If none of the above match, a general message is displayed that describes how to use the script.

Obviously, you will need Python 3.4+ installed for this script to work. In the future I will create a generic Python module that can be used to access HL portfolio files. This will allow faster creation of similar scripts when the need arises.

In most GUI environments the user should be able to drag/drop a HeroLab portfolio file on top of the script and the GUI will execute the script and pass it the portfolio's filename as a parameter. This will activate option #1 in the list above. (This isn't working on my Mac and I haven't started looking into it yet, but other GUIs I'm familiar with will work as described.)

(Note: the forum software won't let me name my Python script with the typical .py extension, so I've named it with .txt instead. You'll need to change the filename extension after downloading it.)

I have subscribed to this thread, so if you have comments or ideas for things to add, let me know and I'll work on them when I can.
 

Attachments

Last edited:
Back
Top