Skip to content

Commit 611a75a

Browse files
add sys argv[] function, implement pyown API
1 parent 5fb1106 commit 611a75a

File tree

3 files changed

+36
-89
lines changed

3 files changed

+36
-89
lines changed

.gitignore

+2-89
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,2 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
3-
*.py[cod]
4-
*$py.class
5-
6-
# C extensions
7-
*.so
8-
9-
# Distribution / packaging
10-
.Python
11-
env/
12-
build/
13-
develop-eggs/
14-
dist/
15-
downloads/
16-
eggs/
17-
.eggs/
18-
lib/
19-
lib64/
20-
parts/
21-
sdist/
22-
var/
23-
*.egg-info/
24-
.installed.cfg
25-
*.egg
26-
27-
# PyInstaller
28-
# Usually these files are written by a python script from a template
29-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30-
*.manifest
31-
*.spec
32-
33-
# Installer logs
34-
pip-log.txt
35-
pip-delete-this-directory.txt
36-
37-
# Unit test / coverage reports
38-
htmlcov/
39-
.tox/
40-
.coverage
41-
.coverage.*
42-
.cache
43-
nosetests.xml
44-
coverage.xml
45-
*,cover
46-
.hypothesis/
47-
48-
# Translations
49-
*.mo
50-
*.pot
51-
52-
# Django stuff:
53-
*.log
54-
local_settings.py
55-
56-
# Flask stuff:
57-
instance/
58-
.webassets-cache
59-
60-
# Scrapy stuff:
61-
.scrapy
62-
63-
# Sphinx documentation
64-
docs/_build/
65-
66-
# PyBuilder
67-
target/
68-
69-
# IPython Notebook
70-
.ipynb_checkpoints
71-
72-
# pyenv
73-
.python-version
74-
75-
# celery beat schedule file
76-
celerybeat-schedule
77-
78-
# dotenv
79-
.env
80-
81-
# virtualenv
82-
venv/
83-
ENV/
84-
85-
# Spyder project settings
86-
.spyderproject
87-
88-
# Rope project settings
89-
.ropeproject
1+
# Pycharm package
2+
*.idea

apollo.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#Apollo: grat tool to get in easy way weather forecast
2+
3+
#module
4+
import sys
5+
import json
6+
import pyowm
7+
# ----------------------function----------------------
8+
def forecast(city,condition):
9+
#Default action
10+
#owm_ru = owm(language='it') # set default language to it
11+
# open config.json file(read)
12+
with open("config.json", "r") as data_file:
13+
data = json.load(data_file)
14+
owm = pyowm.OWM = (data["Api_Key"])
15+
Name = data["Name"]
16+
Surname = data["Surname"]
17+
if condition == True:
18+
city = data["City"]
19+
# close json
20+
data_file.close()
21+
#get weather forecast
22+
observation = owm.weather_at_place(city)
23+
weather = observation.get_weather()
24+
print(weather)
25+
# ----------------------main----------------------
26+
if len(sys.argv) == 1:
27+
print("\nWelcome to Apollo: The great weather forecast tool\n\n")
28+
check_default_city = True
29+
forecast('',check_default_city)
30+
else:
31+
check_default_city = False
32+
#call forecast with user's city
33+
forecast(sys.argv[1],check_default_city)

config.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"City": "#","Api_Key": "1fad2670e91546ebd6f280e185b23732","Name": "#", "Surname": "#"}

0 commit comments

Comments
 (0)