Skip to content

Instantly share code, notes, and snippets.

@arjkb
Last active December 3, 2017 23:01
Show Gist options
  • Save arjkb/7f6183ccf2b8da516d34ee5e6e57e216 to your computer and use it in GitHub Desktop.
Save arjkb/7f6183ccf2b8da516d34ee5e6e57e216 to your computer and use it in GitHub Desktop.
import argparse
from string import Template
def main():
parser = argparse.ArgumentParser()
parser.add_argument("file", help="path to input file")
args = parser.parse_args()
t = Template("|$sno|[$title]($link){:target='_blank'}|$author|")
with open(args.file) as f:
for i, line in enumerate(f, 1):
title, auth, link = line.split('|')
s = t.substitute(sno=i,
title=title.strip(),
link=link.strip(),
author=auth.strip() )
print(s)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment