File Block
简化文件处理 - simplify file processing
Installing from pip
pip 安装
pip install fileblock
清华源安装
pip install fileblock -i https://pypi.tuna.tsinghua.edu.cn/simple
How to use
import fileblock as fb
from fileblock import Block, Directory
Block
Block()
file_block = Block("./") # 创建一个Block
| 参数 | 类型 | 返回值 | 描述 |
|---|---|---|---|
| name | string | None | 创建 block 的逻辑位置 |
Tips:
@path 不一定是真实存在的文件或者文件夹路径
block.sub_block()
| 参数 | 类型 | 返回值 | 描述 |
|---|---|---|---|
| path | string | Block | 相对于 block 的相对路径 |
block.append()
| 参数 | 类型 | 描述 |
|---|---|---|
| name | string | 相对于 block 的相对路径 |
| type | btype.FILE / btype.DIR | 需要添加的节点类型 |
返回新生成节点的Block对象
Tips:
当type == FILE时,若name形如x1/x2, 则会新建x1文件夹,返回的是x2的Block对象,而不是x1
block.join_path()
| 参数 | 类型 | 描述 |
|---|---|---|
| path | string | 需要拼接的文件/文件夹路径 |
返回拼接后的路径
block.remove()
说明:
如果该 block 对象是真实存在的文件/文件夹, 则从磁盘上永久删除该文件/文件夹
block.moveTo()
| 参数 | 类型 | 描述 |
|---|---|---|
| target | Block | 一个类型为Dir的Block对象 |
如果block存在,则会把其中的文件与文件夹移动到target对应的文件夹内
block.copyTo()
| 参数 | 类型 | 描述 |
|---|---|---|
| target | Block | 一个类型为Dir的Block对象 |
把 Block 及其 Children 都拷贝如 target 中
block.cut()
| 参数 | 类型 | 描述 |
|---|---|---|
| rates | int/float | 需要划分的比重 |
🌰举个例子:
文件夹里如果有n个文件,想要划分成7:3,那参数就是7, 3,也就是block.cut(7, 3)
如果想要分成1:2:3,那就block.cut(1, 2, 3)
返回值时一个列表,其中的元素是划分好的Children类型
block.get_file_contents()
如果block时文件,则返回该文件的bytes内容
block.leaves
Block文件树的叶子节点构成的Children集合
block.isfile
当block存在,且为文件时等于True
block.isdir
当block存在,且为文件夹时为True
block.exists
当block存在时为True
block.children
返回block对象包含的子文件与子文件夹构成的Children集合
block.btype
返回该Block对象的类型 FILE | DIR | None
Directory
directory.map()
directory.to_json()
directory.copy()
directory.shuffle()
返回打乱顺序的Directory,不改变本身内容
directory.unfold()
directory.append()
directory.extend()
directory.remove()
directory.pop()
directory.extension_filter()
super_dir_name
directory.abspaths
返回所有Block的绝对路径
License
Metadata
Release files for fileblock 2.0.3.2022.6.27
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 |
|---|---|---|---|---|
| fileblock-2.0.3.2022.6.27.tar.gz | 12.9 kB | Without provenance | Details for fileblock-2.0.3.2022.6.27.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fileblock-2.0.3.2022.6.27-py3-none-any.whl | Python 3 | none | any | Details for fileblock-2.0.3.2022.6.27-py3-none-any.whl |
Total release size: 26.1 kB
Release files / fileblock-2.0.3.2022.6.27.tar.gz
| Download URL | fileblock-2.0.3.2022.6.27.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7d738fc746617e827379ab74b76dfb0644a32c36c60cc2481a05f034b928221
|
|
BLAKE2b-256 checksum How to use checksums |
c32b124543abd476dc5f8be847a16eebaead15c4a140f72b98900ff9305cf79e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.1.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Release files / fileblock-2.0.3.2022.6.27-py3-none-any.whl
| Download URL | fileblock-2.0.3.2022.6.27-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7aa3fd2adb5741ee370781fc395e017ac2038e0509f8e849b150cb96dbb4c22e
|
|
BLAKE2b-256 checksum How to use checksums |
bfbe4781f66359e96d9230aaa0c0f9644c3699295d7f9d5a400f8a691e12407b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.1.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Security for fileblock 2.0.3.2022.6.27
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.