summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--http_prompt/cli.py12
-rw-r--r--http_prompt/context/__init__.py20
-rw-r--r--http_prompt/context/transform.py4
-rw-r--r--http_prompt/execution.py4
-rw-r--r--http_prompt/lexer.py5
5 files changed, 21 insertions, 24 deletions
diff --git a/http_prompt/cli.py b/http_prompt/cli.py
index 3b025fb..0f16f46 100644
--- a/http_prompt/cli.py
+++ b/http_prompt/cli.py
@@ -63,7 +63,7 @@ class ExecutionListener(object):
cookie_pref = self.cfg.get('set_cookies') or 'auto'
if cookie_pref == 'auto' or (
cookie_pref == 'ask' and
- click.confirm("Cookies incoming! Do you want to set them?")):
+ click.confirm('Cookies incoming! Do you want to set them?')):
existing_cookie = context.headers.get('Cookie')
new_cookie = update_cookies(existing_cookie, response.cookies)
context.headers['Cookie'] = new_cookie
@@ -78,12 +78,10 @@ def normalize_url(ctx, param, value):
return None
-@click.command(context_settings=dict(
- ignore_unknown_options=True,
-))
-@click.option('--spec', help="OpenAPI/Swagger specification file.",
+@click.command(context_settings={'ignore_unknown_options': True})
+@click.option('--spec', help='OpenAPI/Swagger specification file.',
callback=normalize_url)
-@click.option('--env', help="Environment file to preload.",
+@click.option('--env', help='Environment file to preload.',
type=click.Path(exists=True))
@click.argument('url', default='')
@click.argument('http_options', nargs=-1, type=click.UNPROCESSED)
@@ -168,4 +166,4 @@ def cli(spec, env, url, http_options):
if context.should_exit:
break
- click.echo("Goodbye!")
+ click.echo('Goodbye!')
diff --git a/http_prompt/context/__init__.py b/http_prompt/context/__init__.py
index bb7c87f..5198759 100644
--- a/http_prompt/context/__init__.py
+++ b/http_prompt/context/__init__.py
@@ -47,22 +47,20 @@ class Context(object):
params = info.get('parameters', [])
params = list(global_parameters + params)
if params:
- parameter_key = lambda i: (
- i.get('$ref', None),
- i.get('name', None),
- i.get('in', None)
+ def parameter_key(i): return (
+ i.get('$ref', None),
+ i.get('name', None),
+ i.get('in', None)
)
# parameter is overriden based on $ref/in/name value
# last value (local definition) takes precedence
- params_map = dict([
- (parameter_key(p), p)
- for p in params
- ])
+ params_map = {parameter_key(p): p for p in params}
params = params_map.values()
for param in params:
- if param.get("$ref"):
- for section in param.get("$ref").split('/'):
- param = param.get(section) if not section == "#" else spec
+ if param.get('$ref'):
+ for section in param.get('$ref').split('/'):
+ param = param.get(
+ section) if not section == '#' else spec
if param.get('in') != 'path':
# Note that for completion mechanism, only
diff --git a/http_prompt/context/transform.py b/http_prompt/context/transform.py
index ed13a7f..593a211 100644
--- a/http_prompt/context/transform.py
+++ b/http_prompt/context/transform.py
@@ -82,12 +82,12 @@ def extract_args_for_httpie_main(context, method=None):
def format_to_curl(context, method=None):
"""Format a Context object to a cURL command."""
- raise NotImplementedError("curl format is not supported yet")
+ raise NotImplementedError('curl format is not supported yet')
def format_to_raw(context, method=None):
"""Format a Context object to HTTP raw text."""
- raise NotImplementedError("raw format is not supported yet")
+ raise NotImplementedError('raw format is not supported yet')
def format_to_httpie(context, method=None):
diff --git a/http_prompt/execution.py b/http_prompt/execution.py
index f7994c9..5417f86 100644
--- a/http_prompt/execution.py
+++ b/http_prompt/execution.py
@@ -241,7 +241,7 @@ class ExecutionVisitor(NodeVisitor):
if isinstance(path, Node):
seg = urlparse(self.context_override.url)
- self.context_override.url = seg.scheme + "://" + seg.netloc
+ self.context_override.url = seg.scheme + '://' + seg.netloc
else:
self.context_override.url = urljoin2(
self.context_override.url, path)
@@ -408,7 +408,7 @@ class ExecutionVisitor(NodeVisitor):
return self._mutate(node, key, op, val)
def _visit_mut_key_or_val(self, node, children):
- return unescape(''.join([c for c in children]), exclude=':=')
+ return unescape(''.join(children), exclude=':=')
visit_unquoted_mutkey = _visit_mut_key_or_val
visit_unquoted_mutval = _visit_mut_key_or_val
diff --git a/http_prompt/lexer.py b/http_prompt/lexer.py
index af8392b..9f64829 100644
--- a/http_prompt/lexer.py
+++ b/http_prompt/lexer.py
@@ -12,7 +12,8 @@ __all__ = ['HttpPromptLexer']
FLAG_OPTIONS = [name for name, _ in opt.FLAG_OPTIONS]
VALUE_OPTIONS = [name for name, _ in opt.VALUE_OPTIONS]
-HTTP_METHODS = ('get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'connect')
+HTTP_METHODS = ('get', 'head', 'post', 'put', 'patch',
+ 'delete', 'options', 'connect')
def string_rules(state):
@@ -46,7 +47,7 @@ class HttpPromptLexer(RegexLexer):
(words(HTTP_METHODS, prefix='(?i)', suffix=r'(?!\S)(\s*)'),
bygroups(Keyword, Text), combined('redir_out', 'urlpath')),
-
+
(r'(clear)(\s*)', bygroups(Keyword, Text), 'end'),
(r'(exit)(\s*)', bygroups(Keyword, Text), 'end'),
(r'(help)(\s)*', bygroups(Keyword, Text), 'end'),