angelic-kernel 0.1__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.
- angelic_kernel-0.1/PKG-INFO +296 -0
- angelic_kernel-0.1/README.md +280 -0
- angelic_kernel-0.1/angelic-kernel/__init__.py +2 -0
- angelic_kernel-0.1/angelic-kernel/angelic_kernel.py +539 -0
- angelic_kernel-0.1/angelic_kernel.egg-info/PKG-INFO +296 -0
- angelic_kernel-0.1/angelic_kernel.egg-info/SOURCES.txt +9 -0
- angelic_kernel-0.1/angelic_kernel.egg-info/dependency_links.txt +1 -0
- angelic_kernel-0.1/angelic_kernel.egg-info/requires.txt +1 -0
- angelic_kernel-0.1/angelic_kernel.egg-info/top_level.txt +1 -0
- angelic_kernel-0.1/setup.cfg +4 -0
- angelic_kernel-0.1/setup.py +16 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: angelic-kernel
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A fake OS kernel framework for Python
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: ERROR-Xmakernotfound
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: pygame
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: description
|
|
12
|
+
Dynamic: description-content-type
|
|
13
|
+
Dynamic: requires-dist
|
|
14
|
+
Dynamic: requires-python
|
|
15
|
+
Dynamic: summary
|
|
16
|
+
|
|
17
|
+
# Angelic-Kernel
|
|
18
|
+
\
|
|
19
|
+

|
|
20
|
+

|
|
21
|
+

|
|
22
|
+
Have you ever, and I mean EVER wanted to create an OS but then tried to and then thought, "nah, I'll stick to python" but still want to create an OS?
|
|
23
|
+
|
|
24
|
+
Well, you can now, okay, not a **real OS,** however, with Angelic-Kernel you can make a python program that **feels** like one, now lets get right into it!
|
|
25
|
+
|
|
26
|
+
Sections:
|
|
27
|
+
1. [Installation](#installation)
|
|
28
|
+
2. [Documentation](#documentation)
|
|
29
|
+
3. [Versions](#versions)
|
|
30
|
+
|
|
31
|
+
# Installation
|
|
32
|
+
for installing angelic-kernel, use this command.
|
|
33
|
+
```bash
|
|
34
|
+
pip install angelic-kernel
|
|
35
|
+
```
|
|
36
|
+
# Documentation
|
|
37
|
+
Okay, I *really* don't want to write a full documentation, but at the same time I don't want **anyone** to be in the dark and so it makes sense. So this is the entire documentation for all versions, to see specific data about specific versions go to the version section and find the version that you have and click the link. It will take you to the full documentation with everything about that version. Writing these documentations take 3-5 hours depending on how much is in the version, I write them anyway just so people actually understand what's in the version. And inside the documentation you can find; the change log, the tutorial on how to use angelic-kernel, code examples that work for the version and notes. Now, enough talking about what's **in** the documentations lets get right to them!
|
|
38
|
+
## Documentation for 0.1
|
|
39
|
+
Sections:\
|
|
40
|
+
[Change log](#change-log)\
|
|
41
|
+
[Documentation](#documentation-1)\
|
|
42
|
+
[Examples](#examples)\
|
|
43
|
+
[Notes](#notes)
|
|
44
|
+
### Change log
|
|
45
|
+
Created `Kernel` class\
|
|
46
|
+
Created `SD` subclass for the `Kernel` class\
|
|
47
|
+
Created `screen` subclass for the `Kernel` class\
|
|
48
|
+
Created `sound` subclass for the `Kernel` class\
|
|
49
|
+
Created `file_system` subclass for the `Kernel` class
|
|
50
|
+
### Documentation
|
|
51
|
+
Alright, even though this is literally the **first version** of angelic-kernel, it's feature-rich, made with 500+ lines and five main classes, if you took a peek at the change log you should be able to identify which ones; the `Kernel`, `SD`, `screen`, `sound`, and `file_system` classes that each play important roles for our code, lets first start with the `Kernel` class:
|
|
52
|
+
|
|
53
|
+
First lets setup
|
|
54
|
+
```python
|
|
55
|
+
from angelic_kernel import *
|
|
56
|
+
k=Kernel()
|
|
57
|
+
```
|
|
58
|
+
Now hopefully you know what's going on here, but if you don't I'll explain, `from angelic_kernel import *` imports all the classes that I stuffed into this thing, and `k=Kernel()` sets the `k` variable to a `Kernel()` instance, now let's expand it.
|
|
59
|
+
```python
|
|
60
|
+
from angelic_kernel import *
|
|
61
|
+
k=Kernel()
|
|
62
|
+
sd=k.SD()
|
|
63
|
+
sc=k.screen(640,600,sd)
|
|
64
|
+
sound=k.sound(sd)
|
|
65
|
+
fs=k.file_system(sd)
|
|
66
|
+
```
|
|
67
|
+
Now, let's explain each line of new code; `sd=k.SD()` sets the sd variable to a `Kernel.SD` instance, `sc=k.screen(640,600,sd)` sets the sc variable to a `Kernel.screen` instance, the first and second input is the width and height of the screen, the last input is the sd instance we defined earlier, `sound=k.sound(sd)` sets the sound variable to a `Kernel.sound` instance with the only input being the sd instance we defined earlier *see a pattern yet?* `fs=k.file_system(sd)` sets the fs variable to a `Kernel.file_system` instance with the only input being the sd instance we defined earlier
|
|
68
|
+
|
|
69
|
+
Okay, now lets actually get into the classes, we'll skip SD because there's not much in it, and it doesn't really do anything useful other than provide basic SD saving for the other classes *that's why they need it*
|
|
70
|
+
|
|
71
|
+
**sections**:\
|
|
72
|
+
[screen](#screen-class)\
|
|
73
|
+
[sound](#sound-class)\
|
|
74
|
+
[file_system](#file_system-class)
|
|
75
|
+
|
|
76
|
+
### Screen class
|
|
77
|
+
#### Basic info
|
|
78
|
+
The screen class manages a window with APIs for Graphics and GUI, the GUI engine used is pygame, so if you have even basic knowledge of pygame then this should be easy to use. If not, don't worry, I've spent several days making the screen class *WAY* easier than raw pygame so this shouldn't be too bad.
|
|
79
|
+
#### Core commands:
|
|
80
|
+
Core commands are commands that most likely will be used a **LOT** when using the screen class so, lets list them before we go over what they actually do.\
|
|
81
|
+
`clear()`\
|
|
82
|
+
`clear_logs()`\
|
|
83
|
+
`frame()`\
|
|
84
|
+
`events()`\
|
|
85
|
+
`shift()`\
|
|
86
|
+
Alright, now that we got them down, lets go through them one by one and explain what they do.\
|
|
87
|
+
`clear()`: clears the screen; `clear()` has no inputs however originally `clear()` was going to have an input for clearing the text logs, but that idea was scrapped for `clear_logs()`, on that note, `clear()` does **not** clear the text logs *we'll get into more detail about the text logs soon when we talk about `print()`,`input()`, and `set_font()`.*
|
|
88
|
+
|
|
89
|
+
`clear_logs()`: clears the text logs; `clear_logs()` clears the text logs, preventing text from showing up when input is called.
|
|
90
|
+
|
|
91
|
+
`frame()`: displays the next frame; `frame()` does **one** job, display the next frame, when `clear()` is called the current frame says "Nah, I'm out" and disappears, however in order to see the changes you have to call `frame()`, the only input is the tick input which pauses for a bit to keep the frame rate under control and defaults to 60 so the GUI doesn't run at CPU clock speeds *which is around 2.5 GHz and 4.0 GHz by the time I wrote this*
|
|
92
|
+
|
|
93
|
+
`events()`: returns the current event; `events()` does a lot of jobs at once, but all you need to know is what events it returns; when a key is pressed it returns `("keydown",key_name)` with the second output being the key's name, the opposite of this is `("keyup",key_name)` this is returned when a key is released, with the second output being the name of the key, `("mousedown",(mouse_pos_x,mouse_pos_y))` is returned when the mouse clicks inside the window, the second output is a tuple of two values, value 1 being the x position of the mouse and value 2 being the y position of the mouse, `(None,None)` this is returned when None of the events that I listed here happened.
|
|
94
|
+
|
|
95
|
+
`shift()`: returns the shifted equivalent of the inputted key; `shift()` literally just presses shift for you, when you input a shiftable letter, say, "a" for example, it returns "A", which if you've ever typed in all caps when sending a **totally** formal letter to someone you where mad at, you know that the shifted letter of "a" is "A", and if you're a coder, *like me*, your example is if you input "[" it will output "{", just like pressing shift on a keyboard.
|
|
96
|
+
#### Text commands:
|
|
97
|
+
text commands are stuff like `print()` and `input()` but also `set_font()`? yeah, to explain what's going on here, we're going to have to dive in so lets list then explain\
|
|
98
|
+
`set_font()`\
|
|
99
|
+
`print()`\
|
|
100
|
+
`input()`\
|
|
101
|
+
Now time to explain
|
|
102
|
+
|
|
103
|
+
`set_font()`:sets the font; this one surprisingly is simple even though it's one of the commands that I spent over an hour working on, the first input is the mode, it accepts 1 or 2 as an input, if the mode is 1 it sets the font to an external font file *like a .ttf file* if it is set to 2 then it uses a system font *like Arial*. The second input is the font name or the font file name. if you set the mode to 1 previously then set the font input to the name of the font file, note that the font file has to be inside the same folder as your script. if you set the mode to 2 then set the input to the name of the font, note that the name of the font has to be installed on your computer. the last input is the size input, and luckily this one doesn't change depending on the mode, just enter the size that you want the text to be.
|
|
104
|
+
|
|
105
|
+
`print()`: prints onto the screen window; this one literally is pythons `print()` function for the window, the first input is the text, simple, the next two is the x and y position of the text, the next? the color, it's a tuple of three values up to 255, the last two actually are kinda important, the second-to-last one is `add_to_text_log`, which is a bool `True` or `False`. If it's true then it adds the text to the text logs, and it will appear when `input()` is called. if it's false then it won't touch the text logs, the last is really important and **extremely** useful, `blit_surface` sets the blit surface, that's it, *we'll talk about surfaces later...*
|
|
106
|
+
|
|
107
|
+
`input()`: creates a text prompt on the screen window; this one took me five hours to make, and I'm not joking this time, with how much I crammed into this thing it takes up 100+ lines of the file, just to create a basic input function. Anyway enough with the lore of this **extremely** overweight function, lets get into the inputs. The first input is the prompt input, it's just the prompt text, the next is the base_prompt input which sets the base text that appears when you call it. The third and fourth input is the x and y pos of the prompt the fifth input is the color, and the last is the blit surface
|
|
108
|
+
#### Sprite commands:
|
|
109
|
+
This was simple enough to create, and since there's like ten commands here I'm going to try and keep it short, but there's just a lot of important stuff here so... yeah...\
|
|
110
|
+
`add_sprite()`\
|
|
111
|
+
`render_sprites()`\
|
|
112
|
+
`move_sprite()`\
|
|
113
|
+
`set_sprite_pos()`\
|
|
114
|
+
`set_sprite_image()`\
|
|
115
|
+
`kill_sprite()`\
|
|
116
|
+
`sprite_touching_sprite()`\
|
|
117
|
+
`sprite_touching_mouse()`\
|
|
118
|
+
`sprite_click()`\
|
|
119
|
+
`scale_sprite()`\
|
|
120
|
+
Alright time to explain what each of these do *there's so many :(*
|
|
121
|
+
`add_sprite()`: Adds a sprite; the only input is the name of the sprite, remember the name it's important for most of the next commands
|
|
122
|
+
|
|
123
|
+
`render_sprites()`: renders **ALL** sprites; that's it.
|
|
124
|
+
|
|
125
|
+
`move_sprite()`: moves the inputted sprite; this is simple the first input is *of course* the name of the sprite with the second and third input being the x and y *had to rewrite this, fell asleep halfway through writing this hah...*
|
|
126
|
+
|
|
127
|
+
`set_sprite_pos()`: sets the inputted sprite's position; that's literally all this does, the first input is the name of the sprite and the second and third is the x and y of the sprite
|
|
128
|
+
|
|
129
|
+
`set_sprite_image()`: sets the inputted sprite's image; the first input is the name of the sprite and the second is the name of the image file, note that the image must be in the same folder as the script.
|
|
130
|
+
|
|
131
|
+
`kill_sprite()`: "kills" the inputted sprite; don't worry it only deletes the inputted sprite the only input is the name of the sprite
|
|
132
|
+
|
|
133
|
+
`sprite_touching_sprite()`: returns True if the first sprite inputted is touching the second input; in less confusing terms, if the sprite with the name of the first input is touching the sprite with the name of the second input it returns true, else, it returns false
|
|
134
|
+
|
|
135
|
+
`sprite_touching_mouse()`:returns True if the inputted sprite is touching the mouse; that's it the first input is the name of the sprite
|
|
136
|
+
|
|
137
|
+
`sprite_click()`: returns True if the inputted sprite was clicked; that's it, the first input is the name of the sprite the second should be the output of `events()`
|
|
138
|
+
|
|
139
|
+
`scale_sprite()`: scales the inputted sprite; that's it, the first input is the name of the sprite and the second and third is the width and height
|
|
140
|
+
#### Surface commands:
|
|
141
|
+
Okay this one is much shorter than the sprite second, but uh... yeah, it's in the screen class, we have to go over them... *GOD-*\
|
|
142
|
+
`surface()`\
|
|
143
|
+
`render_surfaces()`\
|
|
144
|
+
`surface_click()`\
|
|
145
|
+
`surface_touching_mouse()`\
|
|
146
|
+
`kill_surface()`\
|
|
147
|
+
Alright now the explanation.../
|
|
148
|
+
`surface()`: creates a surface; this one is one of the functions that have too many inputs, so uh, prepare for me to talk for an hour. The first input is the name and the second and third is the x and y position, forth and fifth is width and height and the last is the color, Huh... that actually wasn't so bad...
|
|
149
|
+
|
|
150
|
+
`render_surfaces()`: renders **ALL** surfaces; that's it, no inputs
|
|
151
|
+
|
|
152
|
+
`surface_click()`: returns true if the inputted surface was clicked; the first input is the name of the surface while the second is the event, the event must be the output of the `events()` command
|
|
153
|
+
|
|
154
|
+
`surface_touching_mouse()`: returns true if the inputted surface was touching the mouse; that's it the only input is the name of the surface
|
|
155
|
+
|
|
156
|
+
`kill_surface()`: don't worry it only deletes the surface; the only input is the name of the surface
|
|
157
|
+
#### misc commands:
|
|
158
|
+
these are just some helper commands that don't really belong to a group of commands so they are just misc
|
|
159
|
+
`quit()`\
|
|
160
|
+
`wait()`\
|
|
161
|
+
`set_window_name()`\
|
|
162
|
+
`set_window_icon()`\
|
|
163
|
+
`mouse_down()`\
|
|
164
|
+
`is_held()`\
|
|
165
|
+
`mouse_pos()`\
|
|
166
|
+
now for the explanation
|
|
167
|
+
|
|
168
|
+
`quit()`: exits the program; that's literally it no inputs
|
|
169
|
+
|
|
170
|
+
`wait()`: waits the inputted time; that's it, the only input is the time
|
|
171
|
+
|
|
172
|
+
`set_window_name()`: sets the screen window's name with the input; that's it the only input is the name
|
|
173
|
+
|
|
174
|
+
`set_window_icon()`: sets the window icon to the inputted file; the file must be in the same folder as the script
|
|
175
|
+
|
|
176
|
+
`mouse_down()`: returns true if the mouse is held down; that's it no inputs
|
|
177
|
+
|
|
178
|
+
`is_held()`: returns true if the inputted key is held down; the only input is the name of the key
|
|
179
|
+
|
|
180
|
+
`mouse_pos()`: returns the mouse position; no inputs, but just as a warning, it returns the mouse's position as a tuple
|
|
181
|
+
|
|
182
|
+
wow... that was a lot... and we're not even done, we still have two classes to go...
|
|
183
|
+
|
|
184
|
+
### Sound class
|
|
185
|
+
#### Basic info:
|
|
186
|
+
the sound class is *overly* simple, and currently only has three commands, so lets get into them
|
|
187
|
+
#### All commands:
|
|
188
|
+
Alright lets list the three commands and then explain what they do
|
|
189
|
+
`add_sound()`\
|
|
190
|
+
`play_sound()`\
|
|
191
|
+
`stop()`\
|
|
192
|
+
Alright now for the explanation
|
|
193
|
+
|
|
194
|
+
`add_sound()`: adds a sound to the sound cache; on its own it doesn't play anything, you need to call `play_sound()` for them to play, the only input is the sound input and the sound file has to be in the same folder as the script
|
|
195
|
+
|
|
196
|
+
`play_sound()`: plays the inputted sound; it only plays the sound if it was in the sound cache, if it's not then nothing will happen.
|
|
197
|
+
|
|
198
|
+
`stop()`: stops the inputted sound; the sound must be in the sound cache, if not then it won't do anything
|
|
199
|
+
|
|
200
|
+
Alright that's all for the Sound class. Now it's time for the last one, the file_system class, which with how *BIG* it is it's probably competing with the screen class in terms of how much does it take up the file!
|
|
201
|
+
|
|
202
|
+
### File_system class
|
|
203
|
+
#### Basic info:
|
|
204
|
+
There's a lot in this one. And even though most of the commands are **microscopic** and easy to explain, there's a **LOT** of them and I mean **25+** commands and even though the screen class has more commands *30 commands by the way* there's just a **LOT** but uh... yeah... I have to go through them...
|
|
205
|
+
#### Useful Tools:
|
|
206
|
+
These are some Useful tools and yeah, they help a **LOT**. Anyway, lets get into them\
|
|
207
|
+
`set_root()`\
|
|
208
|
+
`goto()`\
|
|
209
|
+
`back()`\
|
|
210
|
+
`list_dir()`\
|
|
211
|
+
`current_path()`\
|
|
212
|
+
Alright lets explain what these do
|
|
213
|
+
|
|
214
|
+
`set_root()`: sets the root for the file system; the input is a list, for example if the root is C/Users/User1/Home, then the input would be `["C","Users","User1","Home"]`, and here's a few notes about this though, the paths have to exist, or it will raise a `PathError`, when you set the root you **Cannot go back farther than the root** that's the entire reason the root exists!
|
|
215
|
+
|
|
216
|
+
`goto()`: goes to the inputted path; if the path doesn't exist, is protected, hidden, a file, or the TypeID identifier it will raise Errors, the only input is the path
|
|
217
|
+
|
|
218
|
+
`back()`: goes back to the last path; if the path is at the root then it says "Nah, can't go back farther", and raises a PathError
|
|
219
|
+
|
|
220
|
+
`list_dir()`: lists the current directory; it skips over Type Identifiers, protected dirs, and hidden dirs
|
|
221
|
+
|
|
222
|
+
`current_path()`: returns the current path; that's literally it.
|
|
223
|
+
#### "Make" Tools:
|
|
224
|
+
these basically are just functions that make paths, that's basically all they do, now lets list them and then explain them:\
|
|
225
|
+
`make_dir()`\
|
|
226
|
+
`make_file()`\
|
|
227
|
+
`make_protected()`\
|
|
228
|
+
`make_hidden()`\
|
|
229
|
+
now let's explain them, *this is taking WAY to long, it's been 4+ hours :(*
|
|
230
|
+
`make_dir()`:makes a dir; the only input is the name, just as a disclaimer, the name shouldn't already exist, or it will throw Errors
|
|
231
|
+
`make_file()`: makes a file; the three inputs are the name, the file_type, and the data, the path shouldn't already exist, or it will throw Errors
|
|
232
|
+
`make_protected()`: make a protected path; the only input is the name, and the name shouldn't already exist
|
|
233
|
+
`make_hidden()`: makes a hidden path; the only input is the name, and the name shouldn't already exist
|
|
234
|
+
#### "delete" Tools:
|
|
235
|
+
These tools delete stuff, couldn't be simpler *well, maybe it could if there weren't so many of them AGH*\
|
|
236
|
+
`delete_dir()`\
|
|
237
|
+
`delete_file()`\
|
|
238
|
+
`delete_protected()`\
|
|
239
|
+
`delete_hidden()`\
|
|
240
|
+
Alright now time to explain them...
|
|
241
|
+
`delete_dir()`: deletes the inputted dir; that's it the only input is the name and the dir has to already exist
|
|
242
|
+
|
|
243
|
+
`delete_file()`: deletes the inputted file; the only input is the file name and the file has to already exist
|
|
244
|
+
|
|
245
|
+
`delete_protected()`: deletes the inputted protected path; this one is different from the others, yes, it still has the name input as the first input, but there's also the force input and if you don't set it to True then it's going to raise a PermissionError
|
|
246
|
+
|
|
247
|
+
`delete_hidden()`: deletes the inputted hidden path, that's it the path has to exist and has to be hidden
|
|
248
|
+
#### "Check" Tools:
|
|
249
|
+
these functions check for stuff, good if you don't want your code to be littered with `try` and `except` functions
|
|
250
|
+
`path_exists()`\
|
|
251
|
+
`path_is_dir()`\
|
|
252
|
+
`path_is_file()`\
|
|
253
|
+
`path_is_protected()`\
|
|
254
|
+
`path_is_hidden()`\
|
|
255
|
+
`file_is_type()`\
|
|
256
|
+
`is_root()`\
|
|
257
|
+
Wow.... There's a lot here...
|
|
258
|
+
`path_exists()`: returns true if the inputted path exists; that's it
|
|
259
|
+
|
|
260
|
+
`path_is_dir()`: returns true if the inputted path is a dir; that's it
|
|
261
|
+
|
|
262
|
+
`path_is_file()`: returns true if the inputted path is a file; that's it
|
|
263
|
+
|
|
264
|
+
`path_is_protected()`: returns true if the inputted path is protected; that's it
|
|
265
|
+
|
|
266
|
+
`file_is_type()`: returns true if the inputted file is the second input which is the file type; that's it
|
|
267
|
+
|
|
268
|
+
`is_root()`: returns true if the path is at the set root; that's it
|
|
269
|
+
#### "Open" Tools:
|
|
270
|
+
These tools open files, however I'm going to tell you here *so I can save you time* **the files must exist or all of the functions will raise errors**\
|
|
271
|
+
`open_file()`\
|
|
272
|
+
`open_protected()`\
|
|
273
|
+
`open_hidden()`\
|
|
274
|
+
Alright now to explain\
|
|
275
|
+
`open_file()`: returns the data of the inputted file; the only input is the file name,
|
|
276
|
+
|
|
277
|
+
`open_protected()`: returns the data of the protected path; the only input is the path name
|
|
278
|
+
|
|
279
|
+
`open_hidden()`: returns the data of a hidden path, the only name is the name of the path
|
|
280
|
+
#### "modify" Tools:
|
|
281
|
+
Alright, I'm on the brink of falling asleep, but luckily for me, we only have two commands here
|
|
282
|
+
`modify_hidden()`\
|
|
283
|
+
`modify_file()`\
|
|
284
|
+
Alright now to explain\
|
|
285
|
+
`modify_hidden()`: modifies a hidden path, the first input is the name and the second is the key you want to modify, and the last is just the value, the hidden path must exist for it will raise an Error
|
|
286
|
+
|
|
287
|
+
`modify_file()`: modifies a file, the first input is the name the second is the key you want to modify and the last is the value you want to set it to, the file must exist, or it raises an Error
|
|
288
|
+
### Examples
|
|
289
|
+
*Experimenting, come back in a later update...*
|
|
290
|
+
### Notes
|
|
291
|
+
*none lol*
|
|
292
|
+
|
|
293
|
+
# Versions
|
|
294
|
+
*disclaimer; these dates are in the MM/DD/YYYY format*
|
|
295
|
+
|
|
296
|
+
0.1: \[3/7/2026\] Release date. [Version Documentation](#documentation-for-01)
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Angelic-Kernel
|
|
2
|
+
\
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
Have you ever, and I mean EVER wanted to create an OS but then tried to and then thought, "nah, I'll stick to python" but still want to create an OS?
|
|
7
|
+
|
|
8
|
+
Well, you can now, okay, not a **real OS,** however, with Angelic-Kernel you can make a python program that **feels** like one, now lets get right into it!
|
|
9
|
+
|
|
10
|
+
Sections:
|
|
11
|
+
1. [Installation](#installation)
|
|
12
|
+
2. [Documentation](#documentation)
|
|
13
|
+
3. [Versions](#versions)
|
|
14
|
+
|
|
15
|
+
# Installation
|
|
16
|
+
for installing angelic-kernel, use this command.
|
|
17
|
+
```bash
|
|
18
|
+
pip install angelic-kernel
|
|
19
|
+
```
|
|
20
|
+
# Documentation
|
|
21
|
+
Okay, I *really* don't want to write a full documentation, but at the same time I don't want **anyone** to be in the dark and so it makes sense. So this is the entire documentation for all versions, to see specific data about specific versions go to the version section and find the version that you have and click the link. It will take you to the full documentation with everything about that version. Writing these documentations take 3-5 hours depending on how much is in the version, I write them anyway just so people actually understand what's in the version. And inside the documentation you can find; the change log, the tutorial on how to use angelic-kernel, code examples that work for the version and notes. Now, enough talking about what's **in** the documentations lets get right to them!
|
|
22
|
+
## Documentation for 0.1
|
|
23
|
+
Sections:\
|
|
24
|
+
[Change log](#change-log)\
|
|
25
|
+
[Documentation](#documentation-1)\
|
|
26
|
+
[Examples](#examples)\
|
|
27
|
+
[Notes](#notes)
|
|
28
|
+
### Change log
|
|
29
|
+
Created `Kernel` class\
|
|
30
|
+
Created `SD` subclass for the `Kernel` class\
|
|
31
|
+
Created `screen` subclass for the `Kernel` class\
|
|
32
|
+
Created `sound` subclass for the `Kernel` class\
|
|
33
|
+
Created `file_system` subclass for the `Kernel` class
|
|
34
|
+
### Documentation
|
|
35
|
+
Alright, even though this is literally the **first version** of angelic-kernel, it's feature-rich, made with 500+ lines and five main classes, if you took a peek at the change log you should be able to identify which ones; the `Kernel`, `SD`, `screen`, `sound`, and `file_system` classes that each play important roles for our code, lets first start with the `Kernel` class:
|
|
36
|
+
|
|
37
|
+
First lets setup
|
|
38
|
+
```python
|
|
39
|
+
from angelic_kernel import *
|
|
40
|
+
k=Kernel()
|
|
41
|
+
```
|
|
42
|
+
Now hopefully you know what's going on here, but if you don't I'll explain, `from angelic_kernel import *` imports all the classes that I stuffed into this thing, and `k=Kernel()` sets the `k` variable to a `Kernel()` instance, now let's expand it.
|
|
43
|
+
```python
|
|
44
|
+
from angelic_kernel import *
|
|
45
|
+
k=Kernel()
|
|
46
|
+
sd=k.SD()
|
|
47
|
+
sc=k.screen(640,600,sd)
|
|
48
|
+
sound=k.sound(sd)
|
|
49
|
+
fs=k.file_system(sd)
|
|
50
|
+
```
|
|
51
|
+
Now, let's explain each line of new code; `sd=k.SD()` sets the sd variable to a `Kernel.SD` instance, `sc=k.screen(640,600,sd)` sets the sc variable to a `Kernel.screen` instance, the first and second input is the width and height of the screen, the last input is the sd instance we defined earlier, `sound=k.sound(sd)` sets the sound variable to a `Kernel.sound` instance with the only input being the sd instance we defined earlier *see a pattern yet?* `fs=k.file_system(sd)` sets the fs variable to a `Kernel.file_system` instance with the only input being the sd instance we defined earlier
|
|
52
|
+
|
|
53
|
+
Okay, now lets actually get into the classes, we'll skip SD because there's not much in it, and it doesn't really do anything useful other than provide basic SD saving for the other classes *that's why they need it*
|
|
54
|
+
|
|
55
|
+
**sections**:\
|
|
56
|
+
[screen](#screen-class)\
|
|
57
|
+
[sound](#sound-class)\
|
|
58
|
+
[file_system](#file_system-class)
|
|
59
|
+
|
|
60
|
+
### Screen class
|
|
61
|
+
#### Basic info
|
|
62
|
+
The screen class manages a window with APIs for Graphics and GUI, the GUI engine used is pygame, so if you have even basic knowledge of pygame then this should be easy to use. If not, don't worry, I've spent several days making the screen class *WAY* easier than raw pygame so this shouldn't be too bad.
|
|
63
|
+
#### Core commands:
|
|
64
|
+
Core commands are commands that most likely will be used a **LOT** when using the screen class so, lets list them before we go over what they actually do.\
|
|
65
|
+
`clear()`\
|
|
66
|
+
`clear_logs()`\
|
|
67
|
+
`frame()`\
|
|
68
|
+
`events()`\
|
|
69
|
+
`shift()`\
|
|
70
|
+
Alright, now that we got them down, lets go through them one by one and explain what they do.\
|
|
71
|
+
`clear()`: clears the screen; `clear()` has no inputs however originally `clear()` was going to have an input for clearing the text logs, but that idea was scrapped for `clear_logs()`, on that note, `clear()` does **not** clear the text logs *we'll get into more detail about the text logs soon when we talk about `print()`,`input()`, and `set_font()`.*
|
|
72
|
+
|
|
73
|
+
`clear_logs()`: clears the text logs; `clear_logs()` clears the text logs, preventing text from showing up when input is called.
|
|
74
|
+
|
|
75
|
+
`frame()`: displays the next frame; `frame()` does **one** job, display the next frame, when `clear()` is called the current frame says "Nah, I'm out" and disappears, however in order to see the changes you have to call `frame()`, the only input is the tick input which pauses for a bit to keep the frame rate under control and defaults to 60 so the GUI doesn't run at CPU clock speeds *which is around 2.5 GHz and 4.0 GHz by the time I wrote this*
|
|
76
|
+
|
|
77
|
+
`events()`: returns the current event; `events()` does a lot of jobs at once, but all you need to know is what events it returns; when a key is pressed it returns `("keydown",key_name)` with the second output being the key's name, the opposite of this is `("keyup",key_name)` this is returned when a key is released, with the second output being the name of the key, `("mousedown",(mouse_pos_x,mouse_pos_y))` is returned when the mouse clicks inside the window, the second output is a tuple of two values, value 1 being the x position of the mouse and value 2 being the y position of the mouse, `(None,None)` this is returned when None of the events that I listed here happened.
|
|
78
|
+
|
|
79
|
+
`shift()`: returns the shifted equivalent of the inputted key; `shift()` literally just presses shift for you, when you input a shiftable letter, say, "a" for example, it returns "A", which if you've ever typed in all caps when sending a **totally** formal letter to someone you where mad at, you know that the shifted letter of "a" is "A", and if you're a coder, *like me*, your example is if you input "[" it will output "{", just like pressing shift on a keyboard.
|
|
80
|
+
#### Text commands:
|
|
81
|
+
text commands are stuff like `print()` and `input()` but also `set_font()`? yeah, to explain what's going on here, we're going to have to dive in so lets list then explain\
|
|
82
|
+
`set_font()`\
|
|
83
|
+
`print()`\
|
|
84
|
+
`input()`\
|
|
85
|
+
Now time to explain
|
|
86
|
+
|
|
87
|
+
`set_font()`:sets the font; this one surprisingly is simple even though it's one of the commands that I spent over an hour working on, the first input is the mode, it accepts 1 or 2 as an input, if the mode is 1 it sets the font to an external font file *like a .ttf file* if it is set to 2 then it uses a system font *like Arial*. The second input is the font name or the font file name. if you set the mode to 1 previously then set the font input to the name of the font file, note that the font file has to be inside the same folder as your script. if you set the mode to 2 then set the input to the name of the font, note that the name of the font has to be installed on your computer. the last input is the size input, and luckily this one doesn't change depending on the mode, just enter the size that you want the text to be.
|
|
88
|
+
|
|
89
|
+
`print()`: prints onto the screen window; this one literally is pythons `print()` function for the window, the first input is the text, simple, the next two is the x and y position of the text, the next? the color, it's a tuple of three values up to 255, the last two actually are kinda important, the second-to-last one is `add_to_text_log`, which is a bool `True` or `False`. If it's true then it adds the text to the text logs, and it will appear when `input()` is called. if it's false then it won't touch the text logs, the last is really important and **extremely** useful, `blit_surface` sets the blit surface, that's it, *we'll talk about surfaces later...*
|
|
90
|
+
|
|
91
|
+
`input()`: creates a text prompt on the screen window; this one took me five hours to make, and I'm not joking this time, with how much I crammed into this thing it takes up 100+ lines of the file, just to create a basic input function. Anyway enough with the lore of this **extremely** overweight function, lets get into the inputs. The first input is the prompt input, it's just the prompt text, the next is the base_prompt input which sets the base text that appears when you call it. The third and fourth input is the x and y pos of the prompt the fifth input is the color, and the last is the blit surface
|
|
92
|
+
#### Sprite commands:
|
|
93
|
+
This was simple enough to create, and since there's like ten commands here I'm going to try and keep it short, but there's just a lot of important stuff here so... yeah...\
|
|
94
|
+
`add_sprite()`\
|
|
95
|
+
`render_sprites()`\
|
|
96
|
+
`move_sprite()`\
|
|
97
|
+
`set_sprite_pos()`\
|
|
98
|
+
`set_sprite_image()`\
|
|
99
|
+
`kill_sprite()`\
|
|
100
|
+
`sprite_touching_sprite()`\
|
|
101
|
+
`sprite_touching_mouse()`\
|
|
102
|
+
`sprite_click()`\
|
|
103
|
+
`scale_sprite()`\
|
|
104
|
+
Alright time to explain what each of these do *there's so many :(*
|
|
105
|
+
`add_sprite()`: Adds a sprite; the only input is the name of the sprite, remember the name it's important for most of the next commands
|
|
106
|
+
|
|
107
|
+
`render_sprites()`: renders **ALL** sprites; that's it.
|
|
108
|
+
|
|
109
|
+
`move_sprite()`: moves the inputted sprite; this is simple the first input is *of course* the name of the sprite with the second and third input being the x and y *had to rewrite this, fell asleep halfway through writing this hah...*
|
|
110
|
+
|
|
111
|
+
`set_sprite_pos()`: sets the inputted sprite's position; that's literally all this does, the first input is the name of the sprite and the second and third is the x and y of the sprite
|
|
112
|
+
|
|
113
|
+
`set_sprite_image()`: sets the inputted sprite's image; the first input is the name of the sprite and the second is the name of the image file, note that the image must be in the same folder as the script.
|
|
114
|
+
|
|
115
|
+
`kill_sprite()`: "kills" the inputted sprite; don't worry it only deletes the inputted sprite the only input is the name of the sprite
|
|
116
|
+
|
|
117
|
+
`sprite_touching_sprite()`: returns True if the first sprite inputted is touching the second input; in less confusing terms, if the sprite with the name of the first input is touching the sprite with the name of the second input it returns true, else, it returns false
|
|
118
|
+
|
|
119
|
+
`sprite_touching_mouse()`:returns True if the inputted sprite is touching the mouse; that's it the first input is the name of the sprite
|
|
120
|
+
|
|
121
|
+
`sprite_click()`: returns True if the inputted sprite was clicked; that's it, the first input is the name of the sprite the second should be the output of `events()`
|
|
122
|
+
|
|
123
|
+
`scale_sprite()`: scales the inputted sprite; that's it, the first input is the name of the sprite and the second and third is the width and height
|
|
124
|
+
#### Surface commands:
|
|
125
|
+
Okay this one is much shorter than the sprite second, but uh... yeah, it's in the screen class, we have to go over them... *GOD-*\
|
|
126
|
+
`surface()`\
|
|
127
|
+
`render_surfaces()`\
|
|
128
|
+
`surface_click()`\
|
|
129
|
+
`surface_touching_mouse()`\
|
|
130
|
+
`kill_surface()`\
|
|
131
|
+
Alright now the explanation.../
|
|
132
|
+
`surface()`: creates a surface; this one is one of the functions that have too many inputs, so uh, prepare for me to talk for an hour. The first input is the name and the second and third is the x and y position, forth and fifth is width and height and the last is the color, Huh... that actually wasn't so bad...
|
|
133
|
+
|
|
134
|
+
`render_surfaces()`: renders **ALL** surfaces; that's it, no inputs
|
|
135
|
+
|
|
136
|
+
`surface_click()`: returns true if the inputted surface was clicked; the first input is the name of the surface while the second is the event, the event must be the output of the `events()` command
|
|
137
|
+
|
|
138
|
+
`surface_touching_mouse()`: returns true if the inputted surface was touching the mouse; that's it the only input is the name of the surface
|
|
139
|
+
|
|
140
|
+
`kill_surface()`: don't worry it only deletes the surface; the only input is the name of the surface
|
|
141
|
+
#### misc commands:
|
|
142
|
+
these are just some helper commands that don't really belong to a group of commands so they are just misc
|
|
143
|
+
`quit()`\
|
|
144
|
+
`wait()`\
|
|
145
|
+
`set_window_name()`\
|
|
146
|
+
`set_window_icon()`\
|
|
147
|
+
`mouse_down()`\
|
|
148
|
+
`is_held()`\
|
|
149
|
+
`mouse_pos()`\
|
|
150
|
+
now for the explanation
|
|
151
|
+
|
|
152
|
+
`quit()`: exits the program; that's literally it no inputs
|
|
153
|
+
|
|
154
|
+
`wait()`: waits the inputted time; that's it, the only input is the time
|
|
155
|
+
|
|
156
|
+
`set_window_name()`: sets the screen window's name with the input; that's it the only input is the name
|
|
157
|
+
|
|
158
|
+
`set_window_icon()`: sets the window icon to the inputted file; the file must be in the same folder as the script
|
|
159
|
+
|
|
160
|
+
`mouse_down()`: returns true if the mouse is held down; that's it no inputs
|
|
161
|
+
|
|
162
|
+
`is_held()`: returns true if the inputted key is held down; the only input is the name of the key
|
|
163
|
+
|
|
164
|
+
`mouse_pos()`: returns the mouse position; no inputs, but just as a warning, it returns the mouse's position as a tuple
|
|
165
|
+
|
|
166
|
+
wow... that was a lot... and we're not even done, we still have two classes to go...
|
|
167
|
+
|
|
168
|
+
### Sound class
|
|
169
|
+
#### Basic info:
|
|
170
|
+
the sound class is *overly* simple, and currently only has three commands, so lets get into them
|
|
171
|
+
#### All commands:
|
|
172
|
+
Alright lets list the three commands and then explain what they do
|
|
173
|
+
`add_sound()`\
|
|
174
|
+
`play_sound()`\
|
|
175
|
+
`stop()`\
|
|
176
|
+
Alright now for the explanation
|
|
177
|
+
|
|
178
|
+
`add_sound()`: adds a sound to the sound cache; on its own it doesn't play anything, you need to call `play_sound()` for them to play, the only input is the sound input and the sound file has to be in the same folder as the script
|
|
179
|
+
|
|
180
|
+
`play_sound()`: plays the inputted sound; it only plays the sound if it was in the sound cache, if it's not then nothing will happen.
|
|
181
|
+
|
|
182
|
+
`stop()`: stops the inputted sound; the sound must be in the sound cache, if not then it won't do anything
|
|
183
|
+
|
|
184
|
+
Alright that's all for the Sound class. Now it's time for the last one, the file_system class, which with how *BIG* it is it's probably competing with the screen class in terms of how much does it take up the file!
|
|
185
|
+
|
|
186
|
+
### File_system class
|
|
187
|
+
#### Basic info:
|
|
188
|
+
There's a lot in this one. And even though most of the commands are **microscopic** and easy to explain, there's a **LOT** of them and I mean **25+** commands and even though the screen class has more commands *30 commands by the way* there's just a **LOT** but uh... yeah... I have to go through them...
|
|
189
|
+
#### Useful Tools:
|
|
190
|
+
These are some Useful tools and yeah, they help a **LOT**. Anyway, lets get into them\
|
|
191
|
+
`set_root()`\
|
|
192
|
+
`goto()`\
|
|
193
|
+
`back()`\
|
|
194
|
+
`list_dir()`\
|
|
195
|
+
`current_path()`\
|
|
196
|
+
Alright lets explain what these do
|
|
197
|
+
|
|
198
|
+
`set_root()`: sets the root for the file system; the input is a list, for example if the root is C/Users/User1/Home, then the input would be `["C","Users","User1","Home"]`, and here's a few notes about this though, the paths have to exist, or it will raise a `PathError`, when you set the root you **Cannot go back farther than the root** that's the entire reason the root exists!
|
|
199
|
+
|
|
200
|
+
`goto()`: goes to the inputted path; if the path doesn't exist, is protected, hidden, a file, or the TypeID identifier it will raise Errors, the only input is the path
|
|
201
|
+
|
|
202
|
+
`back()`: goes back to the last path; if the path is at the root then it says "Nah, can't go back farther", and raises a PathError
|
|
203
|
+
|
|
204
|
+
`list_dir()`: lists the current directory; it skips over Type Identifiers, protected dirs, and hidden dirs
|
|
205
|
+
|
|
206
|
+
`current_path()`: returns the current path; that's literally it.
|
|
207
|
+
#### "Make" Tools:
|
|
208
|
+
these basically are just functions that make paths, that's basically all they do, now lets list them and then explain them:\
|
|
209
|
+
`make_dir()`\
|
|
210
|
+
`make_file()`\
|
|
211
|
+
`make_protected()`\
|
|
212
|
+
`make_hidden()`\
|
|
213
|
+
now let's explain them, *this is taking WAY to long, it's been 4+ hours :(*
|
|
214
|
+
`make_dir()`:makes a dir; the only input is the name, just as a disclaimer, the name shouldn't already exist, or it will throw Errors
|
|
215
|
+
`make_file()`: makes a file; the three inputs are the name, the file_type, and the data, the path shouldn't already exist, or it will throw Errors
|
|
216
|
+
`make_protected()`: make a protected path; the only input is the name, and the name shouldn't already exist
|
|
217
|
+
`make_hidden()`: makes a hidden path; the only input is the name, and the name shouldn't already exist
|
|
218
|
+
#### "delete" Tools:
|
|
219
|
+
These tools delete stuff, couldn't be simpler *well, maybe it could if there weren't so many of them AGH*\
|
|
220
|
+
`delete_dir()`\
|
|
221
|
+
`delete_file()`\
|
|
222
|
+
`delete_protected()`\
|
|
223
|
+
`delete_hidden()`\
|
|
224
|
+
Alright now time to explain them...
|
|
225
|
+
`delete_dir()`: deletes the inputted dir; that's it the only input is the name and the dir has to already exist
|
|
226
|
+
|
|
227
|
+
`delete_file()`: deletes the inputted file; the only input is the file name and the file has to already exist
|
|
228
|
+
|
|
229
|
+
`delete_protected()`: deletes the inputted protected path; this one is different from the others, yes, it still has the name input as the first input, but there's also the force input and if you don't set it to True then it's going to raise a PermissionError
|
|
230
|
+
|
|
231
|
+
`delete_hidden()`: deletes the inputted hidden path, that's it the path has to exist and has to be hidden
|
|
232
|
+
#### "Check" Tools:
|
|
233
|
+
these functions check for stuff, good if you don't want your code to be littered with `try` and `except` functions
|
|
234
|
+
`path_exists()`\
|
|
235
|
+
`path_is_dir()`\
|
|
236
|
+
`path_is_file()`\
|
|
237
|
+
`path_is_protected()`\
|
|
238
|
+
`path_is_hidden()`\
|
|
239
|
+
`file_is_type()`\
|
|
240
|
+
`is_root()`\
|
|
241
|
+
Wow.... There's a lot here...
|
|
242
|
+
`path_exists()`: returns true if the inputted path exists; that's it
|
|
243
|
+
|
|
244
|
+
`path_is_dir()`: returns true if the inputted path is a dir; that's it
|
|
245
|
+
|
|
246
|
+
`path_is_file()`: returns true if the inputted path is a file; that's it
|
|
247
|
+
|
|
248
|
+
`path_is_protected()`: returns true if the inputted path is protected; that's it
|
|
249
|
+
|
|
250
|
+
`file_is_type()`: returns true if the inputted file is the second input which is the file type; that's it
|
|
251
|
+
|
|
252
|
+
`is_root()`: returns true if the path is at the set root; that's it
|
|
253
|
+
#### "Open" Tools:
|
|
254
|
+
These tools open files, however I'm going to tell you here *so I can save you time* **the files must exist or all of the functions will raise errors**\
|
|
255
|
+
`open_file()`\
|
|
256
|
+
`open_protected()`\
|
|
257
|
+
`open_hidden()`\
|
|
258
|
+
Alright now to explain\
|
|
259
|
+
`open_file()`: returns the data of the inputted file; the only input is the file name,
|
|
260
|
+
|
|
261
|
+
`open_protected()`: returns the data of the protected path; the only input is the path name
|
|
262
|
+
|
|
263
|
+
`open_hidden()`: returns the data of a hidden path, the only name is the name of the path
|
|
264
|
+
#### "modify" Tools:
|
|
265
|
+
Alright, I'm on the brink of falling asleep, but luckily for me, we only have two commands here
|
|
266
|
+
`modify_hidden()`\
|
|
267
|
+
`modify_file()`\
|
|
268
|
+
Alright now to explain\
|
|
269
|
+
`modify_hidden()`: modifies a hidden path, the first input is the name and the second is the key you want to modify, and the last is just the value, the hidden path must exist for it will raise an Error
|
|
270
|
+
|
|
271
|
+
`modify_file()`: modifies a file, the first input is the name the second is the key you want to modify and the last is the value you want to set it to, the file must exist, or it raises an Error
|
|
272
|
+
### Examples
|
|
273
|
+
*Experimenting, come back in a later update...*
|
|
274
|
+
### Notes
|
|
275
|
+
*none lol*
|
|
276
|
+
|
|
277
|
+
# Versions
|
|
278
|
+
*disclaimer; these dates are in the MM/DD/YYYY format*
|
|
279
|
+
|
|
280
|
+
0.1: \[3/7/2026\] Release date. [Version Documentation](#documentation-for-01)
|