mirror of
https://github.com/httpie/cli.git
synced 2024-11-24 08:22:22 +02:00
rename existing_file to readable_file_arg and move to input
This commit is contained in:
parent
b9d7220b10
commit
d4363a560d
@ -18,8 +18,8 @@ from .input import (Parser, AuthCredentialsArgType, KeyValueArgType,
|
||||
SEP_PROXY, SEP_CREDENTIALS, SEP_GROUP_ALL_ITEMS,
|
||||
OUT_REQ_HEAD, OUT_REQ_BODY, OUT_RESP_HEAD,
|
||||
OUT_RESP_BODY, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT,
|
||||
PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, SessionNameValidator)
|
||||
from .utils import existing_file
|
||||
PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, SessionNameValidator,
|
||||
readable_file_arg)
|
||||
|
||||
|
||||
class HTTPieHelpFormatter(RawDescriptionHelpFormatter):
|
||||
@ -469,7 +469,7 @@ network.add_argument(
|
||||
network.add_argument(
|
||||
'--ssl-cert',
|
||||
default=None,
|
||||
type=existing_file,
|
||||
type=readable_file_arg,
|
||||
help="""
|
||||
You can specify a local cert to use as client side SSL certificate.
|
||||
This file may either contain both private key and certificate or you may
|
||||
@ -481,7 +481,7 @@ network.add_argument(
|
||||
network.add_argument(
|
||||
'--ssl-key',
|
||||
default=None,
|
||||
type=existing_file,
|
||||
type=readable_file_arg,
|
||||
help="""
|
||||
The private key to use with SSL. Only needed if --ssl-cert is given and the
|
||||
certificate file does not contain the private key.
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Parsing and processing of CLI input (args, auth credentials, files, stdin).
|
||||
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
@ -630,3 +631,12 @@ def parse_items(items, data=None, headers=None, files=None, params=None):
|
||||
target[item.key] = value
|
||||
|
||||
return headers, data, files, params
|
||||
|
||||
|
||||
def readable_file_arg(filename):
|
||||
try:
|
||||
open(filename, 'rb')
|
||||
except IOError as ex:
|
||||
raise argparse.ArgumentTypeError(
|
||||
'%s: %s' % (filename, ex.args[1]))
|
||||
return filename
|
||||
|
@ -1,5 +1,4 @@
|
||||
from __future__ import division
|
||||
import argparse
|
||||
|
||||
|
||||
def humanize_bytes(n, precision=2):
|
||||
@ -46,11 +45,3 @@ def humanize_bytes(n, precision=2):
|
||||
|
||||
return '%.*f %s' % (precision, n / factor, suffix)
|
||||
|
||||
|
||||
def existing_file(filename):
|
||||
try:
|
||||
open(filename, 'rb')
|
||||
except IOError as ex:
|
||||
raise argparse.ArgumentTypeError(
|
||||
'%s: %s' % (filename, ex.args[1]))
|
||||
return filename
|
||||
|
Loading…
Reference in New Issue
Block a user