CheeseType


NameCheeseType JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/CheeseUnknown/CheeseType
Summary存放了一些常用自定义类型的库。
upload_time2023-08-18 04:24:31
maintainer
docs_urlNone
authorCheese Unknown
requires_python>=3.11
licenseMIT
keywords type
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **CheeseType**

一个仅是为了方便调用,而自定义了许多常用类型的库。

## **介绍**

该库的类型分为2类:

1. 你可以使用`type()`或`isinstance(value, type)`获取它们确切的类,而不会获取到类似于`int`、`float`这样的基类。它们和`int(value)`、`float(value)`,无法转换时会抛出`ValueError`。

2. 继承于`Enum`的类型。

## **安装**

```bash
pip install CheeseType
```

## **使用**

```python
from CheeseType import Bool, PositiveInt, System

Bool('False') # False
PositiveInt('123') # 123
System('WINDOWS') # System.WINDOWS
```

## **函数**

由于目前内容较少,暂时先存放在本处。

### **`from CheeseType import *`**

- **`class Bool`**

    该方法返回的类型永远是`bool`而不是`Bool`。

    该方法会将`True`、`'True'`、`'TRUE'`和`'true'`视作`True`,将`False`、`'False'`、`'FALSE'`和`'false'`视作`False`。

- **`class PositiveInt(int)`**

    大于0的整数。

- **`class NonNegativeInt(int)`**

    大于等于0的整数。

- **`class NegativeInt(int)`**

    小于0的整数。

- **`class NonPositiveInt(int)`**

    小于等于0的整数。

- **`class PositiveFloat(float)`**

    大于0的浮点数。

- **`class NonNegativeFloat(float)`**

    大于等于0的浮点数。

- **`class NegativeFloat(float)`**

    小于0的浮点数。

- **`class NonPositiveFloat(float)`**

    小于等于0的浮点数。

- **`class System(Enum)`**

    - **`WINDOWS = 'WINDOWS'`**

    - **`MACOS = 'MACOS'`**

    - **`LINUX = 'LINUX`**

    - **`OTHER = 'OTHER'`**

### **`from CheeseType.network import *`**

- **`class Port(NonNegativeInt)`**

    端口号。

- **`class IPv4(str)`**

- **`class IPv6(str)`**

- **`class IP(str)`**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/CheeseUnknown/CheeseType",
    "name": "CheeseType",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "type",
    "author": "Cheese Unknown",
    "author_email": "cheese@cheese.ren",
    "download_url": "https://files.pythonhosted.org/packages/b7/53/36528366f48cccc7b19f3a1286104f0556b1f8d0f22671235a1ebb95c0ff/CheeseType-0.0.3.tar.gz",
    "platform": null,
    "description": "# **CheeseType**\n\n\u4e00\u4e2a\u4ec5\u662f\u4e3a\u4e86\u65b9\u4fbf\u8c03\u7528\uff0c\u800c\u81ea\u5b9a\u4e49\u4e86\u8bb8\u591a\u5e38\u7528\u7c7b\u578b\u7684\u5e93\u3002\n\n## **\u4ecb\u7ecd**\n\n\u8be5\u5e93\u7684\u7c7b\u578b\u5206\u4e3a2\u7c7b\uff1a\n\n1. \u4f60\u53ef\u4ee5\u4f7f\u7528`type()`\u6216`isinstance(value, type)`\u83b7\u53d6\u5b83\u4eec\u786e\u5207\u7684\u7c7b\uff0c\u800c\u4e0d\u4f1a\u83b7\u53d6\u5230\u7c7b\u4f3c\u4e8e`int`\u3001`float`\u8fd9\u6837\u7684\u57fa\u7c7b\u3002\u5b83\u4eec\u548c`int(value)`\u3001`float(value)`\uff0c\u65e0\u6cd5\u8f6c\u6362\u65f6\u4f1a\u629b\u51fa`ValueError`\u3002\n\n2. \u7ee7\u627f\u4e8e`Enum`\u7684\u7c7b\u578b\u3002\n\n## **\u5b89\u88c5**\n\n```bash\npip install CheeseType\n```\n\n## **\u4f7f\u7528**\n\n```python\nfrom CheeseType import Bool, PositiveInt, System\n\nBool('False') # False\nPositiveInt('123') # 123\nSystem('WINDOWS') # System.WINDOWS\n```\n\n## **\u51fd\u6570**\n\n\u7531\u4e8e\u76ee\u524d\u5185\u5bb9\u8f83\u5c11\uff0c\u6682\u65f6\u5148\u5b58\u653e\u5728\u672c\u5904\u3002\n\n### **`from CheeseType import *`**\n\n- **`class Bool`**\n\n    \u8be5\u65b9\u6cd5\u8fd4\u56de\u7684\u7c7b\u578b\u6c38\u8fdc\u662f`bool`\u800c\u4e0d\u662f`Bool`\u3002\n\n    \u8be5\u65b9\u6cd5\u4f1a\u5c06`True`\u3001`'True'`\u3001`'TRUE'`\u548c`'true'`\u89c6\u4f5c`True`\uff0c\u5c06`False`\u3001`'False'`\u3001`'FALSE'`\u548c`'false'`\u89c6\u4f5c`False`\u3002\n\n- **`class PositiveInt(int)`**\n\n    \u5927\u4e8e0\u7684\u6574\u6570\u3002\n\n- **`class NonNegativeInt(int)`**\n\n    \u5927\u4e8e\u7b49\u4e8e0\u7684\u6574\u6570\u3002\n\n- **`class NegativeInt(int)`**\n\n    \u5c0f\u4e8e0\u7684\u6574\u6570\u3002\n\n- **`class NonPositiveInt(int)`**\n\n    \u5c0f\u4e8e\u7b49\u4e8e0\u7684\u6574\u6570\u3002\n\n- **`class PositiveFloat(float)`**\n\n    \u5927\u4e8e0\u7684\u6d6e\u70b9\u6570\u3002\n\n- **`class NonNegativeFloat(float)`**\n\n    \u5927\u4e8e\u7b49\u4e8e0\u7684\u6d6e\u70b9\u6570\u3002\n\n- **`class NegativeFloat(float)`**\n\n    \u5c0f\u4e8e0\u7684\u6d6e\u70b9\u6570\u3002\n\n- **`class NonPositiveFloat(float)`**\n\n    \u5c0f\u4e8e\u7b49\u4e8e0\u7684\u6d6e\u70b9\u6570\u3002\n\n- **`class System(Enum)`**\n\n    - **`WINDOWS = 'WINDOWS'`**\n\n    - **`MACOS = 'MACOS'`**\n\n    - **`LINUX = 'LINUX`**\n\n    - **`OTHER = 'OTHER'`**\n\n### **`from CheeseType.network import *`**\n\n- **`class Port(NonNegativeInt)`**\n\n    \u7aef\u53e3\u53f7\u3002\n\n- **`class IPv4(str)`**\n\n- **`class IPv6(str)`**\n\n- **`class IP(str)`**\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\u5b58\u653e\u4e86\u4e00\u4e9b\u5e38\u7528\u81ea\u5b9a\u4e49\u7c7b\u578b\u7684\u5e93\u3002",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/CheeseUnknown/CheeseType"
    },
    "split_keywords": [
        "type"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73c52b088a80a70d98cfa95b887fbe19efa8f0300cde36dee9667ca7cd8eebb9",
                "md5": "b27553e96e9addda62743843e67e7144",
                "sha256": "a8ce220343e1524ab896ba70100b4cbf6467c3619c404e2ad5c20aab58769ea6"
            },
            "downloads": -1,
            "filename": "CheeseType-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b27553e96e9addda62743843e67e7144",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 4205,
            "upload_time": "2023-08-18T04:24:30",
            "upload_time_iso_8601": "2023-08-18T04:24:30.140698Z",
            "url": "https://files.pythonhosted.org/packages/73/c5/2b088a80a70d98cfa95b887fbe19efa8f0300cde36dee9667ca7cd8eebb9/CheeseType-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b75336528366f48cccc7b19f3a1286104f0556b1f8d0f22671235a1ebb95c0ff",
                "md5": "560d46c21b95403152f1eb76394929a5",
                "sha256": "a0b8b111c3a4592cbafbd6b347af0dd88989800f69470bc0bfc8b6cf27921ca8"
            },
            "downloads": -1,
            "filename": "CheeseType-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "560d46c21b95403152f1eb76394929a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 3525,
            "upload_time": "2023-08-18T04:24:31",
            "upload_time_iso_8601": "2023-08-18T04:24:31.418467Z",
            "url": "https://files.pythonhosted.org/packages/b7/53/36528366f48cccc7b19f3a1286104f0556b1f8d0f22671235a1ebb95c0ff/CheeseType-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-18 04:24:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CheeseUnknown",
    "github_project": "CheeseType",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cheesetype"
}
        
Elapsed time: 0.14885s