Cuclasses
介绍
Cuclasses是我正在写的python库,内容是集合了一些常用的类和方法
项目地址
pypi(少有更新):https://pypi.org/project/cuclasses/ github:https://github.com/HHHHhgqcdxhg/cuclasses
模块
cuclasses.DottableDict
顾名思义,能用 "." 访问的dict.因为喜欢js访问对象属性的方式,可以用下标,也可以用点.
cuclasses.singleton
装饰器.
被装饰的类为单例模式
cuclasses.CallableDict
可以调用的dict,调用时返回自身.
cuclasses.StrKeyDict
在查询时把非字符串键转换为字符串的dict
cuclasses.headerCopy2Dict
因为在复制chrome开发者工具network里请求的header时很不方便,就弄了这个...把chrome里的headers复制进去,会转换成字典
headerStr = """Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Cookie: l=v; buvid3=08DBF55E-086D-4BE2-9FCB-4B60BFA5F05A140254infoc
Host: message.bilibili.com
Origin: https://www.bilibili.com
Referer: https://www.bilibili.com/video/av9912938/?p=11
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36"""
a = headerCopy2Dict(headerStr)
print(a)
#>>> {'Accept': 'application/json, text/plain, */*', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'keep-alive', 'Host': 'message.bilibili.com', 'Origin': 'https://www.bilibili.com', 'Referer': 'https://www.bilibili.com/video/av9912938/?p=11', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36'}
cuclasses.timePrint
上下文管理器.
带时间戳的print.随时可指定时间格式
with timePrint() as print:
print(0)
# >>> [2019-02-10 16:23:35] 0
print(1, strf="[%Y-%m-%d %H:%M:%S]1")
# >>> [2019-02-10 16:23:35]1 1
with timePrint("[%Y-%m-%d %H:%M:%S]2") as print:
print(2)
# >>> [2019-02-10 16:23:35]2 2
print(3, strf="[%Y-%m-%d %H:%M:%S]3")
# >>> [2019-02-10 16:23:35]3 3
print(4)
# >>> 4
cuclasses.timeCount
装饰器.接受两个参数. 被装饰的函数将在执行后打印执行时间
:param enable: 设为False则不计时,直接执行函数
:param method: 可选择的计时所用的获取时间的函数.默认time.perf_counter,或者也可以选填time.time,python3.7可以按需选用time.perf_counter_ns
@timeCount()
def bar():
print({"a": "c"})
bar()
#>>> {'a': 'c'}
#>>> func bar excuted in : 6.044444444444444e-05
cuclasses.Downloader
下载器.
:param directory:下载到的目录
:param urls:需要下载的资源目录
:param threads:并行下载的线程数
:param headers:请求头,默认为{"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36"}
with open("xx.json","r") as f:
data = json.load(f)
d = Downloader(directory=r"E:\ACG\comic\general\どうして私が美術科に",urls=data)
d.downloadAll()
Metadata
Release files for cuclasses 0.0.4
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 |
|---|---|---|---|---|
| cuclasses-0.0.4.tar.gz | 6.2 kB | Without provenance | Details for cuclasses-0.0.4.tar.gz |
Release files / cuclasses-0.0.4.tar.gz
| Download URL | cuclasses-0.0.4.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94220a0b979da0c40d22674a7ad5ad9ebb5232e5651f88139eb4f9c206819996
|
|
BLAKE2b-256 checksum How to use checksums |
abf0a81b611659a2a87978024f5d6e0748d8ad266e34bb1d47554f3653f503c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.7
|
Security for cuclasses 0.0.4
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.