notlang 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
notlang-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.4
2
+ Name: notlang
3
+ Version: 0.1.0
4
+ Summary: GIS uchun soddalashtirilgan buyruqlar tili (Python ustida ishlaydi) — Uzbek-friendly domain-specific language for GIS/RS
5
+ Author: notGIS
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/notgis/notlang
8
+ Project-URL: Repository, https://github.com/notgis/notlang
9
+ Keywords: gis,remote-sensing,geospatial,dsl,uzbekistan,earth-engine,copernicus
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Scientific/Engineering :: GIS
14
+ Classifier: Intended Audience :: Science/Research
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: geopandas>=0.14
18
+ Requires-Dist: rasterio>=1.3
19
+ Requires-Dist: matplotlib>=3.7
20
+ Requires-Dist: numpy>=1.24
21
+ Requires-Dist: shapely>=2.0
22
+ Requires-Dist: lark>=1.1
23
+ Requires-Dist: requests>=2.28
24
+ Provides-Extra: jupyter
25
+ Requires-Dist: ipython>=8.0; extra == "jupyter"
26
+ Provides-Extra: gee
27
+ Requires-Dist: earthengine-api>=0.1; extra == "gee"
28
+ Provides-Extra: full
29
+ Requires-Dist: ipython>=8.0; extra == "full"
30
+ Requires-Dist: earthengine-api>=0.1; extra == "full"
31
+
32
+ # notLang
33
+
34
+ GIS uchun soddalashtirilgan buyruqlar tili. Python ustida ishlaydi, natijada
35
+ uzun GDAL/rasterio/geopandas kodi o'rniga 2-3 qatorlik notLang skripti yeziladi.
36
+
37
+ ## O'rnatish
38
+
39
+ **Eng qulay usul — GitHub'dan to'g'ridan-to'g'ri (zip yuklash shart emas):**
40
+ ```bash
41
+ pip install git+https://github.com/<GITHUB_USER>/notlang.git
42
+ ```
43
+ Colab/Jupyter'da (GEE va Jupyter qo'llab-quvvatlashi bilan):
44
+ ```python
45
+ !pip install "notlang[gee,jupyter] @ git+https://github.com/<GITHUB_USER>/notlang.git"
46
+ ```
47
+
48
+ **Mahalliy (development) rejimida:**
49
+ ```bash
50
+ pip install -e .
51
+ ```
52
+
53
+ O'rnatgandan so'ng `notlang` komandasi terminalda, PowerShell'da va CMD'da
54
+ ishlaydi:
55
+
56
+ ```bash
57
+ notlang # interaktiv rejim (REPL)
58
+ notlang skript.nl # skript faylini ishga tushirish
59
+ notlang --version # versiyani ko'rsatish
60
+ ```
61
+
62
+ ## Holat: Faza 2 (interpretator ulandi — notLang endi ishlaydi!)
63
+
64
+ Endi `notlang` haqiqiy buyruqlarni bajaradi. Misol skript:
65
+
66
+ ```
67
+ load "hudud.geojson" as a
68
+ info a
69
+ stats a
70
+ show a to "hudud.png"
71
+
72
+ load "mask.geojson" as m
73
+ clip a with m -> a_clip
74
+ save a_clip to "natija.geojson"
75
+
76
+ buffer a 500 -> a_buf
77
+ reproject a to 3857 -> a_3857
78
+ ```
79
+
80
+ Ishga tushirish:
81
+ ```bash
82
+ notlang skript.nl # faylni ishga tushirish
83
+ notlang # interaktiv rejim (REPL), qator-qator yozish
84
+ ```
85
+
86
+ REPL'da `help` yozsangiz barcha buyruqlar ro'yxati chiqadi.
87
+
88
+ ### Qo'llab-quvvatlanadigan buyruqlar (Faza 2)
89
+
90
+ | Buyruq | Misol |
91
+ |---|---|
92
+ | `load` | `load "a.shp" as x` |
93
+ | `show` | `show x title "Sarlavha" color "red" to "chiqish.png"` |
94
+ | `info` | `info x` |
95
+ | `stats` | `stats x` |
96
+ | `list` | `list x shapeName` |
97
+ | `save` | `save x to "chiqish.geojson"` |
98
+ | `filter` | `filter x where "shapeName == 'Xorazm'" -> y` |
99
+ | `clip` | `clip x with mask -> y` |
100
+ | `merge` | `merge x y -> z` (ikkita vektor) |
101
+ | `mosaic` | `mosaic x y -> z` (ikkita rastr) |
102
+ | `ndvi` | `ndvi x 3 4 -> z` (red-band nir-band) |
103
+ | `zonal_stats` | `zonal_stats raster with zonalar -> t` (min/max/mean/std) |
104
+ | `chart` | `chart x ustun bar to "grafik.png"` (bar/hist/line) |
105
+ | `install` | `install "paket-nomi"` (kerakli kutubxonani o'rnatadi) |
106
+ | `buffer` | `buffer x 500 -> y` |
107
+ | `reproject` | `reproject x to 4326 -> y` |
108
+
109
+ Sinash uchun:
110
+ ```bash
111
+ python make_test_data.py # sinov fayllarini yaratadi
112
+ python test_core.py # runtime funksiyalarini sinaydi
113
+ notlang examples/skript.nl # to'liq notLang skriptini ishga tushiradi
114
+ ```
115
+
116
+ Keyingi bosqichlar rejasi uchun loyihaning to'liq hujjatiga qarang
117
+ (Faza 5: GEE/Copernicus ulanish).
118
+
119
+ ## Jupyter / Google Colab'da ishlatish (Faza 4)
120
+
121
+ Avval o'rnating (Jupyter/Colab qo'llab-quvvatlashi bilan):
122
+ ```bash
123
+ pip install -e ".[jupyter]"
124
+ ```
125
+
126
+ Notebook katagida:
127
+ ```python
128
+ %load_ext notlang
129
+ ```
130
+
131
+ Keyin har qanday katakda:
132
+ ```python
133
+ %%notlang
134
+ load "hudud.geojson" as a
135
+ info a
136
+ show a
137
+ ```
138
+
139
+ O'zgaruvchilar (`a` kabi) keyingi kataklarda ham ishlatilaveradi —
140
+ xuddi REPL'dagidek, bitta sessiya davomida saqlanib qoladi.
141
+
142
+ Bitta qatorlik buyruq uchun (katak emas, bitta qator):
143
+ ```python
144
+ %notlang_line show a
145
+ ```
146
+
147
+ Google Colab'da ham xuddi shunday ishlaydi — avval
148
+ `!pip install notlang[jupyter]` (yoki paketni yuklab, `!pip install -e .`),
149
+ so'ng `%load_ext notlang` deb yozish kifoya.
150
+
151
+ ## Google Earth Engine'ga ulanish (Faza 5)
152
+
153
+ Avval o'rnating:
154
+ ```bash
155
+ pip install -e ".[gee]"
156
+ ```
157
+
158
+ Ishlatish (REPL, skript yoki `%%notlang` — barchasida bir xil):
159
+ ```
160
+ connect gee
161
+ ```
162
+
163
+ Birinchi marta ishlatganda brauzerda Google login oynasi ochiladi
164
+ (Colab'da bu link ko'rinishida chiqadi — uni bosib, Google hisobingiz
165
+ bilan ruxsat berasiz). Sizda Earth Engine yoqilgan Google Cloud loyihasi
166
+ (project) bo'lishi kerak — https://code.earthengine.google.com/ orqali
167
+ ro'yxatdan o'ting.
168
+
169
+ Tasvir olish:
170
+ ```
171
+ load "hudud.geojson" as region
172
+ connect gee
173
+ get "COPERNICUS/S2_SR_HARMONIC" date "2024-01-01" "2024-02-01" bbox region -> img
174
+ info img
175
+ show img
176
+ ```
177
+
178
+ `get` buyrug'i berilgan kolleksiyadan (`dataset`), sana oralig'ida,
179
+ `region` qatlamining chegara qutisi (bounding box) ichidagi barcha
180
+ tasvirlarning **median kompozitini** yuklab, mahalliy rastr sifatida
181
+ qaytaradi. Katta hududlar yoki uzoq sana oralig'i GEE eksport
182
+ chegarasiga (odatda ~10-50 MB) tegishi mumkin — shunday xato chiqsa,
183
+ hududni yoki sana oralig'ini kichraytiring.
184
+
185
+ **Diqqat:** bu qismni men (Claude) o'z muhitimda haqiqiy Google hisobi
186
+ bilan sinab ko'ra olmadim — internetga chiqish cheklangan. Kod
187
+ sintaksis va mantiq jihatidan tekshirilgan (xato holatlari to'g'ri
188
+ ushlanadi), lekin haqiqiy autentifikatsiya va tasvir yuklashni
189
+ o'zingizning muhitingizda (Colab tavsiya etiladi) sinab ko'rishingiz
190
+ kerak.
191
+
192
+ ## Copernicus Data Space'ga ulanish (Faza 5b)
193
+
194
+ [Dataspace.copernicus.eu](https://dataspace.copernicus.eu/) da ro'yxatdan
195
+ o'ting, so'ng **User Settings -> OAuth clients** bo'limidan `client_id`
196
+ va `client_secret` oling.
197
+
198
+ ```
199
+ connect copernicus "client_id" "client_secret"
200
+ ```
201
+
202
+ Tasvir olish (Sentinel-2 L2A, ko'k/yashil/qizil/NIR bandlari — B02, B03,
203
+ B04, B08):
204
+ ```
205
+ load "hudud.geojson" as region
206
+ connect copernicus "client_id" "client_secret"
207
+ get_sentinel date "2024-01-01" "2024-02-01" bbox region scale 100 -> img
208
+ info img
209
+ show img
210
+ ```
211
+
212
+ Bu autentifikatsiya OAuth `client_credentials` oqimi orqali ishlaydi
213
+ (brauzer kerak emas, GEE'dan farqli). Sinovda ulanish kodi haqiqiy
214
+ Copernicus serveriga yetib bordi va noto'g'ri kredensial uchun to'g'ri
215
+ 403 xatosi qaytardi — demak so'rov formati to'g'ri; siz faqat haqiqiy
216
+ `client_id`/`client_secret` bilan sinashingiz kerak.
@@ -0,0 +1,185 @@
1
+ # notLang
2
+
3
+ GIS uchun soddalashtirilgan buyruqlar tili. Python ustida ishlaydi, natijada
4
+ uzun GDAL/rasterio/geopandas kodi o'rniga 2-3 qatorlik notLang skripti yeziladi.
5
+
6
+ ## O'rnatish
7
+
8
+ **Eng qulay usul — GitHub'dan to'g'ridan-to'g'ri (zip yuklash shart emas):**
9
+ ```bash
10
+ pip install git+https://github.com/<GITHUB_USER>/notlang.git
11
+ ```
12
+ Colab/Jupyter'da (GEE va Jupyter qo'llab-quvvatlashi bilan):
13
+ ```python
14
+ !pip install "notlang[gee,jupyter] @ git+https://github.com/<GITHUB_USER>/notlang.git"
15
+ ```
16
+
17
+ **Mahalliy (development) rejimida:**
18
+ ```bash
19
+ pip install -e .
20
+ ```
21
+
22
+ O'rnatgandan so'ng `notlang` komandasi terminalda, PowerShell'da va CMD'da
23
+ ishlaydi:
24
+
25
+ ```bash
26
+ notlang # interaktiv rejim (REPL)
27
+ notlang skript.nl # skript faylini ishga tushirish
28
+ notlang --version # versiyani ko'rsatish
29
+ ```
30
+
31
+ ## Holat: Faza 2 (interpretator ulandi — notLang endi ishlaydi!)
32
+
33
+ Endi `notlang` haqiqiy buyruqlarni bajaradi. Misol skript:
34
+
35
+ ```
36
+ load "hudud.geojson" as a
37
+ info a
38
+ stats a
39
+ show a to "hudud.png"
40
+
41
+ load "mask.geojson" as m
42
+ clip a with m -> a_clip
43
+ save a_clip to "natija.geojson"
44
+
45
+ buffer a 500 -> a_buf
46
+ reproject a to 3857 -> a_3857
47
+ ```
48
+
49
+ Ishga tushirish:
50
+ ```bash
51
+ notlang skript.nl # faylni ishga tushirish
52
+ notlang # interaktiv rejim (REPL), qator-qator yozish
53
+ ```
54
+
55
+ REPL'da `help` yozsangiz barcha buyruqlar ro'yxati chiqadi.
56
+
57
+ ### Qo'llab-quvvatlanadigan buyruqlar (Faza 2)
58
+
59
+ | Buyruq | Misol |
60
+ |---|---|
61
+ | `load` | `load "a.shp" as x` |
62
+ | `show` | `show x title "Sarlavha" color "red" to "chiqish.png"` |
63
+ | `info` | `info x` |
64
+ | `stats` | `stats x` |
65
+ | `list` | `list x shapeName` |
66
+ | `save` | `save x to "chiqish.geojson"` |
67
+ | `filter` | `filter x where "shapeName == 'Xorazm'" -> y` |
68
+ | `clip` | `clip x with mask -> y` |
69
+ | `merge` | `merge x y -> z` (ikkita vektor) |
70
+ | `mosaic` | `mosaic x y -> z` (ikkita rastr) |
71
+ | `ndvi` | `ndvi x 3 4 -> z` (red-band nir-band) |
72
+ | `zonal_stats` | `zonal_stats raster with zonalar -> t` (min/max/mean/std) |
73
+ | `chart` | `chart x ustun bar to "grafik.png"` (bar/hist/line) |
74
+ | `install` | `install "paket-nomi"` (kerakli kutubxonani o'rnatadi) |
75
+ | `buffer` | `buffer x 500 -> y` |
76
+ | `reproject` | `reproject x to 4326 -> y` |
77
+
78
+ Sinash uchun:
79
+ ```bash
80
+ python make_test_data.py # sinov fayllarini yaratadi
81
+ python test_core.py # runtime funksiyalarini sinaydi
82
+ notlang examples/skript.nl # to'liq notLang skriptini ishga tushiradi
83
+ ```
84
+
85
+ Keyingi bosqichlar rejasi uchun loyihaning to'liq hujjatiga qarang
86
+ (Faza 5: GEE/Copernicus ulanish).
87
+
88
+ ## Jupyter / Google Colab'da ishlatish (Faza 4)
89
+
90
+ Avval o'rnating (Jupyter/Colab qo'llab-quvvatlashi bilan):
91
+ ```bash
92
+ pip install -e ".[jupyter]"
93
+ ```
94
+
95
+ Notebook katagida:
96
+ ```python
97
+ %load_ext notlang
98
+ ```
99
+
100
+ Keyin har qanday katakda:
101
+ ```python
102
+ %%notlang
103
+ load "hudud.geojson" as a
104
+ info a
105
+ show a
106
+ ```
107
+
108
+ O'zgaruvchilar (`a` kabi) keyingi kataklarda ham ishlatilaveradi —
109
+ xuddi REPL'dagidek, bitta sessiya davomida saqlanib qoladi.
110
+
111
+ Bitta qatorlik buyruq uchun (katak emas, bitta qator):
112
+ ```python
113
+ %notlang_line show a
114
+ ```
115
+
116
+ Google Colab'da ham xuddi shunday ishlaydi — avval
117
+ `!pip install notlang[jupyter]` (yoki paketni yuklab, `!pip install -e .`),
118
+ so'ng `%load_ext notlang` deb yozish kifoya.
119
+
120
+ ## Google Earth Engine'ga ulanish (Faza 5)
121
+
122
+ Avval o'rnating:
123
+ ```bash
124
+ pip install -e ".[gee]"
125
+ ```
126
+
127
+ Ishlatish (REPL, skript yoki `%%notlang` — barchasida bir xil):
128
+ ```
129
+ connect gee
130
+ ```
131
+
132
+ Birinchi marta ishlatganda brauzerda Google login oynasi ochiladi
133
+ (Colab'da bu link ko'rinishida chiqadi — uni bosib, Google hisobingiz
134
+ bilan ruxsat berasiz). Sizda Earth Engine yoqilgan Google Cloud loyihasi
135
+ (project) bo'lishi kerak — https://code.earthengine.google.com/ orqali
136
+ ro'yxatdan o'ting.
137
+
138
+ Tasvir olish:
139
+ ```
140
+ load "hudud.geojson" as region
141
+ connect gee
142
+ get "COPERNICUS/S2_SR_HARMONIC" date "2024-01-01" "2024-02-01" bbox region -> img
143
+ info img
144
+ show img
145
+ ```
146
+
147
+ `get` buyrug'i berilgan kolleksiyadan (`dataset`), sana oralig'ida,
148
+ `region` qatlamining chegara qutisi (bounding box) ichidagi barcha
149
+ tasvirlarning **median kompozitini** yuklab, mahalliy rastr sifatida
150
+ qaytaradi. Katta hududlar yoki uzoq sana oralig'i GEE eksport
151
+ chegarasiga (odatda ~10-50 MB) tegishi mumkin — shunday xato chiqsa,
152
+ hududni yoki sana oralig'ini kichraytiring.
153
+
154
+ **Diqqat:** bu qismni men (Claude) o'z muhitimda haqiqiy Google hisobi
155
+ bilan sinab ko'ra olmadim — internetga chiqish cheklangan. Kod
156
+ sintaksis va mantiq jihatidan tekshirilgan (xato holatlari to'g'ri
157
+ ushlanadi), lekin haqiqiy autentifikatsiya va tasvir yuklashni
158
+ o'zingizning muhitingizda (Colab tavsiya etiladi) sinab ko'rishingiz
159
+ kerak.
160
+
161
+ ## Copernicus Data Space'ga ulanish (Faza 5b)
162
+
163
+ [Dataspace.copernicus.eu](https://dataspace.copernicus.eu/) da ro'yxatdan
164
+ o'ting, so'ng **User Settings -> OAuth clients** bo'limidan `client_id`
165
+ va `client_secret` oling.
166
+
167
+ ```
168
+ connect copernicus "client_id" "client_secret"
169
+ ```
170
+
171
+ Tasvir olish (Sentinel-2 L2A, ko'k/yashil/qizil/NIR bandlari — B02, B03,
172
+ B04, B08):
173
+ ```
174
+ load "hudud.geojson" as region
175
+ connect copernicus "client_id" "client_secret"
176
+ get_sentinel date "2024-01-01" "2024-02-01" bbox region scale 100 -> img
177
+ info img
178
+ show img
179
+ ```
180
+
181
+ Bu autentifikatsiya OAuth `client_credentials` oqimi orqali ishlaydi
182
+ (brauzer kerak emas, GEE'dan farqli). Sinovda ulanish kodi haqiqiy
183
+ Copernicus serveriga yetib bordi va noto'g'ri kredensial uchun to'g'ri
184
+ 403 xatosi qaytardi — demak so'rov formati to'g'ri; siz faqat haqiqiy
185
+ `client_id`/`client_secret` bilan sinashingiz kerak.
@@ -0,0 +1,13 @@
1
+ """notLang — GIS uchun soddalashtirilgan buyruqlar tili."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+
6
+ def load_ipython_extension(ipython):
7
+ """Jupyter/Colab'da `%load_ext notlang` ishlashi uchun kerak.
8
+
9
+ IPython o'rnatilmagan muhitda (oddiy terminal) bu funksiya
10
+ chaqirilmaydi, shuning uchun bu yerda import qilinishi xavfsiz.
11
+ """
12
+ from .magic import load_ipython_extension as _load
13
+ _load(ipython)
@@ -0,0 +1,116 @@
1
+ """notLang CLI — Faza 2: interpretator ulandi.
2
+
3
+ Endi notlang komandasi buyruqlarni haqiqatan bajaradi: `load`, `show`,
4
+ `info`, `stats`, `save`, `clip`, `buffer`, `reproject`.
5
+ """
6
+
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ from . import __version__
11
+ from .interpreter import Interpreter, InterpreterError
12
+
13
+ BANNER = f"""notLang v{__version__}
14
+ GIS uchun soddalashtirilgan buyruqlar tili.
15
+ Chiqish uchun: exit yoki Ctrl+D. Yordam uchun: help
16
+ """
17
+
18
+
19
+ def run_repl() -> None:
20
+ print(BANNER)
21
+ interpreter = Interpreter()
22
+ while True:
23
+ try:
24
+ line = input("notlang> ").strip()
25
+ except (EOFError, KeyboardInterrupt):
26
+ print("\nXayr!")
27
+ break
28
+
29
+ if not line:
30
+ continue
31
+ if line in ("exit", "quit"):
32
+ print("Xayr!")
33
+ break
34
+ if line == "help":
35
+ _print_help()
36
+ continue
37
+
38
+ try:
39
+ message = interpreter.run_line(line)
40
+ if message:
41
+ print(message)
42
+ except InterpreterError as e:
43
+ print(f"Xato: {e}")
44
+
45
+
46
+ def run_script(path: str) -> int:
47
+ script_path = Path(path)
48
+ if not script_path.exists():
49
+ print(f"Xato: fayl topilmadi — {path}")
50
+ return 1
51
+
52
+ source = script_path.read_text(encoding="utf-8")
53
+ interpreter = Interpreter()
54
+ try:
55
+ messages = interpreter.run(source)
56
+ except InterpreterError as e:
57
+ print(f"Xato: {e}")
58
+ return 1
59
+
60
+ for message in messages:
61
+ print(message)
62
+ return 0
63
+
64
+
65
+ def _print_help() -> None:
66
+ print("""Mavjud buyruqlar:
67
+ load "fayl" as x faylni yuklaydi (shp/geojson/gpkg/tif)
68
+ show x [title "..."] [color "..."] [to "chiqish.png"] chizadi
69
+ chart x ustun bar|hist|line [title "..."] to "grafik.png" grafik chizish
70
+ info x qatlam haqida ma'lumot
71
+ stats x statistika
72
+ save x to "fayl" faylga yozadi
73
+ list x ustun_nomi ustundagi barcha noyob qiymatlarni ko'rsatadi
74
+ filter x where "shart" -> y attribut bo'yicha ajratib olish
75
+ clip x with mask -> y kesish
76
+ merge x y -> z ikkita vektorni birlashtirish
77
+ mosaic x y -> z ikkita rastrni mozaika qilish
78
+ ndvi x 3 4 -> z NDVI hisoblash (red-band nir-band)
79
+ zonal_stats r with z -> t zonalar bo'yicha statistika (min/max/mean/std)
80
+ connect gee Google Earth Engine'ga ulanish
81
+ get "kolleksiya" date "boshi" "oxiri" bbox x -> y GEE'dan tasvir olish
82
+ connect copernicus "id" "secret" Copernicus Data Space'ga ulanish
83
+ get_sentinel date "boshi" "oxiri" bbox x -> y Copernicus'dan Sentinel-2 olish
84
+ install "paket-nomi" kerakli kutubxonani o'rnatadi
85
+ buffer x 500 -> y bufer (masofa qatlam birligida)
86
+ reproject x to 4326 -> y CRS almashtirish
87
+ exit chiqish""")
88
+
89
+
90
+ def main() -> None:
91
+ args = sys.argv[1:]
92
+
93
+ if not args:
94
+ run_repl()
95
+ return
96
+
97
+ if args[0] in ("-v", "--version"):
98
+ print(f"notLang v{__version__}")
99
+ return
100
+
101
+ if args[0] in ("-h", "--help"):
102
+ print(BANNER)
103
+ print("Foydalanish:")
104
+ print(" notlang interaktiv rejim (REPL)")
105
+ print(" notlang skript.nl skript faylini ishga tushirish")
106
+ print(" notlang --version versiyani ko'rsatish")
107
+ print()
108
+ _print_help()
109
+ return
110
+
111
+ exit_code = run_script(args[0])
112
+ sys.exit(exit_code)
113
+
114
+
115
+ if __name__ == "__main__":
116
+ main()