Esempio n. 1
0
    def import_sheet(self, sheet_id, remove_tags=None):
        from sefaria.sheets import Sheet, refine_ref_by_text

        sheet = Sheet().load({"id": sheet_id})
        if not sheet:
            logger.warning("Failed to load sheet {}".format(sheet_id))

        def process_sources(sources, tags):
            for source in sources:
                if "ref" in source:
                    text = source.get("text", {}).get("he", None)
                    ref = refine_ref_by_text(source["ref"],
                                             text) if text else source["ref"]

                    self.add_stop({
                        "type": "inside_source",
                        "ref": ref,
                        "enText": source['text'].get("en"),
                        "heText": source['text'].get("he"),
                        "tags": tags
                    })
                elif "outsideBiText" in source:
                    self.add_stop({
                        "type": "outside_source",
                        "enText": source['outsideBiText'].get("en"),
                        "heText": source['outsideBiText'].get("he"),
                        "tags": tags
                    })
                elif "outsideText" in source:
                    self.add_stop({
                        "type": "outside_source",
                        "enText": source['outsideText'],
                        "tags": tags
                    })
                elif "comment" in sources:
                    self.add_stop({
                        "type": "blob",
                        "enText": source['comment'],
                        "tags": tags
                    })

                if "subsources" in source:
                    process_sources(source["subsources"], tags)

        tags = getattr(sheet, "tags", [])
        if remove_tags:
            tags = [t for t in tags if t not in remove_tags]
        process_sources(sheet.sources, {
            "default": tags,
            "Sheet Author": [user_name(sheet.owner)]
        })
        return self
Esempio n. 2
0
	def actors_string(self):
		"""
		Returns a nicely formatted string listing the people who acted in this notifcation set
		"""
		actors = [user_name(id) for id in self.actors_list()]
		top, more = actors[:3], actors[3:]
		if len(more) == 1:
			top[2] = ["2 others"]
		elif len(more) > 1:
			top.append("%d others" % len(more))
		if len(top) > 1:
			top[-1] = "and " + top[-1]
		return ", ".join(top).replace(", and ", " and ")
Esempio n. 3
0
 def actors_string(self):
     """
     Returns a nicely formatted string listing the people who acted in this notifcation set
     """
     actors = [user_name(id) for id in self.actors_list()]
     top, more = actors[:3], actors[3:]
     if len(more) == 1:
         top[2] = ["2 others"]
     elif len(more) > 1:
         top.append("%d others" % len(more))
     if len(top) > 1:
         top[-1] = "and " + top[-1]
     return ", ".join(top).replace(", and ", " and ")
Esempio n. 4
0
    def import_sheet(self, sheet_id, remove_tags=None):
        from sefaria.sheets import Sheet, refine_ref_by_text

        sheet = Sheet().load({"id": sheet_id})
        if not sheet:
            logger.warning("Failed to load sheet {}".format(sheet_id))

        def process_sources(sources, tags):
            for source in sources:
                if "ref" in source:
                    text = source.get("text", {}).get("he", None)
                    ref = refine_ref_by_text(source["ref"], text) if text else source["ref"]

                    self.add_stop({
                        "type": "inside_source",
                        "ref": ref,
                        "enText": source['text'].get("en"),
                        "heText": source['text'].get("he"),
                        "tags": tags
                    })
                elif "outsideBiText" in source:
                    self.add_stop({
                        "type": "outside_source",
                        "enText": source['outsideBiText'].get("en"),
                        "heText": source['outsideBiText'].get("he"),
                        "tags": tags
                    })
                elif "outsideText" in source:
                    self.add_stop({
                        "type": "outside_source",
                        "enText": source['outsideText'],
                        "tags": tags
                    })
                elif "comment" in sources:
                    self.add_stop({
                        "type": "blob",
                        "enText": source['comment'],
                        "tags": tags
                    })

                if "subsources" in source:
                    process_sources(source["subsources"], tags)

        tags = getattr(sheet, "tags", [])
        if remove_tags:
            tags = [t for t in tags if t not in remove_tags]
        process_sources(sheet.sources, {"default": tags, "Sheet Author": [user_name(sheet.owner)]})
        return self