Mini Shell
3
{)c� � @ s� d dl Z d dlZd dlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm
Z
ee j�G d
d� de
je j
��ZG dd
� d
e�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de j�ZdS )� N)�
add_metaclass� )�FSReadLabelError)�util� )�availability)�fstask)�taskc @ sH e Zd ZdZdZejdd�Zejdd�Ze dd� �Z
dd � Zd
d� ZdS )
�FSReadLabelzA An abstract class that represents reading a filesystem's label. zread filesystem labelz5Matches the string output by the reading application.)�doczarguments for reading a label.c C s t | j�g| j S )zvGet the command to read the filesystem label.
:return: the command
:rtype: list of str
)�str�ext�args)�self� r �!/usr/lib/python3.6/fsreadlabel.py�
_read_command0 s zFSReadLabel._read_commandc C s. t j| j|�}|dkr$td| j ��|jd�S )z�Extract the label from an output string.
:param str labelstr: the string containing the label information
:return: the label
:rtype: str
Raises an FSReadLabelError if the label can not be extracted.
Nz!Unknown format for application %s�label)�re�match�label_regexr r
�group)r Zlabelstrr r r r �_extract_label9 s
zFSReadLabel._extract_labelc C sV | j }|rtdj|���tj| j�\}}|dkr8td��|j� }|dkrL|S | j|�S )z\ Get the label.
:returns: the filesystem label
:rtype: str
�
r zread label failed� )Zavailability_errorsr �joinr Zrun_program_and_capture_outputr �stripr )r Z
error_msgsZrc�outr r r r �do_taskH s zFSReadLabel.do_taskN)
�__name__�
__module__�__qualname__�__doc__�description�abc�abstractpropertyr r �propertyr r r r r r r r
# s r
c @ s"