Skip to main content

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

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

Only sp_lib is recommended for use, the others are just jokes.

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-badword

Stop swearing.

sp.badword("fuckyou") #Error reporting
sp.badword("thx you") #No error reported.
bad = sp.badword("fuck you",False,True) #Disable error reporting, return the triggered message.

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.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

(It's a joke) 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.

“die” module

That was a joke. Never call

Finally, I would like to say:

fuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuckitfuck

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.2.tar.gz (11.0 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.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sfnf_emo123-0.1.2.tar.gz
  • Upload date:
  • Size: 11.0 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.2.tar.gz
Algorithm Hash digest
SHA256 dffc08017b2f41fddc3427f6f848223eb4c1f1cec6ddccefa11b7fc12260854e
MD5 c8546bfdcc92888a81139684d535b9d2
BLAKE2b-256 44906daaa590931b9b0d3d67afa3e2b66197bf08cd39a560cca88976a46800d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sfnf_emo123-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 675dcba10c7db81a106a4d10a31b6fdd7bd12e036eef18746aed43618c1028a3
MD5 11a4d6e3a853a360f4b745337b657bb0
BLAKE2b-256 63ac3b24cb410dbfefd88ec10db753ecc010c4ca578c85f8ac1ca17055d01932

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