Format all code.
This commit is contained in:
@@ -12,17 +12,17 @@ if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
# Exit with an error code if no ticker is provided
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
ticker_symbol = sys.argv[1]
|
||||
|
||||
|
||||
try:
|
||||
# Directly get the market cap
|
||||
market_cap = yf.Ticker(ticker_symbol).info.get('marketCap')
|
||||
|
||||
market_cap = yf.Ticker(ticker_symbol).info.get("marketCap")
|
||||
|
||||
# On success, print JSON to stdout and exit cleanly
|
||||
print(json.dumps({"market_cap": market_cap}))
|
||||
sys.exit(0)
|
||||
except Exception:
|
||||
# If any error occurs, print an empty JSON and exit with an error code
|
||||
print(json.dumps({"market_cap": None}))
|
||||
sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user