Skip to content

Instantly share code, notes, and snippets.

@vict0rsch
Last active April 12, 2019 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vict0rsch/223858dd409865e0816f8824b003cce8 to your computer and use it in GitHub Desktop.
Save vict0rsch/223858dd409865e0816f8824b003cce8 to your computer and use it in GitHub Desktop.
Produce shields from settings.yml to include as images into Readme.md
from pathlib import Path
if __name__ == "__main__":
labels_path = Path() / "labels.yml"
if labels_path.exists():
with labels_path.open() as f:
lines = f.readlines()
shields = []
names = []
i = 1
while i < len(lines):
l = lines[i]
if " - name" in l:
name = l.split("name:")[-1].strip().replace('"', "")
color = lines[i + 1].split("color:")[-1].strip()
shields.append(
f"https://img.shields.io/badge/{name}-{color}.svg".replace(
" ", "%20"
)
)
names.append(name)
i += 2
else:
i += 1
shields_lines = sorted(list(f"[{n}]: {s}" for n, s in zip(names, shields)))
with open(Path() / "shields.txt", "w") as f:
f.write("\n".join(shields_lines))
@vict0rsch
Copy link
Author

Following up on https://gist.github.com/Vict0rSch/188a60f1e87a68844e41082583df64c4

From:

labels:
  - name: "CLA Signed"
    color: 009900
    description: ""

  - name: "contributions: claimed"
    color: d93f0b
    description: ""

  - name: "contributions: up for grabs!"
    color: 128A0C
    description: ""

  - name: "difficulty: complex"
    color: f9d0c4
    description: ""

  - name: "difficulty: impossible"
    color: e99695
    description: ""

  - name: "difficulty: medium"
    color: fef2c0
    description: ""

  - name: "difficulty: starter"
    color: c5def5
    description: ""

  - name: "good first issue"
    color: 128A0C
    description: ""

  - name: "hacktoberfest"
    color: ff625f
    description: ""

  - name: "issue: announcement"
    color: 5319e7
    description: ""

  - name: "issue: bug"
    color: ee0701
    description: ""

  - name: "issue: install problem"
    color: e5aa4b
    description: ""

  - name: "issue: needs investigation"
    color: d106e8
    description: ""

  - name: "issue: proposal"
    color: fbca04
    description: ""

  - name: "issue: question > PWA"
    color: c5def5
    description: ""

  - name: "issue: question"
    color: 006b75
    description: ""

  - name: "issue: typescript"
    color: 007acc
    description: ""

  - name: "priority: low (ignored issue template)"
    color: d4c5f9
    description: ""

  - name: "priority: low (needs more information)"
    color: d4c5f9
    description: ""

  - name: "stale"
    color: f4d37f
    description: ""

  - name: "tag: breaking change"
    color: e11d21
    description: ""

  - name: "tag: bug fix"
    color: fbca04
    description: ""

  - name: "tag: documentation"
    color: 006b75
    description: ""

  - name: "tag: enhancement"
    color: 1d76db
    description: ""

  - name: "tag: internal"
    color: bfdadc
    description: ""

  - name: "tag: new feature"
    color: 0e8a16
    description: ""

  - name: "tag: underlying tools"
    color: d93f0b
    description: ""

produces:

[CLA Signed]: https://img.shields.io/badge/CLA%20Signed-009900.svg
[contributions: claimed]: https://img.shields.io/badge/contributions:%20claimed-d93f0b.svg
[contributions: up for grabs!]: https://img.shields.io/badge/contributions:%20up%20for%20grabs!-128A0C.svg
[difficulty: complex]: https://img.shields.io/badge/difficulty:%20complex-f9d0c4.svg
[difficulty: impossible]: https://img.shields.io/badge/difficulty:%20impossible-e99695.svg
[difficulty: medium]: https://img.shields.io/badge/difficulty:%20medium-fef2c0.svg
[difficulty: starter]: https://img.shields.io/badge/difficulty:%20starter-c5def5.svg
[good first issue]: https://img.shields.io/badge/good%20first%20issue-128A0C.svg
[hacktoberfest]: https://img.shields.io/badge/hacktoberfest-ff625f.svg
[issue: announcement]: https://img.shields.io/badge/issue:%20announcement-5319e7.svg
[issue: bug]: https://img.shields.io/badge/issue:%20bug-ee0701.svg
[issue: install problem]: https://img.shields.io/badge/issue:%20install%20problem-e5aa4b.svg
[issue: needs investigation]: https://img.shields.io/badge/issue:%20needs%20investigation-d106e8.svg
[issue: proposal]: https://img.shields.io/badge/issue:%20proposal-fbca04.svg
[issue: question > PWA]: https://img.shields.io/badge/issue:%20question%20>%20PWA-c5def5.svg
[issue: question]: https://img.shields.io/badge/issue:%20question-006b75.svg
[issue: typescript]: https://img.shields.io/badge/issue:%20typescript-007acc.svg
[priority: low (ignored issue template)]: https://img.shields.io/badge/priority:%20low%20(ignored%20issue%20template)-d4c5f9.svg
[priority: low (needs more information)]: https://img.shields.io/badge/priority:%20low%20(needs%20more%20information)-d4c5f9.svg
[stale]: https://img.shields.io/badge/stale-f4d37f.svg
[tag: breaking change]: https://img.shields.io/badge/tag:%20breaking%20change-e11d21.svg
[tag: bug fix]: https://img.shields.io/badge/tag:%20bug%20fix-fbca04.svg
[tag: documentation]: https://img.shields.io/badge/tag:%20documentation-006b75.svg
[tag: enhancement]: https://img.shields.io/badge/tag:%20enhancement-1d76db.svg
[tag: internal]: https://img.shields.io/badge/tag:%20internal-bfdadc.svg
[tag: new feature]: https://img.shields.io/badge/tag:%20new%20feature-0e8a16.svg
[tag: underlying tools]: https://img.shields.io/badge/tag:%20underlying%20tools-d93f0b.svg

to use as:
![][CLA Signed] ![][stale] ![][difficulty: impossible] etc.: etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment