remove support for tarball/directory (#68601)
This commit is contained in:
parent
1a4a9933d1
commit
f03f1c1fbd
36
publish.py
36
publish.py
|
@ -4,10 +4,7 @@ import json
|
|||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import re
|
||||
import urllib2
|
||||
import urlparse
|
||||
|
||||
MAL_NS = 'http://projectmallard.org/1.0/'
|
||||
|
||||
|
@ -42,13 +39,6 @@ def checkout(module):
|
|||
subprocess.call(cmd, **kws)
|
||||
|
||||
|
||||
def download(url):
|
||||
filename = os.path.split(urlparse.urlparse(url)[2])[-1]
|
||||
if not os.path.exists(os.path.join(checkouts_directory, filename)):
|
||||
with open(os.path.join(checkouts_directory, filename), 'w') as fd:
|
||||
fd.write(urllib2.urlopen(url).read())
|
||||
|
||||
|
||||
def publish_mallard(module, branch, directory):
|
||||
module_name = module.get('name')
|
||||
checkout_dir = os.path.join(checkouts_directory, module_name)
|
||||
|
@ -106,24 +96,6 @@ def publish_mallard(module, branch, directory):
|
|||
json.dump(pages, open(os.path.join(output_dir, 'pages.json'), 'w'), indent=2)
|
||||
|
||||
|
||||
def publish_tarball(module):
|
||||
output_dir = os.path.join(web_directory, module.get('name'), 'stable')
|
||||
url = module.get('url')
|
||||
directory = module.get('directory')
|
||||
filename = os.path.split(urlparse.urlparse(url)[2])[-1]
|
||||
tar = tarfile.open(os.path.join(checkouts_directory, filename), 'r')
|
||||
for tarinfo in tar:
|
||||
if not tarinfo.name.startswith(directory):
|
||||
continue
|
||||
output_filename = os.path.join(output_dir, tarinfo.name[len(directory):].strip('/'))
|
||||
if tarinfo.isdir():
|
||||
if not os.path.exists(output_filename):
|
||||
os.makedirs(output_filename)
|
||||
else:
|
||||
fd = tar.extractfile(tarinfo)
|
||||
open(output_filename, 'wb').write(fd.read())
|
||||
|
||||
|
||||
def publish_sphinx(module):
|
||||
checkout_dir = os.path.join(checkouts_directory, module.get('name'))
|
||||
output_dir = os.path.join(web_directory, module.get('name'))
|
||||
|
@ -141,14 +113,8 @@ with open('modules.json') as fd:
|
|||
|
||||
for module in modules:
|
||||
if module.get('type') == 'tarball':
|
||||
download(module.get('url'))
|
||||
else:
|
||||
checkout(module.get('name'))
|
||||
|
||||
if module.get('directory'):
|
||||
module['branch'] = 'stable'
|
||||
publish_tarball(module)
|
||||
continue
|
||||
checkout(module.get('name'))
|
||||
|
||||
if module.get('type') == "sphinx":
|
||||
publish_sphinx(module)
|
||||
|
|
Loading…
Reference in New Issue