iconfilters
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
AsciiIcon jinjarope.iconfilters ASCII icons for different file types. |
||
AsciiIconMapping jinjarope.iconfilters |
๐ DocStrings¶
AsciiIcon
¶
Bases: StrEnum
ASCII icons for different file types.
Source code in src/jinjarope/iconfilters.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
get_favicon
¶
get_favicon(
url: str,
provider: Literal[
"google", "duckduckgo", "iconhorse", "yandex", "favicon_io", "favicon_ninja"
] = "duckduckgo",
size: int = 32,
)
Return a favicon URL for the given URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL to get the favicon for. |
required |
provider
|
Literal['google', 'duckduckgo', 'iconhorse', 'yandex', 'favicon_io', 'favicon_ninja']
|
The provider to use for the favicon. |
'duckduckgo'
|
size
|
int
|
Size of the favicon in pixels (not supported by all providers) |
32
|
Source code in src/jinjarope/iconfilters.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
|
get_icon_svg
¶
get_icon_svg(
icon: str,
color: str | None = None,
height: str | int | None = None,
width: str | int | None = None,
flip: Flip | None = None,
rotate: Rotation | None = None,
box: bool | None = None,
) -> str
Return svg for given pyconify icon key.
Key should look like "mdi:file" For compatibility, this method also supports compatibility for emoji-slugs (":material-file:") as well as material-paths ("material/file")
If no icon group is supplied as part of the string, mdi is assumed as group.
When passing a string with "|" delimiters, the returned string will contain multiple icons.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
icon
|
str
|
Pyconify icon name |
required |
color
|
str | None
|
Icon color. Replaces currentColor with specific color, resulting in icon with hardcoded palette. |
None
|
height
|
str | int | None
|
Icon height. If only one dimension is specified, such as height, other dimension will be automatically set to match it. |
None
|
width
|
str | int | None
|
Icon width. If only one dimension is specified, such as height, other dimension will be automatically set to match it. |
None
|
flip
|
Flip | None
|
Flip icon. |
None
|
rotate
|
Rotation | None
|
Rotate icon. If an integer is provided, it is assumed to be in degrees. |
None
|
box
|
bool | None
|
Adds an empty rectangle to SVG that matches the icon's viewBox. It is needed when importing SVG to various UI design tools that ignore viewBox. Those tools, such as Sketch, create layer groups that automatically resize to fit content. Icons usually have empty pixels around icon, so such software crops those empty pixels and icon's group ends up being smaller than actual icon, making it harder to align it in design. |
None
|
Example
get_icon_svg("file") # implicit mdi group
get_icon_svg("mdi:file") # pyconify key
get_icon_svg("material/file") # Material-style path
get_icon_svg(":material-file:") # material-style emoji slug
get_icon_svg("mdi:file|:material-file:") # returns a string with two svgs
Source code in src/jinjarope/iconfilters.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
|
get_path_ascii_icon
¶
Get an ASCII icon for a given file path based on its type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | PathLike[str]
|
File path as string or Path object |
required |
Returns:
Type | Description |
---|---|
str
|
ASCII icon representing the file type |
Source code in src/jinjarope/iconfilters.py
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
|
get_path_icon
¶
Get the icon mapping for a given file path or directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | PathLike[str]
|
Path to the file or directory |
required |
Returns:
Type | Description |
---|---|
str
|
iconify icon slug |
Source code in src/jinjarope/iconfilters.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
|
get_pyconify_key
¶
Convert given string to a pyconify key.
Converts the keys from MkDocs-Material ("material/sth" or ":material-sth:") to their pyconify equivalent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
icon
|
str
|
The string which should be converted to a pyconify key. |
required |
Source code in src/jinjarope/iconfilters.py
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
|