fs-map
项目简介
Python内置文件和路径处理函数的集合和扩展。
安装教程
pip install fs-map
功能说明
- 集成函数
- os 模块
# 函数列表
'''
listdir,
mkdir,
rename,
replace,
rmdir,
remove,
makedirs,
removedirs,
renames
'''
# 参考文档
# https://docs.python.org/zh-cn/3/library/os.html#module-os
- os.path 模块
# 函数列表
'''
exists,
getsize,
isdir,
isfile,
normcase,
isabs,
join,
splitdrive,
split,
splitext,
basename,
dirname,
normpath,
abspath,
realpath,
relpath
'''
# 参考文档
# https://docs.python.org/zh-cn/3/library/os.path.html#module-os.path
- shutil 模块
# 函数列表
'''
copyfileobj,
copyfile,
copymode,
copy,
copy2,
ignore_patterns,
copytree,
rmtree,
move
'''
# 参考文档
# https://docs.python.org/zh-cn/3/library/shutil.html#module-shutil
- glob 模块
# 函数列表
'''
glob,
glob0,
glob1,
iglob,
escape
'''
# 参考文档
# https://docs.python.org/zh-cn/3/library/glob.html#module-glob
- 扩展函数
def get_filename(path):
'''
Returns a file name with a suffix
'''
_, filename = split(path)
return filename
def get_filename1(path):
'''
Returns a file name that does not contain a suffix
'''
filename = get_filename(path)
filename, _ = splitext(filename)
return filename
def get_ext(path):
'''
Returns the file suffix
'''
_, ext = splitext(get_filename(path))
return ext
def normcase1(path):
'''
Converts all characters in the path to lowercase and forward slashes to backslashes
'''
return normcase(path).replace('\\', '/')
def normpath1(path):
'''
Converts forward slashes in a path to backslashes
'''
return normpath(path).replace('\\', '/')
实例
import fs
'''
集成函数实例
'''
# 判断文件是否存在
print(fs.exists('file.txt'))
'''
扩展函数实例
'''
# 获取文件后缀
print(fs.get_ext('c:/a/b/c.txt'))
# 输出结果:.txt
# 获取带后缀的文件名
print(fs.get_filename('c:/a/b/c.txt'))
# 输出结果:'c.txt'
# 获取不带后缀的文件名
print(fs.get_filename1('a.c.txt'))
# 输出结果:'a.c'
# 路径标准化的
print(fs.normcase1('c:\\A/b/c.txt'))
# 输出结果:c:/a/b/c.txt
print(fs.normpath1('c:\\A/b/c.txt'))
# 输出结果:c:/A/b/c.txt
参考文献
Metadata
Release files for fs-map 0.0.3
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 |
|---|---|---|---|---|
| fs-map-0.0.3.tar.gz | 3.3 kB | Without provenance | Details for fs-map-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fs_map-0.0.3-py3.8.egg | Legacy Egg format | - | - | Details for fs_map-0.0.3-py3.8.egg |
Total release size: 7.6 kB
Release files / fs-map-0.0.3.tar.gz
| Download URL | fs-map-0.0.3.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7060c737e04b74d1baa1145650083c8805dce931ca8c768fa7a8c37331f42324
|
|
BLAKE2b-256 checksum How to use checksums |
ac52d9e649130feb48c30040ec9cb7046a37bdf64f18b8ec5f00106f3575f34e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5
|
Release files / fs_map-0.0.3-py3.8.egg
| Download URL | fs_map-0.0.3-py3.8.egg |
|---|---|
| Size | 4.4 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
5e3906707387eafcd4e8a2afbe33c6e5555ccaaa4ad3d7de58852c405e907a64
|
|
BLAKE2b-256 checksum How to use checksums |
d9f88f0a7d4a980d9e0a890b613d0fa4e267ff40f977428f24cd5d7dd5c43c4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5
|
Security for fs-map 0.0.3
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.