From 1bb0f8506da0055713caa373c45383c027756069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Mon, 25 Feb 2019 16:39:18 +0100 Subject: storage/directory.py: Add _FileType enum --- buildstream/storage/directory.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/buildstream/storage/directory.py b/buildstream/storage/directory.py index 4b83b38e7..9022b8770 100644 --- a/buildstream/storage/directory.py +++ b/buildstream/storage/directory.py @@ -31,6 +31,8 @@ See also: :ref:`sandboxing`. """ +from enum import Enum + from .._exceptions import BstError, ErrorDomain from ..utils import _magic_timestamp @@ -183,3 +185,26 @@ class Directory(): and all files and subdirectories in it. Storage space varies by implementation and effective space used may be lower than this number due to deduplication. """ raise NotImplementedError() + + +# FileType: +# +# Type of file or directory entry. +# +class _FileType(Enum): + + # Directory + DIRECTORY = 1 + + # Regular file + REGULAR_FILE = 2 + + # Symbolic link + SYMLINK = 3 + + # Special file (FIFO, character device, block device, or socket) + SPECIAL_FILE = 4 + + def __str__(self): + # https://github.com/PyCQA/pylint/issues/2062 + return self.name.lower().replace('_', ' ') # pylint: disable=no-member -- cgit v1.2.1