Skip to content

Commit

Permalink
Add human readable dates to READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdillon committed Jul 20, 2022
1 parent 23c9458 commit 3c486cc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pipelines/h5c/rtp/v1/stage_1_task_scripts/build_notebook_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import argparse
import os
import glob
from astropy.time import Time

starting_dir = os.getcwd()

Expand Down Expand Up @@ -34,10 +35,17 @@
# build repo
readme = ['# Links to view files:', '']
for file in sorted(glob.glob('*')):
try: # try to append dates in a parethetical
JD = os.path.splitext(file)[0].split('_')[-1]
utc = Time(JD, format='jd').datetime
date_str = f' ({utc.year}-{utc.month}-{utc.day})'
except:
date_str = ''

if file.endswith('.html'):
readme.append(f'* [{file}](https://htmlpreview.github.io/?https://github.com/{user}/{repo}/blob/{branch}/{sub_folders}/{file})')
readme.append(f'* [{file}{date_str}](https://htmlpreview.github.io/?https://github.com/{user}/{repo}/blob/{branch}/{sub_folders}/{file})')
elif file.endswith('.ipynb'):
readme.append(f'* [{file}](https://nbviewer.jupyter.org/github/{user}/{repo}/blob/{branch}/{sub_folders}/{file})')
readme.append(f'* [{file}{date_str}](https://nbviewer.jupyter.org/github/{user}/{repo}/blob/{branch}/{sub_folders}/{file})')


with open('README.md', 'w') as f:
Expand Down

0 comments on commit 3c486cc

Please sign in to comment.