• inyourfaceplate

    This is an appex extension script to remove PDF and color backgrounds from Notability documents. To use, open a doc in Notability, click share, use the Note format, choose Pythonista 3, choose this script. You will then get a ne "open in" dialog. Choose Notability from that dialog to re-import the modified doc.

    The script treats the note as a zip file, unpacks it, removes any PDFs, edits Session.plist to change the bg color to white, then archives the result.

    Notes:

    • Notability's format could change at any time and break this script, so use it at your own risk!!
    • I didn't try to use pip, so I 'installed' the biplist module by copy pasting it into my lib directory. I was not able to get plistlib to read the plist file.
    • camelCase var names, sorry!
    #coding: utf-8
    
    import console, shutil, appex, os.path, zipfile, os, glob, re, plistlib
    
    # Install biplist (I could not get plistlib to read the plist file, even
    # when I used fmt=plistlib.FMT_BINARY))
    # Rather than using pip, I just put the contents of this url in ./lib/biplist.py
    # https://raw.githubusercontent.com/wooster/biplist/master/biplist/__init__.py
    
    from lib.biplist import *
    
    tmpPath = './jtziptmp/'
    extractedPath = './jtziptmp/extracted/'
    tmpFileName = 'tmpfile.zip'
    newFileName = tmpPath+os.path.basename(appex.get_file_path())+'_bgstripped.note'
    shutil.rmtree(tmpPath)
    os.mkdir(tmpPath)
    os.mkdir(extractedPath)
    shutil.copy(appex.get_file_path(),tmpPath+tmpFileName)
    shutil.unpack_archive(tmpPath+tmpFileName,extractedPath)
    
    pattern = "^.*pdf$"
    mypath = extractedPath
    for root, dirs, files in os.walk(mypath):
        for file in filter(lambda x: re.match(pattern, x), files):
            os.remove(os.path.join(root, file)) # remove the pdf bg
    
    pattern = "^Session.plist$"
    mypath = extractedPath
    for root, dirs, files in os.walk(mypath):
        for file in filter(lambda x: re.match(pattern, x), files):
            plist = readPlist(os.path.join(root, file))
            plist['$objects'][1]['paperIndex'] = 12 # set white bg
            writePlist(plist,os.path.join(root, file))
            
    shutil.make_archive(newFileName,'zip',extractedPath)
    shutil.move(newFileName+'.zip',newFileName)
    console.open_in(newFileName)
    

    posted in Pythonista read more
  • inyourfaceplate

    omz's solution works great!

    Thanks everyone!

    posted in Pythonista read more
  • inyourfaceplate

    Hi there!

    Can anyone show me how to access the current WIFI SSID via Pythonista? This would be awesome in the widget.

    Thanks,
    John

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!