nptr_cli package#

Submodules#

nptr_cli.nptr module#

class nptr_cli.nptr.CLI[source]#

Bases: object

static delete(args, args_help)[source]#

CLI wrapper for the delete method.

Parameters:
  • args (argparse.Namespace) – the args parsed by argparse

  • args_help – the print_help function from the argparse parser

static parse_args()[source]#

Parses the args with argparse.

static parse_config(file: str = PosixPath('/home/runner/.config/0x0/config.toml')) dict[source]#

Parses the config file to override defaults.

static upload(args: Namespace, args_help)[source]#

CLI wrapper for the upload method.

Parameters:
  • args (argparse.Namespace) – the args parsed by argparse

  • args_help – the print_help function from the argparse parser

class nptr_cli.nptr.NullPointer(instance_url: str = 'https://0x0.st', username: Optional[str] = None, password: Optional[str] = None, log_dir: Optional[Path] = None)[source]#

Bases: object

The NullPointer class to abstract away 0x0 API.

delete(url: str, token: str)[source]#

Delete a file from 0x0.

Parameters:
  • url (str) – the url for the file to delete

  • token (str) – the token that was returned via the X-Token header when the file was created

Raises:

HTTPError

Returns:

true for success false for failure

Return type:

bool

upload(file: bytes, filename: str = 'file', secret: bool = True)[source]#

Upload a file to a 0x0 instance.

Parameters:
  • file (bytes) – the bytes content of the file to upload

  • secret (bool) – sets the secret flag for 0x0 which makes the path of the returned url longer and more unguessable

Raises:

HTTPError

Returns:

url is the returned content, which should be the url. expires is the X-Expires header which returns the expiration time of the file submitted or no-expires, when the header did not exist token is the X-Token header with this token you are able to delete the file later on or no-token when the header did not exist which usually means that a file with the same content was already uploaded

Return type:

dict

nptr_cli.nptr.argparse_directory(dir)[source]#
nptr_cli.nptr.raise_for_status(response: Response)[source]#

A wrapper for the raise_for_status() method.

Also prints the response body, to better understand the error.

Parameters:

response (requests.Response) – response to raise status for.

nptr_cli.nptr.run()[source]#

Module contents#