Skip to content

Instantly share code, notes, and snippets.

@MarcScott
Created October 11, 2017 13:36
Show Gist options
  • Save MarcScott/3ef1ca7006fb3a580339bcff3401edbf to your computer and use it in GitHub Desktop.
Save MarcScott/3ef1ca7006fb3a580339bcff3401edbf to your computer and use it in GitHub Desktop.
import os
from glob import glob
import re
from pprint import pprint
import itertools
PROJECT = "santa-detector"
PROJECT_DIR = "/home/mjs/WIP/copy/"
preamble_ingredient="""Could I get a copy edit on this resource please?
This is an ingredient that gets pulled automatically into another project.
All work is in the draft branch which is linked below.
I'll merge with master when the copy edit has been completed.
Here is the GitHub repo
"""
preamble_project="""Could I get a copy edit on this resource please?
This is a project that pulls in other ingredients.
All work is in the draft branch which is linked below.
I'll merge with master when the copy edit has been completed.
Here is the GitHub repo
"""
pattern = re.compile("\[\[\[.*?\]\]\]")
result = [y for x in os.walk(PROJECT_DIR+PROJECT) for y in glob(os.path.join(x[0], '*.md'))]
projects = []
for filename in result:
with open(filename, 'r') as f:
matches = re.findall(pattern, f.read())
if matches !=[]:
try:
projects.append([match.replace('[[[','').replace(']]]','') for match in matches])
print(filename)
except:
pass
ingredients = list(itertools.chain.from_iterable(projects))
with open('copy-edit.md','w') as f:
for project in ingredients:
gh_url = "https://github.com/raspberrypilearning/"+project+'/tree/draft/en'
draft_url = "https://learning-admin.raspberrypi.org/en/projects/" + project
f.writelines("ISSUE TITLE" + "\n" + "Copy edit on resource - " + project + "\n\n")
f.writelines(preamble_ingredient + "\n")
f.writelines(gh_url + '\n\n')
f.writelines("Here is the draft preview\n\n" + draft_url + "\n\n" + ("-" * 10) + "\n\n")
f.writelines('Copy edit on resource - ' + PROJECT + "\n\n")
f.writelines(preamble_project + "\n")
f.writelines("https://github.com/raspberrypilearning/" + PROJECT + '/tree/draft/en\n\n')
f.writelines("Here is the draft preview\n\n")
f.writelines("https://learning-admin.raspberrypi.org/en/projects/" + PROJECT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment