Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/boto/file/__pycache__/ |
Upload File : |
o ckF[� � @ s@ d dl Z d dlmZ d dlmZ d dlmZ G dd� de�ZdS )� N)�Key)�SimpleResultSet)�BucketListResultSetc @ s^ e Zd Zdd� Zdd� Zdd� Z ddd �Zdd d�Zddej fdd �Z dej fdd�ZdS )�Bucketc C s || _ || _dS )zHInstantiate an anonymous file-based Bucket around a single key. N)�name� contained_key)�selfr r � r �2/usr/lib/python3/dist-packages/boto/file/bucket.py�__init__ s zBucket.__init__c C s t t| ��S �N)�iterr �r r r r �__iter__% s zBucket.__iter__c C s d| j S )Nzanonymous bucket for file://)r r r r r �__str__( s zBucket.__str__Nc C s t �|� dS )a< Deletes a key from the bucket. :type key_name: string :param key_name: The key name to delete :type version_id: string :param version_id: Unused in this subclass. :type mfa_token: tuple or list of strings :param mfa_token: Unused in this subclass. N)�os�remove)r �key_name�headers� version_id� mfa_tokenr r r � delete_key+ s zBucket.delete_keyc K s t | j| j�}t|g�S )z� This method returns the single key around which this anonymous Bucket was instantiated. :rtype: SimpleResultSet :return: The result from file system listing the keys requested )r r r r )r r �params�keyr r r �get_all_keys; s zBucket.get_all_keysc C s2 |dkr t | jdt jd�S t|d�}t | j||�S )a Check to see if a particular key exists within the bucket. Returns: An instance of a Key object or None :type key_name: string :param key_name: The name of the key to retrieve :type version_id: string :param version_id: Unused in this subclass. :type stream_type: integer :param stream_type: Type of the Key - Regular File or input/output Stream :rtype: :class:`boto.file.key.Key` :returns: A Key object from this bucket. �-��key_type�rb)r r �KEY_STREAM_READABLE�open)r r r r r �fpr r r �get_keyG s zBucket.get_keyc C sX |dkr t | jdt jd�S tj�|�}|r tj�|�s t�|� t|d�}t | j||�S )z� Creates a new key :type key_name: string :param key_name: The name of the key to create :rtype: :class:`boto.file.key.Key` :returns: An instance of the newly created key object r r �wb) r r �KEY_STREAM_WRITABLEr �path�dirname�exists�makedirsr )r r r �dir_namer! r r r �new_key_ s zBucket.new_key)NNNr )�__name__� __module__�__qualname__r r r r r r �KEY_REGULAR_FILEr"