Advertisement
Guest User

Untitled

a guest
Apr 19th, 2022
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.24 KB | None | 0 0
  1. import sys
  2. import os
  3.  
  4. nytimes_com = '''
  5. This New Liquid Is Magnetic, and Mesmerizing
  6.  
  7. Scientists have created “soft” magnets that can flow
  8. and change shape, and that could be a boon to medicine
  9. and robotics. (Source: New York Times)
  10.  
  11.  
  12. Most Wikipedia Profiles Are of Men. This Scientist Is Changing That.
  13.  
  14. Jessica Wade has added nearly 700 Wikipedia biographies for
  15. important female and minority scientists in less than two
  16. years.
  17.  
  18. '''
  19.  
  20. bloomberg_com = '''
  21. The Space Race: From Apollo 11 to Elon Musk
  22.  
  23. It's 50 years since the world was gripped by historic images
  24. of Apollo 11, and Neil Armstrong -- the first man to walk
  25. on the moon. It was the height of the Cold War, and the charts
  26. were filled with David Bowie's Space Oddity, and Creedence's
  27. Bad Moon Rising. The world is a very different place than
  28. it was 5 decades ago. But how has the space race changed since
  29. the summer of '69? (Source: Bloomberg)
  30.  
  31.  
  32. Twitter CEO Jack Dorsey Gives Talk at Apple Headquarters
  33.  
  34. Twitter and Square Chief Executive Officer Jack Dorsey
  35. addressed Apple Inc. employees at the iPhone maker’s headquarters
  36. Tuesday, a signal of the strong ties between the Silicon Valley giants.
  37. '''
  38.  
  39. directory = sys.argv[1]
  40.  
  41. if not os.access(f'{directory}', os.F_OK):
  42.     os.mkdir(f'{directory}')
  43. else:
  44.     pass
  45.  
  46. userinput = ""
  47.  
  48. while userinput != "exit":
  49.     userinput = input()
  50.     if "bloomberg" in userinput and "." in userinput:
  51.         if os.access(f'/{directory}/bloomberg', os.F_OK):
  52.             with open(f'/{directory}/bloomberg', 'r') as file:
  53.                 print(file.read())
  54.         else:
  55.             print(bloomberg_com)
  56.             file_bloomberg = open(f'{directory}/bloomberg', 'w')
  57.             file_bloomberg.write(f'{bloomberg_com}')
  58.             file_bloomberg.close()
  59.     elif "nytimes" in userinput and "." in userinput:
  60.         if os.access(f'/{directory}/bloomberg', os.F_OK):
  61.             with open(f'/{directory}/bloomberg', 'r') as file_:
  62.                 print(file_.read())
  63.         else:
  64.             print(nytimes_com)
  65.             file_nytimes = open(f'{directory}/nytimes', 'w')
  66.             file_nytimes.write(f'{nytimes_com}')
  67.             file_nytimes.close()
  68.     else:
  69.         print("error")
  70.         continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement