Metadata-Version: 2.4
Name: sfnf_emo123
Version: 0.1.1
Summary: It's a bit useful but not useful and strictly doesn't follow PEP8 garbage.
Author: EMO_123
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25.0

# sp-lib
###### There are a lot of dirty words in this section. If you can't stand it, please quit immediately

This is a joke library that is extremely non-compliant with PEP8.
I admit it has some use, but:

**Do not use it in production environment**  
**Please make sure you can tolerate this library, and won't die on the spot.**  
**FuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckItFuckIt**
###### fuck, I actually used the old version name

---

## Installation

```bash
pip install sfnf_emo123
```
## Usage

```python
# Note: Use underscore instead of hyphen when importing.
from sp_lib import sp
with sp.OpenFold(".") as fd:
    ...
```

## Polite Mode (Optional)

```python
from please import *
print("Be polite!", please=True)
```

## sp-print
Your current output can now have colors.
```python
sp.print("Red text",color=1)
```

```python
sp.print("Red background",color2=1)
```

```python
sp.print("white background and black text",color=0,color2=7)
```

## sp-help
This is bullshit.
Return the translated \_\_doc\_\_
```python
print(sp.help(input,"zh"))
```

## sp-ges (Go Empty String)

A string filter that removes specified characters.  
**The name is a joke. The function is actually useful.**

```python
# Remove all 'l' and 'o' from the string
result = sp.ges("hello world", "l", "o")
print(result)  # "he wrd"

# Remove all vowels
result = sp.ges("fuckit", "f", "u", "c", "k", "i", "t")
print(result)  # "" (empty!)

# Remove multiple characters
text = "sp_lib is awesome!"
cleaned = sp.ges(text, " ", "!", "s")  # "p_libiwaome"
```

**Warning:** The name stands for "**G**o **E**mpty **S**tring", not what you think.  
Or is it? 😏

## sp-exit
13 exceptions... No, that's like 14
```python
sp.exit() # fuckit
```

## sp-getfold
Get all contents of a folder
```python
print(sp.getfold("."))
```

## sp-getfile
get a file information
```python
print(sp.getfile("I don't know what to put so I just put a random file name.txt")["name"])
```

## sp-get fold all file
###### The name is too long, so I abbreviated it to gfaf.
Get all files in a folder as sp\.Open, when lazy=True, return the path.
```python
print(sp.gfaf(".",lazy=True))
```

## sp-fuck off
Don't say dirty words.
```python
sp.fuck_off()
```
## sp-json
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
```python
sp.json("d",data=["data"])#return json string
sp.json("df","./test.json",[data])#Directly put the generated JSON into a file, which can be sp.Open or a path.
sp.json("l",data="[data]")#load
sp.json("lf","./test.json")#load from file，can be path or sp.Open
```

## sp-Open
Trash version open(), but don't need close() and default to UTF-8 and can use be open()
```python
f = sp.Open("a.txt","w")
f.write("fuckit").add("fuckit").add("fuckit")
with sp.Open("b.txt","w",encoding="utf-8") as f2:
    f2.write("fuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckit")
```

## sp-OpenFold
Context manager for folder operations, with file listing and subfolder navigation.

```python
with sp.OpenFold(".") as folder:
    # Get all files
    files = folder.getall("file")
    print(files)
    
    # Get all subfolders
    folders = folder.getall("fold")
    print(folders)
    
    # Get files with specific extension
    py_files = folder.getall("file", just=".py")
    
    # Open a file in this folder
    f = folder.openfile("test.txt", "r")
    content = f.read()
    
    # Navigate to subfolder
    folder.gotofold("subfolder")
    print(folder.files)  # Now in subfolder
```
## sp\.Turn & sp\.ctext

A simple text substitution cipher system. Define a mapping dictionary, then encrypt/decrypt text with `do()` and `undo()`.

### Basic Usage

```python
# Direct mapping
turn = sp.Turn({"a": "z", "b": "y"})
encrypted = turn.do("ab")  # "zy"
decrypted = turn.undo("zy")  # "ab"
```

### Using Presets (sp\.ctext subclasses)

```python
# ROT-13 (Caesar cipher, shift by 13)
from sp_lib import ROT
turn = sp.Turn(__ctext__=ROT(13))
print(turn.do("Hello World!"))  # Uryyb Jbeyq!

# Atbash cipher (a↔z, b↔y, c↔x ...)
from sp_lib import Atbash
turn = sp.Turn(__ctext__=Atbash())
print(turn.do("Hello"))  # Svool
```

### Chain Operations

```python
turn = sp.Turn({"a": "b", "c": "d"})
turn.add(e="f", g="h")  # Add multiple mappings
turn.kill("a")          # Remove mapping for 'a'
turn += {"x": "y"}      # Use += to merge
turn -= ["c"]           # Use -= to remove keys
```

### Read from JSON File

```python
# Save mapping to JSON first, then load
turn.read("mapping.json")
```

### Create Your Own Preset

```python
class MyCipher(sp.ctext):
    def __init__(self):
        self.c = {
            "a": "m",
            "b": "n",
            "c": "o",
            # your mapping here...
        }

turn = sp.Turn(__ctext__=MyCipher())
```

### Advanced: JSON + Cipher Combo

```python
# Dump JSON with encrypted values
data = {"secret": "hello"}
turn = sp.Turn(__ctext__=ROT(13))
encrypted_data = {"secret": turn.do(data["secret"])}
sp.json("df", "data.json", encrypted_data)
```
### Available Presets
| Preset | Description | Example |
| --- | --- | --- |
| ROT(n) | Caesar cipher, shift by n | ROT(13) → ROT-13 |
| Atbash() | Alphabet reversal | a↔z, b↔y, c↔x |

## sp\.OpenFold

A context manager for folder operations. Auto-creates folder if it doesn't exist.

---

### Basic Usage

```python
with sp.OpenFold("./my_project") as folder:
    # Get all files and folders
    all_items = folder.getall()
    print(all_items["file"])  # List of files
    print(all_items["fold"])  # List of subfolders
```

---

### Get Files Only

```python
with sp.OpenFold(".") as folder:
    # All files
    files = folder.getall("file")
    
    # Files with specific extension
    py_files = folder.getall("file", just=".py")
    txt_files = folder.getall("file", just=".txt")
```

---

### Get Folders Only

```python
with sp.OpenFold(".") as folder:
    folders = folder.getall("fold")
```

---

### Open a File Inside the Folder

```python
with sp.OpenFold("./data") as folder:
    # Open existing file
    f = folder.openfile("config.json", "r")
    content = f.read()
    
    # Create new file (mode="w" bypasses existence check)
    f = folder.openfile("new.log", "w")
    f.write("Hello")
```

---

### Navigate to Subfolder

```python
with sp.OpenFold(".") as folder:
    # Go to subfolder
    folder.gotofold("src")
    print(folder.fold)  # Now points to ./src
    
    # Go to parent
    folder.gotofold("..")
    print(folder.fold)  # Back to parent
    
    # Go to absolute path
    folder.gotofold("/tmp")
```

---

### Access Attributes

```python
with sp.OpenFold("./project") as folder:
    print(folder.fold)    # Current folder path
    print(folder.files)   # List of file paths
    print(folder.folds)   # List of subfolder paths
```

---

### Combined Example

```python
with sp.OpenFold("./project") as folder:
    # Get all Python files
    py_files = folder.getall("file", just=".py")
    
    # Read the first Python file
    if py_files:
        f = folder.openfile(py_files[0], "r")
        print(f.read())
    
    # Create a new folder and navigate into it
    folder.gotofold("backup")
```

---

### Error Handling

```python
try:
    with sp.OpenFold("/nonexistent/path") as folder:
        pass  # Auto-creates the folder, no error
except Exception as e:
    print(e)
```

---

### Warning

```python
# The "just" parameter only works with mode="file"
# This will raise YourMistake:
with sp.OpenFold(".") as folder:
    folder.getall("fold", just=".py")  # 💀 YourMistake!
```

---

### File Paths

All file paths returned are **absolute paths** (full path from root), not relative. Use `Path(f).name` if you need just the filename:

```python
from pathlib import Path

with sp.OpenFold(".") as folder:
    for f in folder.files:
        print(Path(f).name)  # Just the filename
        print(f)             # Full path
```

---

### Attributes Reference

| Attribute | Type | Description |
|-----------|------|-------------|
| `folder.fold` | `str` | Current folder path |
| `folder.files` | `list[str]` | List of file paths |
| `folder.folds` | `list[str]` | List of subfolder paths |

### Methods Reference

| Method | Description |
|--------|-------------|
| `getall()` | Get everything (files + folders) |
| `getall("file")` | Get all files |
| `getall("file", just=".ext")` | Get files with specific extension |
| `getall("fold")` | Get all subfolders |
| `openfile(name, mode)` | Open a file inside the folder |
| `gotofold(path)` | Navigate to another folder |

## Polite Mode
I believe you must be very puzzled.

First, you need to say: Please import the library

Then, when you call a partial function, you add please=True.
