notlang 0.1.0__py3-none-any.whl
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/__init__.py +13 -0
- notlang/cli.py +116 -0
- notlang/core.py +813 -0
- notlang/grammar.lark +58 -0
- notlang/interpreter.py +249 -0
- notlang/layer.py +55 -0
- notlang/magic.py +55 -0
- notlang-0.1.0.dist-info/METADATA +216 -0
- notlang-0.1.0.dist-info/RECORD +12 -0
- notlang-0.1.0.dist-info/WHEEL +5 -0
- notlang-0.1.0.dist-info/entry_points.txt +2 -0
- notlang-0.1.0.dist-info/top_level.txt +1 -0
notlang/__init__.py
ADDED
|
@@ -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)
|
notlang/cli.py
ADDED
|
@@ -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()
|