Flowdas工具包
flowdas的Python项目详细描述
flowdas需要python 3.4+。
flowdas.command
这个包提供了一种定义命令行接口的简单方法。
示例
# sample.py from flowdas.command import Command class SampleCommand(Command): """flowdas.command demo""" def sum(self, *number: int): """calculate the sum of integers""" print(sum(number)) if __name__ == '__main__': SampleCommand.main()
$ pip install flowdas $ python sample.py sum 1 2 3 6 $ python sample.py usage: sample.py [-h] {sum} ... $ python sample.py -h usage: sample.py [-h] {sum} ... flowdas.command demo optional arguments: -h, --help show this help message and exit subcommands: {sum} sum calculate the sum of integers
flowdas.meta
用于模式建模的平台无关库
示例
>>> from flowdas import meta >>> from pprint import pprint ... >>> class Author(meta.Entity): ... name = meta.String() ... >>> class Book(meta.Entity): ... title = meta.String() ... published = meta.Date() ... authors = Author[1:]() ... >>> author1 = Author({'name': 'O'}) >>> author2 = Author() >>> author2.update(name = 'Flowdas') >>> book = Book() >>> book.title = 'Meta' >>> book.published = '2016-03-15' >>> book.authors = [author1, author2] >>> book.published datetime.date(2016, 3, 15) >>> book.validate() >>> pprint(book.dump()) {'authors': [{'name': 'O'}, {'name': 'Flowdas'}], 'published': '2016-03-15', 'title': 'Meta'}