OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, url=None) |
def | read_configuration (self) |
def | save_configuration (self) |
def | check_credentials (self) |
def | register (self, metadata) |
def | get_sign_command (self, filename, signer, sign_password, keystore=None) |
def | run_command (self, cmd, input_data=None) |
def | sign_file (self, filename, signer, sign_password, keystore=None) |
def | upload_file (self, metadata, filename, signer=None, sign_password=None, filetype='sdist', pyversion='source', keystore=None) |
def | upload_documentation (self, metadata, doc_dir) |
def | get_verify_command (self, signature_filename, data_filename, keystore=None) |
def | verify_signature (self, signature_filename, data_filename, keystore=None) |
def | download_file (self, url, destfile, digest=None, reporthook=None) |
def | send_request (self, req) |
def | encode_request (self, fields, files) |
def | search (self, terms, operator=None) |
Data Fields | |
url | |
password_handler | |
ssl_verifier | |
gpg | |
gpg_home | |
username | |
password | |
realm | |
Static Public Attributes | |
boundary | |
This class represents a package index compatible with PyPI, the Python Package Index.
def __init__ | ( | self, | |
url = None |
|||
) |
Initialise an instance. :param url: The URL of the index. If not specified, the URL for PyPI is used.
def check_credentials | ( | self | ) |
Check that ``username`` and ``password`` have been set, and raise an exception if not.
def download_file | ( | self, | |
url, | |||
destfile, | |||
digest = None , |
|||
reporthook = None |
|||
) |
This is a convenience method for downloading a file from an URL. Normally, this will be a file from the index, though currently no check is made for this (i.e. a file can be downloaded from anywhere). The method is just like the :func:`urlretrieve` function in the standard library, except that it allows digest computation to be done during download and checking that the downloaded data matched any expected value. :param url: The URL of the file to be downloaded (assumed to be available via an HTTP GET request). :param destfile: The pathname where the downloaded file is to be saved. :param digest: If specified, this must be a (hasher, value) tuple, where hasher is the algorithm used (e.g. ``'md5'``) and ``value`` is the expected value. :param reporthook: The same as for :func:`urlretrieve` in the standard library.
def encode_request | ( | self, | |
fields, | |||
files | |||
) |
Encode fields and files for posting to an HTTP server. :param fields: The fields to send as a list of (fieldname, value) tuples. :param files: The files to send as a list of (fieldname, filename, file_bytes) tuple.
def get_sign_command | ( | self, | |
filename, | |||
signer, | |||
sign_password, | |||
keystore = None |
|||
) |
Return a suitable command for signing a file. :param filename: The pathname to the file to be signed. :param signer: The identifier of the signer of the file. :param sign_password: The passphrase for the signer's private key used for signing. :param keystore: The path to a directory which contains the keys used in verification. If not specified, the instance's ``gpg_home`` attribute is used instead. :return: The signing command as a list suitable to be passed to :class:`subprocess.Popen`.
def get_verify_command | ( | self, | |
signature_filename, | |||
data_filename, | |||
keystore = None |
|||
) |
Return a suitable command for verifying a file. :param signature_filename: The pathname to the file containing the signature. :param data_filename: The pathname to the file containing the signed data. :param keystore: The path to a directory which contains the keys used in verification. If not specified, the instance's ``gpg_home`` attribute is used instead. :return: The verifying command as a list suitable to be passed to :class:`subprocess.Popen`.
def read_configuration | ( | self | ) |
Read the PyPI access configuration as supported by distutils, getting PyPI to do the actual work. This populates ``username``, ``password``, ``realm`` and ``url`` attributes from the configuration.
def register | ( | self, | |
metadata | |||
) |
Register a distribution on PyPI, using the provided metadata. :param metadata: A :class:`Metadata` instance defining at least a name and version number for the distribution to be registered. :return: The HTTP response received from PyPI upon submission of the request.
def run_command | ( | self, | |
cmd, | |||
input_data = None |
|||
) |
Run a command in a child process , passing it any input data specified. :param cmd: The command to run. :param input_data: If specified, this must be a byte string containing data to be sent to the child process. :return: A tuple consisting of the subprocess' exit code, a list of lines read from the subprocess' ``stdout``, and a list of lines read from the subprocess' ``stderr``.
def save_configuration | ( | self | ) |
Save the PyPI access configuration. You must have set ``username`` and ``password`` attributes before calling this method. Again, distutils is used to do the actual work.
def search | ( | self, | |
terms, | |||
operator = None |
|||
) |
def send_request | ( | self, | |
req | |||
) |
Send a standard library :class:`Request` to PyPI and return its response. :param req: The request to send. :return: The HTTP response from PyPI (a standard library HTTPResponse).
def sign_file | ( | self, | |
filename, | |||
signer, | |||
sign_password, | |||
keystore = None |
|||
) |
Sign a file. :param filename: The pathname to the file to be signed. :param signer: The identifier of the signer of the file. :param sign_password: The passphrase for the signer's private key used for signing. :param keystore: The path to a directory which contains the keys used in signing. If not specified, the instance's ``gpg_home`` attribute is used instead. :return: The absolute pathname of the file where the signature is stored.
def upload_documentation | ( | self, | |
metadata, | |||
doc_dir | |||
) |
Upload documentation to the index. :param metadata: A :class:`Metadata` instance defining at least a name and version number for the documentation to be uploaded. :param doc_dir: The pathname of the directory which contains the documentation. This should be the directory that contains the ``index.html`` for the documentation. :return: The HTTP response received from PyPI upon submission of the request.
def upload_file | ( | self, | |
metadata, | |||
filename, | |||
signer = None , |
|||
sign_password = None , |
|||
filetype = 'sdist' , |
|||
pyversion = 'source' , |
|||
keystore = None |
|||
) |
Upload a release file to the index. :param metadata: A :class:`Metadata` instance defining at least a name and version number for the file to be uploaded. :param filename: The pathname of the file to be uploaded. :param signer: The identifier of the signer of the file. :param sign_password: The passphrase for the signer's private key used for signing. :param filetype: The type of the file being uploaded. This is the distutils command which produced that file, e.g. ``sdist`` or ``bdist_wheel``. :param pyversion: The version of Python which the release relates to. For code compatible with any Python, this would be ``source``, otherwise it would be e.g. ``3.2``. :param keystore: The path to a directory which contains the keys used in signing. If not specified, the instance's ``gpg_home`` attribute is used instead. :return: The HTTP response received from PyPI upon submission of the request.
def verify_signature | ( | self, | |
signature_filename, | |||
data_filename, | |||
keystore = None |
|||
) |
Verify a signature for a file. :param signature_filename: The pathname to the file containing the signature. :param data_filename: The pathname to the file containing the signed data. :param keystore: The path to a directory which contains the keys used in verification. If not specified, the instance's ``gpg_home`` attribute is used instead. :return: True if the signature was verified, else False.
|
static |
gpg |
gpg_home |
password |
password_handler |
realm |
ssl_verifier |
url |
username |