# ftp
一个 ftp 下载器
包含 ftp 连接与下载器的方法
- GFTP:新增 FTP 没有的方法
- FTPConn:FTP 连接创建、快速重连
- FTPDownloader:FTP 文件、文件列表、文件夹下载
# 安装
```
pip install gftp
```
# GFTP
新增了一些 FTP 没有的方法
- show_dir:列表形式返回文件夹下的所有文件、文件夹(返回全路径)
- show_file:列表形式返回当前文件夹下的所有文件(返回全路径)
- show_folder:列表形式返回当前文件夹下的所有文件夹(返回全路径)
- iter_dir:遍历指定路径下的文件、文件夹并输出(迭代器,返回全路径)
这里就介绍下 iter_dir
```
from gftp import FTPConn
ftp = FTPConn(**连接配置)
for f in ftp.connection.iter_dir('/'):
print(f)
```
# FTPConn
创建连接用
```
from gftp import FTPConn
ftp = FTPConn(**连接配置)
ftp.connection.pwd() # 通过 connection 使用 FTP 命令
ftp.reconnection() # 重新连接
ftp.close() # 关闭连接,会自动回收,关不关无所谓
```
# FTPDownloader
下载文件、文件列表、文件夹
可以多线程,即创建多个连接
介绍两个参数:
- 类实例参数 keep_structure 会在 save_path 的基础上,保留 ftp 目录结构
- download 参数 callback 是线程,线程数量和类实例的 threads 数量一致
```
from gftp import FTPDownloader
downloader = FTPDownloader(**连接配置, save_path='')
downloader.download_file(ftp_path='xx', callback=xx)
downloader.download_list(ftp_path_list=['xx'], callback=xx)
downloader.download_dir(dir_path='xx', callback=xx)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Leviathangk/gftp",
"name": "gftp",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "ftp",
"author": "\u90ed\u4e00\u4f1a\u513f",
"author_email": "1015295213@qq.com",
"download_url": "https://files.pythonhosted.org/packages/58/ae/da1dd0e7e5ddf28f4308814920c919a0d24b99131817151fe89bf63e981c/gftp-0.0.4.tar.gz",
"platform": "any",
"description": "# ftp\r\n\r\n\u4e00\u4e2a ftp \u4e0b\u8f7d\u5668\r\n\r\n\u5305\u542b ftp \u8fde\u63a5\u4e0e\u4e0b\u8f7d\u5668\u7684\u65b9\u6cd5\r\n\r\n- GFTP\uff1a\u65b0\u589e FTP \u6ca1\u6709\u7684\u65b9\u6cd5\r\n- FTPConn\uff1aFTP \u8fde\u63a5\u521b\u5efa\u3001\u5feb\u901f\u91cd\u8fde\r\n- FTPDownloader\uff1aFTP \u6587\u4ef6\u3001\u6587\u4ef6\u5217\u8868\u3001\u6587\u4ef6\u5939\u4e0b\u8f7d\r\n\r\n# \u5b89\u88c5\r\n\r\n```\r\npip install gftp\r\n```\r\n\r\n# GFTP\r\n\r\n\u65b0\u589e\u4e86\u4e00\u4e9b FTP \u6ca1\u6709\u7684\u65b9\u6cd5\r\n\r\n- show_dir\uff1a\u5217\u8868\u5f62\u5f0f\u8fd4\u56de\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u3001\u6587\u4ef6\u5939\uff08\u8fd4\u56de\u5168\u8def\u5f84\uff09\r\n- show_file\uff1a\u5217\u8868\u5f62\u5f0f\u8fd4\u56de\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u6587\u4ef6\uff08\u8fd4\u56de\u5168\u8def\u5f84\uff09\r\n- show_folder\uff1a\u5217\u8868\u5f62\u5f0f\u8fd4\u56de\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u5939\uff08\u8fd4\u56de\u5168\u8def\u5f84\uff09\r\n- iter_dir\uff1a\u904d\u5386\u6307\u5b9a\u8def\u5f84\u4e0b\u7684\u6587\u4ef6\u3001\u6587\u4ef6\u5939\u5e76\u8f93\u51fa\uff08\u8fed\u4ee3\u5668\uff0c\u8fd4\u56de\u5168\u8def\u5f84\uff09\r\n\r\n\u8fd9\u91cc\u5c31\u4ecb\u7ecd\u4e0b iter_dir\r\n\r\n```\r\nfrom gftp import FTPConn\r\n\r\nftp = FTPConn(**\u8fde\u63a5\u914d\u7f6e)\r\nfor f in ftp.connection.iter_dir('/'):\r\n print(f)\r\n```\r\n\r\n# FTPConn\r\n\r\n\u521b\u5efa\u8fde\u63a5\u7528\r\n\r\n```\r\nfrom gftp import FTPConn\r\n\r\nftp = FTPConn(**\u8fde\u63a5\u914d\u7f6e)\r\nftp.connection.pwd() # \u901a\u8fc7 connection \u4f7f\u7528 FTP \u547d\u4ee4\r\nftp.reconnection() # \u91cd\u65b0\u8fde\u63a5\r\nftp.close() # \u5173\u95ed\u8fde\u63a5\uff0c\u4f1a\u81ea\u52a8\u56de\u6536\uff0c\u5173\u4e0d\u5173\u65e0\u6240\u8c13\r\n```\r\n\r\n# FTPDownloader\r\n\r\n\u4e0b\u8f7d\u6587\u4ef6\u3001\u6587\u4ef6\u5217\u8868\u3001\u6587\u4ef6\u5939 \r\n\u53ef\u4ee5\u591a\u7ebf\u7a0b\uff0c\u5373\u521b\u5efa\u591a\u4e2a\u8fde\u63a5 \r\n\u4ecb\u7ecd\u4e24\u4e2a\u53c2\u6570\uff1a\r\n\r\n- \u7c7b\u5b9e\u4f8b\u53c2\u6570 keep_structure \u4f1a\u5728 save_path \u7684\u57fa\u7840\u4e0a\uff0c\u4fdd\u7559 ftp \u76ee\u5f55\u7ed3\u6784\r\n- download \u53c2\u6570 callback \u662f\u7ebf\u7a0b\uff0c\u7ebf\u7a0b\u6570\u91cf\u548c\u7c7b\u5b9e\u4f8b\u7684 threads \u6570\u91cf\u4e00\u81f4\r\n\r\n```\r\nfrom gftp import FTPDownloader\r\n\r\ndownloader = FTPDownloader(**\u8fde\u63a5\u914d\u7f6e, save_path='')\r\ndownloader.download_file(ftp_path='xx', callback=xx)\r\ndownloader.download_list(ftp_path_list=['xx'], callback=xx)\r\ndownloader.download_dir(dir_path='xx', callback=xx)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT Licence",
"summary": "\u4e00\u4e2a ftp \u4fbf\u6377\u5de5\u5177\u5305",
"version": "0.0.4",
"split_keywords": [
"ftp"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "8feea76df73043c75c1e04a01d0b53b2",
"sha256": "7538f5dae765438aafa11baaf30dbcf58cf2ee79ea80cf5a87aaba2086fe2b1a"
},
"downloads": -1,
"filename": "gftp-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "8feea76df73043c75c1e04a01d0b53b2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5565,
"upload_time": "2022-12-01T03:08:09",
"upload_time_iso_8601": "2022-12-01T03:08:09.912114Z",
"url": "https://files.pythonhosted.org/packages/58/ae/da1dd0e7e5ddf28f4308814920c919a0d24b99131817151fe89bf63e981c/gftp-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-01 03:08:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Leviathangk",
"github_project": "gftp",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "gftp"
}