+
+def download_and_unzip_data_file(spec, job, build, pid):
+ """Download and unzip a source file.
+
+ :param spec: Specification read form the specification file.
+ :param job: Name of the Jenkins job.
+ :param build: Information about the build.
+ :param pid: PID of the process executing this method.
+ :type spec: Specification
+ :type job: str
+ :type build: dict
+ :type pid: int
+ :returns: True if the download was successful, otherwise False.
+ :rtype: bool
+ """
+
+ download = {
+ "json": _download_json,
+ "xml": _download_xml,
+ "xml-docs": _download_xml_docs
+ }
+
+ success = False
+ downloaded_name = u""
+ arch = bool(spec.environment.get(u"archive-inputs", True))
+
+ for source in spec.environment.get(u"data-sources", tuple()):
+ if not source.get(u"enabled", False):
+ continue
+ download_type = source.get(u"type", None)
+ if not download_type:
+ continue
+ success, downloaded_name = download[download_type](
+ source,
+ job,
+ build,
+ spec.environment[u"paths"][u"DIR[WORKING,DATA]"],
+ arch
+ )
+ if success:
+ source[u"successful-downloads"] += 1
+ build[u"source"] = source[u"type"]
+ break
+
+ # TODO: Remove when only .gz is used.