Skip to main content

fs-map

项目简介

Python内置文件和路径处理函数的集合和扩展。

安装教程

pip install fs-map

功能说明

  • 集成函数
  1. os 模块
# 函数列表
'''
listdir, 
mkdir, 
rename, 
replace, 
rmdir,
remove,
makedirs,
removedirs,
renames
'''

# 参考文档 
# https://docs.python.org/zh-cn/3/library/os.html#module-os
  1. 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
  1. shutil 模块
# 函数列表
'''
copyfileobj, 
copyfile, 
copymode, 
copy, 
copy2, 
ignore_patterns, 
copytree, 
rmtree, 
move
'''

# 参考文档 
# https://docs.python.org/zh-cn/3/library/shutil.html#module-shutil
  1. 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

参考文献

https://docs.python.org/zh-cn/3/py-modindex.html

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)

Source distribution for fs-map 0.0.3
File Size Uploaded
fs-map-0.0.3.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fs-map 0.0.3
File Interpreter ABI Platform
fs_map-0.0.3-py3.8.egg Legacy Egg format - - Details

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

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page