Gist file retrieval
used to work, even for multi file gists, and allowed you to rev gists easily.. I don't think the bookmarklets work anymore in safari, or at least not ones that launch apps, and likely enough has changed in Pythonista3 that this won't work at all without some effort.
But this shows you how you could retrieve a gist using the gist api.
The way I tend to do this these days is with a simple App Extension (i.e from Safari share menu) script that download the current page into pythonista.
Do you have your script posted somewhere?
Be interested in seeing how it works.
JonB last edited by JonB
i updated my savefile script to handle gists, including multi file gists.
Add to the appex shortcuts, then from safari simply Share-> Run Pythonista3 script->savedfile. For normal files, it will guess the name, and weite the file to your home folder. For gists it will create a gists/gis_id folder and download all files associated with the gist.
Ok, that is totally awesome.
Works flawlessly and the .pyui file just opens up right into the GUI.
I have both versions of Pythonista on my iPad.
The share sheet from Safari opens up Pythonista not Pythonista 3.
Any idea how to change That?
I am a much happier camper.
ccc last edited by ccc
Got the Pythonista 3 Sharesheet.
Thanks, i just thought it was a repeat.
abcabc last edited by
@JonB savefile is a great utility. There seems to be a bug and it gives error If the file contains unicode character. For example I am not able save this file.
I have modified your file as follows to make it work (convert the "content" to bytes). May be you can make appropriate changes.
console.hud_alert('writing '+filename) content=f['content'] with open(os.path.join(destpath,filename),'wb') as file: file.write(bytes(content, 'utf8')) else: console.hud_alert('could not download') else: destpath=urlfilename with open(destpath,'wb') as file: file.write(bytes(requests.get(url).content, 'utf8'))
idcrook last edited by
Thanks for catching this -- I forgot that json was going to return a
I updated the gist. I actually opted for downloading the raw url, rather than using the content field -- in skimming the api, gists may sometimes be truncated, so redownloading the raw url takes care of both issues. (probably paranoid, but I am always wary of using json to capture truly binary data). Slightly wasteful, but gists are usually small enough.
I have been trying different versions of Gist and Github downloaders and came up with the following solution after combining several together. It works with both Gists and Github repos. It does work with Unicode and it runs nicely from the sharesheet with some prompts to tell you what it is doing.
Phuket2 last edited by
@mrcoxall , I just had a look to see if you were in on this discussion-
Maybe you seen it. Not sure. But @ccc approach is pretty nice. Granted you need another app (working-copy) and it's a few steps.
Not a one click solution. But It can be 2 way solution (I tested it). Also via working-copy you have a real link back to the source. But the solution is pretty fast and memorable for repeating over and over. I just mention it because it's helped me tremendously. It takes me around 20-30 seconds to the the gist/repo into working-copy then using @ccc apex script to move it into Pythonista.
Anyway, just a thought. Personally, I prefer the structure over the speed.