Commit bbaf2e12 authored by legoktm's avatar legoktm

Download extension clover.xml

parent 8a5d3218
......@@ -19,6 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import datetime
import os
import re
import requests
import toolforge
......@@ -26,12 +27,12 @@ toolforge.set_user_agent('coverage')
CLOVER = 'https://doc.wikimedia.org/cover/mediawiki-core/clover.xml'
def main():
r = requests.get(CLOVER)
def download_clover(url, directory):
r = requests.get(url)
modified = r.headers['last-modified']
dt = datetime.datetime.strptime(modified, '%a, %d %b %Y %H:%M:%S GMT')
fname = os.path.expanduser(
'~/mediawiki/clover-%s.xml' % str(dt).split(' ')[0]
directory + '/clover-%s.xml' % str(dt).split(' ')[0]
)
if os.path.isfile(fname):
print('Already downloaded %s' % fname)
......@@ -42,5 +43,16 @@ def main():
print('Saved to %s' % fname)
def main():
download_clover(CLOVER, '~/mediawiki')
r = requests.get('https://doc.wikimedia.org/cover-extensions/')
extensions = re.findall('<a class="cover-item" href="./(.*?)/">', r.text)
for extension in extensions:
directory = os.path.expanduser('~/extensions/' + extension)
if not os.path.isdir(directory):
os.mkdir(directory)
download_clover('https://doc.wikimedia.org/cover-extensions/%s/clover.xml' % extension, directory)
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment