hoshi

Hoshi ☄️ (:mod:`qurry.capsule.hoshi)

hoshi

Hoshi - A process content printer ?

  • Before:

>>> print(" ### Qiskit version outdated warning")
>>> print("Please keep mind on your qiskit version,
an very outdated version may cause some problems.")
>>> print(" - Local Qiskit version ".ljust(40, '-')+f" {__qiskit_version__['qiskit']}")
>>> print(" - Latest Qiskit version ".ljust(40, '-')+f" {latest_version}")
```
### Qiskit version outdated warning
Please keep mind on your qiskit version, an very outdated version may cause some problems.
- Local Qiskit version ---------------- 0.39.0
- Latest Qiskit version --------------- 0.39.0
```
  • After:

>>> check_msg = Hoshi(
        [
            ("divider", 60),
            ("h3", "Qiskit version outdated warning"),
            (
                "txt",
                "Please keep mind on your qiskit version,"
                + " an very outdated version may cause some problems.",
            ),
            ("itemize", "Local Qiskit version", 3),
            {
                "type": "itemize",
                "description": "Latest Qiskit version",
                "value": 3,
            },
        ],
        ljust_description_len=40,
    )
>>> print(check_msg)

```

  • Local Qiskit version ——————- 0.39.0

  • Latest Qiskit version —————— 0.39.0

```

Hoshi - A process content printer ?

## Why this name?

I made it when I was listening the songs made by Hoshimachi Suisei, a VTuber in Hololive. I was inspired by her songs, and I made this tool. I named it Hoshi, which means star in Japanese. I hope this tool can help you to make your code more beautiful.

(Hint: The last sentence is auto-complete by Github Copilot from ‘Hoshimachi’ to the end. That’s meaning that Github Copilot knows VTuber, Hololive, even Suisei, who trains it with such content and how. “Does Skynet subscribe to Virtual Youtuber?”)

class qurry.capsule.hoshi.hoshi.Hoshi(raw: list[tuple[Any, ...] | dict[str, Any]] | None = None, name: str = 'Hoshi', **kwargs)[source]

Hoshi - A process content printer ?

class ConfigContainer(listing_level: int = 1, listing_itemize: str = '-', ljust_description_len: int = 0, ljust_description_filler: str = '-', ljust_value_len: int = 40, ljust_value_filler: str = '.', ljust_value_max_len: int = 40, max_value_len: int = 2000, hint_itemize: str = '#', divider_length: int = 60)[source]

Config container for Hoshi.

property divider_fields: tuple[str, ...]

Return a list of divider fields.

divider_length: int

Alias for field number 9

hint_itemize: str

Alias for field number 8

property itemize_fields: tuple[str, ...]

Return a list of itemize fields.

listing_itemize: str

Alias for field number 1

listing_level: int

Alias for field number 0

ljust_description_filler: str

Alias for field number 3

ljust_description_len: int

Alias for field number 2

ljust_value_filler: str

Alias for field number 5

ljust_value_len: int

Alias for field number 4

ljust_value_max_len: int

Alias for field number 6

max_value_len: int

Alias for field number 7

divider(length: int = 60)[source]

Add a divider.

Parameters:

length (int, optional) – Length of the divider. Defaults to 60.

h1(text: str)[source]

Add a h1 title.

h2(text: str)[source]

Add a h2 title.

h3(text: str)[source]

Add a h3 title.

h4(text: str)[source]

Add a h4 title.

h5(text: str)[source]

Add a h5 title.

h6(text: str)[source]

Add a h6 title.

itemize(description: str, value: str | None = None, hint: str | None = None, listing_level: int = 1)[source]

Add a listing item.

Parameters:
  • description (str) – Description of the item.

  • value (str, optional) – Value of the item. Defaults to None.

  • hint (str, optional) – Hint of the item. Defaults to None.

  • listing_level (int, optional) – Listing level. Defaults to 1.

property lines: list[str]

Return the print lines.

newline(item: dict[str, Any] | tuple[Any, ...])[source]

Add a new line.

Parameters:

item (Union[dict[str, Any], tuple[str]]) – Item to add.

print()[source]

Print the content.

txt(text: str, listing_level: int = 1)[source]

Add a text.

Parameters:
  • text (str) – Text to print.

  • listing_level (int, optional) – Listing level. Defaults to 1.

qurry.capsule.hoshi.hoshi.divider(length: int = 60, raw_input=False) str | dict[str, Any][source]

Print a divider.

Parameters:
  • length (int, optional) – Length of the divider. Defaults to 60.

  • raw_input (bool, optional) – If True, return a dict. Defaults to False.

Returns:

Content to print.

Return type:

Union[str, dict[str, Any]]

qurry.capsule.hoshi.hoshi.hnprint(title, heading=3, raw_input=False) str | dict[str, Any][source]

Print a title.

Parameters:
  • title (str) – tilte of the section.

  • heading (int, optional) – Heading level. Defaults to 3.

  • raw_input (bool, optional) – If True, return a dict. Defaults to False.

Returns:

Content to print.

Return type:

Union[str, dict[str, Any]]

qurry.capsule.hoshi.hoshi.itemize(description: str, *, export_len: Literal[True]) tuple[str, int, int][source]
qurry.capsule.hoshi.hoshi.itemize(description: str, *, independent_newline: Literal[True]) tuple[str, str] | str
qurry.capsule.hoshi.hoshi.itemize(description: str, *, export_len: bool, independent_newline: bool) str

Print a listing item.

qurry.capsule.hoshi.hoshi.txt(text: str, listing_level: int = 1, raw_input=False) str | dict[str, Any][source]

Print a text.

Parameters:
  • text (str) – Text to print.

  • listing_level (int, optional) – Listing level. Defaults to 1.

  • raw_input (bool, optional) – If True, return a dict. Defaults to False.

Returns:

Content to print.

Return type:

Union[str, dict[str, Any]]

repr_modify

Representation modification for Hoshi CapSule (qurry.capsule.hoshi.repr_modify)

I write this class just for having better representation for the functions internet_is_fxxking_awesome(). :3

qurry.capsule.hoshi.repr_modify.easy_repr_modify_wrapper(repr_content: str | Callable[[...], str] | None) Callable[[...], Any][source]

Wrapper for easy representation modification.

Parameters:

repr_content (Optional[Union[str, Callable[..., str]]]) – The content of the representation. If it is a string, it will be the representation. If it is a function, it will be the representation function.

Returns:

The wrapper function for the representation modification.

Return type:

Callable[…, Any]