package
stringlengths
1
122
pacakge-description
stringlengths
0
1.3M
zgx
No description available on PyPI.
zgy2sgz
zgy2sgzTiny utility package which has only one job: Provide a Python function which uses Schlumberger's ZGY library and LLNL's ZFP library to read ZGY files and writeseismic-zfp (.SGZ) formatfiles.zgy2sgz is intended exclusively for use by theseismic-zfp packageExamplefromzgy2sgzimportconvertFile# Yes, the first two arguments are bytes rather than strings# The 3rd argument is bits_per_voxel {16, 8, 4, 2, 1}convertFile(b'seismic_file.zgy',b'seismic_file.sgz',4)
zgy_first_bao
No description available on PyPI.
zgyio
Convenience wrapper around OpenZGY Python implementation which enables reading ZGY files with a syntax familiar to users of segyio.
zgy-pkg
Failed to fetch description. HTTP Status Code: 404
zh
UNKNOWN
zhandegao-test-2
this is a pyproject.toml test project
zhang
UNKNOWN
zhang2016dependency
zhang2016dependencyThis package provides a simple implementation of the models proposed in the paper:Zhang, R., Lee, H., & Radev, D. (2016). Dependency sensitive convolutional neural networks for modeling sentences and documents. arXiv preprint arXiv:1611.02361.InstallationThis package depends on theKeraslibrary. This means you will need to install a backend library in order to use this module. Take a look toKeras installationto get more information.After having installed the backend of yout choice, you just need to install this package usingpip:pip install zhang2016dependencyUsageThis package only provides a single model. To get detailed information on the parameters the model accepts, take a look to the documentation included with the module class.Here is a complete example of instantiation of the model proposed in the original paper using two channel of randomly initialized word embeddings:importnumpyasnpimportnumpy.randomasrngvocabulary_size=1000embedding_size=300value=np.sqrt(6/embedding_size)weights_shape=(vocabulary_size+1,embedding_size)weights=rng.uniform(low=-value,high=value,size=weights_shape)channels=[{'weights':[weights],'trainable':False,'input_dim':vocabulary_size+1,'output_dim':embedding_size,'name':'random-embedding-1'},{'weights':[weights],'trainable':True,'input_dim':vocabulary_size+1,'output_dim':embedding_size,'name':'random-embedding-2'}]windows=[{'filters':100,'kernel_size':3,'activation':'relu','name':'3-grams'},{'filters':100,'kernel_size':4,'activation':'relu','name':'4-grams'},{'filters':100,'kernel_size':5,'activation':'relu','name':'5-grams'}]fromzhang2016dependencyimportModelmodel=Model(channels=channels,windows=windows,sentence_length=37,num_classes=6,dropout_rate=0.5,classifier_activation='softmax',include_top=True,name='DSCNN')model.compile(optimizer='adadelta',loss='categorical_crossentropy',metrics=['accuracy'])model.summary()
zhang4122738
No description available on PyPI.
zhangbinnester
No description available on PyPI.
zhangbin-test1
zbtesting~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
zhangchao
UNKNOWN
zhangda
No description available on PyPI.
zhanghao
No description available on PyPI.
zhang-hello
测试有序列表adj --app polls -a forms dj --app polls -a urlsbdj --app polls -a forms dj --app polls -a urlscdj --app polls -a forms dj --app polls -a urlsdjangoshortcuts提供一个全局命令,用于方便快捷生成模板等相关文件。安装python setup.py install使用方式在安装成功之后,获得一个全局命令:dj,通过 dj -h 可以查看到该命令的使用方式$dj -h usage: dj [-h] --app APP [-a ADD] [-t TEMPLATE] [-s STATIC] Easily to create files when using django optional arguments: -h, --help show this help message and exit --app APP input the app name which django created -a, --add ADD add file automatically, the value must be one of ['forms', 'urls'] -t, --template TEMPLATE add templates html files -s, --static STATIC add static files You must cd BASE_DIR to run this script全局命令备忘查询有时候忘记安装这些模块都提供了哪些全局命令,可以通过以下这种方式查询。$python -m djangoshortcuts -h Please use command [dj -h] for the detail.举例说明下面简要举例说明这个命令的使用方式,其实看上面的 usage 就可以明白九成以上了。假设 django app 名称为 polls, 首先需要切换到网站的根目录下,就可以运行以下命令生成 forms.py 或者 urls.py 文件dj --app polls -a forms dj --app polls -a urls生成 index.html 文件dj --app polls -t index.html该命令会自动创建 polls/templates/polls 相关的文件夹,并生成 polls/templates/polls/index.html 文件生成 style.css 文件dj --app polls -s style.css该命令会自动创建 polls/static/polls 相关的文件夹,并生成 polls/static/polls/style.css 文件考虑到静态文件夹下常增加 css 和 js 文件夹来管理相关静态文件,所以在 -s 参数的行动逻辑多增加一个功能dj --app polls -s css/style.css该命令和 3 的区别在于,文件的路径为 polls/static/polls/css/style.css,相关的文件夹会自动创建dj --app polls -s js/login.js同样地,文件的路径为 polls/static/polls/js/login.js后记以上参数中,--app 是必选参数,除此之外的参数都是可选参数并且不互斥。也就是说添加文件的时候,不同的参数可以同时进行。
zhangjie
#ReadMe ##Hello
zhangjx
鏃犵敤涔嬪簱
zhanglei
Text Classification with CNN and RNN需要修改地方1,需要修改单词字典;2,文件读取不成功 3,修改cnn模型中的类别数目update这么多东西去哪里了 CNN做句子分类的论文可以参看:Convolutional Neural Networks for Sentence Classification还可以去读dennybritz大牛的博客:Implementing a CNN for Text Classification in TensorFlow以及字符级CNN的论文:Character-level Convolutional Networks for Text Classification本文是基于TensorFlow在中文数据集上的简化实现,使用了字符级CNN和RNN对中文文本进行分类,达到了较好的效果。文中所使用的Conv1D与论文中有些不同,详细参考官方文档:tf.nn.conv1d环境Python 2/3 (感谢howie.hu调试Python2环境)TensorFlow 1.3以上numpyscikit-learnscipy数据集使用THUCNews的一个子集进行训练与测试,数据集请自行到THUCTC:一个高效的中文文本分类工具包下载,请遵循数据提供方的开源协议。本次训练使用了其中的10个分类,每个分类6500条数据。类别如下:体育, 财经, 房产, 家居, 教育, 科技, 时尚, 时政, 游戏, 娱乐这个子集可以在此下载:链接:https://pan.baidu.com/s/1hugrfRu密码: qfud数据集划分如下:训练集: 5000*10验证集: 500*10测试集: 1000*10从原数据集生成子集的过程请参看helper下的两个脚本。其中,copy_data.sh用于从每个分类拷贝6500个文件,cnews_group.py用于将多个文件整合到一个文件中。执行该文件后,得到三个数据文件:cnews.train.txt: 训练集(50000条)cnews.val.txt: 验证集(5000条)cnews.test.txt: 测试集(10000条)预处理data/cnews_loader.py为数据的预处理文件。read_file(): 读取文件数据;build_vocab(): 构建词汇表,使用字符级的表示,这一函数会将词汇表存储下来,避免每一次重复处理;read_vocab(): 读取上一步存储的词汇表,转换为{词:id}表示;read_category(): 将分类目录固定,转换为{类别: id}表示;to_words(): 将一条由id表示的数据重新转换为文字;process_file(): 将数据集从文字转换为固定长度的id序列表示;batch_iter(): 为神经网络的训练准备经过shuffle的批次的数据。经过数据预处理,数据的格式如下:DataShapeDataShapex_train[50000, 600]y_train[50000, 10]x_val[5000, 600]y_val[5000, 10]x_test[10000, 600]y_test[10000, 10]CNN卷积神经网络配置项CNN可配置的参数如下所示,在cnn_model.py中。classTCNNConfig(object):"""CNN配置参数"""embedding_dim=64# 词向量维度seq_length=600# 序列长度num_classes=10# 类别数num_filters=128# 卷积核数目kernel_size=5# 卷积核尺寸vocab_size=5000# 词汇表达小hidden_dim=128# 全连接层神经元dropout_keep_prob=0.5# dropout保留比例learning_rate=1e-3# 学习率batch_size=64# 每批训练大小num_epochs=10# 总迭代轮次print_per_batch=100# 每多少轮输出一次结果save_per_batch=10# 每多少轮存入tensorboardCNN模型具体参看cnn_model.py的实现。大致结构如下:训练与验证运行python run_cnn.py train,可以开始训练。若之前进行过训练,请把tensorboard/textcnn删除,避免TensorBoard多次训练结果重叠。Configuring CNN model... Configuring TensorBoard and Saver... Loading training and validation data... Time usage: 0:00:14 Training and evaluating... Epoch: 1 Iter: 0, Train Loss: 2.3, Train Acc: 10.94%, Val Loss: 2.3, Val Acc: 8.92%, Time: 0:00:01 * Iter: 100, Train Loss: 0.88, Train Acc: 73.44%, Val Loss: 1.2, Val Acc: 68.46%, Time: 0:00:04 * Iter: 200, Train Loss: 0.38, Train Acc: 92.19%, Val Loss: 0.75, Val Acc: 77.32%, Time: 0:00:07 * Iter: 300, Train Loss: 0.22, Train Acc: 92.19%, Val Loss: 0.46, Val Acc: 87.08%, Time: 0:00:09 * Iter: 400, Train Loss: 0.24, Train Acc: 90.62%, Val Loss: 0.4, Val Acc: 88.62%, Time: 0:00:12 * Iter: 500, Train Loss: 0.16, Train Acc: 96.88%, Val Loss: 0.36, Val Acc: 90.38%, Time: 0:00:15 * Iter: 600, Train Loss: 0.084, Train Acc: 96.88%, Val Loss: 0.35, Val Acc: 91.36%, Time: 0:00:17 * Iter: 700, Train Loss: 0.21, Train Acc: 93.75%, Val Loss: 0.26, Val Acc: 92.58%, Time: 0:00:20 * Epoch: 2 Iter: 800, Train Loss: 0.07, Train Acc: 98.44%, Val Loss: 0.24, Val Acc: 94.12%, Time: 0:00:23 * Iter: 900, Train Loss: 0.092, Train Acc: 96.88%, Val Loss: 0.27, Val Acc: 92.86%, Time: 0:00:25 Iter: 1000, Train Loss: 0.17, Train Acc: 95.31%, Val Loss: 0.28, Val Acc: 92.82%, Time: 0:00:28 Iter: 1100, Train Loss: 0.2, Train Acc: 93.75%, Val Loss: 0.23, Val Acc: 93.26%, Time: 0:00:31 Iter: 1200, Train Loss: 0.081, Train Acc: 98.44%, Val Loss: 0.25, Val Acc: 92.96%, Time: 0:00:33 Iter: 1300, Train Loss: 0.052, Train Acc: 100.00%, Val Loss: 0.24, Val Acc: 93.58%, Time: 0:00:36 Iter: 1400, Train Loss: 0.1, Train Acc: 95.31%, Val Loss: 0.22, Val Acc: 94.12%, Time: 0:00:39 Iter: 1500, Train Loss: 0.12, Train Acc: 98.44%, Val Loss: 0.23, Val Acc: 93.58%, Time: 0:00:41 Epoch: 3 Iter: 1600, Train Loss: 0.1, Train Acc: 96.88%, Val Loss: 0.26, Val Acc: 92.34%, Time: 0:00:44 Iter: 1700, Train Loss: 0.018, Train Acc: 100.00%, Val Loss: 0.22, Val Acc: 93.46%, Time: 0:00:47 Iter: 1800, Train Loss: 0.036, Train Acc: 100.00%, Val Loss: 0.28, Val Acc: 92.72%, Time: 0:00:50 No optimization for a long time, auto-stopping...在验证集上的最佳效果为94.12%,且只经过了3轮迭代就已经停止。准确率和误差如图所示:测试运行python run_cnn.py test在测试集上进行测试。Configuring CNN model... Loading test data... Testing... Test Loss: 0.14, Test Acc: 96.04% Precision, Recall and F1-Score... precision recall f1-score support 体育 0.99 0.99 0.99 1000 财经 0.96 0.99 0.97 1000 房产 1.00 1.00 1.00 1000 家居 0.95 0.91 0.93 1000 教育 0.95 0.89 0.92 1000 科技 0.94 0.97 0.95 1000 时尚 0.95 0.97 0.96 1000 时政 0.94 0.94 0.94 1000 游戏 0.97 0.96 0.97 1000 娱乐 0.95 0.98 0.97 1000 avg / total 0.96 0.96 0.96 10000 Confusion Matrix... [[991 0 0 0 2 1 0 4 1 1] [ 0 992 0 0 2 1 0 5 0 0] [ 0 1 996 0 1 1 0 0 0 1] [ 0 14 0 912 7 15 9 29 3 11] [ 2 9 0 12 892 22 18 21 10 14] [ 0 0 0 10 1 968 4 3 12 2] [ 1 0 0 9 4 4 971 0 2 9] [ 1 16 0 4 18 12 1 941 1 6] [ 2 4 1 5 4 5 10 1 962 6] [ 1 0 1 6 4 3 5 0 1 979]] Time usage: 0:00:05在测试集上的准确率达到了96.04%,且各类的precision, recall和f1-score都超过了0.9。从混淆矩阵也可以看出分类效果非常优秀。RNN循环神经网络配置项RNN可配置的参数如下所示,在rnn_model.py中。classTRNNConfig(object):"""RNN配置参数"""# 模型参数embedding_dim=64# 词向量维度seq_length=600# 序列长度num_classes=10# 类别数vocab_size=5000# 词汇表达小num_layers=2# 隐藏层层数hidden_dim=128# 隐藏层神经元rnn='gru'# lstm 或 grudropout_keep_prob=0.8# dropout保留比例learning_rate=1e-3# 学习率batch_size=128# 每批训练大小num_epochs=10# 总迭代轮次print_per_batch=100# 每多少轮输出一次结果save_per_batch=10# 每多少轮存入tensorboardRNN模型具体参看rnn_model.py的实现。大致结构如下:训练与验证这部分的代码与 run_cnn.py极为相似,只需要将模型和部分目录稍微修改。运行python run_rnn.py train,可以开始训练。若之前进行过训练,请把tensorboard/textrnn删除,避免TensorBoard多次训练结果重叠。Configuring RNN model... Configuring TensorBoard and Saver... Loading training and validation data... Time usage: 0:00:14 Training and evaluating... Epoch: 1 Iter: 0, Train Loss: 2.3, Train Acc: 8.59%, Val Loss: 2.3, Val Acc: 11.96%, Time: 0:00:08 * Iter: 100, Train Loss: 0.95, Train Acc: 64.06%, Val Loss: 1.3, Val Acc: 53.06%, Time: 0:01:15 * Iter: 200, Train Loss: 0.61, Train Acc: 79.69%, Val Loss: 0.94, Val Acc: 69.88%, Time: 0:02:22 * Iter: 300, Train Loss: 0.49, Train Acc: 85.16%, Val Loss: 0.63, Val Acc: 81.44%, Time: 0:03:29 * Epoch: 2 Iter: 400, Train Loss: 0.23, Train Acc: 92.97%, Val Loss: 0.6, Val Acc: 82.86%, Time: 0:04:36 * Iter: 500, Train Loss: 0.27, Train Acc: 92.97%, Val Loss: 0.47, Val Acc: 86.72%, Time: 0:05:43 * Iter: 600, Train Loss: 0.13, Train Acc: 98.44%, Val Loss: 0.43, Val Acc: 87.46%, Time: 0:06:50 * Iter: 700, Train Loss: 0.24, Train Acc: 91.41%, Val Loss: 0.46, Val Acc: 87.12%, Time: 0:07:57 Epoch: 3 Iter: 800, Train Loss: 0.11, Train Acc: 96.09%, Val Loss: 0.49, Val Acc: 87.02%, Time: 0:09:03 Iter: 900, Train Loss: 0.15, Train Acc: 96.09%, Val Loss: 0.55, Val Acc: 85.86%, Time: 0:10:10 Iter: 1000, Train Loss: 0.17, Train Acc: 96.09%, Val Loss: 0.43, Val Acc: 89.44%, Time: 0:11:18 * Iter: 1100, Train Loss: 0.25, Train Acc: 93.75%, Val Loss: 0.42, Val Acc: 88.98%, Time: 0:12:25 Epoch: 4 Iter: 1200, Train Loss: 0.14, Train Acc: 96.09%, Val Loss: 0.39, Val Acc: 89.82%, Time: 0:13:32 * Iter: 1300, Train Loss: 0.2, Train Acc: 96.09%, Val Loss: 0.43, Val Acc: 88.68%, Time: 0:14:38 Iter: 1400, Train Loss: 0.012, Train Acc: 100.00%, Val Loss: 0.37, Val Acc: 90.58%, Time: 0:15:45 * Iter: 1500, Train Loss: 0.15, Train Acc: 96.88%, Val Loss: 0.39, Val Acc: 90.58%, Time: 0:16:52 Epoch: 5 Iter: 1600, Train Loss: 0.075, Train Acc: 97.66%, Val Loss: 0.41, Val Acc: 89.90%, Time: 0:17:59 Iter: 1700, Train Loss: 0.042, Train Acc: 98.44%, Val Loss: 0.41, Val Acc: 90.08%, Time: 0:19:06 Iter: 1800, Train Loss: 0.08, Train Acc: 97.66%, Val Loss: 0.38, Val Acc: 91.36%, Time: 0:20:13 * Iter: 1900, Train Loss: 0.089, Train Acc: 98.44%, Val Loss: 0.39, Val Acc: 90.18%, Time: 0:21:20 Epoch: 6 Iter: 2000, Train Loss: 0.092, Train Acc: 96.88%, Val Loss: 0.36, Val Acc: 91.42%, Time: 0:22:27 * Iter: 2100, Train Loss: 0.062, Train Acc: 98.44%, Val Loss: 0.39, Val Acc: 90.56%, Time: 0:23:34 Iter: 2200, Train Loss: 0.053, Train Acc: 98.44%, Val Loss: 0.39, Val Acc: 90.02%, Time: 0:24:41 Iter: 2300, Train Loss: 0.12, Train Acc: 96.09%, Val Loss: 0.37, Val Acc: 90.84%, Time: 0:25:48 Epoch: 7 Iter: 2400, Train Loss: 0.014, Train Acc: 100.00%, Val Loss: 0.41, Val Acc: 90.38%, Time: 0:26:55 Iter: 2500, Train Loss: 0.14, Train Acc: 96.88%, Val Loss: 0.37, Val Acc: 91.22%, Time: 0:28:01 Iter: 2600, Train Loss: 0.11, Train Acc: 96.88%, Val Loss: 0.43, Val Acc: 89.76%, Time: 0:29:08 Iter: 2700, Train Loss: 0.089, Train Acc: 97.66%, Val Loss: 0.37, Val Acc: 91.18%, Time: 0:30:15 Epoch: 8 Iter: 2800, Train Loss: 0.0081, Train Acc: 100.00%, Val Loss: 0.44, Val Acc: 90.66%, Time: 0:31:22 Iter: 2900, Train Loss: 0.017, Train Acc: 100.00%, Val Loss: 0.44, Val Acc: 89.62%, Time: 0:32:29 Iter: 3000, Train Loss: 0.061, Train Acc: 96.88%, Val Loss: 0.43, Val Acc: 90.04%, Time: 0:33:36 No optimization for a long time, auto-stopping...在验证集上的最佳效果为91.42%,经过了8轮迭代停止,速度相比CNN慢很多。准确率和误差如图所示:测试运行python run_rnn.py test在测试集上进行测试。Testing... Test Loss: 0.21, Test Acc: 94.22% Precision, Recall and F1-Score... precision recall f1-score support 体育 0.99 0.99 0.99 1000 财经 0.91 0.99 0.95 1000 房产 1.00 1.00 1.00 1000 家居 0.97 0.73 0.83 1000 教育 0.91 0.92 0.91 1000 科技 0.93 0.96 0.94 1000 时尚 0.89 0.97 0.93 1000 时政 0.93 0.93 0.93 1000 游戏 0.95 0.97 0.96 1000 娱乐 0.97 0.96 0.97 1000 avg / total 0.94 0.94 0.94 10000 Confusion Matrix... [[988 0 0 0 4 0 2 0 5 1] [ 0 990 1 1 1 1 0 6 0 0] [ 0 2 996 1 1 0 0 0 0 0] [ 2 71 1 731 51 20 88 28 3 5] [ 1 3 0 7 918 23 4 31 9 4] [ 1 3 0 3 0 964 3 5 21 0] [ 1 0 1 7 1 3 972 0 6 9] [ 0 16 0 0 22 26 0 931 2 3] [ 2 3 0 0 2 2 12 0 972 7] [ 0 3 1 1 7 3 11 5 9 960]] Time usage: 0:00:33在测试集上的准确率达到了94.22%,且各类的precision, recall和f1-score,除了家居这一类别,都超过了0.9。从混淆矩阵可以看出分类效果非常优秀。对比两个模型,可见RNN除了在家居分类的表现不是很理想,其他几个类别较CNN差别不大。还可以通过进一步的调节参数,来达到更好的效果。预测为方便预测,repo 中predict.py提供了 CNN 模型的预测方法。
zhangpan-soft-commons
py-commonspy-commons
zhangpsuperlist
Failed to fetch description. HTTP Status Code: 404
zhangpsupetlist
Failed to fetch description. HTTP Status Code: 404
zhang-py-ios-device
py-ios-deviceA python based Apple instruments protocol,you can get CPU, Memory and other metrics from real iOS deviceslink:https://testerhome.com/topics/27159中文文档Java link:https://github.com/YueChen-C/java-ios-device)pip :pip install py-ios-devicepython version: 3.7 +Instruments:Get system Memory and CPU dataGet processes Memory and CPU dataGet FPS dataGet network dataSet the device network status. eg: 2G, 3G ,100% LossSet the device behaves as though under a high thermal stateMonitoring app start、exit、backgroundLaunch and Kill appRun xctest. eg: WebDriverAgentDump core profile stack snapshotAnalyze the core profile data streamGet Metal GPU CountersGet App Launch LifecycleOtherProfiles & Device Management. eg: Install and uninstall Fiddler certificateGet syslogGet crash logGet the captured packet traffic and forward it to wiresharkApp install and uninstallGet device batterySet simulate-location optionsUsage:pip :> pip install py-ios-device > pyidevice --help > pyidevice instruments --helpGet device list$pyidevicedevicesGet device info$pyidevice--udid=xxxxxxdeviceinfoGet System performance data$pyideviceinstrumentsmonitorMemory>>{'App Memory':'699.69 MiB','Cached Files':'1.48 GiB','Compressed':'155.17 MiB','Memory Used':'1.42 GiB','Wired Memory':'427.91 MiB','Swap Used':'46.25 MiB'}Network>>{'Data Received':'4.07 GiB','Data Received/sec':'4.07 GiB','Data Sent':'2.54 GiB','Data Sent/sec':'2.54 GiB','Packets in':2885929,'Packets in/sec':6031576,'Packets Out':2885929,'Packets Out/sec':2885929}Disk>>{'Data Read':'117.91 GiB','Data Read/sec':0,'Data Written':'64.28 GiB','Data Written/sec':0,'Reads in':9734132,'Reads in/sec':9734132,'Writes Out':6810640,'Writes Out/sec':6810640}$pyideviceinstrumentsmonitor--filter=memory Memory>>{'App Memory':'699.69 MiB','Cached Files':'1.48 GiB','Compressed':'155.17 MiB','Memory Used':'1.42 GiB','Wired Memory':'427.91 MiB','Swap Used':'46.25 MiB'}Get Processes performance data$pyideviceinstrumentssysmontap--help $pyideviceinstrumentssysmontap-bcom.tencent.xin--proc_filtermemVirtualSize,cpuUsage--processes--sortcpuUsage# 只显示 memVirtualSize,cpuUsage 参数的进程列表,且根据 cpuUsage 字段排序[('WeChat',{'cpuUsage':0.03663705586691998,'memVirtualSize':2179284992,'name':'WeChat','pid':99269})][('WeChat',{'cpuUsage':0.036558268613227536,'memVirtualSize':2179284992,'name':'WeChat','pid':99269})]Get FPS data$pyideviceinstrumentsfps{'currentTime':'2021-05-11 14:14:40.259059','fps':52}{'currentTime':'2021-05-11 14:14:40.259059','fps':56}Get network data$pyideviceinstrumentsnetworking# Get all network data"connection-update{\"RxPackets\": 2, \"RxBytes\": 148, \"TxPackets\": 2, \"TxBytes\": 263, \"RxDups\": 0, \"RxOOO\": 0, \"TxRetx\": 0, \"MinRTT\": 0.05046875, \"AvgRTT\": 0.05046875, \"ConnectionSerial\": 5}""connection-update{\"RxPackets\": 4, \"RxBytes\": 150, \"TxPackets\": 3, \"TxBytes\": 1431, \"RxDups\": 0, \"RxOOO\": 0, \"TxRetx\": 0, \"MinRTT\": 0.0539375, \"AvgRTT\": 0.0541875, \"ConnectionSerial\": 4}"$pyideviceinstrumentsnetwork_process-pcom.tencent.xin# Get application network data{403:{'net.packets.delta':119,'time':1620720061.0643349,'net.tx.bytes':366715,'net.bytes.delta':63721,'net.rx.packets.delta':47,'net.tx.packets':633,'net.rx.bytes':34532,'net.bytes':401247,'net.tx.bytes.delta':56978,'net.rx.bytes.delta':6743,'net.rx.packets':169,'pid':403,'net.tx.packets.delta':72,'net.packets':802}}{403:{'net.packets.delta':13,'time':1620720076.2191892,'net.tx.bytes':1303204,'net.bytes.delta':5060,'net.rx.packets.delta':5,'net.tx.packets':2083,'net.rx.bytes':46736,'net.bytes':1349940,'net.tx.bytes.delta':4682,'net.rx.bytes.delta':378,'net.rx.packets':379,'pid':403,'net.tx.packets.delta':8,'net.packets':2462}}Set device status. iOS version > 12$pyideviceinstrumentsconditionget# Get device configuration information$pyideviceinstrumentsconditionset-cSlowNetworkCondition-pSlowNetwork2GUrban# Set the device network status. eg: 2G, 3G ,100% Loss$pyideviceinstrumentsconditionset-cThermalCondition-pThermalCritical# Set the device behaves as though under a high thermal stateListen to app notifications$pyideviceinstrumentsnotifications[{'execName':'MobileNotes','state_description':'Foreground Running','elevated_state_description':'Foreground Running','displayID':'com.apple.mobilenotes','mach_absolute_time':27205542653928,'appName':'Notes','elevated_state':8,'timestamp':1620714619.1264,'state':8,'pid':99367}][{'execName':'MobileNotes','state_description':'Background Running','elevated_state_description':'Background Running','displayID':'com.apple.mobilenotes','mach_absolute_time':27205678872050,'appName':'Notes','elevated_state':4,'timestamp':1620714624.802145,'state':4,'pid':99367}][{'execName':'MobileNotes','state_description':'Background Task Suspended','elevated_state_description':'Background Task Suspended','displayID':'com.apple.mobilenotes','mach_absolute_time':27205683486410,'appName':'Notes','elevated_state':2,'timestamp':1620714624.99441,'state':2,'pid':99367}]Dump core profile stack snapshot$instrumentsstackshot--outstackshot.logAnalyze the core profile data stream$instrumentsinstrumentscore_profile--pid=1107SealTalk(1107)PERF_THD_CSwitch(0x25010014)DBG_PERFPERF_DATADBG_FUNC_NONESealTalk(1107)MACH_DISPATCH(0x1400080)DBG_MACHDBG_MACH_SCHEDDBG_FUNC_NONESealTalk(1107)DecrSet(0x1090004)DBG_MACHDBG_MACH_EXCP_DECIDBG_FUNC_NONEGet Metal GPU Counters$instrumentsgpu_counters15.132907ALULimiter93.7715.132907TextureSampleLimiter39.6215.132907TextureWriteLimiter13.8715.132907BufferReadLimiter0.0115.132907BufferWriteLimiter015.132907Threadgroup/ImageblockLoadLimiter17.1615.132907Threadgroup/ImageblockStoreLimiter10.915.132907FragmentInputInterpolationLimiter15.7415.132907GPULastLevelCacheLimiter6.2415.132907VertexOccupancy015.132907FragmentOccupancy91.4415.132907ComputeOccupancy015.132907GPUReadBandwidth2.6515.132907GPUWriteBandwidth1.25Get App Launch Lifecycle$instrumentsapp_lifecycle-bcn.rongcloud.im31.20msInitializing-SystemInterfaceInitialization(Dyldinit)14.33msInitializing-StaticRuntimeInitialization35.68msLaunching-UIKitInitialization810.46usLaunching-UIKitSceneCreation100.64msLaunching-didFinishLaunchingWithOptions()2.91msLaunching-UIKitSceneCreation21.85msLaunching-InitialFrameRendering AppThreadProcessID:6506076,TotalTime:207.41msOtherProfiles & Device Management$pyideviceprofileslist{"OrderedIdentifiers":["aaaff7e2b7df39eeb77bfbc0cd7a70ea99f3fd97a"],"ProfileManifest":{"aaaff7e2b7df39eeb77bfbc0cd7a70ea99f3fd97a":{"Description":"DO_NOT_TRUST_FiddlerRoot","IsActive":true}},"ProfileMetadata":{"aaaff7e2b7df39eeb77bfbc0cd7a70ea99f3fd97a":{"PayloadDisplayName":"DO_NOT_TRUST_FiddlerRoot","PayloadRemovalDisallowed":false,"PayloadUUID":"C8CE7BC1-F840-4616-B606-337F8CB6AE19","PayloadVersion":1}},"Status":"Acknowledged"}$pyideviceprofilesinstall--pathDownloads/charles-certificate.pem## install charles certificate$pyideviceprofilesremove--namefe7371d9ce36c541ac8dee5f51f3b490b2aa98dcd95699ee44717fd5233fe7a0a## uninstall charles certificateget syslog$pyidevicesyslog# --path# --filterget crash syslog$pyidevicecrashlist['.','..','com.apple.appstored','JetsamEvent-2021-05-12-112126.ips']$pyidevicecrashexport--nameJetsamEvent-2021-05-12-112126.ips $pyidevicecrashdelete--nameJetsamEvent-2021-05-12-112126.ips $pyidevicecrashshellapps$pyideviceappslist $pyideviceappsinstall--ipa_path $pyideviceappsuninstall--bundle_id$pyideviceappslaunch--bundle_id $pyideviceappskill--bundle_id $pyideviceappsshellpacket traffic$pyidevicepcapd./test/test.pacp $pyidevicepcapd-|"/Applications/Wireshark.app/Contents/MacOS/Wireshark"-k-i-# mac forword Wireshark$pyidevicepcapd-|"D:\Program Files\Wireshark\Wireshark.exe"-k-i-# win forword Wiresharkdevice battery$pyidevicebattery# [Battery] time=1622777708, current=-71, voltage=4330, power=-307.43, temperature=3279enable developer mode$pyideviceenable_developer_modeQQ :37042417api :documentdemo:document
zhangsan12345abc
No description available on PyPI.
zhangsan12345-birds
Failed to fetch description. HTTP Status Code: 404
zhangTCD
A. To-do listpack data informationImage correlationImage contrast adjustthickness recognitionAdd labels to multiple linesComplete linescan for SEMAdd information for saved dataB. Completed taskMerge individual curves from multiple filesAdd shaded regions for peak rangeSEM - remove data zoneimage data structure createdxyplot data structure createdrestructure - abstract a base class for plotting/updating data (figProc)Add save/load toOutput individual maps/2d plots so that they can be plotted in a subfigureOutput images1. Data structure1.0 imgData1.1 lineData1.1 figProc1.2 hyperImg1.2 spcMap1.3 imgMap1.3.1. SEMremove_data_zone(kept = 0.85):kept: the portion (from top) remains; returns a new instance.
zhang-test
UNKNOWN
zhangtest3
No description available on PyPI.
zhangwei-helper
#zhangwei_helper zhangwei_helper is a package include all common part,like function,enum,writtenby zhang wei(zwzw911)installpip install zhangwei-helpercontentenumSelfEnumdescription: a module include self defined enumusage:import zhangwei_helper.SelfEnum as self_enumCpuBits: bits64/bits32OsType: Windows/LinuxWindowsVersion: Windows7/Windows8/Windows10/UnknownWindowsBits: Win32/Win64PythonVersion: Python2/Python3/UnknownProxyType: Transparent/Anonymous/High_anonymousBrowserType: FireFox/Chrome/Allfunctionosdescription: a module include some functions about osusage:import zhangwei_helper.function.Os as zw_osget_cpu_bits(): 枚举(CpuBits):cpu的位数get_os_type(): 枚举(OsType):os的类型:windows或者linuxget_windows_ver(): 枚举(WindowsVersion):windows的版本(7/8/10)get_windows_bits(): 枚举(WindowsBits):windows的位数:32或者64windows_login_as_admin(): Boolean:当前是否以admin登录get_python_major_version():枚举(PythonVersion):返回python的大版本号:2或者3或者unknownWindowsServicedescription: a module include some functions about osusage:import zhangwei_helper.function.WindowsServices as zw_winserif_service_exists(): Boolean:服务是否存在if_service_running(): Booleans:服务是否运行Networkdescription: a module include some functions about networkusage:import zhangwei_helper.function.Network as zw_networkextract_protocol_from_url(url):获得协议http或者httpsextract_host_from_url(url):获得hostextract_base_url_from_url(url):获得基础urlhttps://github.comgen_proxies_from_ip(ip): 根据IP生成request/request_html需要的代理detect_if_need_proxy(url): Boolean:是否需要代理detect_if_proxy_usable(proxies, timeout=5, url='https://www.baidu.com'):Boolean:代理是否有效detect_url_exist(url, proxies, headers): url是否存在(返回404)send_request_get_response(**args): request_html或者error。同步获得页面htmlasync_send_request_get_response(**args): request_html或者error。异步获得页面htmldownload_file(url,save_path): Error(下载失败);None(下载成功)download_unzip_chrome_driverdownload_unzip_firefox_driverSoftwaredescription: a module include some functions about softwareusage:check_minimum_python_version(ver=str): Error(python版本不匹配或者未安装);python安装路径check_firefox_version(): None(未安装FF);FF版本(自动补齐.0)check_chrome_version(): None(未安装):chrome版本check_driver_exist(python_dir, browser_type): 检查对应的driver在python目录下是否存在unzip_file():解压zip文件到指定目录is_valid_zip_file():是否为合格的zip文件Regeditdescription: a module include some functions to operate windows regusage:_open_item: 返回item_read_key_value:读取item下一个key的值和类型_save_key_value:以某种类型的方式,把值保存到某个key中read_PATH_value:读取环境变量PATH的值append_value_in_PATH:为PATH添加一个值del_value_in_PATH:从PATH中删除一个值check_key_value_exists(key,value_name):检查某个key小,value_name是否存在create_value(key,value_name,value_type,value): 直接调用_save_key_valuedelete_value(key,value_name): 删除key下的valuechange history0.0.1 add SelfEnum/Os/WindowsServices0.0.2 add const/Const.py, function/Network.py, function/Software0.0.3 add function/TypeCheck, add new enum VariantType, add test case for function/TypeCheck 0.0.4 fix issue of network/gen_proxies_from_ip & download_file & download_unzip_firefox_driver 0.0.5 add new function/Regedit.py, to operate windows reg 0.0.6 add create/delete_value/check_key_value_exists in function/Regedit.py0.0.7 software/get_chrome_version: from 2 different place get version and raise error if not found, so that can be caught by outer functionHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\Google ChromeHKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon
zhangwlgq
it is just an exercise program to print lists (the example in the book <head first python>), wish you like it.
zhangxulong
Ver: 0.0.12 hmmlearn # cannot build wheel on ubuntuVer: 0.0.11 remove qrcodeVer: 0.0.10 mail send by 126 day counterVer: 0.0.9 CloudFlare api admin dns recordVer: 0.0.8 encode vps subscribeVer: 0.0.7 wechat bot with tulingVer: 0.0.5 baseZhang review codesVer: 0.0.2 python 3.0 and init# A python module of utils for Zhang Xu-long# zhangxulong [![zhangxulong](https://img.shields.io/pypi/v/zhangxulong.svg)](https://pypi.python.org/pypi/zhangxulong)# python 3.7# Q&A[SSL: CERTIFICATE_VERIFY_FAILED]Just browse to Applications/Python 3.7 and double-click Install Certificates.command.pypircpython3 setup.py sdist uploadpython3 setup.py check# requirementspip3 installsoundfile itchat PyPDF2
zhangyilong
zhangyilong
zhangyong87524
UNKNOWN
zhangyuyan
UNKNOWN
zhangyx-test-1
My test module for Jupyter notebook call external python file
zhanlan
Failed to fetch description. HTTP Status Code: 404
zhan-lan
Failed to fetch description. HTTP Status Code: 404
zhanlan1
Failed to fetch description. HTTP Status Code: 404
zhanlan2
zhanlan_pkg
zhanlanpkg
Failed to fetch description. HTTP Status Code: 404
zhanlan-pkg
Failed to fetch description. HTTP Status Code: 404
zhanlanu
Failed to fetch description. HTTP Status Code: 404
zhao
包包简介本包包之所以仅发布了 Python3 的版本,是因为一度坚守着 Python2 的我如今也转到3了。而且,我要推荐大家将 Python3 作为您学习和使用 Python 的起点。这个包包里的东西是我准备写给自己用的一些小玩意,您可能会觉得有点五花八门,但我真心希望其中的某些代码对您也有用(使用说明中提到的内容尤其值得您的信赖)。安装升级$pip3install--user-Uzhao使用说明百度语音API通过 zhao.xin_api.BaiduYuyin 对象,使用百度语音API进行语音识别或语音合成:fromzhao.xin_api.baiduyuyinimportBaiduYuyinyaya=BaiduYuyin(api_key='您自己的百度开发者API_KEY',secret_key='您自己的百度开发者SECRET_KEY')yaya.tts_setup(speed=3,person=4)yaya.tts('我是百度语音的丫丫',save='yaya.mp3')听,百度的小妹声音真甜:)小米路由器API如果您可能也使用小米路由器 ,可能您也发现它会不时掉线,只有手动断开ADSL并重新拨号才能恢复上网?那么,您可以试试 zhao.xin_api.miwifi.MiWiFi 对象,在自己家的服务器上编写一个脚本,并设为每分钟执行一次的计划任务,让它免除您掉线的烦恼。fromzhao.xin_api.miwifiimportMiWiFiMIWIFI=MiWiFi(password='您自己的小米路由器WEB登录密码')ifMIWIFI.is_offline:ifMIWIFI.reconnect():printf('自动重新拨号成功')else:printf('自动重新拨号失败')用 zhao.xin_email.Mailman 发送带附件的邮件fromzhao.xin_emailimportMailmanmailman=Mailman(host='YOUR_SMTP_HOST',user='YOUR_SMTP_USER',password='YOUR_SMTP_PASS')ifmailman.sendmail(sender='[email protected]',receivers=['[email protected]','[email protected]'],subject='Hello, World!',content='你好,世界!',cc=['[email protected]'],bcc=['[email protected]'],files=[__file__]):print('邮件发送成功')else:print('邮件发送失败')简单好用的数据库类 XinSQLite>>>fromzhao.xin_sqliteimportXinSQLite>>>DB=XinSQLite(sql='CREATE TABLE language (name text, year integer);')>>>DB.execute('insert into language values (:name, :year);',name='C',year=1972)1>>>DB.executemany('insert into language values (:name, :year);',[dict(name='Python',year=1991),dict(name='Go',year=2009)])2>>>DB.query('select count(*) as total from language;',fetch=1).get('total',0)3>>>DB.query('select * from language where name=:name limit 1;',fetch=1,name='Ruby'){}>>>DB.query('select * from language where name=:name limit 1;',fetch=1,name='Python'){'year':1991,'name':'Python'}>>>forrowinDB.query('select name, year from language;'):print(row){'year':1972,'name':'C'}{'year':1991,'name':'Python'}{'year':2009,'name':'Go'}更多用途和秘密,有待您的探索 …更新历史v0.0.94时间: 2018-05-14添加: xin_api.amazon_mws 模块v0.0.92时间: 2018-04-11添加: xin_os 模块的几个新函数v0.0.87时间: 2018-03-29添加: xin_api 包添加: xin_api.baiduyuyin 模块添加: xin_api.miwifi 模块v0.0.80时间: 2018-03-28添加: xin_os 模块添加: xin_re 模块添加: xin_net 模块添加: xin_audio 模块添加: xin_sqlite 模块添加: xin_postgresql 模块更新: 为 xin_email.Mailman.sendmail() 添加 cc, bcc, 发送附件等功能v0.0.62时间: 2018-03-27添加: xin_email 模块
zhaogang-collec
no long_description
zhaogang-collection
no long_description
zhaogl1991
Json转换工具
zhaojl-util
No description available on PyPI.
zhaomath
No description available on PyPI.
zhaostephen-rebrn
rebrn 📘⇶🖊⇶📗rebrn is a CLI tool for bulk renaming files using dfregex (datetime-format enabled regex) to perform search and replace within file names.
zhao_test
UNKNOWN
zhaotiezhuang
UNKNOWN
zhaowenlei
UNKNOWN
zhaoyangtest
UNKNOWN
zha-quirks
ZHA Device Handlers For Home AssistantZHA Device Handlers are custom quirks implementations forZigpy, the library that provides theZigbeesupport for theZHAcomponent inHome Assistant.ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices. Zigbee devices that deviate from or do not fully conform to the standard specifications set by the Zigbee Alliance may require the development of custom ZHA Device Handlers (ZHA custom quirks handler implementation) to for all their functions to work properly with the ZHA component in Home Assistant.Custom quirks implementations for zigpy implemented as ZHA Device Handlers are a similar concept to that ofHub-connected Device Handlers for the SmartThings Classics platformas well that ofZigbee-Herdsman Converters (formerly Zigbee-Shepherd Converters) as used by Zigbee2mqtt, meaning they are virtual representation of a physical device that expose additional functionality that is not provided out-of-the-box by the existing integration between these platforms. SeeDevice Specificsfor details.How to contributePrimerZHA device handlers and its provided Quirks allow Zigpy, ZHA and Home Assistant to work with non-standard Zigbee devices. If you are reading this you may have a device that isn't working as expected. This can be the case for a number of reasons but in this guide we will cover the cases where functionality is provided by a device in a non specification compliant manner by the device manufacturer.What are these specificationsReference official Zigbee specification documentation from Connectivity Standards Alliance (a.k.a. "CSA-IOT", formerly "Zigbee Alliance"):Zigbee Cluster Library SpecificationZigbee Cluster Library Specification R8 (Revision 8)Zigbee Cluster Library Specification R7 (Revision 7)Zigbee Cluster Library Specification R6 (Revision 6)Zigbee Protocol Specification (also known as "Zigbee Pro" specifications)Zigbee Protocol Specification 2023 (also known as "Zigbee PRO 2023" / Zigbee R23)Zigbee Protocol Specification 2017 (also known as "Zigbee PRO 2017" / Zigbee R22)Zigbee Protocol Specification 2015 (also known as "Zigbee PRO 2015" / Zigbee R21)Zigbee Device SpecificationsZigbee Base Device Behavior Specification (v1.0)Zigbee Lighting & Occupancy Device Specification (v1.0)Zigbee Green Power (ZGP "GreenPower" Profile) specificationsZigbee PRO Green Power feature specification Basic functionality set (v1.1.1)Zigbee PRO Green Power feature specification 1.0a (Revision 26)Zigbee Smart Energy (ZSE / Zigbee SE "Smart Energy" Profile) specificationsZigbee Smart Energy Standard 1.4ZigBee Smart Energy Standard (v1.2a)Additionally, see these third-party and manufacturer specific documents:Tuya - Zigbee Connection Standard (Tuya Smart Documentation)Zigbee2MQTT guide on understanding the custom 'manuSpecificTuya' cluster that TuYa devices usesSamsung SmartThings -Device HandlersSamsung SmartThings - Zigbee PrimerSamsung SmartThings - Building ZigBee Device HandlersWhat is a device in human termsA device is a physical object that you want to join to a Zigbee network: a light bulb, a switch, a sensor etc. The host application, in this case Zigpy, needs to understand how to interact with the device so there are standards that define how the application and devices can communicate. The device's functionality is described by severaldescriptorswhile the device itself containsendpointsandendpointscontainclusters. There are two types of clusters an endpoint contains:in_clusters- are "Server" clusters in ZCL terms. These clusters control the device, e.g. a smart plug or light bulb would have anon_offserver cluster.in_clustersare also the ones which also send attribute reports and/or you can read an attribute from anin_cluster.out_clusters- are "Client" clusters. These clusters control some other device, as "Client" cluster sends commands to "Server" cluster. For example an On/Off remote would have anon_offclient cluster and will generate cluster commands and send those to some other device. Zigpy needs to understand all these elements in order to correctly work with the device.EndpointsEndpoints are essentially groupings of functionality. For example, a typical Zigbee light bulb will have a single endpoint for the light. A multi-gang wall switch may have an endpoint for each individual switch, so they can all be controlled separately. Each endpoint has several functions represented by clusters.ClustersClusters are objects that contain the information (attributes and commands) for individual functions. There is the ability to turn the switch on and off, maybe there is energy monitoring, maybe there is the ability to add each switch to an individual group or a scene, etc. Each of these functions belong to a cluster.DescriptorsFor the purposes of Zigpy and Quirks we will focus on two descriptors:Node DescriptorandSimple Descriptor.Node DescriptorA node descriptor explains some basic device attributes to Zigpy. The manufacturer code and the power type are the ones that we generally care about. In most cases you won't have to worry about this, but it is good to know why it is there in case you come across it while looking at an existing quirk. Here is an example:<Optional byte1=2 byte2=64 mac_capability_flags=128 manufacturer_code=4174 maximum_buffer_size=82 maximum_incoming_transfer_size=82 server_mask=0 maximum_outgoing_transfer_size=82 descriptor_capability_field=0>Simple DescriptorA simple descriptor is a description of a Zigbee device endpoint and is responsible for explaining the endpoint's functionality. It contains a profile id, the device type, and collections of clusters. The profile id tells the application what set of Zigbee rules to use. The most common profile will be 260 (0x0104) for the Home Automation profile. The device type tells the application what logical type of device this is ex: on off light, color light, etc. The clusters explain to the application what types of functionality exist on the endpoint. Here is an example:<SimpleDescriptor endpoint=1 profile=260 device_type=1026 device_version=0 input_clusters=[0, 1, 3, 32, 1026, 1280, 2821] output_clusters=[25]>What the heck is a quirkIn human terms you can think of a quirk like Google Translate. I know it's a weird comparison but let's dig in a bit. You may only speak one language but there is an interesting article written in another language that you really want to read. Google Translate takes the original article and displays it in a format (language) that you understand. A quirk is a file that translates device functionality from the format that the manufacturer chose to implement it in to a format that Zigpy and in turn ZHA understand. The main purpose of a quirk is to serve as a translator. A quirk comprises several parts:Signature - To identify and apply the correct quirkReplacement - To allow Zigpy and ZHA to correctly work with the devicedevice_automation_triggers - To let the Home Assistant Device Automation engine and users interact with the deviceSignatureThe signature on a quirk identifies the device as the manufacturer implemented it. You can think of it as a fingerprint or the dna of the device. The signature is what we use to identify the device. If any part of the signature doesn't match what the device returns during discovery the quirk will not match and as a result it will not be applied. The signature is made up of several parts:models_infoendpointsModels info tells the application which devices should use this particular quirk. Endpoints are the simple descriptors that we spoke about earlier exactly as they are on the device.endpointsis a dict where the key is the id of the endpoint and the value is an object with the following properties:profile_id,device_type,input_clustersandoutput_clusters. Creating the signature element is generally just a job of transcribing what the device gives us. Here is an example:signature={MODELS_INFO:[(LUMI,"lumi.plug.maus01")],ENDPOINTS:{# <SimpleDescriptor endpoint=1 profile=260 device_type=81# device_version=1# input_clusters=[0, 4, 3, 6, 16, 5, 10, 1, 2, 2820]# output_clusters=[25, 10]>1:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.SMART_PLUG,INPUT_CLUSTERS:[Basic.cluster_id,PowerConfiguration.cluster_id,DeviceTemperature.cluster_id,Groups.cluster_id,Identify.cluster_id,OnOff.cluster_id,Scenes.cluster_id,BinaryOutput.cluster_id,Time.cluster_id,ElectricalMeasurement.cluster_id,],OUTPUT_CLUSTERS:[Ota.cluster_id,Time.cluster_id],},},}ReplacementThe replacement on a quirk is what we want the device to be. Remember, we said that quirks were like Google Translate... You can think of the replacement like the output from Google Translate. The replacement dict is what will actually be used by Zigpy and ZHA to interact with the device. The structure ofreplacementis the same as signature with 2 key differences:models_infois generally omitted and there is an extra elementskip_configurationthat instructs the application to skip configuration if necessary. Some manufacturers have not implemented the specifications correctly and the devices come pre-configured and therefore the configuration calls fail (non Zigbee 3.0 Xiaomi devices for instance). Usually, you should not addskip_configuration.Here is an example:replacement={SKIP_CONFIGURATION:True,ENDPOINTS:{1:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.SMART_PLUG,INPUT_CLUSTERS:[BasicCluster,PowerConfiguration.cluster_id,DeviceTemperature.cluster_id,Groups.cluster_id,Identify.cluster_id,OnOff.cluster_id,Scenes.cluster_id,BinaryOutput.cluster_id,Time.cluster_id,ElectricalMeasurementCluster,],OUTPUT_CLUSTERS:[Ota.cluster_id,Time.cluster_id],},},}device_automation_triggersDevice automation triggers are essentially representations of the events that the devices fire in HA. They allow users to use actions in the UI instead of using the raw events.Building a quirkNow that we got that out of the way we can focus on the task at hand: make our devices work the way they should with Zigpy and ZHA. Because the device doesn't work correctly out of the box we have to write a quirk for it. First lets look at what the quirk looks like when complete:classPlug(XiaomiCustomDevice):"""lumi.plug.maus01 plug."""def__init__(self,*args,**kwargs):"""Init."""self.voltage_bus=Bus()self.consumption_bus=Bus()self.power_bus=Bus()super().__init__(*args,**kwargs)signature={MODELS_INFO:[(LUMI,"lumi.plug.maus01")],ENDPOINTS:{# <SimpleDescriptor endpoint=1 profile=260 device_type=81# device_version=1# input_clusters=[0, 4, 3, 6, 16, 5, 10, 1, 2, 2820]# output_clusters=[25, 10]>1:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.SMART_PLUG,INPUT_CLUSTERS:[Basic.cluster_id,PowerConfiguration.cluster_id,DeviceTemperature.cluster_id,Groups.cluster_id,Identify.cluster_id,OnOff.cluster_id,Scenes.cluster_id,BinaryOutput.cluster_id,Time.cluster_id,ElectricalMeasurement.cluster_id,],OUTPUT_CLUSTERS:[Ota.cluster_id,Time.cluster_id],},# <SimpleDescriptor endpoint=2 profile=260 device_type=9# device_version=1# input_clusters=[12]# output_clusters=[12, 4]>2:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.MAIN_POWER_OUTLET,INPUT_CLUSTERS:[AnalogInput.cluster_id],OUTPUT_CLUSTERS:[AnalogInput.cluster_id,Groups.cluster_id],},# <SimpleDescriptor endpoint=3 profile=260 device_type=83# device_version=1# input_clusters=[12]# output_clusters=[12]>3:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.METER_INTERFACE,INPUT_CLUSTERS:[AnalogInput.cluster_id],OUTPUT_CLUSTERS:[AnalogInput.cluster_id],},# <SimpleDescriptor endpoint=100 profile=260 device_type=263# device_version=2# input_clusters=[15]# output_clusters=[15, 4]>100:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.OCCUPANCY_SENSOR,INPUT_CLUSTERS:[BinaryInput.cluster_id],OUTPUT_CLUSTERS:[BinaryInput.cluster_id,Groups.cluster_id],},},}replacement={SKIP_CONFIGURATION:True,ENDPOINTS:{1:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.SMART_PLUG,INPUT_CLUSTERS:[BasicCluster,PowerConfiguration.cluster_id,DeviceTemperature.cluster_id,Groups.cluster_id,Identify.cluster_id,OnOff.cluster_id,Scenes.cluster_id,BinaryOutput.cluster_id,Time.cluster_id,ElectricalMeasurementCluster,],OUTPUT_CLUSTERS:[Ota.cluster_id,Time.cluster_id],},2:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.MAIN_POWER_OUTLET,INPUT_CLUSTERS:[AnalogInputCluster],OUTPUT_CLUSTERS:[AnalogInput.cluster_id,Groups.cluster_id],},3:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.METER_INTERFACE,INPUT_CLUSTERS:[AnalogInput.cluster_id],OUTPUT_CLUSTERS:[AnalogInput.cluster_id],},100:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.OCCUPANCY_SENSOR,INPUT_CLUSTERS:[BinaryInput.cluster_id],OUTPUT_CLUSTERS:[BinaryInput.cluster_id,Groups.cluster_id],},},}This quirk is for the US version of the Xiaomi plug. Xiaomi is notorious for not following the Zigbee specifications and most of their non Zigbee 3.0 devices need a quirk to function correctly. In this case we are correcting theElectricalMeasurementcluster readings. Xiaomi decided to report the values for this cluster on theAnalogInputcluster instead. To fix this we will create a custom cluster to replace theAnalogInputandElectricalMeasurementclusters. We will take the values that are reported on theAnalogInputcluster and publish them to theElectricalMeasurementcluster. Doing this allows the device to work as if Xiaomi had implemented this in the first place. This is the act of translating that was mentioned in the Google Translate analogy above.First things first. All device definitions in quirks must extendCustomDeviceor a derivative of it and all clusters that you define must extendCustomClusteror a derivative of it. If you want to send messages betweenCustomClusterdefinitions as we do here you need to create channels for the communication to flow through. We do this by adding instances ofBuson ourCustomDeviceimplementation.Busis a utility class used specifically for this purpose and adding it to the device implementation ensures that all clusters that you define will have access to theBusso that they can communicate with each other.classPlug(XiaomiCustomDevice):"""lumi.plug.maus01 plug."""def__init__(self,*args,**kwargs):"""Init."""self.voltage_bus=Bus()self.consumption_bus=Bus()self.power_bus=Bus()super().__init__(*args,**kwargs)You can see that we have extendedXiaomiCustomDevicewhich is a derivative ofCustomDeviceshared by Xiaomi devices. You can also see that we have added some instances ofBusso that we can pass messages betweenCustomClusterdefinitions. To be clear, this is not always necessary. Quirks can be used to change formats of data on an existing cluster, to add manufacturer specific attributes or commands to clusters etc. In these instances you just need to create a derivative ofCustomClusterand add your logic. This is more of an advanced example to illustrate what is possible.Here are the custom cluster definitions:classAnalogInputCluster(CustomCluster,AnalogInput):"""Analog input cluster, only used to relay power consumption information to ElectricalMeasurementCluster."""cluster_id=AnalogInput.cluster_iddef__init__(self,*args,**kwargs):"""Init."""self._current_state={}super().__init__(*args,**kwargs)def_update_attribute(self,attrid,value):super()._update_attribute(attrid,value)ifvalueisnotNoneandvalue>=0:self.endpoint.device.power_bus.listener_event(POWER_REPORTED,value)classElectricalMeasurementCluster(LocalDataCluster,ElectricalMeasurement):"""Electrical measurement cluster to receive reports that are sent to the basic cluster."""cluster_id=ElectricalMeasurement.cluster_idPOWER_ID=0x050BVOLTAGE_ID=0x0500CONSUMPTION_ID=0x0304def__init__(self,*args,**kwargs):"""Init."""super().__init__(*args,**kwargs)self.endpoint.device.voltage_bus.add_listener(self)self.endpoint.device.consumption_bus.add_listener(self)self.endpoint.device.power_bus.add_listener(self)defpower_reported(self,value):"""Power reported."""self._update_attribute(self.POWER_ID,value)defvoltage_reported(self,value):"""Voltage reported."""self._update_attribute(self.VOLTAGE_ID,value)defconsumption_reported(self,value):"""Consumption reported."""self._update_attribute(self.CONSUMPTION_ID,value)In theAnalogInputcluster we override the_update_attributemethod so that we can access the data that the cluster receives when the device sends a report and we send the data via an event on a bus to theElectricalMeasurementcluster. This is the line that does the heavy lifting:self.endpoint.device.power_bus.listener_event(POWER_REPORTED, value)Then in theElectricalMeasurementcluster we need to subscribe to these events and handle them. This is how we subscribe to our custom events:self.endpoint.device.power_bus.add_listener(self)and this method (the method name must match the event name that you publish EXACTLY):defpower_reported(self,value):"""Power reported."""self._update_attribute(self.POWER_ID,value)receives the event and handles updating the attribute on the correct zigbee cluster. As you can see there really isn't much here that needs to be done to accomplish our goal.Once we have created ourCustomClusterimplementations we have to tell theCustomDeviceimplementation to use them. We do this in thereplacementdict in the quirk definition. Start by copying thesignaturedict and remove themodels_infofrom it. Then we replace the cluster ids that we want to override with the names of ourCustomClusterimplementations that we have created. The result looks like this:replacement={SKIP_CONFIGURATION:True,ENDPOINTS:{1:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.SMART_PLUG,INPUT_CLUSTERS:[BasicCluster,PowerConfiguration.cluster_id,DeviceTemperature.cluster_id,Groups.cluster_id,Identify.cluster_id,OnOff.cluster_id,Scenes.cluster_id,BinaryOutput.cluster_id,Time.cluster_id,ElectricalMeasurementCluster,],OUTPUT_CLUSTERS:[Ota.cluster_id,Time.cluster_id],},2:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.MAIN_POWER_OUTLET,INPUT_CLUSTERS:[AnalogInputCluster],OUTPUT_CLUSTERS:[AnalogInput.cluster_id,Groups.cluster_id],},3:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.METER_INTERFACE,INPUT_CLUSTERS:[AnalogInput.cluster_id],OUTPUT_CLUSTERS:[AnalogInput.cluster_id],},100:{PROFILE_ID:zha.PROFILE_ID,DEVICE_TYPE:zha.DeviceType.OCCUPANCY_SENSOR,INPUT_CLUSTERS:[BinaryInput.cluster_id],OUTPUT_CLUSTERS:[BinaryInput.cluster_id,Groups.cluster_id],},You can see that we have replacedElectricalMeasurement.cluster_idfrom endpoint 1 in thesignaturedict with the name of our cluster that we created:ElectricalMeasurementClusterand on endpoint 2 we replacedAnalogInput.cluster_idwith the implementation we created for that:AnalogInputCluster. This instructs Zigpy to use theseCustomClusterderivatives instead of the normal cluster definitions for these clusters and this is why this part of the quirk is calledreplacement.Now lets put this all together. If you examine the device definition above you will see that we have defined our custom device, we defined thesignaturedict where we transcribed theSimpleDescriptoroutput we obtained when the device joined the network and we defined thereplacementdict where we swapped the cluster ids for the culsters that we wanted to replace with theCustomClusterimplementations that we created.Contribution GuidelinesAll code is formatted with black. The check format script that runs in CI will ensure that code meets this requirement and that it is correctly formatted with black. Instructions for installing black in many editors can be found here:https://github.com/psf/black#editor-integrationCapture the SimpleDescriptor log entries for each endpoint on the device. These can be found in the HA logs after joining a device and they look like this:<SimpleDescriptor endpoint=1 profile=260 device_type=1026 device_version=0 input_clusters=[0, 1, 3, 32, 1026, 1280, 2821] output_clusters=[25]>. This information can also be obtained from the zigbee.db if you want to take the time to query the tables and reconstitute the log entry. I find it easier to just remove and rejoin the device. ZHA entity ids are stable for the most part so itshouldn'tdisrupt anything you have configured. These need to match what the device reports EXACTLY or zigpy will not match them when a device joins and the handler will not be used for the device. You can also obtain this information from the device screen in HA for the device. TheZigbee Device Signaturebutton will launch a dialog that contains all of the information necessary to create quirks.All custom device definitions must extendCustomDeviceor a derivative of itAll custom cluster definitions must extendCustomClusteror a derivative of itUse constants for all attribute values referencing the appropriate labels from Zigpy / HA as necessaryUse an existing handler as a guide. signature and replacement dicts are required. Include the SimpleDescriptor entry for each endpoint in the signature dict above the definition of the endpoint in this format:# <SimpleDescriptor endpoint=1 profile=260 device_type=1026# device_version=0# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821]# output_clusters=[25]>Howdevice_automation_triggersworkDevice automation triggers are essentially representations of the events that the devices fire in HA. They allow users to use actions in the UI instead of using the raw events. Ex: For the Hue remote - the on button fires this event:<Event zha_event[L]: unique_id=00:17:88:01:04:e7:f9:37:1:0x0006, device_ieee=00:17:88:01:04:e7:f9:37, endpoint_id=1, cluster_id=6, command=on, args=[]>and the action defined for this is:(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON}The first part(SHORT_PRESS, TURN_ON)corresponds to the txt the user will see in the UI:The second part is the event data. You only need to supply enough of the event data to uniquely match the event which in this case is just the command for this event fired by this device:{COMMAND: COMMAND_ON}If you look at another example for the same device:(SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_STEP, CLUSTER_ID: 8, ENDPOINT_ID: 1, PARAMS: {'step_mode': 0},}You can see a pattern that illustrates how to match a more complex event. In this case the step command is used for the dim up and dim down buttons so we need to match more of the event data to uniquely match the event.Setting up the development environmentOpen a terminal at the root of the project and run the setup script:script/setupThis script will install all necessary dependencies and it will install the precommit hook.The tests use thepytestframework.Getting startedTo get set up, you need install the test dependencies:pipinstall-rrequirements_test_all.txtRunning the testsSee thepytest documentationfor details about how to run the tests. For example, to run all thetest_tuya.pytests:$pytest--disable-warningstests/test_tuya.py Testsessionstarts(platform:linux,Python3.9.2,pytest6.2.5,pytest-sugar0.9.4)collecting...tests/test_tuya.py✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓100%██████████ Results(3.58s):41passedWriting testsTo add a new test, start by adding a new function to one of the existing test files. You can follow the instructions in theGetting startedsection of the pytest documentation.Using fixtures to set things upIn order to write a test, you will need to access an instance of a quirk to run the tests against. Pytest provides a useful feature called Fixtures that allow you to write and use the setup code necessary in one place, similar to how we use libraries to provide common functions to other code.You can read more about fixtureshere.You can find the common fixtures in files namedconftest.py. Pytest will list them for you as follows:$pytest--fixtures[...]---fixturesdefinedfromtests.conftest--- MockAppControllerAppcontrollermock. ieee_mockReturnastaticieee. zigpy_device_mockZigpydevicemock. zigpy_device_from_quirkCreatezigpydevicefromQuirkssignature.[...]---fixturesdefinedfromtests.test_tuya_clusters--- TuyaClusterMockofthenewTuyamanufacturercluster.Some fixtures such asapp_controller_mockwill provide an object instance that you can use directly. Others, such aszigpy_device_mockwill return a function, which you can call to create a customised object during your own setup.Testing the quirk signature matchingThe fixtureassert_signature_matches_quirkprovides a function that can be used to check that a particular device signature matches the corresponding quirk. By capturing the signature and adding a few lines to the test file, this means that you can verify that your device will be matched against the quirk without needing to go through the paring process directly.You need to capture the device signature and save it. If you have previously started the pairing process in Home assistant, you can find the signature under 'Zigbee Device Signature' on the device page.Now you can create a test that checks the signature as follows:deftest_ts0121_signature(assert_signature_matches_quirk):signature={"node_descriptor":"NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)","endpoints":{"1":{"profile_id":260,"device_type":"0x0051","in_clusters":["0x0000","0x0004","0x0005","0x0006","0x0702","0x0b04"],"out_clusters":["0x000a","0x0019"]}},"manufacturer":"_TZ3000_g5xawfcq","model":"TS0121","class":"zhaquirks.tuya.ts0121_plug.Plug"}assert_signature_matches_quirk(zhaquirks.tuya.ts0121_plug.Plug,signature)ThanksSpecial thanks to damarco for the majority of the device tracker codeSpecial thanks to Yoda-x for the Xioami attribute parsing codeSpecial thanks to damarco and Adminiuga for allowing me to bounce ideas off of them and for listening to me rambleRelated projectsZigpyzigpyis aZigbee protocol stackintegration project to implement theZigbee Home Automationstandard as a Python 3 library. Zigbee Home Automation integration with zigpy allows you to connect one of many off-the-shelf Zigbee adapters using one of the available Zigbee radio library modules compatible with zigpy to control Zigbee based devices. There is currently support for controlling Zigbee device types such as binary sensors (e.g., motion and door sensors), sensors (e.g., temperature sensors), light bulbs, switches, locks, fans, covers (blinds, marquees, and more). A working implementation of zigpy exists inHome Assistant(Python based open source home automation software) as part of itsZHA componentZHA Network Cardzha-network-cardis a custom Lovelace card that displays ZHA network and device information in Home Assistant
zhash
zser content hashing algorithm
zhatlebaye-kafka
Zhatlebaye KafkaZhatlebaye Kafka is an extension to the aiokafka library with enhanced producer and consumer functionalities.InstallationYou can install the Zhatlebaye Kafka library using pip:pipinstallzhatlebaye_kafkaClasses and FunctionsKafkaProducerTheKafkaProducerclass is used to produce messages to Kafka topics. It uses theaiokafka.AIOKafkaProducerclass under the hood. It has the following methods:connect(): Connects to the Kafka server.disconnect(): Disconnects from the Kafka server.send_message(topic, message, callback=None): Sends a message to a Kafka topic. If a callback function is provided, it will be called with the result of the send operation.send_message_sync(topic, message): A synchronous version ofsend_message(). It blocks until the message has been sent.KafkaProducerSingletonTheKafkaProducerSingletonclass is a singleton version of theKafkaProducerclass. It has the same methods asKafkaProducer, but they are class methods instead of instance methods.KafkaRouterTheKafkaRouterclass is used to route messages from Kafka topics to their respective handlers. It has the following methods:add_handler(topic, handler): Adds a handler function for a Kafka topic. The handler function will be called with the message whenever a message is received from the topic.handle_message(message): Calls the handler function for the topic of the given message with the message as an argument.KafkaConsumerTheKafkaConsumerclass is used to consume messages from Kafka topics. It uses theaiokafka.AIOKafkaConsumerclass under the hood. It has the following methods:start(): Starts the consumer. It will begin consuming messages from its topics and passing them to their respective handlers.stop(): Stops the consumer.run(): Starts the consumer and keeps it running untilstop()is called.UsageKafkaProducerfromzhatlebaye_kafkaimportKafkaProducerproducer=KafkaProducer(bootstrap_servers='localhost:9092')awaitproducer.connect()awaitproducer.send_message('my-topic',{'key':'value'})KafkaProducerSingletonfromzhatlebaye_kafkaimportKafkaProducerSingletonawaitKafkaProducerSingleton.connect(bootstrap_servers='localhost:9092')awaitKafkaProducerSingleton.send_message_sync('my-topic',{'key':'value'})KafkaRouterfromzhatlebaye_kafkaimportKafkaRouterrouter=KafkaRouter()router.add_handler('my-topic',my_handler)KafkaRouterThe KafkaRouter is used to route messages from Kafka topics to their respective handlers. Here's a basic example of how to use it:fromzhatlebaye_kafkaimportKafkaRouter,KafkaConsumerdefmy_handler(message):print(f"Received message:{message}")router=KafkaRouter()router.add_handler('my-topic',my_handler)consumer=KafkaConsumer(group_id='my-group',bootstrap_servers='localhost:9092',router=router)awaitconsumer.start()LicenseThis project is licensed under the terms of the MIT license.ContactYerlan Yesmoldin [email protected] Link:https://gitlab.com/di-halyk-academy-zhatlebaye/zhatlebaye-kafka
zhaws
zha-websocket-serverRunning the serverCheckout the code and open a terminal at the root of the project. Then run the following commands:script/setup script/runOpen another terminal at the root of the project and run the following command:script/run_clientTo start the server modify the content of thestart_network.jsonfile in the examples directory to match your radio and paste it as a single line into the console and press return / enterto stop the server paste the content of thestop_network.jsonfile into the prompt in the console as a single line and press return / enter
zhcevanstest
Put a detailed description of your package here
zhcode
zhcodezhcodeis a Python library designed to facilitate coding in Chinese. It's main purpose is to createesoteric forms of programming languages using the Chinese language.You can installzhcodeby runningpip3 install zhcodein your environment.PythonCurrently, basic Python 3 functions are supported. The project is still in the process of translating library keywords, names, and functions into Chinese equivalents. In general, the syntax for coding in 中文Python is the same as that of normal Python, simply with variables switched. However, several syntactic additions have been made: the dot delimeter.in standard Python has been changed to·, and variables should be enclosed with「」to facilitate easier differentiation.Furthermore, Chinese keyboard characters often have a tendency to include extra space as part of the character—-thus oftentimes reducing the need for extra whitespace after the character. In particular, variable delimeters. Thus, there is no need to add an extra space after a closing variable delimeter (」)--the translator will add one automatically.
zhcode-cli
No description available on PyPI.
zhconv
zhconv提供基于 MediaWiki 词汇表的最大正向匹配简繁转换。Python 2, 3 通用。支持以下地区词转换:zh-cn大陆简体zh-tw台灣正體zh-hk香港繁體zh-sg马新简体(无词汇表,需要手工指定)zh-hans简体zh-hant繁體示例>>>print(convert(u'我幹什麼不干你事。','zh-cn'))我干什么不干你事。>>>print(convert(u'人体内存在很多微生物','zh-tw'))人體內存在很多微生物完整支持 MediaWiki 人工转换语法:>>>print(convert_for_mw(u'在现代,机械计算-{}-机的应用已经完全被电子计算-{}-机所取代','zh-hk'))在現代,機械計算機的應用已經完全被電子計算機所取代>>>print(convert_for_mw(u'-{zh-hant:資訊工程;zh-hans:计算机工程学;}-是电子工程的一个分支,主要研究计算机软硬件和二者间的彼此联系。','zh-tw'))資訊工程是電子工程的一個分支,主要研究計算機軟硬體和二者間的彼此聯繫。>>>print(convert_for_mw(u'張國榮曾在英國-{zh:利兹;zh-hans:利兹;zh-hk:列斯;zh-tw:里茲}-大学學習。','zh-sg'))张国荣曾在英国利兹大学学习。>>>print(convert_for_mw('毫米(毫公分),符號mm,是長度單位和降雨量單位,-{zh-hans:台湾作-{公釐}-或-{公厘}-;zh-hant:港澳和大陸稱為-{毫米}-(台灣亦有使用,但較常使用名稱為毫公分);zh-mo:台灣作-{公釐}-或-{公厘}-;zh-hk:台灣作-{公釐}-或-{公厘}-;}-。','zh-cn'))毫米(毫公分),符号mm,是长度单位和降雨量单位,台湾作公釐或公厘。和其他高级字词转换语法。命令行工具python -mzhconv [-w] {zh-cn|zh-tw|zh-hk|zh-sg|zh-hans|zh-hant|zh} < input > output
zhconv-rs
zhconv-rs 中文简繁及地區詞轉換zhconv-rs converts Chinese text among traditional/simplified scripts or regional variants (e.g.zh-TW <-> zh-CN <-> zh-HK <-> zh-Hans <-> zh-Hant), built on the top of rulesets from MediaWiki/Wikipedia and OpenCC.The implementation is powered by anAho-Corasickautomaton, ensuring linear time complexity with respect to the length of input text and conversion rules (O(n+m)), processing dozens of MiBs text per second.🔗Web App:https://zhconv.pages.dev(powered by WASM)⚙️Cli:cargo install zhconv-clior checkreleases.🦀Rust Crate:cargo add zhconv(checkdocsfor examples)🐍Python Package via PyO3:pip install zhconv-rs(WASM with wheels)Python snippet# > pip install zhconv_rs# Convert with builtin rulesets:fromzhconv_rsimportzhconvassertzhconv("天干物燥 小心火烛","zh-tw")=="天乾物燥 小心火燭"assertzhconv("霧失樓臺,月迷津渡","zh-hans")=="雾失楼台,月迷津渡"assertzhconv("《-{zh-hans:三个火枪手;zh-hant:三劍客;zh-tw:三劍客}-》是亞歷山大·仲馬的作品。","zh-cn",mediawiki=True)=="《三个火枪手》是亚历山大·仲马的作品。"assertzhconv("-{H|zh-cn:雾都孤儿;zh-tw:孤雛淚;zh-hk:苦海孤雛;zh-sg:雾都孤儿;zh-mo:苦海孤雛;}-《雾都孤儿》是查尔斯·狄更斯的作品。","zh-tw",True)=="《孤雛淚》是查爾斯·狄更斯的作品。"# Convert with custom rules:fromzhconv_rsimportmake_converterassertmake_converter(None,[("天","地"),("水","火")])("甘肅天水")=="甘肅地火"importioconvert=make_converter("zh-hans",io.StringIO("䖏 处\n罨畫 掩画"))# or path to rule fileassertconvert("秀州西去湖州近 幾䖏樓臺罨畫間")=="秀州西去湖州近 几处楼台掩画间"JS (Webpack):npm install zhconvoryarn add zhconv(WASM,instructions)JS in browser:https://cdn.jsdelivr.net/npm/zhconv-web@latest(WASM)HTML snippet<scripttype="module">// Use ES module import syntax to import functionality from the module// that we have compiled.//// Note that the `default` import is an initialization function which// will "boot" the module and make it ready to use. Currently browsers// don't support natively imported WebAssembly as an ES module, but// eventually the manual initialization won't be required!importinit,{zhconv}from'https://cdn.jsdelivr.net/npm/zhconv-web@latest/zhconv.js';// specify a version tag if in prodasyncfunctionrun(){awaitinit();alert(zhconv(prompt("Text to convert to zh-hans:"),"zh-hans"));}run();</script>Supported variantszh-Hant, zh-Hans, zh-TW, zh-HK, zh-MO, zh-CN, zh-SG, zh-MYTargetTagScriptDescriptionSimplifiedChinese / 简体中文zh-HansSC / 简W/O substituing region-specific phrases.TraditionalChinese / 繁體中文zh-HantTC / 繁W/O substituing region-specific phrases.Chinese (Taiwan) / 臺灣正體zh-TWTC / 繁With Taiwan-specific phrases adapted.Chinese (Hong Kong) / 香港繁體zh-HKTC / 繁With Hong Kong-specific phrases adapted.Chinese (Macau) / 澳门繁體zh-MOTC / 繁Same aszh-HKfor now.Chinese (Mainland China) / 大陆简体zh-CNSC / 简With mainland China-specific phrases adapted.Chinese (Singapore) / 新加坡简体zh-SGSC / 简Same aszh-CNfor now.Chinese (Malaysia) / 大马简体zh-MYSC / 简Same aszh-CNfor now.Note:zh-TWandzh-HKare based onzh-Hant.zh-CNare based onzh-Hans. Currently,zh-MOshares the same rulesets withzh-HKunless additional rules are manually configured;zh-MYandzh-SGshares the same rulesets withzh-CNunless additional rules are manually configured.Performancecargo benchonIntel(R) Xeon(R) CPU @ 2.80GHz(GitPod), without parsing inline conversion rules:load zh2Hant time: [45.442 ms 45.946 ms 46.459 ms] load zh2Hans time: [8.1378 ms 8.3787 ms 8.6414 ms] load zh2TW time: [60.209 ms 61.261 ms 62.407 ms] load zh2HK time: [89.457 ms 90.847 ms 92.297 ms] load zh2MO time: [96.670 ms 98.063 ms 99.586 ms] load zh2CN time: [27.850 ms 28.520 ms 29.240 ms] load zh2SG time: [28.175 ms 28.963 ms 29.796 ms] load zh2MY time: [27.142 ms 27.635 ms 28.143 ms] zh2TW data54k time: [546.10 us 553.14 us 561.24 us] zh2CN data54k time: [504.34 us 511.22 us 518.59 us] zh2Hant data689k time: [3.4375 ms 3.5182 ms 3.6013 ms] zh2TW data689k time: [3.6062 ms 3.6784 ms 3.7545 ms] zh2Hant data3185k time: [62.457 ms 64.257 ms 66.099 ms] zh2TW data3185k time: [60.217 ms 61.348 ms 62.556 ms] zh2TW data55m time: [1.0773 s 1.0872 s 1.0976 s]The benchmark was performed on a previous version that had only Mediawiki rulesets. In the newer version, with OpenCC rulesets activated by default, the performance may degrade ~2x.Differences with other convertersZhConver{sion,ter}.phpof MediaWiki: zhconv-rs just takes conversion tables listed inZhConversion.php. MediaWiki relies on the inefficient PHP built-in functionstrtr. Under the basic mode, zhconv-rs guarantees linear time complexity (T = O(n+m)instead ofO(nm)) and single-pass scanning of input text. Optionally, zhconv-rs supports the same conversion rule syntax with MediaWiki.OpenCC: Theconversion rulesetsof OpenCC is independent of MediaWiki. The coreconversion implementationof OpenCC is kinda similar to the aforementionedstrtr. However, OpenCC supports pre-segmentation and maintains multiple rulesets which are applied successively. By contrast, the Aho-Corasick-powered zhconv-rs merges rulesets from MediaWiki and OpenCC in compile time and converts text in single-pass linear time, resulting in much more efficiency. Though, conversion results may differ in some cases.LimitationsThe converter takes leftmost-longest matching strategy. It gives priority to the leftmost-matched words or phrases. For instance, if a ruleset includes both干 -> 幹and天干物燥 -> 天乾物燥, the converter would prioritize天乾物燥because天干物燥gets matched earlier compared to干at a later position. The strategy yields good results in general, but may occasionally lead to wrong conversions.The implementation support most of the MediaWiki conversion rules. But it is not fully compliant with the original implementation.Besides, for wikitext, if input text contains global conversion rules (in MediaWiki syntax like -{H|zh-hans:鹿|zh-hant:马}-), the time complexity of the implementation may degrade toO(n*m)wherenandmare the length of the text and the maximum lengths of sources words in conversion rulesets in the worst case (equivalent to brute-force).CreditsAll rulesets that power the converter come from theMediaWikiproject andOpenCC.The project takes the following projects/pages as references:https://github.com/gumblex/zhconv: Python implementation ofzhConver{ter,sion}.php.https://github.com/BYVoid/OpenCC/: Widely adopted Chinese converter.https://zh.wikipedia.org/wiki/Wikipedia:字詞轉換處理https://zh.wikipedia.org/wiki/Help:高级字词转换语法https://github.com/wikimedia/mediawiki/blob/master/includes/language/LanguageConverter.phpTODOSupportModule:CGroupPropogate error properly with Anyhow and thiserrorPython libMore exmaples in READMEAdd rulesets from OpenCC
zhdan-utils
No description available on PyPI.
zh-dataset-inews
NLP tool
zhdate
ZhDate 中国农历日期处理对象不用网络接口直接本地计算中国农历,支持农历阳历互转感谢EillesWan更新修正农历初一前一天错误修正f 字符串输出方式安装方法通过 pip 直接安装pipinstallzhdate或从git拉取gitclonehttps://github.com/CutePandaSh/zhdate.gitcdzhdate pythonsetup.pyinstall更新pipinstallzhdate--upgrade使用方法见如下代码案例:fromzhdateimportZhDatedate1=ZhDate(2010,1,1)# 新建农历 2010年正月初一 的日期对象print(date1)# 直接返回农历日期字符串dt_date1=date1.to_datetime()# 农历转换成阳历日期 datetime 类型dt_date2=datetime(2010,2,6)date2=ZhDate.from_datetime(dt_date2)# 从阳历日期转换成农历日期对象date3=ZhDate(2020,4,30,leap_month=True)# 新建农历 2020年闰4月30日print(date3.to_datetime())# 支持比较ifZhDate(2019,1,1)==ZhDate.from_datetime(datetime(2019,2,5)):pass# 减法支持new_zhdate=ZhDate(2019,1,1)-30#减整数,得到差额天数的新农历对象new_zhdate2=ZhDate(2019,1,1)-ZhDate(2018,1,1)#两个zhdate对象相减得到两个农历日期的差额new_zhdate3=ZhDate(2019,1,1)-datetime(2019,1,1)# 减去阳历日期,得到农历日期和阳历日期之间的天数差额# 加法支持new_zhdate4=ZhDate(2019,1,1)+30# 加整数返回相隔天数以后的新农历对象# 中文输出new_zhdate5=ZhDate(2019,1,1)print(new_zhdate5.chinese())# 当天的农历日期ZhDate.today()
zhdk
ZHDKOur mission atZamais to protect people’s privacy by preventing data breaches and unethical surveillance.Following a recent breakthrough in homomorphic encryption, we are now building a ZeroTrust deep learning framework that enables fast and accurate inference over encrypted data, with minimal performance overhead, no changes to the network architecture and no retraining necessary.Zamais open-source by design, as we believe privacy-enabling technologies should benefit the widest possible community of developers and researchers.WarningThis package is not a working package.Testimportzhdkzhdk.hello_world()
zh_doclint
# zh-doclintNote: This project is highly related to Chinese, so the document is writtern in Chinese.## 简介一个检查文档风格的工具。## 安装```pip install zh-doclint```## 使用```shell$ zh-doclint --helpUsage: zh-doclint [OPTIONS] FPATHOptions:--version Show the version and exit.--help Show this message and exit.$ ccat doc.md我跟你讲,这里有问题. 这个case一看就是“药丸”$ zh-doclint doc.md==========================================E101: 英文与非标点的中文之间需要有一个空格==========================================LINE: 2case一看就是“--...............==================================================E201: 只有中文或中英文混排中,一律使用中文全角标点==================================================LINE: 1里有问题.-.........==========================================================E204: 中文文案中使用中文引号「」和『』,其中「」为外层引号==========================================================LINE: 2一看就是“药丸-..............LINE: 2是“药丸”-..........```## 支持的检查项目| 错误码 | 检查范围 | 描述 || ---- | -------- | ------------------------------------------------------------------------------ || E101 | 段落 | 英文与非标点的中文之间需要有一个空格 || E102 | 段落 | 数字与非标点的中文之间需要有一个空格 || E103 | 段落 | 除了「%」、「℃」、以及倍数单位(如 2x、3n)之外,其余数字与单位之间需要加空格 || E104 | 段落 | 书写时括号中全为数字,则括号用半角括号且首括号前要空一格 || E201 | 句子 | 只有中文或中英文混排中,一律使用中文全角标点 || E202 | 句子 | 如果出现整句英文,则在这句英文中使用英文、半角标点 || E203 | 段落 | 中文标点与其他字符间一律不加空格 || E204 | 句子 | 中文文案中使用中文引号「」和『』,其中「」为外层引号 || E205 | 段落 | 省略号请使用「……」标准用法 || E206 | 段落 | 感叹号请使用「!」标准用法 || E207 | 段落 | 请勿在文章内使用「~」 || E301 | 段落 | 常用名词错误 |详情见 [写作规范和格式规范,DaoCloud 文档](http://docs-static.daocloud.io/write-docs/format)。
zhei
安装pipinstallzhei使用importzheiasjj.hi()功能支持帮助信息hi():打印 Bannerhelp():打印帮助信息,待完善print_error_info(e: Exception):打印错误信息通知notice(msg, warning=False, access_token="", secret=""):钉钉通知,默认读取 init_env() 设置的环境变量中的凭证Args: msg (str): 通知内容 warning (bool, optional): 是否为警告. Defaults to False. access_token (str, optional): 钉钉机器人 access_token. Defaults to "". secret (str, optional): 钉钉机器人 secret. Defaults to "".配置init_env(config: Union[DictConfig, dict]):初始化环境包括随机种子、可见GPU、Comet.ml环境变量、进程名 Args: config (DictConfig): 配置文件 seed (str, optional): 种子. Defaults to '3407'. use_deterministic (bool, optional): 是否使用确定性算法,使用了训练会变慢. Defaults to False. visibale_cuda (str, optional): 设置可见 GPU,如果不使用设置为 ''. Defaults to 'all'. comet_exp (dict, optional): Comet.ml相关环境变量设置. Defaults to {}. proctitle (str, optional): 进程名. Defaults to 'python'. proctitle_prefix_id (bool, optional): 是否在进程名前边添加进程 ID. Defaults to True.处理器gpu_ready()):检查 GPU 是否可用set_processing_units(config: Union[DictConfig, dict] = {}):设置处理器支持自动选择和手动选择、排队和不排队 Args: config (dict, optional): Defaults to {}. processing_unit: 处理器类型,可选值为:cpu、mps, 1, ^2 等,其中 ^2 表示自动选择两块 GPU,默认为 cpu processing_unit_type: 选择处理器,可选值为:cpu、mps、gpu-a-s、gpu-a-m、gpu-m-s、gpu-m-m processing_unit_min_free_memory: 最小空闲内存,单位为 GiB,默认为 10 processing_unit_min_free_memory_ratio: 最小空闲内存比例,默认为 0.5 queuing: 是否排队,依赖 Redis,默认为 False visible_devices: 可见的 GPU 序号,用逗号分隔,默认为 None Returns: Union[DictConfig, dict]: config包装类Result:包装类,用于作为模块间通信的媒介,可使用字典进行初始化文件读取和保存load_in(path, data_name=""):读取文件根据文件后缀名自动选择读取方法 目前支持保存类型有:‘pkl’、‘txt’、‘pt’、‘json’, 'jsonl'、'csv' Args: data_name: str, 打印提示时需要,便于控制台查看保存的文件是什么文件, 默认为空 Returns: data:Objectsave_as(data, save_path, file_format="pt", data_name="", protocol=4):保存文件将参数中的文件对象保存为指定格式格式文件 目前支持保存类型有:‘pkl’、‘txt’、‘pt’、‘json’, 'jsonl' 默认为‘pt’ Args: data: obj, 要保存的文件对象 save_path: str, 文件的保存路径,应当包含文件名和后缀名 data_name: str, 打印提示时需要,便于控制台查看保存的文件是什么文件, 默认为空 protocol: int, 当文件特别大的时候,需要将此参数调到4以上, 默认为4 file_format: str, 要保存的文件类型,支持‘pkl’、‘txt’、‘pt’、‘json’、‘jsonl’ Returns: None
zheinit
功能在新的服务器上初始化环境安装pipinstallzhei使用importzheiasjj.init()
zhejiang-zhuque-graph
Failed to fetch description. HTTP Status Code: 404
zhenbin-awesome-helloworld-script
Example PackageThis is a simple example package. You can useGithub-flavored Markdownto write your content.
zheng
No description available on PyPI.
zhengen-src
The HTML Report for Python unit testing Base on HTMLTestRunner
zhenglin
pip install zhenglin@ Author: zhenglin@version: 1.18.14This package contains some off-the-shelves deep-learning networks implemented with.usepipinstallzhenglinto install this package.zhenglinpackage is mainly motivated by eriklindernoren and hisrepowhich provides manysuper clean and easy-to-readimplementation of GAN variants. It is friendly to beginners and also a good reference for advanced users, especially for DL developpers.Specifically, this package providesA universal structure underzhenglin.dl.template.v1.*Loss functions underzhenglin.dl.lossesMetrics underzhenglin.dl.metrics16 highly modular and easy-to-use implementation of deep-learning networks underzhenglin.dl.networks.*which includes(from a to z)cycleGANDDPMDeblurGANEDSRESRGANNoise2VoidPix2PixRCANResNetRestormerRRDBNetSqueezeNetSRDRMSRGANSWinIRU2NetUNetAttention-UNetNews and UpdatesAug 13 2021:Version: 1.18.15Add basic quantization support.
zhengxiang
No description available on PyPI.
zhengyang-env-2
Trying to create my own enviornment and upload to github + pypi.
zhengyang-env-3
Trying to create my own enviornment and upload to github + pypi.In this version of environment, I am trying to change the reward function a little bit I am stil keeping the original reward function, but I am adding a new penalty funciton if the agent is below the 0.2 height, then it will give a penalty of negative 1. We will see what will happen.
zhengyang-env-4
Trying to create my own enviornment and upload to github + pypi.In this version of environment, I am trying to change the reward function a little bit I am stil keeping the original reward function, but I am adding a new penalty funciton if the agent is below the 0.2 height, then it will give a penalty of negative 1. We will see what will happen.
zhengyang-env-5
Trying to create my own enviornment and upload to github + pypi.In this version of environment, I am trying to change the reward function a little bit I am stil keeping the original reward function, but I want to change the gravity of the environment, just to see how it will affect the agent's performance.
zhenxun-bot
No description available on PyPI.
zhenxun-plugin-chatgpt
nonebot-plugin-chatgpt✨ ChatGPT AI 对话 ✨📖 介绍智能对话聊天插件。💿 安装使用 nb-cli 安装在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装nb plugin install nonebot-plugin-chatgpt使用包管理器安装在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令pippip install nonebot-plugin-chatgptpdmpdm add nonebot-plugin-chatgptpoetrypoetry add nonebot-plugin-chatgptcondaconda install nonebot-plugin-chatgpt打开 nonebot2 项目的bot.py文件, 在其中写入nonebot.load_plugin('nonebot_plugin_chatgpt')⚙️ 配置在 nonebot2 项目的.env文件中添加下表中的必填配置(在ARM平台,可能必须使用CHATGPT_SESSION_TOKEN登录)⚠️Windows系统下需要在.env.dev文件中设置FASTAPI_RELOAD=false配置项必填默认值说明CHATGPT_SESSION_TOKEN否空字符串ChatGPT 的 session_token,如配置则优先使用CHATGPT_ACCOUNT否空字符串ChatGPT 登陆邮箱,未配置则使用 session_tokenCHATGPT_PASSWORD否空字符串ChatGPT 登陆密码,未配置则使用 session_tokenCHATGPT_CD_TIME否60冷却时间,单位:秒CHATGPT_PROXIES否None代理地址,格式为:http://ip:portCHATGPT_REFRESH_INTERVAL否30session_token 自动刷新间隔,单位:分钟CHATGPT_COMMAND否空字符串触发聊天的命令,可以是字符串或者字符串列表。如果为空字符串或者空列表,则默认响应全部消息CHATGPT_TO_ME否True是否需要@机器人CHATGPT_TIMEOUT否30请求服务器的超时时间,单位:秒CHATGPT_API否https://chat.openai.com/API 地址,可配置反代CHATGPT_IMAGE否False是否以图片形式发送。如果无法显示文字,请点击此处查看解决办法CHATGPT_IMAGE_WIDTH否500消息图片宽度,单位:像素CHATGPT_PRIORITY否999事件响应器优先级CHATGPT_BLOCK否True是否阻断消息传播CHATGPT_PRIVATE否True是否允许私聊使用CHATGPT_SCOPE否private设置公共会话或私有会话private:私有会话,群内成员会话各自独立public:公共对话,群内成员共用同一会话CHATGPT_DATA否插件目录下插件数据保存目录的路径CHATGPT_MAX_ROLLBACK否5设置最多支持回滚多少会话CHATGPT_DETAILED_ERROR否否是否允许输出详细错误信息获取 session_token登录https://chat.openai.com/chat,并点掉所有弹窗按F12打开控制台切换到Application/应用选项卡,找到Cookies复制__Secure-next-auth.session-token的值,配置到CHATGPT_SESSION_TOKEN即可🎉 使用默认配置下,@机器人加任意文本即可。如果需要修改插件的触发方式,自定义CHATGPT_COMMAND和CHATGPT_TO_ME配置项即可。指令需要@范围说明刷新会话/刷新对话是群聊/私聊重置会话记录,开始新的对话导出会话/导出对话是群聊/私聊导出当前会话记录导入会话/导入对话 + 会话ID + 父消息ID(可选)是群聊/私聊将会话记录导入,这会替换当前的会话保存会话/保存对话 + 会话名称是群聊/私聊将当前会话保存查看会话/查看对话是群聊/私聊查看已保存的所有会话切换会话/切换对话 + 会话名称是群聊/私聊切换到指定的会话回滚会话/回滚对话是群聊/私聊返回到之前的会话,输入数字可以返回多个会话,但不可以超过最大支持数量🤝 贡献🎉 鸣谢感谢以下开发者对该项目做出的贡献:
zheyang
UNKNOWN
zhfirstpypi
No description available on PyPI.
zhfnote
Just run itimport zhfnote
zhhgood
No description available on PyPI.
zhhmathmodel
No description available on PyPI.
zhihu
## 关于Zhihu-API 的初衷是希望提供一套简洁、优雅的、Pythonic的API接口,面向的用户是对知乎数据有兴趣的群体,它可以用在数据分析、数据挖掘、增长黑客、以及希望通过程序自动完成知乎某个操作等应用场景。注意:只支持Python3## 安装```pythonpip install -U zhihu# 或者安装最新包pip install git+git://github.com/lzjun567/zhihu-api --upgrade```## 快速上手```pythonfrom zhihu import Zhihuzhihu = Zhihu()#获取用户基本信息profile = zhihu.profile(user_slug="xiaoxiaodouzi")print(profile)>>>{'name': '我是x','headline': '程序员','gender': -1,'user_type': 'people','is_advertiser': False,'url_token': 'xiaoxiaodouzi','id': '1da75b85900e00adb072e91c56fd9149','is_org': False}# 发送私信>>> zhihu.send_message(content="私信测试", user_slug="xiaoxiaodouzi")<Response [200]># 关注用户>>> zhihu.follow(user_slug="xiaoxiaodouzi"){'follower_count': 12, 'followed': True}# 取消关注>>> zhihu.unfollow(user_slug="xiaoxiaodouzi"){'follower_count': 11, 'followed': False}>>> from zhihu import Answer>>> answer = Answer(url="https://www.zhihu.com/question/62569341/answer/205327777")# 赞同回答>>> answer.vote_up(){'voting': 1, 'voteup_count': 260}# 反对>>> answer.vote_down(){'voting': -1, 'voteup_count': 259}# 中立>>> answer.vote_neutral(){'voting': 0, 'voteup_count': 260}# 感谢回答>>> answer.thank(){'is_thanked': True}# 取消感谢>>> answer.thank_cancel(){'is_thanked': False}```## 贡献者欢迎 PR, 所有贡献者都将出现在这里,排名不分先后* [@BigBorg](https://github.com/BigBorg)* [@xiaowenlong100](https://github.com/xiaowenlong100)* [@chenghengchao](https://github.com/chenghengchao)* [@MaxPoon](https://github.com/MaxPoon)* [@Oopswc](https://github.com/Oopswc)## 交流群已经加不进,可以先加微信:lzjun567 拉你入群![群](https://dn-mhke0kuv.qbox.me/30f70119cd4a840560d4.jpeg)
zhihuapi
UNOFFICIALAPI forzhihu. This package supports only Python 3.x.ANode.js implementationis also available.Installation$pipinstallzhihuapiQuich Startimportzhihuapiasapiwithopen('cookie')asf:api.cookie(f.read())data=api.user('zhihuadmin').profile()print(data)The result is:{"url_token":"zhihuadmin","avatar_url":"https://pic3.zhimg.com/34bf96bf5584ac4b5264bd7ed4fdbc5a_is.jpg","avatar_url_template":"https://pic3.zhimg.com/34bf96bf5584ac4b5264bd7ed4fdbc5a_{size}.jpg","type":"people","name":"知乎小管家","headline":"欢迎反馈问题和建议!","is_org":false,"url":"https://www.zhihu.com/people/zhihuadmin","badge":[{"type":"identity","description":"知乎官方帐号"}],"user_type":"people","is_advertiser":false,"id":"3d198a56310c02c4a83efb9f4a4c027e"}LicenseMIT
zhihubackup
退乎前备份知乎回答:zhihubackup每个知乎答主都有退乎的梦想,但退乎前如果删光回答,则十分可惜。因此,我用Python写了60行的脚本,可以在退乎前备份自己的所有回答和文章,以免事后后悔。安装pipinstallzhihubackup[node]如果已安装Node.js,则可以去掉[node]。使用假如你是@贱贱,你的id是splitter,那么可以执行命令:zhihubackupsplitter静等一段时间。运行结束后,可以看到产生了名为splitter的文件夹:- splitter |- answer (842 files) |- article (101 files) |- pin (3214 files) |- question (57 files)备份已经成功,现在可以删光回答和文章了。
zhihu-cli
zhihuzhihu 是一个简单的知乎信息获取工具,可以免登陆实现获取知乎的用户(User),提问(Question),回答(Answer)信息installpip3 install zhihu-cliUsage用户类 User可以通过用户的自定义ID(customized_id)或者内部ID(internal_id)初始化用户信息,其中自定义ID从用户URL中即可获得例如 知乎小管家URL:https://www.zhihu.com/people/zhihuadmin/activities自定义ID即为zhihuadmin内部ID是形如3d198a56310c02c4a83efb9f4a4c027e这样的ID,需要通过其他手段拿到。而这两种ID均可以初始化User类fromzhihuimportUseruser=User('zhihuadmin')而此时就可以通过user.internal_id来获取到知乎小管家的内部ID(就是上面的3d198a56310c02c4a83efb9f4a4c027e)用户类的属性包括:属性类型描述customized_idstr自定义IDinternal_idstr内部IDnicknamestr昵称genderstr昵称avatarstr头像URLheadlinestr个人简介is_vipbool盐选会员follower_countint关注者数量following_countint关注的人数量followersgenerator 对象关注者followingsgenerator 对象关注的人answer_countint回答数量question_countint提问数量articles_countint文章数量voteup_countint获得赞同数infodict以上所有信息提问类 Question通过问题ID(qid)初始化一个问题问题ID可以通过问题URL获得例如:《如何使用知乎?》问题URL:https://www.zhihu.com/question/19550225问题ID即为19550225fromzhihuimportQuestionquestion=Question('19550225')问题类的属性包括:属性类型描述qidstr问题IDtitlestr标题detailstr详细描述typestr问题状态createddatetime发布时间updateddatetime最后一次更新时间authorUser 对象提问人infodict以上所有信息answers()generator 对象所有回答的生成器answers()接受sort_by = default|updated参数,返回类型为 Answer 对象回答类 Answer通过回答ID(aid)初始化一个回答回答ID可从一个回答的URL中获得:例如:https://www.zhihu.com/question/19550225/answer/95067981回答ID即为95067981fromzhihuimportAnsweranswer=Answer('95067981')回答类的属性包括:属性类型描述aidstr回答IDtypestr该回答状态authorUser 对象回答者excerptstr摘要contentstr回答的原始内容(包含HTML内容)textstr回答的纯文字(不包含HTML内容)comment_countint回答评论数voteup_countint回答赞同数createddatetime回答时间updateddatetime最后一次修改时间questionQuestion 对象回答的问题对象infodict以上所有信息
zhihu-crawler
zhihu_crawler本程序支持关键词搜索、热榜、用户信息、回答、专栏文章、评论等信息的抓取项目目录__init__.py 为程序的对外统一入口constants.py 常量exceptions.py 自定义异常extractors.py 数据清洗page_iterators.py 简单的页面处理zhihu_scraper.py 页面请求、cookie设置zhihu_types.py 类型提示、检查。项目自定义类型注意事项: 项目内有部分异步操作,在模块引用之前需要使用猴子补丁; 同时该项目没有对ip限制、登录做针对性处理安装pipinstallzhihu_crawler使用if__name__=='__main__':# 设置代理; 如采集量较大,建议每次请求都切换代理set_proxy({'http':'http://127.0.0.1:8125','https':'http://127.0.0.1:8125'})# 设置cookieset_cookie({'d_c0':'AIBfvRMxmhSPTk1AffR--QLwm-gDM5V5scE=|1646725014'})# 搜索采集使用案例:forinfoinsearch_crawl(key_word='天空',count=10):print(info)# 可传入data_type 指定搜索类型forinfoinsearch_crawl(key_word='天空',count=10,data_type='answer'):print(info)# 用户信息回答列表使用案例(采集该用户信息及50条回答信息,每条回答包含50条评论):forinfoinuser_crawler('wo-men-de-tai-kong',answer_count=50,comment_count=50):print(info)# 用户信息提问列表使用案例(采集该用户信息及10条问题信息,每条问题包含10条回答,每条回答包含50条评论):forinfoinuser_crawler('wo-men-de-tai-kong',question_count=10,drill_down_count=10,comment_count=50):print(info)# 热点问题采集使用案例# 采集 前10个问题, 每个问题采集10条回答forinfoinhot_questions_crawl(question_count=10,drill_down_count=10):print(info)# 可传入period 指定热榜性质。如小时榜、日榜、周榜、月榜# 传入domains 采集指定主题的问题forinfoinhot_questions_crawl(question_count=10,period='day',domains=['1001',1003]):print(info)
zhihui-sdk-python
zhihui-sdk-python智绘设计SKD-python
zhihu-oauth
Zhihu-OAuth近况由于知乎给 Github 发了DMCA要求删除zhihu-oauth 仓库,所以 Github 把仓库设置为不可公开访问了。所以目前我只能把最新版代码同步到我自己个人的 Git Server 上了。虽然一直有用户和我反馈还在使用这个库,并且某些功能也确实可以继续正常使用,但由于本人已经不用知乎多年,所以这个库其实有两年多没更新过了。这次移动到个人站点之后,由于本站点不对外开放注册,游客就没法使用 Issue 和 PR 功能,所以可以预见的未来估计也不会有什么更新了,这里基本只提供代码备份和下载功能。由于以上原因,README 中的捐款渠道也已一并删除。如果你有想交流的问题,请使用邮件,或者Twitter联系我。—— 2019.10.19简介同学们,由于知乎新的 API 验证 UA,0.0.14 之前的版本已经不可用了,请尽快升级到 0.0.14 以上版本。最近在尝试解析出知乎官方未开放的 OAuth2 接口,顺便提供优雅的使用方式,作为zhihu-py3项目的继任者。恩,理论上来说会比 zhihu-py3 更加稳定,原因如下:知乎 API 相比前端 HTML 来说肯定更加稳定和规范这次的代码更加规范网络请求统一放在基类中属性解析统一放在装饰器中,各知乎类只用于声明有哪些属性可供使用统一翻页逻辑,再也不用一个地方一个逻辑了翻页时的自动重试机制(虽然不知道有没有用吧)这一新库与 zhihu-py3 相比速度更快。有关速度对比的详细信息请点击这里。这个库是 Py2 和 Py3 通用的!但是 Py3 的优先级比 Py2 高,也就是说,我会优先保证在 Py3 下的稳定性和正确性。毕竟在我学的时候选了 Py3,所以对 2 与 3 的差异了解不是很清楚,Py2 只能尽力而为了,后期的计划是这样的:0.0.x 这个阶段是 alpha 期,主要做的是补齐功能的工作。基本上 TODO 里的功能都会在这个时期实现。其中 0.0.5 版本计划完成和 zhihu-py3 同样多的功能(已完成)。0.1.x 这个阶段是 beta 期,主要做完善测试,修复 bug,提升性能,改善架构之类的工作吧。以上两个阶段变化很大,有可能出现不兼容老版本的更新。使用需要注意。0.2.x 及以后就是 stable 期,只要 API 不变,基本上代码结构就不会变了,接口可能会增加但一定不会减。由于现在使用的 CLIENT_ID 和 SECRET 的获取方法并不正当,所以请大家暂时不要大规模宣传,自己用用就好啦,Thanks。等我什么时候觉得时机成熟(等知乎真•开放 OAuth 申请?),会去知乎专栏里宣传一波的。最近更新目前版本是 0.0.41,没更新的快更新一下,更新说明在这里。0.0.41 版本修复了 Feed 流的一些问题,加上了Topic.activities接口。0.0.40 版本增加了 Feed 首页信息流的支持。使用安装pipinstall-Uzhihu_oauth如果安装遇到问题,请查看文档:安装登录请参见文档:登录获取基础信息代码:fromzhihu_oauthimportZhihuClientclient=ZhihuClient()client.load_token('token.pkl')me=client.me()print('name',me.name)print('headline',me.headline)print('description',me.description)print('following topic count',me.following_topic_count)print('following people count',me.following_count)print('followers count',me.follower_count)print('voteup count',me.voteup_count)print('get thanks count',me.thanked_count)print('answered question',me.answer_count)print('question asked',me.question_count)print('collection count',me.collection_count)print('article count',me.articles_count)print('following column count',me.following_column_count)输出:name 7sDream headline 二次元普通居民,不入流程序员,http://0v0.link description 关注本AI的话,会自动给你发私信的哟! following topic count 35 following people count 101 followers count 1294 voteup count 2493 get thanks count 760 answered question 258 question asked 18 collection count 9 article count 7 following column count 11更多功能请参见文档:使用方法文档完整的文档可以在这里找到。我写的文档好吧,可详细了……有啥问题先去找文档。我写的那么累你们看都不看我好不服啊!(貌似 ReadTheDocs 在伟大的国家访问速度有点慢,建议自备手段。)TODO保证对 Python 2 和 3 的兼容性用户私信支持Live 支持Pin(分享)支持搜索功能(还差电子书搜索)用户首页 Feed知乎电子书获取用户消息。新关注者,新评论,关注的回答有新问题Token check/refreshSetting规范、完善的测试article.voters 文章点赞者,貌似 OAuth2 没有这个 APIcollection.followers 这个 API 不稳定,没法返回所有关注者协助开发通过代码Fork从 dev 分支新建一个分支编写代码,更新 Changelog 和 sphinx 文档,如果可能的话加上测试PR 到原 dev 分支通过捐款由于开发不积极,不再接受捐款。捐款记录LICENSEMIT
zhihu-py3
通知由于知乎前端老是改阿改的,每次我都要更新弄的我好烦的说……所以我开发了一个新的项目Zhihu-OAuth。这个新项目用了一些黑科技手段,反正应该是更加稳定和快速了!而且还支持 Python 2 哟!稳定我倒是没测,但是这里有一个速度对比。如果你是准备新开一个项目的话,我强烈建议你看看我的新项目~如果你已经用 Zhihu-py3 写了一些代码的话,我最近会写一个从 Zhihu-py3 转到 Zhihu-OAuth 的简易指南,你也可以关注一下哟。毕竟嘛,有更好的方案的话,为什么不试试呢?功能由于知乎没有公开API,加上受到zhihu-python项目的启发,在Python3下重新写了一个知乎的数据解析模块。提供的功能一句话概括为,用户提供知乎的网址构用于建对应类的对象,可以获取到某些需要的数据。简单例子:fromzhihuimportZhihuClientCookies_File='cookies.json'client=ZhihuClient(Cookies_File)url='http://www.zhihu.com/question/24825703'question=client.question(url)print(question.title)print(question.answer_num)print(question.follower_num)print(question.topics)foranswerinquestion.answers:print(answer.author.name,answer.upvote_num)这段代码的输出为:关系亲密的人之间要说「谢谢」吗? 627 4322 ['心理学', '恋爱', '社会', '礼仪', '亲密关系'] 龙晓航 50 小不点儿 198 芝士就是力量 89 欧阳忆希 425 ...另外还有Author(用户)、Answer(答案)、Collection(收藏夹)、Column(专栏)、Post(文章)、Topic(话题)等类可以使用,Answer,Post类提供了save方法能将答案或文章保存为HTML或Markdown格式,具体请看文档,或者zhihu-test.py。安装本项目依赖于requests、BeautifulSoup4、html2text已将项目发布到pypi,请使用下列命令安装(sudo)pip(3)install(--upgrade)zhihu-py3希望开启lxml的话请使用:(sudo)pip(3)install(--upgrade)zhihu-py3[lxml]因为lxml解析html效率高而且容错率强,在知乎使用<br>时,自带的html.parser会将其转换成<br>...</br>,而lxml则转换为<br/>,更为标准且美观,所以推荐使用第二个命令。不安装lxml也能使用本模块,此时会自动使用html.parser作为解析器。PS 若在安装lxml时出错,请安装libxml和libxslt后重试:sudoapt-getinstalllibxml2libxml2-devlibxslt1.1libxslt1-dev准备工作第一次使用推荐运行以下代码生成 cookies 文件:fromzhihuimportZhihuClientZhihuClient().create_cookies('cookies.json')运行结果====== zhihu login ===== email: <your-email> password: <your-password> please check captcha.gif for captcha captcha: <captcha-code> ====== logging.... ===== login successfully cookies file created.运行成功后会在目录下生成cookies.json文件。以下示例皆以登录成功为前提。建议在正式使用之前运行zhihu-test.py测试一下。用法实例为了精简 Readme,本部分移动至文档内。请看文档的「用法示例」部分。登录方法综述为了精简 Readme,本部分移动至文档内。请看文档的「登录方法综述」部分。文档终于搞定了文档这个磨人的小妖精,可惜 Sphinx 还是不会用 T^T 先随意弄成这样吧:Master版文档Dev版文档其他有问题请开Issue,几个小时后无回应可加最后面的QQ群询问。友链:zhihurss:一个基于 zhihu-py3 做的跨平台知乎 rss(any user) 的客户端。TODO List[x] 增加获取用户关注者,用户追随者[x] 增加获取答案点赞用户功能[x] 获取用户头像地址[x] 打包为标准Python模块[x] 重构代码,增加ZhihuClient类,使类可以自定义cookies文件[x] 收藏夹关注者,问题关注者等等[x]ZhihuClient增加各种用户操作(比如给某答案点赞)[ ] Unittest (因为知乎可能会变,所以这个有点难[x] 增加获取用户关注专栏数和关注专栏的功能[x] 增加获取用户关注话题数和关注话题的功能[x] 评论类也要慢慢提上议程了吧联系我Github:@7sDream知乎:@7sDream新浪微博:@Dilover邮箱:给我发邮件编程交流群:478786205
zhihu_question_autopass_thrift
No description available on PyPI.
zhihutool
An easy way to control your zhihu account
zhijian
No description available on PyPI.
zhijiang
A project used to setup development environment, especially the rcfiles(aka dotfiles)After pip install, the shell command "zhijiang" could be used, "zhijiang info" could be used to get help.
zhijie-toolbox
Project descriptionInstallpip install zhijie_toolboxMethodcreate_package_template(current_path, project_name, version="0.0.1", license_type="MIT")This will help you to create a package template that speed up publishing package.Usage:from zhijie_toolbox import toolbox toolbox.create_package_template(current_path, project_name)version_control(current_path, runs_name, not_save_list=[".git", "runs"], log="")This will help you to copy current codes to a runs folder where we can record our codes locally We can define not save list by ourself by specify files nameUsage:from zhijie_toolbox import toolbox toolbox.version_control(current_path, runs_name)create_project_template(current_path, add_folder=None)This function will help you create a project template. Basic folders are ["configs", "datasets", "experiments", "scripts", "tests", "packages"]Usage:from zhijie_toolbox import toolbox toolbox.create_project_template(current_path)
zhimabot
zhimabotPython library for zhimabotFree software: MIT licenseDocumentation:https://zhimabot.readthedocs.io.FeaturesTODOCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2017-02-06)First release on PyPI.