Exemple #1
0
 def __init__(self, pod_path, _pod):
     utils.validate_name(pod_path)
     self.pod = _pod
     self.collection_path = pod_path.lstrip("/content")
     self.pod_path = pod_path
     self._default_locale = _pod.podspec.default_locale
     self._blueprint_path = os.path.join(self.pod_path, "_blueprint.yaml")
Exemple #2
0
 def __init__(self, pod_path, _pod):
     utils.validate_name(pod_path)
     self.pod = _pod
     self.collection_path = re.sub('^/content/?', '', pod_path).strip('/')
     self.pod_path = pod_path
     self._default_locale = _pod.podspec.default_locale
     self._blueprint_path = os.path.join(self.pod_path, '_blueprint.yaml')
Exemple #3
0
 def __init__(self, pod_path, _pod):
     utils.validate_name(pod_path)
     self.pod = _pod
     self.collection_path = pod_path.lstrip('/content')
     self.pod_path = pod_path
     self._default_locale = _pod.podspec.default_locale
     self._blueprint_path = os.path.join(self.pod_path, '_blueprint.yaml')
Exemple #4
0
  def __init__(self, pod_path, _pod, locale=None, _collection=None, body_format=None):
    utils.validate_name(pod_path)
    self._default_locale = _pod.podspec.default_locale
    self.locale = locale or _pod.podspec.default_locale
    self.pod_path = pod_path
    self.basename = os.path.basename(pod_path)
    self.base, self.ext = os.path.splitext(self.basename)

    self.pod = _pod
    self.collection = _collection

    self.format = messages.extensions_to_formats.get(self.ext)
    if self.format == messages.Format.MARKDOWN:
      self.doc_storage = MarkdownDocumentStorage(
          self.pod_path, self.pod, locale=locale, default_locale=self._default_locale)
    elif self.format == messages.Format.YAML:
      self.doc_storage = YamlDocumentStorage(
          self.pod_path, self.pod, locale=locale, default_locale=self._default_locale)
    else:
      formats = messages.extensions_to_formats.keys()
      text = 'Basename "{}" does not have a valid extension. Valid formats are: {}'
      raise BadFormatError(text.format(self.basename, ', '.join(formats)))

    self.fields = self.doc_storage.fields
    self.tagged_fields = self.doc_storage.tagged_fields
Exemple #5
0
 def __init__(self, pod_path, _pod):
     utils.validate_name(pod_path)
     self.pod = _pod
     self.pod_path = pod_path
     self.collection_path = Collection.clean_collection_path(pod_path)
     self.basename = os.path.basename(self.collection_path)
     self.blueprint_path = os.path.join(self.pod_path,
                                        Collection.BLUEPRINT_PATH)
Exemple #6
0
 def __init__(self, pod_path, _pod):
     utils.validate_name(pod_path)
     self.pod = _pod
     self.pod_path = pod_path
     self.collection_path = Collection.clean_collection_path(pod_path)
     self.basename = os.path.basename(self.collection_path)
     self.blueprint_path = os.path.join(
         self.pod_path, Collection.BLUEPRINT_PATH)
Exemple #7
0
 def __init__(self, pod_path, _pod, locale=None, _collection=None, body_format=None):
   utils.validate_name(pod_path)
   self.default_locale = _pod.podspec.default_locale
   self.locale = _pod.normalize_locale(locale)
   self.pod_path = pod_path
   self.basename = os.path.basename(pod_path)
   self.base, self.ext = os.path.splitext(self.basename)
   self.pod = _pod
   self.collection = _collection
Exemple #8
0
 def __init__(self, pod_path, _pod, locale=None, _collection=None):
   self._locale_kwarg = locale
   utils.validate_name(pod_path)
   self.pod_path = pod_path
   self.basename = os.path.basename(pod_path)
   self.base, self.ext = os.path.splitext(self.basename)
   self.pod = _pod
   self.collection = _collection
   self.locale = _pod.normalize_locale(locale, default=self.default_locale)
Exemple #9
0
 def __init__(self, pod_path, _pod):
     utils.validate_name(pod_path)
     regex = Collection._content_path_regex
     self.pod = _pod
     self.collection_path = regex.sub('', pod_path).strip('/')
     self.pod_path = pod_path
     self.basename = os.path.basename(self.collection_path)
     self._blueprint_path = os.path.join(self.pod_path,
                                         Collection.BLUEPRINT_PATH)
Exemple #10
0
 def __init__(self, pod_path, _pod, locale=None, _collection=None):
     self._locale_kwarg = locale
     utils.validate_name(pod_path)
     self.pod_path = pod_path
     self.root_pod_path = pod_path  # For multi-file localization.
     self.basename = Document._clean_basename(pod_path)
     self.base, self.ext = os.path.splitext(self.basename)
     self.pod = _pod
     self.collection = _collection
     self.locale = self._init_locale(locale, pod_path)
Exemple #11
0
 def __init__(self, pod_path, _pod, locale=None, _collection=None):
     self._locale_kwarg = locale
     utils.validate_name(pod_path)
     self.pod_path = pod_path
     self.root_pod_path = pod_path  # For multi-file localization.
     self.basename = Document._clean_basename(pod_path)
     self.base, self.ext = os.path.splitext(self.basename)
     self.pod = _pod
     self.collection = _collection
     self._locale = utils.SENTINEL
Exemple #12
0
 def __init__(self, pod_path, _pod):
     utils.validate_name(pod_path)
     regex = Collection._content_path_regex
     self.pod = _pod
     self.collection_path = regex.sub('', pod_path).strip('/')
     self.pod_path = pod_path
     self.basename = os.path.basename(self.collection_path)
     self._default_locale = _pod.podspec.default_locale
     self._blueprint_path = os.path.join(
         self.pod_path, Collection.BLUEPRINT_PATH)
Exemple #13
0
 def __init__(self, pod_path, _pod, locale=None, _collection=None):
     self._locale_kwarg = locale
     utils.validate_name(pod_path)
     self.pod_path = pod_path
     # For multi-file localization and comparison.
     self.root_pod_path, _ = Document.parse_localized_path(pod_path)
     self.basename = Document._clean_basename(pod_path)
     self.base, self.ext = os.path.splitext(self.basename)
     self.pod = _pod
     self.collection = _collection
     self._locale = utils.SENTINEL
Exemple #14
0
 def __init__(self, pod_path, _pod, locale=None, _collection=None, body_format=None):
   utils.validate_name(pod_path)
   self.default_locale = _pod.podspec.default_locale
   self.locale = locale or _pod.podspec.default_locale
   if isinstance(self.locale, basestring):
     self.locale = locales.Locale(self.locale)
   if self.locale is not None:
     self.locale.set_alias(_pod)
   self.pod_path = pod_path
   self.basename = os.path.basename(pod_path)
   self.base, self.ext = os.path.splitext(self.basename)
   self.pod = _pod
   self.collection = _collection
Exemple #15
0
 def __init__(self,
              pod_path,
              _pod,
              locale=None,
              _collection=None,
              body_format=None):
     utils.validate_name(pod_path)
     self.default_locale = _pod.podspec.default_locale
     self.locale = locale or _pod.podspec.default_locale
     if isinstance(self.locale, basestring):
         self.locale = locales.Locale(self.locale)
     if self.locale is not None:
         self.locale.set_alias(_pod)
     self.pod_path = pod_path
     self.basename = os.path.basename(pod_path)
     self.base, self.ext = os.path.splitext(self.basename)
     self.pod = _pod
     self.collection = _collection
Exemple #16
0
 def __init__(self, pod_path, _pod):
   utils.validate_name(pod_path)
   self.pod = _pod
   self.collection_path = pod_path.lstrip('/content')
   self.pod_path = pod_path
   self._blueprint_path = os.path.join(self.pod_path, '_blueprint.yaml')
Exemple #17
0
 def __init__(self, pod_path, pod):
     utils.validate_name(pod_path)
     self.pod_path = pod_path
     self.pod = pod