Gist file retrieval
Using the Save to Gist is the easiest built in way to archive out your Pythonista files.
I am using it to save both my .py and .pyui files.
(Just select both and the hit the share sheet)
Does anyone have a nice easy way to read a single Gist URL and save back all the associated files back into Pythonista?
(Ex Gist directory: https://gist.github.com/Mr-Coxall/4e21e9fe4ea65abcd9cd0d3ec094d0b7)
Do you have your script posted somewhere?
Be interested in seeing how it works.
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.
@mrcoxall in the share sheet on the same row where you see
Run Pythonista Script, scroll all the way to the right (maybe even under
More...) you will find another
Run Pythonista Scriptthat has a 3 in the icon.
Got the Pythonista 3 Sharesheet.
Thanks, i just thought it was a repeat.
@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'))
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.
@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.