{"id":51036907,"url":"https://github.com/farfarfun/nltfile","last_synced_at":"2026-06-22T07:01:51.962Z","repository":{"id":41276774,"uuid":"415185750","full_name":"farfarfun/nltfile","owner":"farfarfun","description":"文件操作工具包 - 提供文件处理、管理和操作的增强功能","archived":false,"fork":false,"pushed_at":"2026-06-05T09:20:32.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-05T12:11:06.508Z","etag":null,"topics":["farfarfun","file-management","file-operations","filesystem","io","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/funfile/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/farfarfun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-10-09T02:59:59.000Z","updated_at":"2026-06-05T09:20:34.000Z","dependencies_parsed_at":"2022-07-13T15:29:46.982Z","dependency_job_id":"18bbc11a-1c9f-48d0-832c-fea9b0e8c9b6","html_url":"https://github.com/farfarfun/nltfile","commit_stats":null,"previous_names":["farfarfun/notefile","farfarfun/funfile","farfarfun/nltfile"],"tags_count":68,"template":false,"template_full_name":null,"purl":"pkg:github/farfarfun/nltfile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farfarfun%2Fnltfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farfarfun%2Fnltfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farfarfun%2Fnltfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farfarfun%2Fnltfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farfarfun","download_url":"https://codeload.github.com/farfarfun/nltfile/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farfarfun%2Fnltfile/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34637937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["farfarfun","file-management","file-operations","filesystem","io","python"],"created_at":"2026-06-22T07:01:50.955Z","updated_at":"2026-06-22T07:01:51.953Z","avatar_url":"https://github.com/farfarfun.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nltfile\n\n一个实用的 Python 文件操作工具库，提供带进度条的压缩/解压、并发写入、pickle 序列化等功能的增强封装。\n\n## 特性\n\n- 带进度条的 tar/zip 压缩与解压，用法与标准库一致\n- 线程安全的并发文件写入，支持断点续写\n- pickle 序列化/反序列化的便捷封装\n- 常用文件系统操作（创建目录、删除、复制）\n\n## 安装\n\n```bash\npip install nltfile\n```\n\n## 依赖\n\n- Python \u003e= 3.7\n- [funutil](https://pypi.org/project/funutil/) \u003e= 1.0.15\n- [tqdm](https://pypi.org/project/tqdm/) \u003e= 4.66.5\n\n## 使用\n\n### tar 压缩/解压（带进度条）\n\n用法与标准库 `tarfile` 一致，自动显示进度条：\n\n```python\nfrom nltfile import tarfile\n\n# 压缩\nwith tarfile.open(\"results.tar\", \"w|xz\") as tar:\n    tar.add(\"a.txt\")\n\n# 解压\nwith tarfile.open(\"results.tar\", \"r|xz\") as tar:\n    tar.extractall(\"local\")\n```\n\n也可以使用快捷函数：\n\n```python\nfrom nltfile.compress.tarfile import file_entar, file_detar\n\n# 一键压缩\nfile_entar(\"mydir\", \"mydir.tar\")\n\n# 一键解压\nfile_detar(\"mydir.tar\", \"output\")\n```\n\n### zip 解压\n\n```python\nfrom nltfile import zipfile\n\nwith zipfile.ZipFile(\"archive.zip\") as zf:\n    zf.extractall(\"output\")\n```\n\n### 通用解压\n\n根据文件后缀自动选择解压方式，支持 `.zip`、`.tar`、`.tar.gz`、`.tgz`、`.tar.bz2`、`.tar.xz`、`.txz`：\n\n```python\nfrom nltfile.compress.allfile import extractall\n\nextractall(\"archive.tar.gz\", \"output\")\n```\n\n### 并发文件写入\n\n线程安全的异步写入，适用于多线程场景。支持指定偏移量写入，并在写入过程中自动记录进度，异常中断后可断点续写：\n\n```python\nfrom nltfile import ConcurrentFile\n\nwith ConcurrentFile(\"output.txt\", mode=\"w\") as fw:\n    fw.write(\"hello, nltfile.\")\n    fw.write(\"another line.\")\n```\n\n支持指定偏移量的随机写入：\n\n```python\nwith ConcurrentFile(\"output.bin\", mode=\"wb\") as fw:\n    fw.write(b\"chunk1\", offset=0)\n    fw.write(b\"chunk2\", offset=1024)\n```\n\n### pickle 序列化\n\n便捷的 pickle 读写封装：\n\n```python\nfrom nltfile.pickle import dump, load, dumps, loads\n\n# 写入文件\ndump({\"key\": \"value\"}, \"data.pkl\")\n\n# 从文件读取\ndata = load(\"data.pkl\")\n\n# 序列化为 bytes\nraw = dumps({\"key\": \"value\"})\n\n# 从 bytes 反序列化\nobj = loads(raw)\n```\n\n### 文件系统工具\n\n```python\nfrom nltfile.funos import makedirs, delete\n\n# 递归创建目录（已存在不报错）\nmakedirs(\"path/to/dir\")\n\n# 递归删除目录\ndelete(\"path/to/dir\")\n```\n\n```python\nfrom nltfile.file import copy\n\n# 复制文件\ncopy(\"src.txt\", \"dst.txt\")\n```\n\n### 获取文件/目录大小\n\n```python\nfrom nltfile import get_size\n\n# 获取文件大小（字节）\nsize = get_size(\"large_file.bin\")\n\n# 递归获取目录大小\nsize = get_size(\"mydir\", recursive=True)\n```\n\n## 项目结构\n\n```\nsrc/nltfile/\n├── __init__.py            # 顶层导出\n├── funos.py               # 文件系统工具（makedirs, delete）\n├── file/\n│   ├── core.py            # 文件复制\n│   └── concurrent.py      # 并发文件写入\n├── compress/\n│   ├── utils.py           # 进度条、文件大小计算\n│   ├── tarfile.py         # 带进度条的 tar 操作\n│   ├── zipfile.py         # zip 操作封装\n│   └── allfile.py         # 通用解压\n└── pickle/\n    └── core.py            # pickle 序列化封装\n```\n\n## 许可证\n\n[Apache License 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarfarfun%2Fnltfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarfarfun%2Fnltfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarfarfun%2Fnltfile/lists"}