Skip to content

Commit

Permalink
Add publisher_id, and series_id properties
Browse files Browse the repository at this point in the history
Fill in more docs
  • Loading branch information
Buried-In-Code committed Dec 23, 2024
1 parent 0aab3c3 commit 45bb566
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 66 deletions.
76 changes: 41 additions & 35 deletions grayven/schemas/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ class Story(BaseModel):
"""Contains fields relating to the stories inside an Issue.
Attributes:
characters:
colors:
editing:
characters: The characters in the story.
colors: The color credits for the story.
editing: The editing credits for the story.
feature:
genre:
inks:
genre: The genre of the story.
inks: The ink credits for the story.
job_number:
letters:
notes:
page_count:
pencils:
script:
sequence_number:
synopsis:
title:
type:
letters: The letter credits for the story.
notes: Additional notes about the story.
page_count: The page count of the story.
pencils: The pencil credits for the story.
script: The script credits for the story.
sequence_number: The order of the story in the larger issue.
synopsis: The synopsis of the story.
title: The title of the story.
type: The type of the story.
"""

characters: Annotated[Optional[str], BeforeValidator(blank_is_none)]
Expand All @@ -77,14 +77,14 @@ class BasicIssue(BaseModel):
"""Contains fields for all Issues.
Attributes:
api_url:
descriptor:
page_count:
price:
publication_date:
series:
series_name:
variant_of:
api_url: Url to the resource in the GCD API.
descriptor: The descriptor of the issue.
page_count: The page count of the issue.
price: The price of the issue.
publication_date: The publication date of the issue.
series: Url to the Series of this resource in the GCD API.
series_name: The name of the series.
variant_of: The URL of the original issue if this issue is a variant.
"""

api_url: HttpUrl
Expand All @@ -98,28 +98,34 @@ class BasicIssue(BaseModel):

@property
def id(self) -> int:
"""The Issue id, extracted from the `api_url`."""
match = re.search(r"/issue/(\d+)/", str(self.api_url))
if match:
"""The Issue id, extracted from the `api_url` field."""
if match := re.search(r"/issue/(\d+)/", str(self.api_url)):
return int(match.group(1))
raise ValueError("Unable to get id from url: '%s'", self.api_url)

@property
def series_id(self) -> int:
"""The Series id, extracted from the `series` field."""
if match := re.search(r"/series/(\d+)/", str(self.series)):
return int(match.group(1))
raise ValueError("Unable to get id from url: '%s'", self.series)


class Issue(BasicIssue):
"""Extends BasicIssue to include more details.
Attributes:
barcode:
barcode: The barcode of the issue.
brand:
cover:
editing:
indicia_frequency:
indicia_publisher:
isbn:
notes:
on_sale_date:
rating:
story_set:
cover: The URL of the issue's cover image.
editing: The editing credits for the issue.
indicia_frequency: According to the indicia what is the frequency release of the issue.
indicia_publisher: According to the indicia what is the publisher of the issue.
isbn: The ISBN of the issue.
notes: Additional notes about the issue.
on_sale_date: The on-sale date of the issue.
rating: The rating of the issue.
story_set: A list of stories in the issue.
"""

barcode: str
Expand Down
29 changes: 14 additions & 15 deletions grayven/schemas/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ class Publisher(BaseModel):
"""Contains fields for all Publishers.
Attributes:
api_url:
brand_count:
country:
indicia_publisher_count:
issue_count:
modified:
name:
notes:
series_count:
url:
year_began:
api_url: Url to the resource in the GCD API.
brand_count: The number of brands associated with the publisher.
country: The country where the publisher is based.
indicia_publisher_count: The number of indicia publishers associated with the publisher.
issue_count: The total number of issues published.
modified: The date and time when the publisher's information was last modified.
name: The name of the publisher.
notes: Additional notes about the publisher.
series_count: The number of series published by the publisher.
url: Url to the resource in the GCD.
year_began: The year the publisher began.
year_began_uncertain:
year_ended:
year_ended: The year the publisher ended.
year_ended_uncertain:
year_overall_began:
year_overall_began_uncertain:
Expand Down Expand Up @@ -61,8 +61,7 @@ class Publisher(BaseModel):

@property
def id(self) -> int:
"""The Publisher id, extracted from the `api_url`."""
match = re.search(r"/publisher/(\d+)/", str(self.api_url))
if match:
"""The Publisher id, extracted from the `api_url` field."""
if match := re.search(r"/publisher/(\d+)/", str(self.api_url)):
return int(match.group(1))
raise ValueError("Unable to get id from url: '%s'", self.api_url)
38 changes: 22 additions & 16 deletions grayven/schemas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ class Series(BaseModel):
"""Contains fields for all Series.
Attributes:
active_issues:
api_url:
binding:
color:
country:
dimensions:
active_issues: A list of URLs for active issues in the series.
api_url: Url to the resource in the GCD API.
binding: The binding type of the series.
color: The color information of the series.
country: The country where the series is published.
dimensions: The dimensions of the series.
issue_descriptors:
language:
name:
notes:
language: The language of the series.
name: The name of the series.
notes: Additional notes about the series.
paper_stock:
publisher:
publishing_format:
year_began:
year_ended:
publisher: Url to the Publisher of this resource in the GCD API.
publishing_format: The publishing format of the series.
year_began: The year the series began.
year_ended: The year the series ended.
"""

active_issues: list[HttpUrl]
Expand All @@ -54,8 +54,14 @@ class Series(BaseModel):

@property
def id(self) -> int:
"""The Series id, extracted from the `api_url`."""
match = re.search(r"/series/(\d+)/", str(self.api_url))
if match:
"""The Series id, extracted from the `api_url` field."""
if match := re.search(r"/series/(\d+)/", str(self.api_url)):
return int(match.group(1))
raise ValueError("Unable to get id from url: '%s'", self.api_url)

@property
def publisher_id(self) -> int:
"""The Publisher id, extracted from the `publisher` field."""
if match := re.search(r"/publisher/(\d+)/", str(self.api_url)):
return int(match.group(1))
raise ValueError("Unable to get id from url: '%s'", self.api_url)

0 comments on commit 45bb566

Please sign in to comment.