美文网首页
How to import markdown files int

How to import markdown files int

作者: Jiafu | 来源:发表于2021-10-17 17:30 被阅读0次
    import os
    
    import json
    import requests
    
    # List your markdown directories here.
    dirs = [
        'xxx',
        'xxx'
    ]
    
    for file_dir in dirs:
        filenames = os.listdir(file_dir)
        for i in range(0, len(filenames)):
            if filenames[i].startswith('.'):
                continue
            file_name = filenames[i]
            if '.md' in file_name:
                file_name = file_name[:-3]
                print(file_name)
    
            path = os.path.join(file_dir, filenames[i])
            f = open(path)
            file_content = f.read()
    
            url = 'https://api.github.com/repos/%s/%s/issues' % ('your username', 'your repo name')
            session = requests.session()
            session.auth = ('your username', 'you password')
            title = file_name
    
            issue = {
                'title': file_name,
                'body': file_content,
                'labels': [],
                'milestone': None
            }
    
            r = session.post(url, json.dumps(issue))
            if r.status_code == 201:
                print('Successfully created Issue "%s"' % title)
                # os.remove(path)
            else:
                print('Could not create Issue "%s"' % title)
                print('Response:', r.content)
    

    相关文章

      网友评论

          本文标题:How to import markdown files int

          本文链接:https://www.haomeiwen.com/subject/alewoltx.html