一份文件?一条信息!使用一行代码获取文件信息!与文件扩展名数据库一起使用,因此它甚至可以为您提供文件的类型。
项目描述
文件中心
一个简单的 Python 文件管理和信息中心
表中的内容
安装
PIP您可以使用Python 包管理器安装此库
只需输入pip install filecenter您的终端/命令行提示符。
该库没有外部/第三方依赖项。
什么是文件中心?
File Center 是一个简单的库,可让开发人员在文件管理和信息方面更轻松。
您只需将其导入您的项目!
import filecenter
用法
文件操作
open(filepath)
在其默认软件中打开给定文件
论据:
file: the path to the file.
成功返回 0,失败返回 1
move(filepath, new_path)
将给定文件移动到提供的新路径。
论据:
origin: the path to the file.
destination: the new path
成功返回 0,失败返回 1
delete(filepath)
删除给定的文件。
论据:
file: the path of the file
成功返回 0,获取文件失败返回 1,移动文件失败返回 2,移动目录失败返回 3。
makedir(path)
在给定路径创建一个目录。
论据:
path_of_new_dir: the path where the directory needs to be created
如果成功则返回目录的路径,如果失败则返回字符串 'Error while making the new folder'。
分机信息
popularity(extension)
给出给定文件扩展名的流行度。
论据:
file_extension: the extension you want to check.
返回“非常受欢迎”、“非常受欢迎”或“不太受欢迎”。
type_from_extension(extension)
使用给定的扩展名给出文件的类型。
论据:
extension: the extension you want to check.
返回具有类型的字符串(有关支持的类型的完整列表,请参见下文)。
extension_to_human_readeable(extension)
提供给定扩展的人类可读版本。
论据:
extension: the file extension you want to get the human readeable version from.
返回人类可读版本的字符串。
extension_info(extension)
给出一个包含给定扩展名的多个信息的字典。
论据:
extension: the file extension you want to get information from.
返回一个 python 字典。
extension_description(extension)
给出给定文件扩展名的描述。
论据:
extension: the file extension you want to get the description from.
返回带有扩展描述的字符串。
extension_usage(extension)
使用给定的文件扩展名提供软件。
论据:
extension: the file extension you want to get the using softwares from.
返回软件名称列表。
文件库信息
name_from_base(base)
从给定的文件库中返回文件的名称。
文件基础是文件名及其扩展名(即 something.png)
论据:
base: the file base you want to get the name from.
返回带有文件名的字符串。
extension_from_base(base)
从给定的文件库返回文件的扩展名。
论据:
base: the file base you want to get the extension from.
返回带有文件扩展名的字符串。(包括点)
档案资料
布尔值
exists(path)
检查一个文件或目录是否存在。
论据:
file: the file path to check.
返回一个布尔值。
isdir(path)
检查给定的路径是一个目录。
论据:
path: the path to check.
返回一个布尔值。
isfile(path)
检查给定路径是否为文件。
论据:
path: the path to check.
返回一个布尔值。
issymboliclink(path)
检查给定路径是否是符号链接(别名)。
论据:
path: the path to check.
返回一个布尔值。
ismountpoint(path)
检查给定路径是否是磁盘安装点。
论据:
path: the path to check.
返回一个布尔值。
iscommon(extension)
检查给定的文件扩展名是否常用。
论据:
file_extension: the extension you want to check.
返回一个布尔值。
资讯
permissions(file)
返回给定文件的权限。
论据:
file: the path to the file you want to get the permissions from.
返回具有给定文件的所有者、组和其他人的权限的字典。返回
{'information': 'Unable to get permissions'}未找到文件的字典。
mimetype(file)
返回给定文件的 MIME 类型。
论据:
file: the path of the file you want to get the MIME type from.
如果检索失败,则返回 MIME 类型的字符串或“获取文件时发生错误”。
base(file)
从给定路径返回文件库。
论据:
file: the path of the file you want to get the base from.
返回带有文件基础的字符串。
path(file)
返回文件路径的绝对路径。
论据:
file: the path of the file you want to get the absolute path from.
返回带有路径的字符串。
name(file)
根据路径给出文件的名称。
论据:
file: the path of the file you want to get the name from.
返回带有文件名的字符串。
extension(file)
根据路径返回文件的扩展名。
论据:
file: the path of the file you want to get the extension from.
返回带有文件扩展名的字符串(包括点)。
size(file)
返回文件的大小。
论据:
file: the path to the file you want to get the size from.
返回具有文件大小的字符串(以正确缩放的、人类可读的格式)。
get_real_path(path)
检查文件/目录的真实路径(没有符号链接)。
论据:
path: the path to check.
返回一个布尔值。
files_in_dir(path_to_folder)
给出给定目录中的文件列表。
论据:
path_of_dir: the path of the directory where the files are located.
返回文件 basename 的列表。
时间
last_access(file)
给出最后访问时间。
论据:
file: the path to the file you want to get the last access time from.
返回一个日期时间对象。
last_modification(file)
给出最后修改时间。
论据:
file: the path to the file you want to get the last modification time from.
返回一个日期时间对象。
last_metadata_change(file)
给出最后一次元数据更改时间。
论据:
file: the path to the file you want to get the last modification time from.
返回一个日期时间对象。
type(file)
返回文件的类型。
论据:
file: the path of the file you want to know the type from.
返回具有类型的字符串。
一次所有信息
info(file)
提供您可以从给定文件的文件中心获得的所有信息。
论据:
file: the path to the file you want to get the infos from.
返回包含所有内容的 python 字典。
其他
os_name()
返回操作系统的名称。
get_readeable_size(bytes, suffix)
将字节缩放为正确的格式。
论据:
bytes: the number of bytes to convert.
suffix: if you want to change the suffix of the given size.
返回正确的缩放大小。
get_correct_path(path)
将非 python 可用路径更改为 python 可用路径。
论据:
path: the path to check.
返回在 python 中可用的路径。
先进的
osstat_mode(file)
返回给定文件的 os.stat() 的模式部分。
主要用于获取文件的权限(即使您可以使用 permissions() 或 permissions_in_oct() 这样做)
论据:
file: the path to the file you want to get the mode part from.
如果失败,则返回 os.stat() 类或 0。
permissions_in_oct(file)
返回给定文件权限的八进制版本。
论据:
file: the path to the file you want to get the permissions from.
如果找不到文件,则返回八进制字符串或字符串“无法获取文件权限”。
size_in_bytes(file)
返回文件的大小(以字节为单位)。
论据:
file: the path to the file you want to get the size from.
返回一个带有字节数的整数。
file_stat(file)
返回给定文件的 os.stat()。
论据:
file: the path to the file you want to get the stats from.
返回一个 os.stat() 类对象。
last_access_raw(file)
以时间戳的形式给出最后一次访问时间。
论据:
file: the path to the file you want to get the last access timestamp from.
返回带有上次访问时间时间戳的整数。
last_modification_raw(file)
以时间戳的形式给出最后修改时间。
论据:
file: the path to the file you want to get the last modification timestamp from.
返回带有最后修改时间的时间戳的整数。
last_metadata_change_raw(file)
以时间戳的形式给出最后的元数据更改时间。
论据:
file: the path to the file you want to get the last metadata change time from.
返回带有上次元数据更改时间的时间戳的整数。
类型列表
- 档案
- 声音的
- 备份
- 电子书
- 数据库文件
- 开发商
- 磁盘映像
- 编码文件
- 应用程序/可执行文件
- 字体
- 3D 图像
- 插入
- 预设/设置
- 图片
- 原始图像
- ROM/游戏文件
- 电子表格
- 系统文件
- 文本文件/文档
- 矢量图像
- 视频
- 网络文档
- 文件夹
- 文档
如果不在数据库中,该类型被定义为“未知”
发展
文件中心正在不断开发中,并且会定期进行修复(但我也尝试添加一些新功能,呵呵)
如果您有任何问题、疑问、开发问题:请随时在问题部分提出。
如果您想帮助我们并加入我的行列,这里有一个快速指南。
文件
__init.py__是主要模块
data_所有带data_后缀的文件都是数据文件(例如扩展名列表)。
data_common.py是常见的文件扩展名列表。
data_ext_to_human_readable.py是文件扩展名及其人类可读格式的列表。
data_extension_desc.py是使用软件的文件扩展名及其描述的列表。
data_type.py是文件扩展名及其一般类型(文件类型,即图像、Web 开发)的列表。
README.md是您当前正在阅读的文本文件,其中包含所有文档和说明。
LICENSE是具有文件中心许可证的文本文件
依赖项
文件中心库不需要第三方依赖项。
来源
| 数据文件 | 资源 |
|---|---|
| data_common | 文件信息,维基百科, ComputerHope |
| data_ext_to_human_readeable | 网络百科 |
| data_extension_desc.py | 维基百科 |
| 数据类型 | 文件信息 |
版权和法律
这里的每一个数据都是手动从网站上提取的(我自己也是哈哈)(是的,这花了相当长的时间)
如果您认为有任何形式的侵犯版权,请随时要求我删除它,我会尽快删除
维基百科由维基媒体基金会主办
Computer Hope属于Nathan Emberton
Webopedia是属于 TechnologyAdvice, LLC 的品牌
FileInfo属于 Sharpened Productions
GitHub是属于 GitHub, Inc. (Microsoft) 的品牌
Python属于 Python 软件基金会
我现在隶属于 FileInfo.com
©Anime no Sekai - 2020 ✨
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
内置分布
filecenter -1.5.1.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | aff20e1332f6403e199ae55139a95a4527b9460483fcb58b4496c072958f904e |
|
| MD5 | 1f1a414917fda884236a48e615128380 |
|
| 布莱克2-256 | 8e69868e0883f25d645d293578746eb7625f0d25f913fa723adc812a7b9a4df6 |
filecenter -1.5.1-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | ebee67f998cd225b52987efabf7b6a3864b71d4645aae2f0072cd4c5784832eb |
|
| MD5 | acd99acb57974f781b4bac82b5f6a393 |
|
| 布莱克2-256 | fcb9e4f539cb4c0c9b554cda333765000bb595df79004cc17543a66085d57d0f |