sfnf-emo123 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.
@@ -0,0 +1,399 @@
1
+ Metadata-Version: 2.4
2
+ Name: sfnf_emo123
3
+ Version: 0.1.0
4
+ Summary: It's a bit useful but not useful and strictly doesn't follow PEP8 garbage.
5
+ Author: EMO_123
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: requests>=2.25.0
10
+
11
+ # sp-lib
12
+ ###### There are a lot of dirty words in this section. If you can't stand it, please quit immediately
13
+
14
+ This is a joke library that is extremely non-compliant with PEP8.
15
+ I admit it has some use, but:
16
+
17
+ **Do not use it in production environment**
18
+ **Please make sure you can tolerate this library, and won't die on the spot.**
19
+ **FuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckIt**
20
+
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install sp-lib
28
+ ```
29
+ ## Usage
30
+
31
+ ```python
32
+ # Note: Use underscore instead of hyphen when importing.
33
+ from sp_lib import sp
34
+ with sp.OpenFold(".") as fd:
35
+ ...
36
+ ```
37
+
38
+ ## Polite Mode (Optional)
39
+
40
+ ```python
41
+ from please import *
42
+ print("Be polite!", please=True)
43
+ ```
44
+
45
+ ## sp-print
46
+ Your current output can now have colors.
47
+ ```python
48
+ sp.print("Red text",color=1)
49
+ ```
50
+
51
+ ```python
52
+ sp.print("Red background",color2=1)
53
+ ```
54
+
55
+ ```python
56
+ sp.print("white background and black text",color=0,color2=7)
57
+ ```
58
+
59
+ ## sp-help
60
+ This is bullshit.
61
+ Return the translated \_\_doc\_\_
62
+ ```python
63
+ print(sp.help(input,"zh"))
64
+ ```
65
+
66
+ ## sp-ges (Go Empty String)
67
+
68
+ A string filter that removes specified characters.
69
+ **The name is a joke. The function is actually useful.**
70
+
71
+ ```python
72
+ # Remove all 'l' and 'o' from the string
73
+ result = sp.ges("hello world", "l", "o")
74
+ print(result) # "he wrd"
75
+
76
+ # Remove all vowels
77
+ result = sp.ges("fuckit", "f", "u", "c", "k", "i", "t")
78
+ print(result) # "" (empty!)
79
+
80
+ # Remove multiple characters
81
+ text = "sp_lib is awesome!"
82
+ cleaned = sp.ges(text, " ", "!", "s") # "p_libiwaome"
83
+ ```
84
+
85
+ **Warning:** The name stands for "**G**o **E**mpty **S**tring", not what you think.
86
+ Or is it? 😏
87
+
88
+ ## sp-exit
89
+ 13 exceptions... No, that's like 14
90
+ ```python
91
+ sp.exit() # fuckit
92
+ ```
93
+
94
+ ## sp-getfold
95
+ Get all contents of a folder
96
+ ```python
97
+ print(sp.getfold("."))
98
+ ```
99
+
100
+ ## sp-getfile
101
+ get a file information
102
+ ```python
103
+ print(sp.getfile("I don't know what to put so I just put a random file name.txt")["name"])
104
+ ```
105
+
106
+ ## sp-get fold all file
107
+ ###### The name is too long, so I abbreviated it to gfaf.
108
+ Get all files in a folder as sp\.Open, when lazy=True, return the path.
109
+ ```python
110
+ print(sp.gfaf(".",lazy=True))
111
+ ```
112
+
113
+ ## sp-fuck off
114
+ Don't say dirty words.
115
+ ```python
116
+ sp.fuck_off()
117
+ ```
118
+ ## sp-json
119
+ Why do I have to imitate the style of open()? Oh my god, I'm about to cry, I'm so helpless, oh oh oh oh oh oh no no no no no, after I finish writing this thing, all I see in my eyes are if, elif, else, raise fuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckit
120
+ ```python
121
+ sp.json("d",data=["data"])#return json string
122
+ sp.json("df","./test.json",[data])#Directly put the generated JSON into a file, which can be sp.Open or a path.
123
+ sp.json("l",data="[data]")#load
124
+ sp.json("lf","./test.json")#load from file,can be path or sp.Open
125
+ ```
126
+
127
+ ## sp-Open
128
+ Trash version open(), but don't need close() and default to UTF-8 and can use be open()
129
+ ```python
130
+ f = sp.Open("a.txt","w")
131
+ f.write("fuckit").add("fuckit").add("fuckit")
132
+ with sp.Open("b.txt","w",encoding="utf-8") as f2:
133
+ f2.write("fuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckit")
134
+ ```
135
+
136
+ ## sp-OpenFold
137
+ Context manager for folder operations, with file listing and subfolder navigation.
138
+
139
+ ```python
140
+ with sp.OpenFold(".") as folder:
141
+ # Get all files
142
+ files = folder.getall("file")
143
+ print(files)
144
+
145
+ # Get all subfolders
146
+ folders = folder.getall("fold")
147
+ print(folders)
148
+
149
+ # Get files with specific extension
150
+ py_files = folder.getall("file", just=".py")
151
+
152
+ # Open a file in this folder
153
+ f = folder.openfile("test.txt", "r")
154
+ content = f.read()
155
+
156
+ # Navigate to subfolder
157
+ folder.gotofold("subfolder")
158
+ print(folder.files) # Now in subfolder
159
+ ```
160
+ ## sp\.Turn & sp\.ctext
161
+
162
+ A simple text substitution cipher system. Define a mapping dictionary, then encrypt/decrypt text with `do()` and `undo()`.
163
+
164
+ ### Basic Usage
165
+
166
+ ```python
167
+ # Direct mapping
168
+ turn = sp.Turn({"a": "z", "b": "y"})
169
+ encrypted = turn.do("ab") # "zy"
170
+ decrypted = turn.undo("zy") # "ab"
171
+ ```
172
+
173
+ ### Using Presets (sp\.ctext subclasses)
174
+
175
+ ```python
176
+ # ROT-13 (Caesar cipher, shift by 13)
177
+ from sp_lib import ROT
178
+ turn = sp.Turn(__ctext__=ROT(13))
179
+ print(turn.do("Hello World!")) # Uryyb Jbeyq!
180
+
181
+ # Atbash cipher (a↔z, b↔y, c↔x ...)
182
+ from sp_lib import Atbash
183
+ turn = sp.Turn(__ctext__=Atbash())
184
+ print(turn.do("Hello")) # Svool
185
+ ```
186
+
187
+ ### Chain Operations
188
+
189
+ ```python
190
+ turn = sp.Turn({"a": "b", "c": "d"})
191
+ turn.add(e="f", g="h") # Add multiple mappings
192
+ turn.kill("a") # Remove mapping for 'a'
193
+ turn += {"x": "y"} # Use += to merge
194
+ turn -= ["c"] # Use -= to remove keys
195
+ ```
196
+
197
+ ### Read from JSON File
198
+
199
+ ```python
200
+ # Save mapping to JSON first, then load
201
+ turn.read("mapping.json")
202
+ ```
203
+
204
+ ### Create Your Own Preset
205
+
206
+ ```python
207
+ class MyCipher(sp.ctext):
208
+ def __init__(self):
209
+ self.c = {
210
+ "a": "m",
211
+ "b": "n",
212
+ "c": "o",
213
+ # your mapping here...
214
+ }
215
+
216
+ turn = sp.Turn(__ctext__=MyCipher())
217
+ ```
218
+
219
+ ### Advanced: JSON + Cipher Combo
220
+
221
+ ```python
222
+ # Dump JSON with encrypted values
223
+ data = {"secret": "hello"}
224
+ turn = sp.Turn(__ctext__=ROT(13))
225
+ encrypted_data = {"secret": turn.do(data["secret"])}
226
+ sp.json("df", "data.json", encrypted_data)
227
+ ```
228
+ ### Available Presets
229
+ | Preset | Description | Example |
230
+ | --- | --- | --- |
231
+ | ROT(n) | Caesar cipher, shift by n | ROT(13) → ROT-13 |
232
+ | Atbash() | Alphabet reversal | a↔z, b↔y, c↔x |
233
+
234
+ ## sp\.OpenFold
235
+
236
+ A context manager for folder operations. Auto-creates folder if it doesn't exist.
237
+
238
+ ---
239
+
240
+ ### Basic Usage
241
+
242
+ ```python
243
+ with sp.OpenFold("./my_project") as folder:
244
+ # Get all files and folders
245
+ all_items = folder.getall()
246
+ print(all_items["file"]) # List of files
247
+ print(all_items["fold"]) # List of subfolders
248
+ ```
249
+
250
+ ---
251
+
252
+ ### Get Files Only
253
+
254
+ ```python
255
+ with sp.OpenFold(".") as folder:
256
+ # All files
257
+ files = folder.getall("file")
258
+
259
+ # Files with specific extension
260
+ py_files = folder.getall("file", just=".py")
261
+ txt_files = folder.getall("file", just=".txt")
262
+ ```
263
+
264
+ ---
265
+
266
+ ### Get Folders Only
267
+
268
+ ```python
269
+ with sp.OpenFold(".") as folder:
270
+ folders = folder.getall("fold")
271
+ ```
272
+
273
+ ---
274
+
275
+ ### Open a File Inside the Folder
276
+
277
+ ```python
278
+ with sp.OpenFold("./data") as folder:
279
+ # Open existing file
280
+ f = folder.openfile("config.json", "r")
281
+ content = f.read()
282
+
283
+ # Create new file (mode="w" bypasses existence check)
284
+ f = folder.openfile("new.log", "w")
285
+ f.write("Hello")
286
+ ```
287
+
288
+ ---
289
+
290
+ ### Navigate to Subfolder
291
+
292
+ ```python
293
+ with sp.OpenFold(".") as folder:
294
+ # Go to subfolder
295
+ folder.gotofold("src")
296
+ print(folder.fold) # Now points to ./src
297
+
298
+ # Go to parent
299
+ folder.gotofold("..")
300
+ print(folder.fold) # Back to parent
301
+
302
+ # Go to absolute path
303
+ folder.gotofold("/tmp")
304
+ ```
305
+
306
+ ---
307
+
308
+ ### Access Attributes
309
+
310
+ ```python
311
+ with sp.OpenFold("./project") as folder:
312
+ print(folder.fold) # Current folder path
313
+ print(folder.files) # List of file paths
314
+ print(folder.folds) # List of subfolder paths
315
+ ```
316
+
317
+ ---
318
+
319
+ ### Combined Example
320
+
321
+ ```python
322
+ with sp.OpenFold("./project") as folder:
323
+ # Get all Python files
324
+ py_files = folder.getall("file", just=".py")
325
+
326
+ # Read the first Python file
327
+ if py_files:
328
+ f = folder.openfile(py_files[0], "r")
329
+ print(f.read())
330
+
331
+ # Create a new folder and navigate into it
332
+ folder.gotofold("backup")
333
+ ```
334
+
335
+ ---
336
+
337
+ ### Error Handling
338
+
339
+ ```python
340
+ try:
341
+ with sp.OpenFold("/nonexistent/path") as folder:
342
+ pass # Auto-creates the folder, no error
343
+ except Exception as e:
344
+ print(e)
345
+ ```
346
+
347
+ ---
348
+
349
+ ### Warning
350
+
351
+ ```python
352
+ # The "just" parameter only works with mode="file"
353
+ # This will raise YourMistake:
354
+ with sp.OpenFold(".") as folder:
355
+ folder.getall("fold", just=".py") # 💀 YourMistake!
356
+ ```
357
+
358
+ ---
359
+
360
+ ### File Paths
361
+
362
+ All file paths returned are **absolute paths** (full path from root), not relative. Use `Path(f).name` if you need just the filename:
363
+
364
+ ```python
365
+ from pathlib import Path
366
+
367
+ with sp.OpenFold(".") as folder:
368
+ for f in folder.files:
369
+ print(Path(f).name) # Just the filename
370
+ print(f) # Full path
371
+ ```
372
+
373
+ ---
374
+
375
+ ### Attributes Reference
376
+
377
+ | Attribute | Type | Description |
378
+ |-----------|------|-------------|
379
+ | `folder.fold` | `str` | Current folder path |
380
+ | `folder.files` | `list[str]` | List of file paths |
381
+ | `folder.folds` | `list[str]` | List of subfolder paths |
382
+
383
+ ### Methods Reference
384
+
385
+ | Method | Description |
386
+ |--------|-------------|
387
+ | `getall()` | Get everything (files + folders) |
388
+ | `getall("file")` | Get all files |
389
+ | `getall("file", just=".ext")` | Get files with specific extension |
390
+ | `getall("fold")` | Get all subfolders |
391
+ | `openfile(name, mode)` | Open a file inside the folder |
392
+ | `gotofold(path)` | Navigate to another folder |
393
+
394
+ ## Polite Mode
395
+ I believe you must be very puzzled.
396
+
397
+ First, you need to say: Please import the library
398
+
399
+ Then, when you call a partial function, you add please=True.