def inject(self, doc): path = doc.pod_path try: content = GoogleSheetsPreprocessor.download( path=path, sheet_id=self.config.id, gid=self.config.gid, raise_errors=True) except (errors.HttpError, base.PreprocessorError): doc.pod.logger.error('Error downloading sheet -> %s', path) raise if not content: return existing_data = doc.pod.read_yaml(doc.pod_path) fields = GoogleSheetsPreprocessor.format_content( content, path=path, format_as=self.config.format, preserve=self.config.preserve, existing_data=existing_data) fields = utils.untag_fields(fields) doc.inject(fields=fields)
def inject(self, doc): path, key_to_update = self._parse_path(self.config.path) try: content = GoogleSheetsPreprocessor.download( path=path, sheet_id=self.config.id, gid=self.config.gid, raise_errors=True) except (errors.HttpError, base.PreprocessorError): doc.pod.logger.error('Error downloading sheet -> %s', path) raise if not content: return existing_data = doc.pod.read_yaml(doc.pod_path) fields = GoogleSheetsPreprocessor.format_content( content, path=path, format_as=self.config.format, preserve=self.config.preserve, existing_data=existing_data, key_to_update=key_to_update) fields = self._normalize_formatted_content(fields) fields = utils.untag_fields(fields) doc.inject(fields=fields)
def read_yaml(self, path): fields = utils.parse_yaml(self.read_file(path), pod=self) return utils.untag_fields(fields)
def fields(self): catalog = self.pod.catalogs.get(self.locale) fields = utils.untag_fields(self.tagged_fields, catalog=catalog) if fields is None: return {} return fields
def fields(self): fields = utils.untag_fields(self.tagged_fields) return {} if not fields else fields
def fields(self): tagged_fields = self.get_tagged_fields() fields = utils.untag_fields(tagged_fields) if fields is None: return {} return fields
def yaml(path, _pod): fields = utils.parse_yaml(_pod.read_file(path), pod=_pod) return utils.untag_fields(fields)
def fields(self): tagged_fields = self.yaml fields = utils.untag_fields(tagged_fields) return {} if not fields else fields
def yaml(path, _doc, _pod): catalog = _pod.catalogs.get(_doc.locale) if _doc else None fields = utils.parse_yaml(_pod.read_file(path), pod=_pod) return utils.untag_fields(fields, catalog=catalog)
def fields(self): identifier = self.locale or self.collection.default_locale tagged_fields = self.get_tagged_fields() fields = utils.untag_fields(tagged_fields, locale=str(identifier)) return {} if not fields else fields
def fields(self): catalog = self.pod.catalogs.get(self.locale) return utils.untag_fields(copy.deepcopy(self.tagged_fields), catalog=catalog)