Skip to main content

suger is a sugar. use python in @decorator/@Annotation like other languages~

Project description

suger

suger is a sugar ~

use python with @decorator/@Annotation Like Java、C#、TypeScript

@author SolarisNeko

What is it

Use Python in Decorator / Annotation Like Java Lombok / C# Annotation / TypeScript Decorator

作者是写 Java / TypeScript 习惯了注解

Use Like Other Language:

  1. Java Lombok @Data
  2. TypeScript @Async
  3. C# [Required(ErrorMessage = "{0} is required")]

顺手写

How to use 如何使用

install 安装依赖

pip install suger

decorator 装饰器/注解

@string | str

@string
class MockData:
    def __init__(self, age):
        self.age = age


data = MockData(18)

# Output = "MockData(age=18)"
print(data)

@csv | CSV

@csv
class MockData:
    def __init__(self, name, age):
        self.name = name
        self.age = age
        self.emptyTips = ''




class Test(TestCase):
    def test_csv(self):
        data = MockData(name='neko', age=18)

        # csv 输出文本
        print(data.csv_str())
        # csv 的格式
        print(data.csv_format())

# 示例中,有个字段为空
# neko,18,
# name,age,emptyTips

工具

FileUtils 文件工具

from suger.common import FileUtils

# 递归扫描, png 格式
fileArray = FileUtils.scanDir('C:/Users/suger/Documents/WeChat Files', 'png')
print(fileArray)

ObjectUtils 对象工具

from suger.common import ObjectUtils

# true
ObjectUtils.isNull(None)

#  true
data = {}
ObjectUtils.isNotNull(data)

my project init

git init

 git remote add github https://github.com/SolarisNeko/neko233-python-suger.git
 git remote add origin https://gitee.com/SolarisNeko/neko233-python-suger.git

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

suger-0.0.7.tar.gz (12.2 kB view hashes)

Uploaded Source

Built Distribution

suger-0.0.7-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

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