clapp-pm 1.0.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.
where_command.py ADDED
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ where_command.py - Uygulama konum bulma modülü
4
+
5
+ Bu modül `clapp where <app_name>` komutunu destekler ve
6
+ yüklü uygulamaların dosya sistemi konumlarını gösterir.
7
+ """
8
+
9
+ import os
10
+ import json
11
+ from pathlib import Path
12
+
13
+ def locate_app_path(app_name, check_entry=False):
14
+ """Uygulama konumunu bulur"""
15
+ print(f"📍 '{app_name}' uygulaması aranıyor...")
16
+ print("=" * 50)
17
+
18
+ # Varsayılan uygulama dizini
19
+ apps_dir = Path("apps")
20
+ app_dir = apps_dir / app_name
21
+
22
+ if not app_dir.exists():
23
+ print(f"❌ '{app_name}' uygulaması bulunamadı.")
24
+ print()
25
+ print("🔍 Öneriler:")
26
+ print("• Uygulama adını kontrol edin")
27
+ print("• Yüklü uygulamaları görmek için: clapp list")
28
+ print("• Uygulama yüklemek için: clapp install <kaynak>")
29
+ return False
30
+
31
+ if not app_dir.is_dir():
32
+ print(f"❌ '{app_name}' bir dizin değil.")
33
+ return False
34
+
35
+ # Temel bilgiler
36
+ abs_path = app_dir.resolve()
37
+ print(f"📂 Uygulama konumu:")
38
+ print(f" {abs_path}")
39
+ print()
40
+
41
+ # Dizin içeriği
42
+ try:
43
+ contents = list(app_dir.iterdir())
44
+ print(f"📋 Dizin içeriği ({len(contents)} öğe):")
45
+
46
+ for item in contents:
47
+ if item.is_file():
48
+ size = item.stat().st_size
49
+ print(f" 📄 {item.name} ({format_size(size)})")
50
+ elif item.is_dir():
51
+ print(f" 📁 {item.name}/")
52
+ print()
53
+ except Exception as e:
54
+ print(f"⚠️ Dizin içeriği okunamadı: {e}")
55
+ print()
56
+
57
+ # Manifest kontrolü
58
+ manifest_path = app_dir / "manifest.json"
59
+ if manifest_path.exists():
60
+ print("✅ manifest.json mevcut")
61
+
62
+ try:
63
+ with open(manifest_path, 'r', encoding='utf-8') as f:
64
+ manifest = json.load(f)
65
+
66
+ # Temel manifest bilgileri
67
+ print(f" 📝 Ad: {manifest.get('name', 'Belirtilmemiş')}")
68
+ print(f" 🔢 Sürüm: {manifest.get('version', 'Belirtilmemiş')}")
69
+ print(f" 🔧 Dil: {manifest.get('language', 'Belirtilmemiş')}")
70
+ print(f" 🚀 Giriş: {manifest.get('entry', 'Belirtilmemiş')}")
71
+
72
+ # Giriş dosyası kontrolü
73
+ if check_entry and "entry" in manifest:
74
+ entry_file = app_dir / manifest["entry"]
75
+ print()
76
+ print("🔍 Giriş dosyası kontrolü:")
77
+ if entry_file.exists():
78
+ size = entry_file.stat().st_size
79
+ print(f" ✅ {manifest['entry']} mevcut ({format_size(size)})")
80
+ print(f" 📍 Tam yol: {entry_file.resolve()}")
81
+ else:
82
+ print(f" ❌ {manifest['entry']} bulunamadı")
83
+
84
+ except json.JSONDecodeError:
85
+ print(" ❌ manifest.json geçersiz JSON formatında")
86
+ except Exception as e:
87
+ print(f" ❌ manifest.json okunamadı: {e}")
88
+ else:
89
+ print("❌ manifest.json bulunamadı")
90
+
91
+ print()
92
+
93
+ # Kullanım örnekleri
94
+ print("🚀 Kullanım:")
95
+ print(f" clapp run {app_name}")
96
+ print(f" clapp info {app_name}")
97
+ print(f" clapp validate {app_dir}")
98
+
99
+ return True
100
+
101
+ def format_size(size_bytes):
102
+ """Dosya boyutunu formatlar"""
103
+ if size_bytes == 0:
104
+ return "0 B"
105
+
106
+ for unit in ['B', 'KB', 'MB', 'GB']:
107
+ if size_bytes < 1024.0:
108
+ return f"{size_bytes:.1f} {unit}"
109
+ size_bytes /= 1024.0
110
+
111
+ return f"{size_bytes:.1f} TB"
112
+
113
+ def list_all_app_locations():
114
+ """Tüm uygulamaların konumlarını listeler"""
115
+ print("📍 Tüm Uygulama Konumları")
116
+ print("=" * 60)
117
+
118
+ apps_dir = Path("apps")
119
+ if not apps_dir.exists():
120
+ print("❌ apps/ dizini bulunamadı")
121
+ return False
122
+
123
+ app_dirs = [d for d in apps_dir.iterdir() if d.is_dir()]
124
+
125
+ if not app_dirs:
126
+ print("📦 Yüklü uygulama bulunamadı")
127
+ return True
128
+
129
+ print(f"📂 Toplam {len(app_dirs)} uygulama bulundu:\n")
130
+
131
+ for app_dir in sorted(app_dirs):
132
+ app_name = app_dir.name
133
+ abs_path = app_dir.resolve()
134
+
135
+ # Manifest kontrolü
136
+ manifest_path = app_dir / "manifest.json"
137
+ version = "?"
138
+ language = "?"
139
+
140
+ if manifest_path.exists():
141
+ try:
142
+ with open(manifest_path, 'r', encoding='utf-8') as f:
143
+ manifest = json.load(f)
144
+ version = manifest.get('version', '?')
145
+ language = manifest.get('language', '?')
146
+ except:
147
+ pass
148
+
149
+ # Dizin boyutu
150
+ try:
151
+ total_size = sum(f.stat().st_size for f in app_dir.rglob("*") if f.is_file())
152
+ size_str = format_size(total_size)
153
+ except:
154
+ size_str = "?"
155
+
156
+ print(f"📦 {app_name} (v{version}, {language})")
157
+ print(f" 📍 {abs_path}")
158
+ print(f" 📊 {size_str}")
159
+ print()
160
+
161
+ return True
162
+
163
+ def open_app_location(app_name):
164
+ """Uygulama konumunu dosya yöneticisinde açar"""
165
+ apps_dir = Path("apps")
166
+ app_dir = apps_dir / app_name
167
+
168
+ if not app_dir.exists():
169
+ print(f"❌ '{app_name}' uygulaması bulunamadı.")
170
+ return False
171
+
172
+ abs_path = app_dir.resolve()
173
+
174
+ try:
175
+ import platform
176
+ system = platform.system()
177
+
178
+ if system == "Windows":
179
+ os.startfile(abs_path)
180
+ elif system == "Darwin": # macOS
181
+ os.system(f"open '{abs_path}'")
182
+ else: # Linux
183
+ os.system(f"xdg-open '{abs_path}'")
184
+
185
+ print(f"📂 '{app_name}' konumu dosya yöneticisinde açıldı")
186
+ print(f"📍 {abs_path}")
187
+ return True
188
+
189
+ except Exception as e:
190
+ print(f"❌ Dosya yöneticisi açılamadı: {e}")
191
+ print(f"📍 Manuel olarak açın: {abs_path}")
192
+ return False
193
+
194
+ if __name__ == "__main__":
195
+ import sys
196
+
197
+ if len(sys.argv) < 2:
198
+ list_all_app_locations()
199
+ else:
200
+ app_name = sys.argv[1]
201
+ check_entry = "--check-entry" in sys.argv
202
+ open_flag = "--open" in sys.argv
203
+
204
+ if open_flag:
205
+ open_app_location(app_name)
206
+ else:
207
+ locate_app_path(app_name, check_entry)