Last active
June 26, 2024 15:17
-
-
Save ad2ien/b4837878bf046edaf14065b7ebe3fbcf to your computer and use it in GitHub Desktop.
A markdown Github report about closed issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from github import Github | |
start_date = datetime.strptime('2023-12-01', '%Y-%m-%d') | |
end_date = datetime.strptime('2023-12-01', '%Y-%m-%d') | |
project = 'org/repo' | |
output_file = './gh-report.md' | |
escaped_triple_backquotes = '\\```' | |
def main(): | |
g = Github() | |
repo = g.get_repo(project) | |
issues = repo.get_issues(state='closed', since=start_date, sort='closed', direction='asc') | |
prs = filter(lambda issue: issue.pull_request, issues) | |
tickets = filter(lambda issue: not issue.pull_request, issues) | |
# clear output file | |
with open(output_file,'w') as file: | |
pass | |
## append issues to file | |
with open(output_file, 'a') as file: | |
file.write('# Github Report\n') | |
file.write('\n') | |
file.write('## Tickets\n') | |
file.write('\n') | |
for ticket in tickets: | |
write_paragraphe(file, ticket) | |
file.write('\n') | |
file.write('## Pull requests\n') | |
file.write('\n') | |
for ticket in prs: | |
write_paragraphe(file, ticket) | |
def write_paragraphe(file, issue): | |
file.write(f"### {issue.number} - {issue.title}\n\n") | |
file.write(f"> [https://github.com/{project}/issues/{issue.number}](https://github.com/{project}/issues/{issue.number})\n\n") | |
if issue.body: | |
file.write(f"```markdown\n{issue.body.replace('```', escaped_triple_backquotes)}\n```\n\n") | |
else: | |
file.write(f"```markdown\nNo description 👿\n```\n\n") | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pdf2image import convert_from_path | |
PDF_FOLDER = 'demo-pdfs' | |
IMAGE_FOLDER = 'demo-images' | |
MARKDOWN_FILE = 'demo-slides.md' | |
# list files of demo pdf directory | |
pdf_files = os.listdir(PDF_FOLDER) | |
with open(MARKDOWN_FILE, 'a') as file: | |
for pdf_file in pdf_files: | |
file.write(f'#### Demo XX\n\n') | |
pages = convert_from_path(f'{PDF_FOLDER}/{pdf_file}', 500) | |
for count, page in enumerate(pages): | |
page.save(f'{IMAGE_FOLDER}/pdf_file-{count}.jpg', 'JPEG') | |
file.write(f'![slide-{count}]({IMAGE_FOLDER}/pdf_file-{count}.jpg)\n') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias pandoc='docker run --rm -v "$(pwd):/data" -u $(id -u):$(id -g) pandoc/core' | |
pandoc demo-slides.md -o output.docx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment