Skip to main content

DocumentParser

ClassSource

DocumentParser()

Document Parser.

This parser converts the other document formats (like BBCode, Markdown or HTML) to structured pydantic data.

Arguments​

No argument is needed.

Methods​

parse_achievements​

v_1: Document = self.parse_achievements(
ach_list: AchievementList,
ach_parser: Callable[[str, Achievement], Node] | None = None,
)

Convert the list of achievements into a document.

Requires​

NameTypeRequired
Description
ach_listAchievementListThe achievement list fetched from the online pages. This data collection can be provided by steaminfo.get_achievement_list
ach_parserCallable[[str, Achievement], Node] | None

An optional achievement data parser. It converts the data of a single achievement to a document node. If not specified, will use the default parser.

The first argument is the icon name. The second argument is the achievement information.

Returns​

NameType
Description
v_1DocumentThe converted structured data of the achievement list.

parse_bbcode​

v_1: Document = self.parse_bbcode(bbcode: str | IO[str])

Parse the BBCode data.

Requires​

NameTypeRequired
Description
bbcodestr | IO[str]The BBCode text or BBCode file-like object.

Returns​

NameType
Description
v_1DocumentThe parsed structured data.

parse_file​

v_1: Document = self.parse_file(file_path: str | PathLike[str], encoding: str = "utf-8")

Parse a file.

Requires​

NameTypeRequired
Description
file_pathstr | PathLike[str]The path to the file to be read.
encodingstrThe encoding when opening the file.

Returns​

NameType
Description
v_1DocumentThe parsed structured data.

parse_html​

v_1: Document = self.parse_html(html: str | IO[str])

Parse the HTML data.

Requires​

NameTypeRequired
Description
htmlstr | IO[str]The HTML text or HTML file-like object.

Returns​

NameType
Description
v_1DocumentThe parsed structured data.

parse_markdown​

v_1: Document = self.parse_markdown(md: str | IO[str])

Parse the Markdown data.

Requires​

NameTypeRequired
Description
mdstr | IO[str]The Markdown text or Markdown file-like object.

Returns​

NameType
Description
v_1DocumentThe parsed structured data.