diff --git a/cdist/config.py b/cdist/config.py index 73ba4710..2fd80db0 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# 2010-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # diff --git a/cdist/core/__init__.py b/cdist/core/__init__.py index 66ee00a5..5dafd061 100644 --- a/cdist/core/__init__.py +++ b/cdist/core/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -23,7 +24,6 @@ from cdist.core.cdist_type import CdistType from cdist.core.cdist_type import NoSuchTypeError from cdist.core.cdist_object import CdistObject from cdist.core.cdist_object import IllegalObjectIdError -from cdist.core.cdist_object import OBJECT_MARKER from cdist.core.explorer import Explorer from cdist.core.manifest import Manifest from cdist.core.code import Code diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index e8c58a67..d13c33dd 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -32,9 +32,6 @@ from cdist.util import fsproperty log = logging.getLogger(__name__) -OBJECT_MARKER = '.cdist' - - class IllegalObjectIdError(cdist.Error): def __init__(self, object_id, message=None): self.object_id = object_id @@ -66,16 +63,18 @@ class CdistObject(object): STATE_RUNNING = "running" STATE_DONE = "done" - def __init__(self, cdist_type, base_path, object_id=''): + def __init__(self, cdist_type, base_path, object_marker=".cdist", object_id=''): self.cdist_type = cdist_type # instance of Type self.base_path = base_path self.object_id = object_id + self.object_marker = object_marker + self.validate_object_id() self.sanitise_object_id() self.name = self.join_name(self.cdist_type.name, self.object_id) - self.path = os.path.join(self.cdist_type.path, self.object_id, OBJECT_MARKER) + self.path = os.path.join(self.cdist_type.path, self.object_id, self.object_marker) self.absolute_path = os.path.join(self.base_path, self.path) self.code_local_path = os.path.join(self.path, "code-local") self.code_remote_path = os.path.join(self.path, "code-remote") @@ -97,7 +96,7 @@ class CdistObject(object): def list_object_names(cls, object_base_path): """Return a list of object names""" for path, dirs, files in os.walk(object_base_path): - if OBJECT_MARKER in dirs: + if self.object_marker in dirs: yield os.path.relpath(path, object_base_path) @staticmethod @@ -127,8 +126,8 @@ class CdistObject(object): """Validate the given object_id and raise IllegalObjectIdError if it's not valid. """ if self.object_id: - if OBJECT_MARKER in self.object_id.split(os.sep): - raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % OBJECT_MARKER) + if self.object_marker in self.object_id.split(os.sep): + raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % self.object_marker) if '//' in self.object_id: raise IllegalObjectIdError(self.object_id, 'object_id may not contain //') if self.object_id == '.': diff --git a/docs/dev/logs/2014-05-06.object-marker b/docs/dev/logs/2014-05-06.object-marker new file mode 100644 index 00000000..4878a2f5 --- /dev/null +++ b/docs/dev/logs/2014-05-06.object-marker @@ -0,0 +1,14 @@ +Change object marker from .cdist to .cdist-TEMPNAME to allow using +object ids that contain / are .cdist. + +Changes required: + + cdist/emulator.py: + needs to know suffix/name + tests: + allow object id named /.cdist + tests: + many + cdist/config.py: + have suffix +