Last active
December 3, 2017 23:01
-
-
Save arjkb/7f6183ccf2b8da516d34ee5e6e57e216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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