I want to get the value of the 'latest' version tag from here: https://papermc.io/repo/repository/maven-public/com/destroystokyo/paper/paper-api/maven-metadata.xml
I tried using this python:
import urllib.request
from xml.etree import ElementTree
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
data = opener.open('https://papermc.io/repo/repository/maven-public/com/destroystokyo/paper/paper-api/maven-metadata.xml').
root = ElementTree.fromstring(data)
versioning = root.find("versioning")
latest = versioning.find("latest")
snip.rv = latest.text
The problem is, using this inside of vim (I'm trying to make UltiSnips snippets with it) makes the whole of vim extremely slow after the code has finished running.
What's causing my program to slow down just when I add that ^^ code?
I don't know if this will solve the performance issue in vim, but the code was not running for me due to errors in it.
opener.open
returns a file-like object, so you should read it usingElementTree.parse
instead ofElementTree.fromstring
(actually there is a trailing dot afteropener.open(...)
, so I don't know if you missed aread()
thereafter. In that case the return value is indeed a string).Apart from that, you could try to close the
opener
to see if that frees up some resources (or use thewith
).I attach an example of the improved code: