HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/parted/__pycache__/disk.cpython-312.pyc
�

�XZ�@���ddlZddlZddlmZddlmZGd�de�ZiZej�Z
e
ee
j<		eje
�Z
e
ee
j<�##ee
ejf$rYnwxYwiZej d�Zej$e�ee<dZer0ej e�ZesdZnej$e�ee<er�/yy)�N)�
CachedList)�localeCc���eZdZdZed3d��Zd�Zd�Zd�Zd�Z	d�Z
eed	���Zeed
���Z
eed���Zeed���Zeed
���Zeed���Zeed���Zed��Zed��Zed��Zed��Zed��Zed��Zed�d��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Z ed3d��Z!ed4d ��Z"ed!��Z#ed"��Z$ed5d#��Z%ed3d$��Z&ed3d%��Z'ed&��Z(ed'��Z)ed(��Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/ed.��Z0ed/��Z1ed0��Z2ed1��Z3d2�Z4y)6�Diskz�Disk()

       A Disk object describes a type of device in the system.  Disks
       can hold partitions.  A Disk is a basic operating system-specific
       object.Nc�>��|rA|�_|�0tj�jj���_nN|�_nF|�tj
d��t
j|j���_|�_t�fd���_
y)z�Create a new Disk object from the device and type specified.  The
           device is a Device object and type is a string matching a key in
           the diskType hash.N)�	PedDevicezno device specifiedc�$���j�S�N)�_Disk__getPartitions��selfs��-/usr/lib/python3/dist-packages/parted/disk.py�<lambda>zDisk.__init__.<locals>.<lambda>8s���t�/C�/C�/E��)�_Disk__disk�parted�Device�dev�_device�
DiskException�_pedr�getPedDevicer�_partitions)r
�device�PedDisks`  r�__init__z
Disk.__init__%sz���
�!�D�K��~�%�}�}�t�{�{���G���%���
�^��&�&�'<�=�=��)�)�F�$7�$7�$9�:�D�K�!�D�L�&�&E�F��rc��ddl}t|j�t|j�k7ry|jj	|j|j�}		t|�\}}||k7ry	�#t$rYywxYw)NrFT)�six�len�
partitions�moves�zip�next�
StopIteration)r
�otherr�partIter�left�rights      r�
_hasSamePartszDisk._hasSameParts:s����t����3�u�'7�'7�#8�8���9�9�=�=����%�2B�2B�C���
� $�X��
��u��5�=� �!���
!�
��
�s�#A9�9	B�Bc�&�|j|�Sr
)�__ne__�r
r%s  r�__eq__zDisk.__eq__Is���;�;�u�%�%�%rc��t||j�sy|j|jk7xs|j|�S)NT)�
isinstance�	__class__rr)r,s  rr+zDisk.__ne__Ls9���$����0���{�{�e�l�l�*�K�$�2D�2D�U�2K�.K�Krc	��d|j|j|j|j|j|j
|jd�z}|S)Nz�parted.Disk instance --
  type: %(type)s  primaryPartitionCount: %(primaryCount)s
  lastPartitionNumber: %(last)s  maxPrimaryPartitionCount: %(max)s
  partitions: %(partitions)s
  device: %(device)r
  PedDisk: %(ped)r)�type�primaryCount�last�maxr r�ped)r2�primaryPartitionCount�lastPartitionNumber�maxPrimaryPartitionCountr rr)r
�ss  r�__str__zDisk.__str__RsP��"��i�i��1K�1K��.�.�t�7T�7T� �O�O�t�{�{��[�[�"�
	"���rc�F�g}|j�}|r�|jtjzs:|jtjzs|jtj
zr|j
�}�j|j|�|j
�}|r��|S)z�Construct a list of partitions on the disk.  This is called only as
           needed from the self.partitions property, which just happens to be
           a CachedList.)�getFirstPartitionr2r�PARTITION_FREESPACE�PARTITION_METADATA�PARTITION_PROTECTED�
nextPartition�append)r
r �	partitions   r�__getPartitionszDisk.__getPartitions_s����
��*�*�,�	���~�~�� :� :�:��~�~�� 9� 9�9��~�~�� :� :�:�%�3�3�5�	�����i�(�!�/�/�1�I���rc�6�|jj�S)z.The number of primary partitions on this disk.)r�get_primary_partition_countrs rr7zDisk.primaryPartitionCountrs���{�{�6�6�8�8rc�6�|jj�S)z:The last assigned partition number currently on this disk.)r�get_last_partition_numrs rr8zDisk.lastPartitionNumberxs���{�{�1�1�3�3rc�6�|jj�S)z>The maximum number of primary partitions allowed on this disk.)r�get_max_primary_partition_countrs rr9zDisk.maxPrimaryPartitionCount~s���{�{�:�:�<�<rc�6�|jj�S)z6The maximum number of partitions allowed on this disk.)r�!get_max_supported_partition_countrs r�maxSupportedPartitionCountzDisk.maxSupportedPartitionCount�s���{�{�<�<�>�>rc�b�|jj�}tj|��S)z"Partition start address Alignment.)�PedAlignment)r�get_partition_alignmentr�	Alignment)r
�	alignments  r�partitionAlignmentzDisk.partitionAlignment�s'���K�K�7�7�9�	����Y�7�7rc�6�|jj�S)z4Max Partition Length the disk's label can represent.)r�max_partition_lengthrs r�maxPartitionLengthzDisk.maxPartitionLength�s���{�{�/�/�1�1rc�6�|jj�S)z:Max Partition Start Sector the disk's label can represent.)r�max_partition_start_sectorrs r�maxPartitionStartSectorzDisk.maxPartitionStartSector�s���{�{�5�5�7�7rc�8�|jj|�S)z�Get the value of a particular flag on the disk.  Valid flags
           are the _ped.DISK_* constants.  See _ped.disk_flag_get_name() and
           _ped.disk_flag_get_by_name() for more help working with disk flags.
        )r�get_flag�r
�flags  r�getFlagzDisk.getFlag�s���{�{�#�#�D�)�)rc�:�|jj|d�S)z�Set the flag on this disk.  On error, an Exception will be raised.
           See getFlag() for more help on working with disk flags.��r�set_flagr\s  r�setFlagzDisk.setFlag�����{�{�#�#�D�!�,�,rc�:�|jj|d�S)z�Unset the flag on this disk.  On error, an Exception will be raised.
           See getFlag() for more help on working with disk flags.rrar\s  r�	unsetFlagzDisk.unsetFlag�rdrc�8�|jj|�S)zJReturn True if flag is available on this Disk, False
           otherwise.)r�is_flag_availabler\s  r�isFlagAvailablezDisk.isFlagAvailable�s���{�{�,�,�T�2�2rc��|jS)z.The list of partitions currently on this disk.)rrs rr zDisk.partitions�s�����rc��|jS)z7The underlying Device holding this disk and partitions.)rrs rrzDisk.device�s���|�|�rc�B�|jjjSr
)rr2�name)r:s rrz
Disk.<lambda>�s��a�h�h�m�m�0�0�rc�R�t|jdtj|�S)Nr2)�setattrrr�diskType)r:�vs  rrz
Disk.<lambda>�s!��w�q�x�x�QW�Y_�Yh�Yh�ij�Yk�?l�rc�J�t|jj���S)zMake a deep copy of this Disk.)r)rr�	duplicaters rrszDisk.duplicate�s���D�K�K�1�1�3�4�4rc�6�|jj�S)z<Closes the Disk ensuring all outstanding writes are flushed.)r�destroyrs rruzDisk.destroy�s���{�{�"�"�$�$rc�j�|jj�|jj�S)z�Writes in-memory changes to a partition table to disk and
           informs the operating system of the changes.  Equivalent to
           calling self.commitToDevice() then self.commitToOS().)r �
invalidater�commitrs rrxzDisk.commit�s'��
	
���"�"�$��{�{�!�!�#�#rc�j�|jj�|jj�S)zbWrite the changes made to the in-memory description of a
           partition table to the device.)r rwr�
commit_to_devrs r�commitToDevicezDisk.commitToDevice�s'��	
���"�"�$��{�{�(�(�*�*rc�j�|jj�|jj�S)zZTell the operating system kernel about the partition table
           layout of this Disk.)r rwr�commit_to_osrs r�
commitToOSzDisk.commitToOS�s'��	
���"�"�$��{�{�'�'�)�)rc�6�|jj�S)z;Perform a sanity check on the partition table of this Disk.)r�checkrs rr�z
Disk.check�s���{�{� � �"�"rc�L�|jjj|�S)z7Check that the disk type supports the provided feature.)rr2�
check_feature)r
�features  r�supportsFeaturezDisk.supportsFeature�s���{�{���-�-�g�6�6rc��|r9|jj|j�|j��}n@|st	j
d��|jj|j��}|rNt	j|j�j��|_|jj�yy)z;Add a new Partition to this Disk with the given Constraint.�$no partition or constraint specified��PedGeometryTF)r�
add_partition�getPedPartition�getPedConstraintrr�Geometry�geom�geometryr rw)r
rC�
constraint�results    r�addPartitionzDisk.addPartition�s�����[�[�.�.�y�/H�/H�/J�/9�/J�/J�/L�N�F���&�&�'M�N�N��[�[�.�.�y�/H�/H�/J�K�F��!'���Y�=V�=V�=X�=]�=]�!^�I���O�O�&�&�(��rc��|stjd��|jj|j	��r|j
j
�yy)aRemoves specified Partition from this Disk.  NOTE:  If the
           Partition is an extended partition, it must not contain any
           logical partitions.  Also note that the partition is not
           actually destroyed unless you use the deletePartition()
           method.�no partition specifiedTF)rrr�remove_partitionr�r rw�r
rCs  r�removePartitionzDisk.removePartitionsJ����&�&�'?�@�@��;�;�'�'�	�(A�(A�(C�D��O�O�&�&�(��rc��|jj|j��r|jj	�yy)z�Removes specified Partition from this Disk under the same
           conditions as removePartition(), but also destroy the
           removed Partition.TF)r�delete_partitionr�r rwr�s  r�deletePartitionzDisk.deletePartitions5��
�;�;�'�'�	�(A�(A�(C�D��O�O�&�&�(��rc�n�|jj�r|jj�yy)z1Removes and destroys all Partitions in this Disk.TF)r�
delete_allr rwrs r�deleteAllPartitionszDisk.deleteAllPartitionss*���;�;�!�!�#��O�O�&�&�(��rc���|r|stjd��|r|stjd��|jj|j	�|j�||�S)z�Sets the Geometry of the specified Partition using the given
           Constraint and start and end sectors.  Note that this method
           does not modify the partition contents, just the partition
           table.r�z"no start or end geometry specified)rrr�set_partition_geomr�r�)r
rCr��start�ends     r�setPartitionGeometryzDisk.setPartitionGeometry&se���
��&�&�'M�N�N��C��&�&�'K�L�L��{�{�-�-�i�.G�.G�.I�.8�.I�.I�.K�.3�S�:�	:rc��|stjd��|r8|jj|j	�|j��S|jj|j	��S)zWGrow the Partition's Geometry to the maximum possible subject
           to Constraint.r�)rrr�maximize_partitionr�r��r
rCr�s   r�maximizePartitionzDisk.maximizePartition6sl����&�&�'?�@�@���;�;�1�1�)�2K�2K�2M�2<�2M�2M�2O�Q�
Q��;�;�1�1�)�2K�2K�2M�N�Nrc�F�|stjd��|rLtj|jj	|j�|j
����Stj|jj	|j����S)zcGet the maximum Geometry the Partition can be grown to,
           subject to the given Constraint.r�r�)rrr�r�get_max_partition_geometryr�r�r�s   r�calculateMaxPartitionGeometryz"Disk.calculateMaxPartitionGeometryCs�����&�&�'?�@�@���?�?�t�{�{�/U�/U�V_�Vo�Vo�Vq�s}�tO�tO�tQ�0R�S�
S��?�?�t�{�{�/U�/U�V_�Vo�Vo�Vq�/r�s�src�r�|jj�}|r|jj�|S)z�Reduce the size of the extended partition to a minimum while
           still wrapping its logical partitions.  If there are no logical
           partitions, remove the extended partition.)r�minimize_extended_partitionr rw)r
�rets  r�minimizeExtendedPartitionzDisk.minimizeExtendedPartitionOs.��
�k�k�5�5�7����O�O�&�&�(��
rc�b�tj||jj|���S)z�Returns the Partition that contains the sector.  If the sector
           lies within a logical partition, then the logical partition is
           returned (not the extended partition).��disk�PedPartition)r�	Partitionr�get_partition_by_sector)r
�sectors  r�getPartitionBySectorzDisk.getPartitionBySector[s'��
���T����8[�8[�\b�8c�d�drc�p�	tj||jj���S#YyxYw)z4Return the extended Partition, if any, on this Disk.r�N)rr�r�extended_partitionrs r�getExtendedPartitionzDisk.getExtendedPartitionbs1��	��#�#��D�K�K�<Z�<Z�<\�]�]��	��s�.1�5c�R�|jD�cgc]
}||�s�|��c}Scc}wr
)r )r
�fn�parts   r�__filterPartitionszDisk.__filterPartitionsks ��!%���=��B�t�H��=�=��=s�
$�$c�&�|jd��S)z1Return a list of logical Partitions on this Disk.c�X�|jxr|jtjzSr
)�activer2r�PARTITION_LOGICAL��ps rrz+Disk.getLogicalPartitions.<locals>.<lambda>ps�����1_�a�f�f�v�G_�G_�>_�r��_Disk__filterPartitionsrs r�getLogicalPartitionszDisk.getLogicalPartitionsns���&�&�'_�`�`rc�&�|jd��S)z=Return a list of primary (or normal) Partitions on this Disk.c�<�|jtjk(Sr
)r2r�PARTITION_NORMALr�s rrz+Disk.getPrimaryPartitions.<locals>.<lambda>ts�����6�;R�;R�1R�rr�rs r�getPrimaryPartitionszDisk.getPrimaryPartitionsrs���&�&�'R�S�Src�&�|jd��S)z:Return a list of RAID (or normal) Partitions on this Disk.c�\�|jxr|jtj�Sr
)r�r^r�PARTITION_RAIDr�s rrz(Disk.getRaidPartitions.<locals>.<lambda>xs�����1^�a�i�i��H]�H]�>^�rr�rs r�getRaidPartitionszDisk.getRaidPartitionsvs���&�&�'^�_�_rc�&�|jd��S)z>Return a list of physical volume-type Partitions on this Disk.c�\�|jxr|jtj�Sr
)r�r^r�
PARTITION_LVMr�s rrz'Disk.getLVMPartitions.<locals>.<lambda>|s�����1]�a�i�i��H\�H\�>]�rr�rs r�getLVMPartitionszDisk.getLVMPartitionszs���&�&�']�^�^rc��g}|jj�}|rj|jtjzr/|jtj|j���|jj|�}|r�j|S)zhReturn a list of Geometry objects representing the available
           free space regions on this Disk.r�)r�next_partitionr2rr>rBr�r��r
�	freespacer�s   r�getFreeSpaceRegionszDisk.getFreeSpaceRegions~sl���	��{�{�)�)�+����y�y�6�5�5�5�� � ����T�Y�Y�!G�H��;�;�-�-�d�3�D�	��rc��g}|jj�}|ra|jtjzr&|jtj||���|jj|�}|r�a|S)ziReturn a list of Partition objects representing the available
           free space regions on this Disk.r�)rr�r2rr>rBr�r�s   r�getFreeSpacePartitionszDisk.getFreeSpacePartitions�sl���	��{�{�)�)�+����y�y�6�5�5�5�� � ��!1�!1�t�$�!O�P��;�;�-�-�d�3�D�	��rc�`�tj||jj���S)zUReturn the first Partition object on the disk or None if
           there is not one.r�)rr�rr�rs rr=zDisk.getFirstPartition�s$�����T����8R�8R�8T�U�Urc�L�|jD]}|j|k(s�|cSy)z�Return a Partition object associated with the partition device
           path, such as /dev/sda1.  Returns None if no partition is found.N)r �path)r
r�rCs   r�getPartitionByPathzDisk.getPartitionByPath�s.�����	!�I��~�~��%� � �	!�rc��|jS)z]Return the _ped.Disk object contained in this Disk.  For internal
           module use only.)rrs r�
getPedDiskzDisk.getPedDisk�s���{�{�r)NNr
)NNNN)5�__name__�
__module__�__qualname__�__doc__rrr)r-r+r;r�propertyr7r8r9rMrSrVrYr^rcrfrir rr2rsrurxr{r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r=r�r��rrrrsO���

�G�
�G�(
�&�L���&��9�
��9���4�
��4���=�
��=���?�
��?���8�
��8�
��2�
��2���8�
��8�
�*�
�*�
�-�
�-�

�-�
�-�

�3�
�3�
� �� ������0�2l�m�D��5�
�5�
�%�
�%�
�$�
�$�
�+�
�+�
�*�
�*�
�#�
�#�
�7�
�7�
��
��"
�
�
�
�
��
��
��
��
�
:�
�
:�
�
O�
�
O�
�	t�
�	t�
�	�
�	�
�e�
�e�
��
��>�a�T�`�_�
��
��
��
��
�V�
�V�

��
��rrTF)rr�parted.cachedlistr�parted.decoratorsr�objectrrp�disk_type_get_next�__typerm�
IndexError�	TypeError�UnknownTypeException�diskFlag�disk_flag_next�__flag�disk_flag_get_name�__readFlagsr�rr�<module>r�s��2�
�(�%�P�6�P�f��	 ��	 �	 �	"��������
��(��(�(��0�� &��������
�	�4�#<�#<�=��
�����	��	�	�Q�	��*�4�*�*�6�2�������
 �T�
 �
 ��
(�F����2�4�2�2�6�:����s�!A&�&A;�:A;