summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2020-05-11 08:56:59 +0000
committerBenjamin Schubert <contact@benschubert.me>2020-05-11 08:56:59 +0000
commit4adcb0583375bd533c58b5cd9cf827f62659cc08 (patch)
tree6a175d1b5dbe9e9e570f295a435192163223ac04
parent14dd3598024b58e9e626897e7062dd9563a1502a (diff)
parentcae8cd14f5ad31687d578494cb707b353a241ac5 (diff)
downloadbuildstream-4adcb0583375bd533c58b5cd9cf827f62659cc08.tar.gz
Merge branch 'bschubert/make-downloadable-filesource-public' into 'master'
downloadablefilesource.py: Make it publicly accessible Closes #610 See merge request BuildStream/buildstream!1908
-rw-r--r--doc/source/core_framework.rst1
-rw-r--r--src/buildstream/__init__.py1
-rw-r--r--src/buildstream/downloadablefilesource.py (renamed from src/buildstream/plugins/sources/_downloadablefilesource.py)38
-rw-r--r--src/buildstream/plugins/sources/remote.py3
-rw-r--r--src/buildstream/plugins/sources/tar.py4
-rw-r--r--src/buildstream/plugins/sources/zip.py4
6 files changed, 40 insertions, 11 deletions
diff --git a/doc/source/core_framework.rst b/doc/source/core_framework.rst
index bdfa600f5..605ecad1e 100644
--- a/doc/source/core_framework.rst
+++ b/doc/source/core_framework.rst
@@ -16,6 +16,7 @@ useful for working on BuildStream itself.
buildstream.node
buildstream.plugin
buildstream.source
+ buildstream.downloadablefilesource
buildstream.element
buildstream.buildelement
buildstream.scriptelement
diff --git a/src/buildstream/__init__.py b/src/buildstream/__init__.py
index c68c63e39..1bc564e2e 100644
--- a/src/buildstream/__init__.py
+++ b/src/buildstream/__init__.py
@@ -34,6 +34,7 @@ if "_BST_COMPLETION" not in os.environ:
from .node import MappingNode, Node, ProvenanceInformation, ScalarNode, SequenceNode
from .plugin import Plugin
from .source import Source, SourceError, SourceFetcher
+ from .downloadablefilesource import DownloadableFileSource
from .element import Element, ElementError
from .buildelement import BuildElement
from .scriptelement import ScriptElement
diff --git a/src/buildstream/plugins/sources/_downloadablefilesource.py b/src/buildstream/downloadablefilesource.py
index fcdd005ac..7c2da1c02 100644
--- a/src/buildstream/plugins/sources/_downloadablefilesource.py
+++ b/src/buildstream/downloadablefilesource.py
@@ -1,4 +1,36 @@
-"""A base abstract class for source implementations which download a file"""
+#
+# Copyright (C) 2019 Bloomberg LP
+# Copyright (C) 2019 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""
+DownloadableFileSource - Abstract class for sources downloaded from a URI
+=========================================================================
+
+This DownloadableFileSource class is a convenience class on can derive for
+implementing sources that get downloaded from a URI.
+
+It provides utilities around handling mirrors, tracking and fetching the source.
+
+Any derived classes must write their own stage() and get_unique_key()
+implementation.
+
+
+"""
+
import os
import urllib.request
@@ -7,8 +39,8 @@ import contextlib
import shutil
import netrc
-from buildstream import Source, SourceError
-from buildstream import utils
+from .source import Source, SourceError
+from . import utils
class _NetrcFTPOpener(urllib.request.FTPHandler):
diff --git a/src/buildstream/plugins/sources/remote.py b/src/buildstream/plugins/sources/remote.py
index 57d8743a7..9ed3099d9 100644
--- a/src/buildstream/plugins/sources/remote.py
+++ b/src/buildstream/plugins/sources/remote.py
@@ -48,8 +48,7 @@ See :ref:`built-in functionality doumentation <core_source_builtins>` for
details on common configuration options for sources.
"""
import os
-from buildstream import SourceError, utils
-from ._downloadablefilesource import DownloadableFileSource
+from buildstream import DownloadableFileSource, SourceError, utils
class RemoteSource(DownloadableFileSource):
diff --git a/src/buildstream/plugins/sources/tar.py b/src/buildstream/plugins/sources/tar.py
index 793fd11c9..aba927b99 100644
--- a/src/buildstream/plugins/sources/tar.py
+++ b/src/buildstream/plugins/sources/tar.py
@@ -60,11 +60,9 @@ import tarfile
from contextlib import contextmanager
from tempfile import TemporaryFile
-from buildstream import SourceError
+from buildstream import DownloadableFileSource, SourceError
from buildstream import utils
-from ._downloadablefilesource import DownloadableFileSource
-
class ReadableTarInfo(tarfile.TarInfo):
"""
diff --git a/src/buildstream/plugins/sources/zip.py b/src/buildstream/plugins/sources/zip.py
index c112cf10e..116425934 100644
--- a/src/buildstream/plugins/sources/zip.py
+++ b/src/buildstream/plugins/sources/zip.py
@@ -60,11 +60,9 @@ import os
import zipfile
import stat
-from buildstream import SourceError
+from buildstream import DownloadableFileSource, SourceError
from buildstream import utils
-from ._downloadablefilesource import DownloadableFileSource
-
class ZipSource(DownloadableFileSource):
# pylint: disable=attribute-defined-outside-init