Example #1
0
def create_season(series_id, label, descr, ordinal, dry):
    dry_str = "[DRY-RUN] " if dry else ""
    repoutil = RepoUtils(Site().data_repository())
    print(
        f"{dry_str}Creating season with\n\tlabel='{label}'\n\tdescription='{descr}'"
    )
    if not dry:
        season = ItemPage(repoutil.repo)
        season.editLabels({"en": label}, summary="Setting label")
        season.editDescriptions({"en": descr}, summary="Setting description")
        print(f"Created a new Item: {season.getID()}")

    print(f"{dry_str}Setting {wp.INSTANCE_OF}={wp.TELEVISION_SERIES_SEASON}")
    if not dry:
        instance_claim = repoutil.new_claim(wp.INSTANCE_OF.pid)
        instance_claim.setTarget(
            ItemPage(repoutil.repo, wp.TELEVISION_SERIES_SEASON))
        season.addClaim(instance_claim,
                        summary=f"Setting {wp.INSTANCE_OF.pid}")

    print(
        f"{dry_str}Setting {wp.PART_OF_THE_SERIES}={series_id}, with {wp.SERIES_ORDINAL.pid}={ordinal}"
    )
    if not dry:
        series_claim = repoutil.new_claim(wp.PART_OF_THE_SERIES.pid)
        series_claim.setTarget(ItemPage(repoutil.repo, series_id))
        season_ordinal = repoutil.new_claim(wp.SERIES_ORDINAL.pid)
        season_ordinal.setTarget(str(ordinal))
        series_claim.addQualifier(season_ordinal)
        season.addClaim(series_claim,
                        summary=f"Setting {wp.PART_OF_THE_SERIES.pid}")
Example #2
0
 def new_item(self, labels, descriptions) -> ItemPage:
     item = ItemPage(self.repo)
     if labels:
         item.editLabels(labels, summary="Setting label")
     if descriptions:
         item.editDescriptions(descriptions, summary="Setting description")
     return item