move the main decision tree to __main__
This commit is contained in:
parent
5f0de1e8e2
commit
89806e0be2
|
@ -5,12 +5,22 @@ from url2markdown.file import write_to_file
|
|||
from url2markdown.header import Header
|
||||
|
||||
|
||||
def main():
|
||||
args = cli()
|
||||
article = downloader(args.URL)
|
||||
header = Header(article, args.topics)
|
||||
def main(url, topics):
|
||||
article = downloader(url)
|
||||
header = Header(article, topics)
|
||||
write_to_file(article, header.build_header())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
args = cli()
|
||||
if args.url:
|
||||
main(args.url, args.topics)
|
||||
if args.file:
|
||||
with args.file as input_file:
|
||||
for line in input_file:
|
||||
try:
|
||||
url, topics = line.split(' ')
|
||||
except ValueError:
|
||||
url = line
|
||||
topics = []
|
||||
main(url, topics)
|
||||
|
|
Loading…
Reference in New Issue