Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
models.py45 linesDownload Raw Back to output
1import argparse2from typing import Any, Dict, Union, List, NamedTuple, Optional3 4from httpie.context import Environment5from httpie.cli.constants import PrettyOptions, PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY6from httpie.cli.argtypes import PARSED_DEFAULT_FORMAT_OPTIONS7from httpie.output.formatters.colors import AUTO_STYLE8 9 10class ProcessingOptions(NamedTuple):11    """Represents a set of stylistic options12    that are used when deciding which stream13    should be used."""14 15    debug: bool = False16    traceback: bool = False17 18    stream: bool = False19    style: str = AUTO_STYLE20    prettify: Union[List[str], PrettyOptions] = PRETTY_STDOUT_TTY_ONLY21 22    response_mime: Optional[str] = None23    response_charset: Optional[str] = None24 25    json: bool = False26    format_options: Dict[str, Any] = PARSED_DEFAULT_FORMAT_OPTIONS27 28    def get_prettify(self, env: Environment) -> List[str]:29        if self.prettify is PRETTY_STDOUT_TTY_ONLY:30            return PRETTY_MAP['all' if env.stdout_isatty else 'none']31        else:32            return self.prettify33 34    @classmethod35    def from_raw_args(cls, options: argparse.Namespace) -> 'ProcessingOptions':36        fetched_options = {37            option: getattr(options, option)38            for option in cls._fields39        }40        return cls(**fetched_options)41 42    @property43    def show_traceback(self):44        return self.debug or self.traceback45 
codekingpro/portable-devtools · Team Ai