Skip to content
Myr

Implemented UNPROCESSED type.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent f1249f8 · Browse files · 3 files+28 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+28 added−2 removed

  • other:+28 added−2 removed

3 files+28 added−2 removed

modified:click/__init__.py+2 added-2 removed
23 unmodified lines
24 password_option, version_option, help_option2526# Types27from .types import ParamType, File, Path, Choice, IntRange, STRING, INT, \28 FLOAT, BOOL, UUID28 FLOAT, BOOL, UUID, UNPROCESSED2930# Utilities31from .utils import echo, get_binary_stream, get_text_stream, open_file, \32 format_filename, get_app_dir
25 unmodified lines
58 'version_option', 'help_option',5960 # Types61 'ParamType', 'File', 'Path', 'Choice', 'IntRange', 'STRING', 'INT',62 'FLOAT', 'BOOL', 'UUID',62 'FLOAT', 'BOOL', 'UUID', 'UNPROCESSED',6364 # Utilities65 'echo', 'get_binary_stream', 'get_text_stream', 'open_file',66 'format_filename', 'get_app_dir',
19 unmodified lines
modified:click/types.py+24 added
82 unmodified lines
83 value = str(value).decode('utf-8', 'replace')84 self.fail(value, param, ctx)858687class UnprocessedParamType(ParamType):88 name = 'text'8990 def convert(self, value, param, ctx):91 return value9293 def __repr__(self):94 return 'UNPROCESSED'959697class StringParamType(ParamType):98 name = 'text'99100 def convert(self, value, param, ctx):
339 unmodified lines
440 pass441 return FuncParamType(ty)442443444#: A dummy parameter type that just does nothing. From a user's445#: perspective this appears to just be the same as `STRING` but internally446#: no string conversion takes place. This is necessary to achieve the447#: same bytes/unicode behavior on Python 2/3 in situations where you want448#: to not convert argument types. This is usually useful when working449#: with file paths as they can appear in bytes and unicode.450#:451#: For path related uses the :class:`Path` type is a better choice but452#: there are situations where an unprocessed type is useful which is why453#: it is is provided.454#:455#: .. versionadded:: 4.0456UNPROCESSED = UnprocessedParamType()457458#: A unicode string parameter type which is the implicit default. This459#: can also be selected by using ``str`` as type.460STRING = StringParamType()461
14 unmodified lines
modified:CHANGES+2 added
10 unmodified lines
11- Added `color` parameters to lots of interfaces that directly or indirectly12 call into echoing. This previously was always autodetection (with the13 exception of the `echo_via_pager` function). Now you can forcefully14 enable or disable it, overriding the auto detection of Click.15- Added an `UNPROCESSED` type which does not perform any type changes which16 simplifies text handling on 2.x / 3.x in some special advanced usecases.1718Version 3.319-----------20
176 unmodified lines