-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_readme.py
37 lines (25 loc) · 1.98 KB
/
update_readme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
readme_template ="""# A traveler's guide to Oak Ridge National Laboratory
Dear all, change is hard. If you are coming to a completely different city for work, doubly so. We get you, it's terrifying, and there's seemingly a million things you need to take care of. But you're also excited, and you want this. I've been there, and I know how scary it is. You're going in completely blind. My hope is to make this transition at least a bit smoother for you.
I have been a summer intern, a post-master research associate, and am now a staff at ORNL. Throughout my beautiful years with ORNL, I learned a thing or two cause I've seen a thing or two (insert Farmer's insurance jingle here), and hopefully I can transfer my experience to make your transition smoother.
The goal of this rpeo is to be constantly iterated and become a living, evolving, central repository for new-to-ORNL people's survival guide. Please do comment and ask questions - I want to know what you want to know.
## Ways to contribute / join:
- make issues on your questions!
- make pull requests on what you think would be helpful!
## Table of Contents
$table_of_contents
"""
link_parent = 'https://github.com/jbae11/travellers_guide_to_ornl/blob/master/'
here = os.path.dirname(os.path.abspath(__file__))
exempt = ['.git', 'images']
folders = [x for x in os.listdir(here) if os.path.isdir(x) and x not in exempt]
table_of_contents_str = ''
for indx, folder in enumerate(folders):
table_of_contents_str += '%s. %s\n' %(indx+1, folder.replace('_', ' ').capitalize())
subfiles = sorted([q for q in os.listdir(os.path.join(here, folder))])
for indx2, file in enumerate(subfiles):
link = os.path.join(link_parent, folder, file)
name = file.replace('.md', '').replace('_', ' ').capitalize()
table_of_contents_str += '\t%s. [%s](%s)\n' %(indx2+1, name, link)
with open('README.md', 'w') as f:
f.write(readme_template.replace('$table_of_contents', table_of_contents_str))