Skip to main content

A Python library for cross-platform filesystem operations, providing classes for handling files and directories.

Project description

fsinfo

fsinfo is a Python library providing a high-level abstraction for working with filesystem paths, files, and directories in a cross-platform way. It simplifies file system operations like querying file attributes, manipulating directories, and handling files across Linux, macOS, and Windows.

Features

FileSystemInfo

This base class offers common attributes and methods for dealing with filesystem entities.

  • creation_time: Get the time of creation of the file/directory.
  • exists: Check if the file/directory exists.
  • full_name: Get the fully qualified name of the file/directory.
  • last_access_time: Get the last access time of the file/directory.
  • last_write_time: Get the last modification time of the file/directory.
  • name: Get the name of the file/directory.
  • delete: Delete the file/directory.

FileInfo

The FileInfo class extends FileSystemInfo with file-specific functionality.

  • directory: Get the parent directory of the file.
  • directory_name: Get the full path of the file's parent directory.
  • length: Get the size of the file in bytes.
  • is_read_only: Check if the file is read-only.
  • extension: Get the file extension.
  • create_text: Open the file for writing text.
  • open_text: Open the file for reading text.
  • copy_to: Copy the file to a specified destination.
  • move_to: Move the file to a specified destination.

DirectoryInfo

The DirectoryInfo class extends FileSystemInfo with directory-specific functionality.

  • length: Get the total size of all the files within the directory.
  • create: Create the directory.
  • get_files: Get a list of all the files in the directory matching a specified pattern.
  • get_directories: Get a list of all the subdirectories in the directory matching a specified pattern.
  • move_to: Move the directory to a specified destination.

Installation

Install fsinfo using pip:

pip install fsinfo

Usage

Working with Files

from fsinfo import FileInfo

file_path = '/Users/foo/bar/baz.log'
file_info = FileInfo(file_path)

print(file_info.full_name)
print(file_info.extension)
print(file_info.length)
print(file_info.directory)

Working with Directories

from fsinfo import DirectoryInfo

dir_path = '/Users/foo/bar'
dir_info = DirectoryInfo(dir_path)

print(dir_info.full_name)
print(dir_info.length)
print(dir_info.exists)

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fsinfo-0.0.8.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

fsinfo-0.0.8-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file fsinfo-0.0.8.tar.gz.

File metadata

  • Download URL: fsinfo-0.0.8.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.7

File hashes

Hashes for fsinfo-0.0.8.tar.gz
Algorithm Hash digest
SHA256 aed6c006898601aee6e5d72f9e3931297774a073ecb5559592a571e4f5111dc0
MD5 83b63b0d3f447fb2693151c45fcc5ee8
BLAKE2b-256 7c7d65d0d6b0c10739b3191b2652463825b3312b114907452e335f57d2a418f7

See more details on using hashes here.

File details

Details for the file fsinfo-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: fsinfo-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.7

File hashes

Hashes for fsinfo-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a16b7050934a9ba3f4b2e122689ad129b2904ddcea9022b5981ad0763ff51b01
MD5 3816d79e024bb2f34837a1154446251c
BLAKE2b-256 df457e0e499facc9f4434d8a06b0e4d9459ec60b50d0a8acfc7858fcb9d58c82

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page