Current File : //usr/lib/python2.7/site-packages/keyczar/writers.pyo
�
N�Pc@scdZddlZddlZddlZd�Zdefd��YZdefd��YZdS(su
A Writer supports writing metadata and key info for key sets.

@author: rleftwich@lightkeeper.com (Robert Leftwich)
i����NcCsQtj�x-tj�D]}|j|�}|r|SqWtjd|��dS(s�Factory function for Writers
  
    @param location: where (file, uri, etc) the writer should write to
    @type location: string
  s:Unable to create a writer for %s. Does the location exist?N(tutiltImportBackendstWritert__subclasses__tCreateWriterterrorstKeyczarError(tlocationtsctwriter((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyRs
RcBsteZdZejZejed��Zejdd��Z
ejd��Zejd��Ze
d��ZRS(sJAbstract class/interface providing supported methods for writing key sets.cCsdS(s�
    Write the metadata for the key.
    
    @param metadata: metadata for key
    @type: KeyMetadata
    
    @raise KeyczarError: if unable to write metadata (e.g. IOError) 
    N((tselftmetadatat	overwrite((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyt
WriteMetadata.s
cCsdS(sa
    Write out the key at the given version.
    
    @param key: key value
    @type: string
    
    @param version_number: the version number of the key
    @type version_number: integer
    
    @param encrypter: existing Keyczar encrypter for key
    @type: Keyczar.Crypter

    @raise KeyczarError: if unable to write key info (e.g. IOError) 
    N((R
tkeytversion_numbert	encrypter((s3/usr/lib/python2.7/site-packages/keyczar/writers.pytWriteKey:scCsdS(s�
    Remove the key for the given version.
    
    @param version_number: the version number of the key
    @type version_number: integer
    
    @raise KeyczarError: if unable to remove key info (e.g. IOError) 
    N((R
R((s3/usr/lib/python2.7/site-packages/keyczar/writers.pytRemoveLs
cCsdS(sR
    Clean up this writer
    
    @raise KeyczarError: if error during close
    N((R
((s3/usr/lib/python2.7/site-packages/keyczar/writers.pytCloseXscCstd|��dS(sE
    Return an instance of this class if it handles the location
    s6CreateWriter() class method MUST be implemented for:%sN(tNotImplementedError(tclsR((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyRasN(t__name__t
__module__t__doc__RtABCMetat
__metaclass__tabstractmethodtTrueR
tNoneRRRtclassmethodR(((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyR)s		t
FileWritercBsPeZdZd�Zed�Zdd�Zd�Zd�Z	e
d��ZRS(sWrite key sets to a file.cCs
||_dS(s4Construct a key set writer at the specified locationN(R(R
R((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyt__init__kscCsatjj|jd�}|rGtjj|�rGtjd|��ntjt	|�|�dS(s)
    Write the metadata for the key.
    tmetasFile:%s already existsN(
tostpathtjoinRtexistsRRRt	WriteFiletstr(R
RRtfname((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyR
os
cCsPt|�}|r$|j|�}ntj|tjj|jt|���dS(s1
    Write out the key at the given version.
    N(R'tEncryptRR&R"R#R$R(R
RRR((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyRys
(cCs)tjtjj|jt|���dS(s/
    Remove the key for the given version.
    N(R"tremoveR#R$RR'(R
R((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyR�scCsdS(s
    Clean up this writer
    N((R
((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyR�scCs+d}tjj|�r't|�}n|S(sE
    Return an instance of this class if it handles the location
    N(RR"R#R%R(RRtresult((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyR�sN(RRRR RR
RRRRRR(((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyRhs	

		(RR"RRRtobjectRR(((s3/usr/lib/python2.7/site-packages/keyczar/writers.pyt<module>s	?