mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
c51b1ed1da
Summary: This will force future changes to this file to be fully type checked. Reviewed By: fanzeyi Differential Revision: D28544421 fbshipit-source-id: 67d15e4d6ed13c139adffa7cedf7795856d87c7e
36 lines
803 B
Python
36 lines
803 B
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
# pyre-strict
|
|
|
|
import abc
|
|
import os
|
|
import shutil
|
|
|
|
from . import util
|
|
|
|
|
|
class FsUtil(abc.ABC):
|
|
@abc.abstractmethod
|
|
def mkdir_p(self, path: str) -> str:
|
|
"""Performs `mkdir -p <path>` and returns the path."""
|
|
|
|
@abc.abstractmethod
|
|
def disk_usage(self, path: str) -> shutil._ntuple_diskusage:
|
|
"""Calls os.statvfs on the mount"""
|
|
|
|
|
|
class RealFsUtil(FsUtil):
|
|
def mkdir_p(self, path: str) -> str:
|
|
return util.mkdir_p(path)
|
|
|
|
def disk_usage(self, path: str) -> shutil._ntuple_diskusage:
|
|
return shutil.disk_usage(path)
|
|
|
|
|
|
def new() -> FsUtil:
|
|
return RealFsUtil()
|