1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

Added configuration file.

The "default_content_type" option can be set to "form".

Closes #91.
This commit is contained in:
Jakub Roztocil
2012-09-17 00:37:36 +02:00
parent 478d654945
commit 4029dbf309
6 changed files with 102 additions and 46 deletions

View File

@@ -2,6 +2,8 @@ import os
import sys
from requests.compat import urlparse, is_windows, bytes, str
from .config import DEFAULT_CONFIG_DIR, Config
class Environment(object):
"""Holds information about the execution context.
@@ -22,6 +24,8 @@ class Environment(object):
stdin = sys.stdin
stdout_isatty = sys.stdout.isatty()
config_dir = DEFAULT_CONFIG_DIR
if stdout_isatty and is_windows:
from colorama.initialise import wrap_stream
stdout = wrap_stream(sys.stdout, convert=None,
@@ -38,6 +42,17 @@ class Environment(object):
for attr in kwargs.keys())
self.__dict__.update(**kwargs)
@property
def config(self):
if not hasattr(self, '_config'):
self._config = Config()
self._config.directory = self.config_dir
if self._config.is_new:
self._config.save()
else:
self._config.load()
return self._config
class HTTPMessage(object):
"""Abstract class for HTTP messages."""