variable definitions
This commit is contained in:
parent
5777aa57d9
commit
bb76112e3a
4 changed files with 133 additions and 339 deletions
|
|
@ -146,240 +146,171 @@ class VariableDefinitions:
|
||||||
@property
|
@property
|
||||||
def webpage_url(self) -> MetadataVariable:
|
def webpage_url(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The url to the webpage.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The url to the webpage.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(metadata_key="webpage_url", variable_name="webpage_url")
|
return MetadataVariable(metadata_key="webpage_url", variable_name="webpage_url")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def info_json_ext(self) -> Variable:
|
def info_json_ext(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The "info.json" extension
|
||||||
-------
|
|
||||||
str
|
|
||||||
The "info.json" extension
|
|
||||||
"""
|
"""
|
||||||
return Variable("info_json_ext")
|
return Variable("info_json_ext")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def description(self) -> MetadataVariable:
|
def description(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The description if it exists. Otherwise, returns an emtpy string.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The description if it exists. Otherwise, returns an emtpy string.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="description", metadata_key="description")
|
return MetadataVariable(variable_name="description", metadata_key="description")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def uploader_id(self) -> MetadataVariable:
|
def uploader_id(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The uploader id if it exists, otherwise return the unique ID.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The uploader id if it exists, otherwise return the unique ID.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="uploader_id", metadata_key="uploader_id")
|
return MetadataVariable(variable_name="uploader_id", metadata_key="uploader_id")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def uploader(self) -> MetadataVariable:
|
def uploader(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The uploader if it exists, otherwise return the uploader ID.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The uploader if it exists, otherwise return the uploader ID.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="uploader", metadata_key="uploader")
|
return MetadataVariable(variable_name="uploader", metadata_key="uploader")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def uploader_url(self) -> MetadataVariable:
|
def uploader_url(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The uploader url if it exists, otherwise returns the webpage_url.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The uploader url if it exists, otherwise returns the webpage_url.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("uploader_url", metadata_key="uploader_url")
|
return MetadataVariable("uploader_url", metadata_key="uploader_url")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_title(self) -> MetadataVariable:
|
def source_title(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Name of the source (i.e. channel with multiple playlists) if it exists, otherwise
|
||||||
-------
|
returns its playlist_title.
|
||||||
str
|
|
||||||
Name of the source (i.e. channel with multiple playlists) if it exists, otherwise
|
|
||||||
returns its playlist_title.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_title", metadata_key=self.title.metadata_key)
|
return MetadataVariable("source_title", metadata_key=self.title.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_uid(self) -> MetadataVariable:
|
def source_uid(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source unique id if it exists, otherwise returns the playlist unique ID.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The source unique id if it exists, otherwise returns the playlist unique ID.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_uid", metadata_key=self.uid.metadata_key)
|
return MetadataVariable("source_uid", metadata_key=self.uid.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_index(self) -> MetadataVariable:
|
def source_index(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Source index if it exists, otherwise returns ``1``.
|
||||||
-------
|
|
||||||
int
|
|
||||||
Source index if it exists, otherwise returns ``1``.
|
|
||||||
|
|
||||||
It is recommended to not use this unless you know the source will never add new content
|
It is recommended to not use this unless you know the source will never add new content
|
||||||
(it is easy for this value to change).
|
(it is easy for this value to change).
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_index", metadata_key=self.playlist_index.metadata_key)
|
return MetadataVariable("source_index", metadata_key=self.playlist_index.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_index_padded(self) -> Variable:
|
def source_index_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source index, padded.
|
||||||
-------
|
|
||||||
int
|
|
||||||
The source index, padded.
|
|
||||||
"""
|
"""
|
||||||
return Variable("source_index_padded")
|
return Variable("source_index_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_count(self) -> MetadataVariable:
|
def source_count(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source count if it exists, otherwise returns the playlist count.
|
||||||
-------
|
|
||||||
int
|
|
||||||
The source count if it exists, otherwise returns the playlist count.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_count", metadata_key=self.playlist_count.metadata_key)
|
return MetadataVariable("source_count", metadata_key=self.playlist_count.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_webpage_url(self) -> MetadataVariable:
|
def source_webpage_url(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source webpage url if it exists, otherwise returns the playlist webpage url.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The source webpage url if it exists, otherwise returns the playlist webpage url.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_webpage_url", metadata_key=self.webpage_url.metadata_key)
|
return MetadataVariable("source_webpage_url", metadata_key=self.webpage_url.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_description(self) -> MetadataVariable:
|
def source_description(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source description if it exists, otherwise returns the playlist description.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The source description if it exists, otherwise returns the playlist description.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_description", metadata_key=self.description.metadata_key)
|
return MetadataVariable("source_description", metadata_key=self.description.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_uid(self) -> MetadataVariable:
|
def playlist_uid(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The playlist unique ID if it exists, otherwise return the entry unique ID.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The playlist unique ID if it exists, otherwise return the entry unique ID.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="playlist_uid", metadata_key="playlist_id")
|
return MetadataVariable(variable_name="playlist_uid", metadata_key="playlist_id")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_title(self) -> MetadataVariable:
|
def playlist_title(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Name of its parent playlist/channel if it exists, otherwise returns its title.
|
||||||
-------
|
|
||||||
str
|
|
||||||
Name of its parent playlist/channel if it exists, otherwise returns its title.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="playlist_title", metadata_key="playlist_title")
|
return MetadataVariable(variable_name="playlist_title", metadata_key="playlist_title")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_index(self) -> MetadataVariable:
|
def playlist_index(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Playlist index if it exists, otherwise returns ``1``.
|
||||||
-------
|
|
||||||
int
|
|
||||||
Playlist index if it exists, otherwise returns ``1``.
|
|
||||||
|
|
||||||
Note that for channels/playlists, any change (i.e. adding or removing a video) will make
|
Note that for channels/playlists, any change (i.e. adding or removing a video) will make
|
||||||
this value change. Use with caution.
|
this value change. Use with caution.
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(metadata_key="playlist_index", variable_name="playlist_index")
|
return MetadataVariable(metadata_key="playlist_index", variable_name="playlist_index")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_index_reversed(self) -> Variable:
|
def playlist_index_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Playlist index reversed via ``playlist_count - playlist_index + 1``
|
||||||
-------
|
|
||||||
int
|
|
||||||
Playlist index reversed via ``playlist_count - playlist_index + 1``
|
|
||||||
"""
|
"""
|
||||||
return Variable("playlist_index_reversed")
|
return Variable("playlist_index_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_index_padded(self) -> Variable:
|
def playlist_index_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
playlist_index padded two digits
|
||||||
-------
|
|
||||||
str
|
|
||||||
playlist_index padded two digits
|
|
||||||
"""
|
"""
|
||||||
return Variable("playlist_index_padded")
|
return Variable("playlist_index_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_index_reversed_padded(self) -> Variable:
|
def playlist_index_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
playlist_index_reversed padded two digits
|
||||||
-------
|
|
||||||
str
|
|
||||||
playlist_index_reversed padded two digits
|
|
||||||
"""
|
"""
|
||||||
return Variable("playlist_index_reversed_padded")
|
return Variable("playlist_index_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_index_padded6(self) -> Variable:
|
def playlist_index_padded6(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
playlist_index padded six digits.
|
||||||
-------
|
|
||||||
str
|
|
||||||
playlist_index padded six digits.
|
|
||||||
"""
|
"""
|
||||||
return Variable("playlist_index_padded6")
|
return Variable("playlist_index_padded6")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_index_reversed_padded6(self) -> Variable:
|
def playlist_index_reversed_padded6(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
playlist_index_reversed padded six digits.
|
||||||
-------
|
|
||||||
str
|
|
||||||
playlist_index_reversed padded six digits.
|
|
||||||
"""
|
"""
|
||||||
return Variable("playlist_index_reversed_padded6")
|
return Variable("playlist_index_reversed_padded6")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_count(self) -> MetadataVariable:
|
def playlist_count(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Playlist count if it exists, otherwise returns ``1``.
|
||||||
-------
|
|
||||||
int
|
|
||||||
Playlist count if it exists, otherwise returns ``1``.
|
|
||||||
|
|
||||||
Note that for channels/playlists, any change (i.e. adding or removing a video) will make
|
Note that for channels/playlists, any change (i.e. adding or removing a video) will make
|
||||||
this value change. Use with caution.
|
this value change. Use with caution.
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="playlist_count", metadata_key="playlist_count")
|
return MetadataVariable(variable_name="playlist_count", metadata_key="playlist_count")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_description(self) -> MetadataVariable:
|
def playlist_description(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The playlist description if it exists, otherwise returns the entry's description.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The playlist description if it exists, otherwise returns the entry's description.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(
|
return MetadataVariable(
|
||||||
variable_name="playlist_description", metadata_key=self.description.metadata_key
|
variable_name="playlist_description", metadata_key=self.description.metadata_key
|
||||||
|
|
@ -388,10 +319,7 @@ class VariableDefinitions:
|
||||||
@property
|
@property
|
||||||
def playlist_webpage_url(self) -> MetadataVariable:
|
def playlist_webpage_url(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The playlist webpage url if it exists. Otherwise, returns the entry webpage url.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The playlist webpage url if it exists. Otherwise, returns the entry webpage url.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(
|
return MetadataVariable(
|
||||||
variable_name="playlist_webpage_url", metadata_key=self.webpage_url.metadata_key
|
variable_name="playlist_webpage_url", metadata_key=self.webpage_url.metadata_key
|
||||||
|
|
@ -400,21 +328,16 @@ class VariableDefinitions:
|
||||||
@property
|
@property
|
||||||
def playlist_max_upload_date(self) -> Variable:
|
def playlist_max_upload_date(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Max upload_date for all entries in this entry's playlist if it exists, otherwise returns
|
||||||
-------
|
``upload_date``
|
||||||
Max upload_date for all entries in this entry's playlist if it exists, otherwise returns
|
|
||||||
``upload_date``
|
|
||||||
"""
|
"""
|
||||||
return Variable("playlist_max_upload_date")
|
return Variable("playlist_max_upload_date")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_max_upload_year(self) -> Variable:
|
def playlist_max_upload_year(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
Max upload_year for all entries in this entry's playlist if it exists, otherwise returns
|
||||||
-------
|
``upload_year``
|
||||||
int
|
|
||||||
Max upload_year for all entries in this entry's playlist if it exists, otherwise returns
|
|
||||||
``upload_year``
|
|
||||||
"""
|
"""
|
||||||
# override in EntryParent
|
# override in EntryParent
|
||||||
return Variable("playlist_max_upload_year")
|
return Variable("playlist_max_upload_year")
|
||||||
|
|
@ -422,41 +345,29 @@ class VariableDefinitions:
|
||||||
@property
|
@property
|
||||||
def playlist_max_upload_year_truncated(self) -> Variable:
|
def playlist_max_upload_year_truncated(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The max playlist truncated upload year for all entries in this entry's playlist if it
|
||||||
-------
|
exists, otherwise returns ``upload_year_truncated``.
|
||||||
int
|
|
||||||
The max playlist truncated upload year for all entries in this entry's playlist if it
|
|
||||||
exists, otherwise returns ``upload_year_truncated``.
|
|
||||||
"""
|
"""
|
||||||
return Variable("playlist_max_upload_year_truncated")
|
return Variable("playlist_max_upload_year_truncated")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_uploader_id(self) -> MetadataVariable:
|
def playlist_uploader_id(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The playlist uploader id if it exists, otherwise returns the entry uploader ID.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The playlist uploader id if it exists, otherwise returns the entry uploader ID.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("playlist_uploader_id", metadata_key="playlist_uploader_id")
|
return MetadataVariable("playlist_uploader_id", metadata_key="playlist_uploader_id")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_uploader(self) -> MetadataVariable:
|
def playlist_uploader(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The playlist uploader if it exists, otherwise return the entry uploader.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The playlist uploader if it exists, otherwise return the entry uploader.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("playlist_uploader", metadata_key=self.uploader.metadata_key)
|
return MetadataVariable("playlist_uploader", metadata_key=self.uploader.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playlist_uploader_url(self) -> MetadataVariable:
|
def playlist_uploader_url(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The playlist uploader url if it exists, otherwise returns the playlist webpage_url.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The playlist uploader url if it exists, otherwise returns the playlist webpage_url.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(
|
return MetadataVariable(
|
||||||
"playlist_uploader_url", metadata_key=self.uploader_url.metadata_key
|
"playlist_uploader_url", metadata_key=self.uploader_url.metadata_key
|
||||||
|
|
@ -465,81 +376,57 @@ class VariableDefinitions:
|
||||||
@property
|
@property
|
||||||
def source_uploader_id(self) -> MetadataVariable:
|
def source_uploader_id(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source uploader id if it exists, otherwise returns the playlist_uploader_id
|
||||||
-------
|
|
||||||
str
|
|
||||||
The source uploader id if it exists, otherwise returns the playlist_uploader_id
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_uploader_id", metadata_key=self.uploader_id.metadata_key)
|
return MetadataVariable("source_uploader_id", metadata_key=self.uploader_id.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_uploader(self) -> MetadataVariable:
|
def source_uploader(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source uploader if it exists, otherwise return the playlist_uploader
|
||||||
-------
|
|
||||||
str
|
|
||||||
The source uploader if it exists, otherwise return the playlist_uploader
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_uploader", metadata_key=self.uploader.metadata_key)
|
return MetadataVariable("source_uploader", metadata_key=self.uploader.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_uploader_url(self) -> MetadataVariable:
|
def source_uploader_url(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The source uploader url if it exists, otherwise returns the source webpage_url.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The source uploader url if it exists, otherwise returns the source webpage_url.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable("source_uploader_url", metadata_key=self.uploader_url.metadata_key)
|
return MetadataVariable("source_uploader_url", metadata_key=self.uploader_url.metadata_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def creator(self) -> MetadataVariable:
|
def creator(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The creator name if it exists, otherwise returns the channel.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The creator name if it exists, otherwise returns the channel.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="creator", metadata_key="creator")
|
return MetadataVariable(variable_name="creator", metadata_key="creator")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def channel(self) -> MetadataVariable:
|
def channel(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The channel name if it exists, otherwise returns the uploader.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The channel name if it exists, otherwise returns the uploader.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="channel", metadata_key="channel")
|
return MetadataVariable(variable_name="channel", metadata_key="channel")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def channel_id(self) -> MetadataVariable:
|
def channel_id(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The channel id if it exists, otherwise returns the entry uploader ID.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The channel id if it exists, otherwise returns the entry uploader ID.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="channel_id", metadata_key="channel_id")
|
return MetadataVariable(variable_name="channel_id", metadata_key="channel_id")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ext(self) -> MetadataVariable:
|
def ext(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The downloaded entry's file extension
|
||||||
-------
|
|
||||||
str
|
|
||||||
The downloaded entry's file extension
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="ext", metadata_key="ext")
|
return MetadataVariable(variable_name="ext", metadata_key="ext")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def thumbnail_ext(self) -> Variable:
|
def thumbnail_ext(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The download entry's thumbnail extension. Will always return 'jpg'. Until there is a
|
||||||
-------
|
need to support other image types, we always convert to jpg.
|
||||||
str
|
|
||||||
The download entry's thumbnail extension. Will always return 'jpg'. Until there is a
|
|
||||||
need to support other image types, we always convert to jpg.
|
|
||||||
"""
|
"""
|
||||||
return Variable("thumbnail_ext")
|
return Variable("thumbnail_ext")
|
||||||
|
|
||||||
|
|
@ -581,408 +468,288 @@ class VariableDefinitions:
|
||||||
@property
|
@property
|
||||||
def download_index(self) -> Variable:
|
def download_index(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The i'th entry downloaded. NOTE that this is fetched dynamically from the download
|
||||||
-------
|
archive.
|
||||||
int
|
|
||||||
The i'th entry downloaded. NOTE that this is fetched dynamically from the download
|
|
||||||
archive.
|
|
||||||
"""
|
"""
|
||||||
return Variable(variable_name="download_index")
|
return Variable(variable_name="download_index")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def download_index_padded6(self) -> Variable:
|
def download_index_padded6(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The download_index padded six digits
|
||||||
-------
|
|
||||||
str
|
|
||||||
The download_index padded six digits
|
|
||||||
"""
|
"""
|
||||||
return Variable("download_index_padded6")
|
return Variable("download_index_padded6")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_date_index(self) -> Variable:
|
def upload_date_index(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The i'th entry downloaded with this upload date.
|
||||||
-------
|
|
||||||
int
|
|
||||||
The i'th entry downloaded with this upload date.
|
|
||||||
"""
|
"""
|
||||||
return Variable(variable_name="upload_date_index")
|
return Variable(variable_name="upload_date_index")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_date_index_padded(self) -> Variable:
|
def upload_date_index_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload_date_index padded two digits
|
||||||
-------
|
|
||||||
int
|
|
||||||
The upload_date_index padded two digits
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_date_index_padded")
|
return Variable("upload_date_index_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_date_index_reversed(self) -> Variable:
|
def upload_date_index_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
100 - upload_date_index
|
||||||
-------
|
|
||||||
int
|
|
||||||
100 - upload_date_index
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_date_index_reversed")
|
return Variable("upload_date_index_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_date_index_reversed_padded(self) -> Variable:
|
def upload_date_index_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload_date_index padded two digits
|
||||||
-------
|
|
||||||
int
|
|
||||||
The upload_date_index padded two digits
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_date_index_reversed_padded")
|
return Variable("upload_date_index_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_date(self) -> MetadataVariable:
|
def upload_date(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry’s uploaded date, in YYYYMMDD format. If not present, return today’s date.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry’s uploaded date, in YYYYMMDD format. If not present, return today’s date.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="upload_date", metadata_key="upload_date")
|
return MetadataVariable(variable_name="upload_date", metadata_key="upload_date")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_year(self) -> Variable:
|
def upload_year(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry's upload year
|
||||||
-------
|
|
||||||
int
|
|
||||||
The entry's upload year
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_year")
|
return Variable("upload_year")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_year_truncated(self) -> Variable:
|
def upload_year_truncated(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The last two digits of the upload year, i.e. 22 in 2022
|
||||||
-------
|
|
||||||
int
|
|
||||||
The last two digits of the upload year, i.e. 22 in 2022
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_year_truncated")
|
return Variable("upload_year_truncated")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_year_truncated_reversed(self) -> Variable:
|
def upload_year_truncated_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload year truncated, but reversed using ``100 - {upload_year_truncated}``, i.e.
|
||||||
-------
|
2022 returns ``100 - 22`` = ``78``
|
||||||
int
|
|
||||||
The upload year truncated, but reversed using ``100 - {upload_year_truncated}``, i.e.
|
|
||||||
2022 returns ``100 - 22`` = ``78``
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_year_truncated_reversed")
|
return Variable("upload_year_truncated_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_month_reversed(self) -> Variable:
|
def upload_month_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload month, but reversed using ``13 - {upload_month}``, i.e. March returns ``10``
|
||||||
-------
|
|
||||||
int
|
|
||||||
The upload month, but reversed using ``13 - {upload_month}``, i.e. March returns ``10``
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_month_reversed")
|
return Variable("upload_month_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_month_reversed_padded(self) -> Variable:
|
def upload_month_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The reversed upload month, but padded. i.e. November returns "02"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The reversed upload month, but padded. i.e. November returns "02"
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_month_reversed_padded")
|
return Variable("upload_month_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_month_padded(self) -> Variable:
|
def upload_month_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry's upload month padded to two digits, i.e. March returns "03"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry's upload month padded to two digits, i.e. March returns "03"
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_month_padded")
|
return Variable("upload_month_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day_padded(self) -> Variable:
|
def upload_day_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry's upload day padded to two digits, i.e. the fifth returns "05"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry's upload day padded to two digits, i.e. the fifth returns "05"
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day_padded")
|
return Variable("upload_day_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_month(self) -> Variable:
|
def upload_month(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload month as an integer (no padding).
|
||||||
-------
|
|
||||||
int
|
|
||||||
The upload month as an integer (no padding).
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_month")
|
return Variable("upload_month")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day(self) -> Variable:
|
def upload_day(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload day as an integer (no padding).
|
||||||
-------
|
|
||||||
int
|
|
||||||
The upload day as an integer (no padding).
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day")
|
return Variable("upload_day")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day_reversed(self) -> Variable:
|
def upload_day_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload day, but reversed using ``{total_days_in_month} + 1 - {upload_day}``,
|
||||||
-------
|
i.e. August 8th would have upload_day_reversed of ``31 + 1 - 8`` = ``24``
|
||||||
int
|
|
||||||
The upload day, but reversed using ``{total_days_in_month} + 1 - {upload_day}``,
|
|
||||||
i.e. August 8th would have upload_day_reversed of ``31 + 1 - 8`` = ``24``
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day_reversed")
|
return Variable("upload_day_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day_reversed_padded(self) -> Variable:
|
def upload_day_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The reversed upload day, but padded. i.e. August 30th returns "02".
|
||||||
-------
|
|
||||||
str
|
|
||||||
The reversed upload day, but padded. i.e. August 30th returns "02".
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day_reversed_padded")
|
return Variable("upload_day_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day_of_year(self) -> Variable:
|
def upload_day_of_year(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The day of the year, i.e. February 1st returns ``32``
|
||||||
-------
|
|
||||||
int
|
|
||||||
The day of the year, i.e. February 1st returns ``32``
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day_of_year")
|
return Variable("upload_day_of_year")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day_of_year_padded(self) -> Variable:
|
def upload_day_of_year_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload day of year, but padded i.e. February 1st returns "032"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The upload day of year, but padded i.e. February 1st returns "032"
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day_of_year_padded")
|
return Variable("upload_day_of_year_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day_of_year_reversed(self) -> Variable:
|
def upload_day_of_year_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The upload day, but reversed using ``{total_days_in_year} + 1 - {upload_day}``,
|
||||||
-------
|
i.e. February 2nd would have upload_day_of_year_reversed of ``365 + 1 - 32`` = ``334``
|
||||||
int
|
|
||||||
The upload day, but reversed using ``{total_days_in_year} + 1 - {upload_day}``,
|
|
||||||
i.e. February 2nd would have upload_day_of_year_reversed of ``365 + 1 - 32`` = ``334``
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day_of_year_reversed")
|
return Variable("upload_day_of_year_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_day_of_year_reversed_padded(self) -> Variable:
|
def upload_day_of_year_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The reversed upload day of year, but padded i.e. December 31st returns "001"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The reversed upload day of year, but padded i.e. December 31st returns "001"
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_day_of_year_reversed_padded")
|
return Variable("upload_day_of_year_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def upload_date_standardized(self) -> Variable:
|
def upload_date_standardized(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The uploaded date formatted as YYYY-MM-DD
|
||||||
-------
|
|
||||||
str
|
|
||||||
The uploaded date formatted as YYYY-MM-DD
|
|
||||||
"""
|
"""
|
||||||
return Variable("upload_date_standardized")
|
return Variable("upload_date_standardized")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_date(self) -> MetadataVariable:
|
def release_date(self) -> MetadataVariable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry’s release date, in YYYYMMDD format. If not present, return the upload date.
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry’s release date, in YYYYMMDD format. If not present, return the upload date.
|
|
||||||
"""
|
"""
|
||||||
return MetadataVariable(variable_name="release_date", metadata_key="release_date")
|
return MetadataVariable(variable_name="release_date", metadata_key="release_date")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_year(self) -> Variable:
|
def release_year(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry's release year
|
||||||
-------
|
|
||||||
int
|
|
||||||
The entry's release year
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_year")
|
return Variable("release_year")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_year_truncated(self) -> Variable:
|
def release_year_truncated(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The last two digits of the release year, i.e. 22 in 2022
|
||||||
-------
|
|
||||||
int
|
|
||||||
The last two digits of the release year, i.e. 22 in 2022
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_year_truncated")
|
return Variable("release_year_truncated")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_year_truncated_reversed(self) -> Variable:
|
def release_year_truncated_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release year truncated, but reversed using ``100 - {release_year_truncated}``, i.e.
|
||||||
-------
|
2022 returns ``100 - 22`` = ``78``
|
||||||
int
|
|
||||||
The release year truncated, but reversed using ``100 - {release_year_truncated}``, i.e.
|
|
||||||
2022 returns ``100 - 22`` = ``78``
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_year_truncated_reversed")
|
return Variable("release_year_truncated_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_month_reversed(self) -> Variable:
|
def release_month_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release month, but reversed
|
||||||
-------
|
using ``13 - {release_month}``, i.e. March returns ``10``
|
||||||
int
|
|
||||||
The release month, but reversed
|
|
||||||
using ``13 - {release_month}``, i.e. March returns ``10``
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_month_reversed")
|
return Variable("release_month_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_month_reversed_padded(self) -> Variable:
|
def release_month_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The reversed release month, but padded. i.e. November returns "02"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The reversed release month, but padded. i.e. November returns "02"
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_month_reversed_padded")
|
return Variable("release_month_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_month_padded(self) -> Variable:
|
def release_month_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry's release month padded to two digits, i.e. March returns "03"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry's release month padded to two digits, i.e. March returns "03"
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_month_padded")
|
return Variable("release_month_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day_padded(self) -> Variable:
|
def release_day_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The entry's release day padded to two digits, i.e. the fifth returns "05"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The entry's release day padded to two digits, i.e. the fifth returns "05"
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day_padded")
|
return Variable("release_day_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_month(self) -> Variable:
|
def release_month(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release month as an integer (no padding).
|
||||||
-------
|
|
||||||
int
|
|
||||||
The release month as an integer (no padding).
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_month")
|
return Variable("release_month")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day(self) -> Variable:
|
def release_day(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release day as an integer (no padding).
|
||||||
-------
|
|
||||||
int
|
|
||||||
The release day as an integer (no padding).
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day")
|
return Variable("release_day")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day_reversed(self) -> Variable:
|
def release_day_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release day, but reversed using ``{total_days_in_month} + 1 - {release_day}``,
|
||||||
-------
|
i.e. August 8th would have release_day_reversed of ``31 + 1 - 8`` = ``24``
|
||||||
int
|
|
||||||
The release day, but reversed using ``{total_days_in_month} + 1 - {release_day}``,
|
|
||||||
i.e. August 8th would have release_day_reversed of ``31 + 1 - 8`` = ``24``
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day_reversed")
|
return Variable("release_day_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day_reversed_padded(self) -> Variable:
|
def release_day_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The reversed release day, but padded. i.e. August 30th returns "02".
|
||||||
-------
|
|
||||||
str
|
|
||||||
The reversed release day, but padded. i.e. August 30th returns "02".
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day_reversed_padded")
|
return Variable("release_day_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day_of_year(self) -> Variable:
|
def release_day_of_year(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The day of the year, i.e. February 1st returns ``32``
|
||||||
-------
|
|
||||||
int
|
|
||||||
The day of the year, i.e. February 1st returns ``32``
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day_of_year")
|
return Variable("release_day_of_year")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day_of_year_padded(self) -> Variable:
|
def release_day_of_year_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release day of year, but padded i.e. February 1st returns "032"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The release day of year, but padded i.e. February 1st returns "032"
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day_of_year_padded")
|
return Variable("release_day_of_year_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day_of_year_reversed(self) -> Variable:
|
def release_day_of_year_reversed(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release day, but reversed using ``{total_days_in_year} + 1 - {release_day}``,
|
||||||
-------
|
i.e. February 2nd would have release_day_of_year_reversed of ``365 + 1 - 32`` = ``334``
|
||||||
int
|
|
||||||
The release day, but reversed using ``{total_days_in_year} + 1 - {release_day}``,
|
|
||||||
i.e. February 2nd would have release_day_of_year_reversed of ``365 + 1 - 32`` = ``334``
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day_of_year_reversed")
|
return Variable("release_day_of_year_reversed")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_day_of_year_reversed_padded(self) -> Variable:
|
def release_day_of_year_reversed_padded(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The reversed release day of year, but padded i.e. December 31st returns "001"
|
||||||
-------
|
|
||||||
str
|
|
||||||
The reversed release day of year, but padded i.e. December 31st returns "001"
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_day_of_year_reversed_padded")
|
return Variable("release_day_of_year_reversed_padded")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def release_date_standardized(self) -> Variable:
|
def release_date_standardized(self) -> Variable:
|
||||||
"""
|
"""
|
||||||
Returns
|
The release date formatted as YYYY-MM-DD
|
||||||
-------
|
|
||||||
str
|
|
||||||
The release date formatted as YYYY-MM-DD
|
|
||||||
"""
|
"""
|
||||||
return Variable("release_date_standardized")
|
return Variable("release_date_standardized")
|
||||||
|
|
||||||
|
|
|
||||||
16
tools/docgen/entry_variables.py
Normal file
16
tools/docgen/entry_variables.py
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
from tools.docgen.utils import get_property_docs
|
||||||
|
from tools.docgen.utils import properties
|
||||||
|
from tools.docgen.utils import section
|
||||||
|
from ytdl_sub.entries.script.variable_definitions import VariableDefinitions
|
||||||
|
|
||||||
|
|
||||||
|
def generate_variable_docs() -> str:
|
||||||
|
docs = section("Entry Variables", level=0)
|
||||||
|
|
||||||
|
for variable_name in properties(VariableDefinitions):
|
||||||
|
docs += get_property_docs(property_name=variable_name, obj=VariableDefinitions, level=1)
|
||||||
|
|
||||||
|
return docs
|
||||||
|
|
||||||
|
|
||||||
|
print(generate_variable_docs())
|
||||||
|
|
@ -2,6 +2,8 @@ import inspect
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
|
from tools.docgen.utils import get_property_docs
|
||||||
|
from tools.docgen.utils import properties
|
||||||
from tools.docgen.utils import section
|
from tools.docgen.utils import section
|
||||||
from ytdl_sub.config.overrides import Overrides
|
from ytdl_sub.config.overrides import Overrides
|
||||||
from ytdl_sub.config.plugin.plugin_mapping import PluginMapping
|
from ytdl_sub.config.plugin.plugin_mapping import PluginMapping
|
||||||
|
|
@ -21,22 +23,16 @@ def should_filter_property(property_name: str) -> bool:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def generate_plugin_docs(name: str, options: Type[OptionsValidator], offset: int):
|
def generate_plugin_docs(name: str, options: Type[OptionsValidator], offset: int) -> str:
|
||||||
docs = ""
|
docs = ""
|
||||||
docs += section(name, level=offset + 0)
|
docs += section(name, level=offset + 0)
|
||||||
|
|
||||||
docs += inspect.cleandoc(options.__doc__)
|
docs += inspect.cleandoc(options.__doc__)
|
||||||
docs += "\n"
|
docs += "\n"
|
||||||
|
|
||||||
property_names = [
|
property_names = [prop for prop in properties(options) if not should_filter_property(prop)]
|
||||||
prop
|
|
||||||
for prop in dir(options)
|
|
||||||
if isinstance(getattr(options, prop), property) and not should_filter_property(prop)
|
|
||||||
]
|
|
||||||
for property_name in sorted(property_names):
|
for property_name in sorted(property_names):
|
||||||
docs += section(property_name, level=offset + 1)
|
docs += get_property_docs(property_name=property_name, obj=options, level=offset + 1)
|
||||||
docs += inspect.cleandoc(getattr(options, property_name).__doc__)
|
|
||||||
docs += "\n"
|
|
||||||
|
|
||||||
return docs
|
return docs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,22 @@
|
||||||
|
import inspect
|
||||||
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
from typing import List
|
||||||
|
from typing import Type
|
||||||
|
|
||||||
LEVEL_CHARS: Dict[int, str] = {0: "=", 1: "-", 2: "~", 3: "^"}
|
LEVEL_CHARS: Dict[int, str] = {0: "=", 1: "-", 2: "~", 3: "^"}
|
||||||
|
|
||||||
|
|
||||||
def section(name: str, level: int) -> str:
|
def section(name: str, level: int) -> str:
|
||||||
return f"\n{name}\n{len(name) * LEVEL_CHARS[level]}\n"
|
return f"\n{name}\n{len(name) * LEVEL_CHARS[level]}\n"
|
||||||
|
|
||||||
|
|
||||||
|
def properties(obj: Type[Any]) -> List[str]:
|
||||||
|
return [prop for prop in dir(obj) if isinstance(getattr(obj, prop), property)]
|
||||||
|
|
||||||
|
|
||||||
|
def get_property_docs(property_name: str, obj: Any, level: int) -> str:
|
||||||
|
docs = section(property_name, level=level)
|
||||||
|
docs += inspect.cleandoc(getattr(obj, property_name).__doc__)
|
||||||
|
docs += "\n"
|
||||||
|
return docs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue