Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- nytimes_com = '''
- This New Liquid Is Magnetic, and Mesmerizing
- Scientists have created “soft” magnets that can flow
- and change shape, and that could be a boon to medicine
- and robotics. (Source: New York Times)
- Most Wikipedia Profiles Are of Men. This Scientist Is Changing That.
- Jessica Wade has added nearly 700 Wikipedia biographies for
- important female and minority scientists in less than two
- years.
- '''
- bloomberg_com = '''
- The Space Race: From Apollo 11 to Elon Musk
- It's 50 years since the world was gripped by historic images
- of Apollo 11, and Neil Armstrong -- the first man to walk
- on the moon. It was the height of the Cold War, and the charts
- were filled with David Bowie's Space Oddity, and Creedence's
- Bad Moon Rising. The world is a very different place than
- it was 5 decades ago. But how has the space race changed since
- the summer of '69? (Source: Bloomberg)
- Twitter CEO Jack Dorsey Gives Talk at Apple Headquarters
- Twitter and Square Chief Executive Officer Jack Dorsey
- addressed Apple Inc. employees at the iPhone maker’s headquarters
- Tuesday, a signal of the strong ties between the Silicon Valley giants.
- '''
- directory = sys.argv[1]
- if not os.access(f'{directory}', os.F_OK):
- os.mkdir(f'{directory}')
- else:
- pass
- userinput = ""
- while userinput != "exit":
- userinput = input()
- if "bloomberg" in userinput and "." in userinput:
- if os.access(f'/{directory}/bloomberg', os.F_OK):
- with open(f'/{directory}/bloomberg', 'r') as file:
- print(file.read())
- else:
- print(bloomberg_com)
- file_bloomberg = open(f'{directory}/bloomberg', 'w')
- file_bloomberg.write(f'{bloomberg_com}')
- file_bloomberg.close()
- elif "nytimes" in userinput and "." in userinput:
- if os.access(f'/{directory}/bloomberg', os.F_OK):
- with open(f'/{directory}/bloomberg', 'r') as file_:
- print(file_.read())
- else:
- print(nytimes_com)
- file_nytimes = open(f'{directory}/nytimes', 'w')
- file_nytimes.write(f'{nytimes_com}')
- file_nytimes.close()
- else:
- print("error")
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement