Pysha
Pysha Micro Framework. For Doing Something Beautiful In Python :)
You can See examples of pysha in Examples directory.
Installation
Just Run This Command :
pip install pysha
Usage
Add This At First Of Your Code :
from pysha import *
Examples
- Switch-Case
Switch(var).cases({
Case(5):
lambda: (
print("Number Wasnt 5.") ,
print(2)
),
Case(10):
lambda: (
print("Number Was 10 !") ,
print(3)
),
Case(15):
lambda: (
print("Number Wasnt 15.") ,
print(4)
),
Case(20):
lambda: (
print("Number Wasnt 20.") ,
print(5)
),
Default:
lambda:(
print("Finish")
)
})
- Interface
@interface
class Car:
name = None
speed = 0
def setSpeed(self,speed):
pass
@interface(Car)
class Tesla:
name = "Tesla"
speed = 0
def setSpeed(self, speed):
self.speed = speed
def getSpeed(self):
return self.speed
@interface(Car) # Wrong Because setSpeed Is Not Defined. ( Will Raise Error )
class BMW:
name = "BMW"
speed = 0
@interface(Car) # Wrong Because setSpeed Is Not Defined Right ( Parameter Problem ). ( Will Raise Error )
class Benz:
name = "Benz"
speed = 0
def setSpeed(self):
pass
myCar = Tesla()
myFriendCar = BMW() # Raises Error Because BMW Does Not Have setSpeed Method.
myCar.setSpeed(100)
# Rest Of Your Code...
- Pysha Types
# PyshaString
a = PyshaString("some string")
print(a << " and something else") # "some string and something else"
print(a - "some") # " string"
print(a.replace_dict({"some":"one","string":"int"})) # "one int"
# PyshaDict
b = PyshaDict({"name":"Arshia"})
print(~b) # {"Arshia":"name"}
print(b - "name") # {}
print(~b.get("Arshia")) # "name"
# PyshaList
c = PyshaList(["name","hay"])
print(c.count_deep("a")) # 2
print(c >> 1) # ["hay","name"] thats just right shift
print(c) # [ name, hay ]
print(c + ["yo"]) # ["name","hay","yo"]
- One line Conditions
a = command()
print(a.condition("i > j ? i:j",i=10,j=20))
# Or this way
print(Cond(i>j)(i,j))
- One line loop
a = command()
a.loop("<i:2,j:3>{hey thats _j_ index in _i_ column}",mode="i")
# "p" mode is for just printing and "i" mode is for get input.
# Or this way
ans = Loop(2,3)("Whats number [_1_][_2_] ?")
# This will automatically loop through an array[2][3] and get input from it and will return answer
- CrossPlatformer ( You can make cross platform apps easier )
cp = CrossPlatformer()
cp["clearScreen"] = {"windows": "cls", "linux": "clear","mac":"clear"}
cp["listFiles"] = {"windows": "dir", "linux": "ls","mac":"clear"}
# rest of your code...
print(cp["clearScreen"]) # automatically returns value depends on your platform.
- Cool Decorators
# just for no argument functions that runs once without calling it
@once
def init():
print("Initializing")
# ignore and continue the process in case of ZeroDivisonError ( you can set '*' to ignore everything )
@ignore(exceptions=[ZeroDivisionError])
def test():
print(1 / 0)
# retry the function in case of ZeroDivisonError until 3 times ( you can set '*' to ignore everything )
@retry(count=3, exceptions=[ZeroDivisionError])
def calculation():
print(1 / 0)
- Multi-Layer Ecnryption/Decryption
variable = make_enc(alg=[Algorithms.XOR,Algorithms.Base64],key=10)
variable.enc("Hello")
variable.dec("Qm9mZmU=")
- Colored User-Input
name = colorprompt(colorize("(Fore.GREEN)[Enter Your Name :] "),char_color=fore["cyan"])
password = passprompt(colorize("(Fore.GREEN)[Enter Your Password :] "),mask_color=fore["cyan"])
pp(name)
- Text Options
banner("text",font="3-D") # make cool text with setted font ( uses pyfiglet and figlet fonts )
rect("Hello\nI'm Arshia") # all characters and colors even distances can be customized too
# Customizing helps will be added on wiki
l(('-', Fore.CYAN), count=50) # Draw a line with specific character and color
# and some other cool things :)
- Customizable PercentPrinter
a = PercentPrinter(chars=30,pass_color=fore["green"],loading_color=fore["cyan"])
a.config(char_ok='@',char_loading='-')
a.show(char_ok='%',char_loading='`') # Overwrite Config But Not Changes It.
a.increase(50)
a.finish(show=False)
print("Done")
- Save And Load Variables With Encryption
# Save 2 Variables
Save("test.txt",name="Arshia",age=19)()
# Load Those 2 Variables
import sys
this = sys.modules[__name__]
Load("test.txt")(this)
After Load Variables, They Are Accessable In Your Code !
And Lots Of Beautiful Things :)
Metadata
Release files for pysha 0.1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysha-0.1.3.1.tar.gz | 65.6 kB | Without provenance | Details for pysha-0.1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pysha-0.1.3.1-py3-none-any.whl | Python 3 | none | any | Details for pysha-0.1.3.1-py3-none-any.whl |
Total release size: 120.1 kB
Release files / pysha-0.1.3.1.tar.gz
| Download URL | pysha-0.1.3.1.tar.gz |
|---|---|
| Size | 65.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7c3b6c940a7acb9280be4dd4bdcb5a15766bdf6fc3426f171aea2e2472c26fe
|
|
BLAKE2b-256 checksum How to use checksums |
7c33862fb8fdc531b44af29c99e59b8fb17509e1017466da212ae834613d4065
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.0
|
Release files / pysha-0.1.3.1-py3-none-any.whl
| Download URL | pysha-0.1.3.1-py3-none-any.whl |
|---|---|
| Size | 54.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c27af1280b1542438c101493693981f79a487078a0a3e10d35826084351e263
|
|
BLAKE2b-256 checksum How to use checksums |
6046bcad6f0221be2a2bbf50a42f5ec34de40013c2ccad145b74c59776fd7761
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.0
|
Security for pysha 0.1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.