python-3.xbalsamiq

How to convert Balsamiq mockups to text strings txt with Python34 script on Windows XP


I've been trying to run these scripts https://github.com/balsamiq/mockups-strings-extractor within XP. I'm getting errors per this screenshot https://www.dropbox.com/s/rlbqp1iytkwvq3m/Screenshot%202014-05-30%2011.57.48.png

Also I tried CD into my test directory and although a text output file is generated it is empty and I still get these errors https://www.dropbox.com/s/odjfbr97e5i4gnn/Screenshot%202014-05-30%2012.09.31.png

Is anybody running Balsamiq on windows able to make this work ?


Solution

  • 1) From the looks of the first error pic you included, you were trying to execute a Windows Shell command inside of a Python Interpreter. If you've still got the window open, type quit() before attempting your command again.

    2) Your script was written for Python 2.x. If you're using Python 3.x, you'll need to add parentheses to the print lines in the script file and change urllib to urllib.parse. I made the changes below:

    import os
    import glob
    import re
    import urllib.parse
    
    for infile in glob.glob( os.path.join(".", '*.bmml') ):
        print("STRINGS FOUND IN " + infile)
        print("===========================================================")
        f = open (infile,"r")
        data = f.read()
        p = re.compile("<text>(.*?)</text>")
        textStrings = p.findall(data)
        print(urllib.parse.unquote('\n'.join(textStrings))+"\n")
        f.close()
    

    Hope this helps.