Skip to main content

It's a bit useful but not useful and strictly doesn't follow PEP8 garbage.

Project description

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

pip install sfnf_emo123

Usage

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

Polite Mode (Optional)

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

sp-print

Your current output can now have colors.

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

sp-help

This is bullshit. Return the translated __doc__

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.

# 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 "Go Empty String", not what you think.
Or is it? 😏

sp-exit

13 exceptions... No, that's like 14

sp.exit() # fuckit

sp-getfold

Get all contents of a folder

print(sp.getfold("."))

sp-getfile

get a file information

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.

print(sp.gfaf(".",lazy=True))

sp-fuck off

Don't say dirty words.

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

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()

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.

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

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

Using Presets (sp.ctext subclasses)

# 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

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

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

Create Your Own Preset

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

# 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

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

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

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

Open a File Inside the Folder

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

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

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

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

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

Warning

# 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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sfnf_emo123-0.1.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sfnf_emo123-0.1.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file sfnf_emo123-0.1.1.tar.gz.

File metadata

  • Download URL: sfnf_emo123-0.1.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for sfnf_emo123-0.1.1.tar.gz
Algorithm Hash digest
SHA256 359780c76433b1d6b15b83560ef90070d79a108bee04a19d925e687bd8819b13
MD5 0efddda7da981defdbbb80046ec3073d
BLAKE2b-256 f91f49de5e3c4d6bd10e99bff6f3d496a6339580e710aaed66981fcd1688b972

See more details on using hashes here.

File details

Details for the file sfnf_emo123-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sfnf_emo123-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for sfnf_emo123-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c546060cf05f2440a51783ccabb7f839a5a078b1786b7a1c0b38c56e97d128cc
MD5 3aa6e7d9c3789ef821d0acd86b7eade5
BLAKE2b-256 f1f1fcdda5df92fbd540b605ea7c15280d4a54414394363c97c5dfa1ed452a83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page