Skip to content
Snippets Groups Projects
Commit 613a30fe authored by James Ennis's avatar James Ennis
Browse files

_artifactelement.py: New module containing ArtifactElement class

The ArtifactElement class is to be used when we want to pass a
dummy artifact to our scheduler, typically this will be when we
are directly working with artifact refs.
parent ff46ae41
No related branches found
No related tags found
No related merge requests found
#
# Copyright (C) 2019 Bloomberg Finance LP
#
# 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/>.
#
# Authors:
# James Ennis <james.ennis@codethink.co.uk>
from ._exceptions import ArtifactElementError
# ArtifactElement()
#
# Object to be used for directly processing an artifact
#
# Args:
# context (Context): The Context object
# ref (str): The artifact ref
#
class ArtifactElement():
def __init__(self, context, ref):
try:
project_name, element, key = ref.split('/', 2)
except ValueError:
raise ArtifactElementError("Artifact: {} is not of the expected format".format(ref))
self._project_name = project_name
self._element = element
self._key = key
self._context = context
def get_artifact_name(self):
return '{0}/{1}/{2}'.format(self._project_name, self._element, self._key)
def _cached(self):
return self._context.artifactcache.contains_ref(self.get_artifact_name())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment