Bug 1454640 - [moztreedocs] Move 'create_tarball' into a package submodule r=mshal

These two functions are typically only used by CI for packaging/uploading the
documentation. This is a minor re-organiztion for clarity.

MozReview-Commit-ID: 62UhQhSSkOs

--HG--
extra : source : 9942d2df371989c5dd67a75fd7a695533141dd89
This commit is contained in:
Andrew Halberstadt 2018-04-18 12:17:44 -04:00
Родитель 5dfcabfb35
Коммит cf57ba3bc5
3 изменённых файлов: 33 добавлений и 24 удалений

Просмотреть файл

@ -55,9 +55,9 @@ class Documentation(MachCommandBase):
self.virtualenv_manager.install_pip_requirements(
os.path.join(here, 'requirements.txt'), quiet=True)
import moztreedocs
import webbrowser
from livereload import Server
from moztreedocs.package import create_tarball
outdir = outdir or os.path.join(self.topobjdir, 'docs')
format_outdir = os.path.join(outdir, fmt)
@ -84,7 +84,7 @@ class Documentation(MachCommandBase):
if archive:
archive_path = os.path.join(outdir,
'%s.tar.gz' % props['project'])
moztreedocs.create_tarball(archive_path, savedir)
create_tarball(archive_path, savedir)
print('Archived to %s' % archive_path)
if upload:
@ -147,7 +147,7 @@ class Documentation(MachCommandBase):
def _s3_upload(self, root, project, version=None):
self.virtualenv_manager.install_pip_package('boto3==1.4.4')
from moztreedocs import distribution_files
from moztreedocs.package import distribution_files
from moztreedocs.upload import s3_upload
# Files are uploaded to multiple locations:

Просмотреть файл

@ -7,7 +7,6 @@ from __future__ import unicode_literals
import os
from mozbuild.frontend.reader import BuildReader
from mozpack.archive import create_tar_gz_from_files
from mozpack.copier import FileCopier
from mozpack.files import FileFinder
from mozpack.manifests import InstallManifest
@ -128,23 +127,3 @@ class SphinxManager(object):
with open(os.path.join(self._docs_dir, 'index.rst'), 'wb') as fh:
fh.write(data)
def distribution_files(root):
"""Find all files suitable for distributing.
Given the path to generated Sphinx documentation, returns an iterable
of (path, BaseFile) for files that should be archived, uploaded, etc.
Paths are relative to given root directory.
"""
finder = FileFinder(root, ignore=('_staging', '_venv'))
return finder.find('**')
def create_tarball(filename, root):
"""Create a tar.gz archive of docs in a directory."""
files = dict(distribution_files(root))
with open(filename, 'wb') as fh:
create_tar_gz_from_files(fh, files, filename=os.path.basename(filename),
compresslevel=6)

Просмотреть файл

@ -0,0 +1,30 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, # You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, unicode_literals
import os
from mozpack.archive import create_tar_gz_from_files
from mozpack.files import FileFinder
def distribution_files(root):
"""Find all files suitable for distributing.
Given the path to generated Sphinx documentation, returns an iterable
of (path, BaseFile) for files that should be archived, uploaded, etc.
Paths are relative to given root directory.
"""
finder = FileFinder(root, ignore=('_staging', '_venv'))
return finder.find('**')
def create_tarball(filename, root):
"""Create a tar.gz archive of docs in a directory."""
files = dict(distribution_files(root))
with open(filename, 'wb') as fh:
create_tar_gz_from_files(fh, files, filename=os.path.basename(filename),
compresslevel=6)