我的效用函数。将添加更多
roopeshv.utils的Python项目详细描述
简介
这是一个实用函数的集合,它可以很简单, 而且非常有用。
此版本的实用程序函数仅包括 处理这些文件、目录和完整路径。
功能
获取目录dir_
的扩展路径~is/home/rv的主目录和主目录 zope的是/usr/local/zope
>>> full_path('~') '/home/rv' >>> full_path('~zope') '/usr/local/zope'
对于一个不存在的用户
>>> full_path('~test') '/home/rv/expertpy/roopeshv.utils/roopeshv/utils/~test'
加入列表以形成目录路径
这只是一个方便的功能。
>>> join_path('~', 'test') '~/test' >>> join_path('/home/rv', 'test') '/home/rv/test' >>> join_path('test', 'README.txt') 'test/README.txt'
确定目录是否为目录。
>>> is_directory('.') True >>> is_directory('~') True >>> is_directory('/') True >>> is_directory('no/such/directory') False
获取目录dir_
中的文件列表(绝对路径)the .directory happens to exist in my computer, but for now the function works as intended. >>> get_files_in('/home/') ['/home/.directory'] >>> '/etc/passwd' in get_files_in('/etc/') True
获取目录dir_
中的目录列表(绝对路径)>>> sorted(get_directories_in('/home/')) ['/home/guest', '/home/rv'] >>> '/home/rv/Desktop' in get_directories_in('~') True
获取给定目录中的最新文件
>>> get_latest_file_in('~/expertpy/roopeshv.utils', prefix=[])
历史记录
版本0.0.1
- 增加了一些便利功能