1 Star 0 Fork 21

月弯 / borax

forked from kinegratii / borax 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Borax

PyPI PyPI - Python Version PyPI - Status Build Status

概述

Borax 是一个的 Python3 开发工具集合库,涉及到:

  • 设计模式
  • 数据结构及其实现
  • 一些简单函数的封装

安装

使用 pip

$ pip install borax

使用示例

农历模块

本模块的数据和算法引用自项目 jjonline/calendar.js

获取今天的农历日期,日期推算

>>>from borax.calendars.lunardate import LunarDate
>>>LunarDate.today()
LunarDate(2018, 7, 1, 0)
>>>ld = LunarDate.from_solar_date(2018, 8, 11)
>>>ld
LunarDate(2018, 7, 1, 0)
>>>ld.after(10)
LunarDate(2018, 7, 11, 0)

Choices 模块

在 django models 中使用 choices

from django.db import models
from borax import choices

class GenderChoices(choices.ConstChoices):
    MALE = choices.Item(1, 'male')
    FEMALE = choices.Item(2, 'female')
    UNKOWN = choices.Item(3, 'unkown')
    
class Student(models.Model):        
    gender = models.IntergerFIeld(
        choices=GenderChoices,
        default=GenderChoices.UNKOWN
    )

Fetch

从数据序列中选择一个或多个字段的数据。

from borax.fetch import fetch

objects = [
    {'id': 282, 'name': 'Alice', 'age': 30},
    {'id': 217, 'name': 'Bob', 'age': 56},
    {'id': 328, 'name': 'Charlie', 'age': 56},
]

names = fetch(objects, 'name')
print(names)

输出

['Alice', 'Bob', 'Charlie']

文档

在线文档托管在 https://kinegratii.github.io/borax ,由 docsify 构建。

开发特性和规范

开源协议

MIT License (MIT)

The MIT License (MIT) Copyright (c) 2015-2019 kinegratii Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Borax 是一个的 Python3 开发工具集合库,涉及到:设计模式,数据结构及其实现,一些简单函数的封装 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/yuewan/borax.git
git@gitee.com:yuewan/borax.git
yuewan
borax
borax
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891