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)
网友评论