plain 0.13.1__py3-none-any.whl → 0.14.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. plain/cli/README.md +2 -2
  2. plain/cli/cli.py +7 -11
  3. plain/cli/packages.py +7 -3
  4. plain/cli/startup.py +2 -2
  5. plain/csrf/middleware.py +1 -0
  6. plain/exceptions.py +2 -1
  7. plain/forms/forms.py +5 -5
  8. plain/http/multipartparser.py +5 -5
  9. plain/http/request.py +5 -5
  10. plain/http/response.py +19 -14
  11. plain/internal/files/locks.py +1 -0
  12. plain/internal/files/move.py +1 -2
  13. plain/internal/files/uploadhandler.py +1 -0
  14. plain/internal/files/utils.py +3 -3
  15. plain/internal/handlers/base.py +3 -7
  16. plain/internal/handlers/exception.py +1 -3
  17. plain/internal/handlers/wsgi.py +1 -1
  18. plain/internal/middleware/slash.py +5 -8
  19. plain/packages/config.py +9 -15
  20. plain/packages/registry.py +12 -12
  21. plain/paginator.py +1 -2
  22. plain/preflight/messages.py +3 -10
  23. plain/preflight/registry.py +2 -2
  24. plain/preflight/urls.py +4 -4
  25. plain/runtime/global_settings.py +1 -0
  26. plain/runtime/user_settings.py +6 -6
  27. plain/signing.py +4 -4
  28. plain/test/client.py +22 -21
  29. plain/urls/base.py +1 -1
  30. plain/urls/conf.py +2 -1
  31. plain/urls/resolvers.py +20 -33
  32. plain/utils/cache.py +1 -0
  33. plain/utils/crypto.py +2 -1
  34. plain/utils/datastructures.py +2 -2
  35. plain/utils/dateformat.py +13 -12
  36. plain/utils/dateparse.py +1 -1
  37. plain/utils/decorators.py +1 -1
  38. plain/utils/html.py +7 -7
  39. plain/utils/http.py +8 -8
  40. plain/utils/ipv6.py +1 -1
  41. plain/utils/module_loading.py +2 -2
  42. plain/utils/regex_helper.py +7 -6
  43. plain/utils/text.py +7 -7
  44. plain/utils/timesince.py +1 -1
  45. plain/utils/timezone.py +5 -5
  46. plain/validators.py +1 -3
  47. plain/views/forms.py +4 -4
  48. plain/views/objects.py +2 -2
  49. {plain-0.13.1.dist-info → plain-0.14.0.dist-info}/METADATA +7 -12
  50. {plain-0.13.1.dist-info → plain-0.14.0.dist-info}/RECORD +56 -57
  51. {plain-0.13.1.dist-info → plain-0.14.0.dist-info}/WHEEL +1 -1
  52. plain-0.14.0.dist-info/entry_points.txt +2 -0
  53. plain/utils/termcolors.py +0 -221
  54. plain-0.13.1.dist-info/entry_points.txt +0 -3
  55. {plain-0.13.1.dist-info → plain-0.14.0.dist-info/licenses}/LICENSE +0 -0
plain/utils/termcolors.py DELETED
@@ -1,221 +0,0 @@
1
- """
2
- termcolors.py
3
- """
4
-
5
- color_names = ("black", "red", "green", "yellow", "blue", "magenta", "cyan", "white")
6
- foreground = {color_names[x]: "3%s" % x for x in range(8)}
7
- background = {color_names[x]: "4%s" % x for x in range(8)}
8
-
9
- RESET = "0"
10
- opt_dict = {
11
- "bold": "1",
12
- "underscore": "4",
13
- "blink": "5",
14
- "reverse": "7",
15
- "conceal": "8",
16
- }
17
-
18
-
19
- def colorize(text="", opts=(), **kwargs):
20
- """
21
- Return your text, enclosed in ANSI graphics codes.
22
-
23
- Depends on the keyword arguments 'fg' and 'bg', and the contents of
24
- the opts tuple/list.
25
-
26
- Return the RESET code if no parameters are given.
27
-
28
- Valid colors:
29
- 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
30
-
31
- Valid options:
32
- 'bold'
33
- 'underscore'
34
- 'blink'
35
- 'reverse'
36
- 'conceal'
37
- 'noreset' - string will not be auto-terminated with the RESET code
38
-
39
- Examples:
40
- colorize('hello', fg='red', bg='blue', opts=('blink',))
41
- colorize()
42
- colorize('goodbye', opts=('underscore',))
43
- print(colorize('first line', fg='red', opts=('noreset',)))
44
- print('this should be red too')
45
- print(colorize('and so should this'))
46
- print('this should not be red')
47
- """
48
- code_list = []
49
- if text == "" and len(opts) == 1 and opts[0] == "reset":
50
- return "\x1b[%sm" % RESET
51
- for k, v in kwargs.items():
52
- if k == "fg":
53
- code_list.append(foreground[v])
54
- elif k == "bg":
55
- code_list.append(background[v])
56
- for o in opts:
57
- if o in opt_dict:
58
- code_list.append(opt_dict[o])
59
- if "noreset" not in opts:
60
- text = "{}\x1b[{}m".format(text or "", RESET)
61
- return "{}{}".format(("\x1b[%sm" % ";".join(code_list)), text or "")
62
-
63
-
64
- def make_style(opts=(), **kwargs):
65
- """
66
- Return a function with default parameters for colorize()
67
-
68
- Example:
69
- bold_red = make_style(opts=('bold',), fg='red')
70
- print(bold_red('hello'))
71
- KEYWORD = make_style(fg='yellow')
72
- COMMENT = make_style(fg='blue', opts=('bold',))
73
- """
74
- return lambda text: colorize(text, opts, **kwargs)
75
-
76
-
77
- NOCOLOR_PALETTE = "nocolor"
78
- DARK_PALETTE = "dark"
79
- LIGHT_PALETTE = "light"
80
-
81
- PALETTES = {
82
- NOCOLOR_PALETTE: {
83
- "ERROR": {},
84
- "SUCCESS": {},
85
- "WARNING": {},
86
- "NOTICE": {},
87
- "SQL_FIELD": {},
88
- "SQL_COLTYPE": {},
89
- "SQL_KEYWORD": {},
90
- "SQL_TABLE": {},
91
- "HTTP_INFO": {},
92
- "HTTP_SUCCESS": {},
93
- "HTTP_REDIRECT": {},
94
- "HTTP_NOT_MODIFIED": {},
95
- "HTTP_BAD_REQUEST": {},
96
- "HTTP_NOT_FOUND": {},
97
- "HTTP_SERVER_ERROR": {},
98
- "MIGRATE_HEADING": {},
99
- "MIGRATE_LABEL": {},
100
- },
101
- DARK_PALETTE: {
102
- "ERROR": {"fg": "red", "opts": ("bold",)},
103
- "SUCCESS": {"fg": "green", "opts": ("bold",)},
104
- "WARNING": {"fg": "yellow", "opts": ("bold",)},
105
- "NOTICE": {"fg": "red"},
106
- "SQL_FIELD": {"fg": "green", "opts": ("bold",)},
107
- "SQL_COLTYPE": {"fg": "green"},
108
- "SQL_KEYWORD": {"fg": "yellow"},
109
- "SQL_TABLE": {"opts": ("bold",)},
110
- "HTTP_INFO": {"opts": ("bold",)},
111
- "HTTP_SUCCESS": {},
112
- "HTTP_REDIRECT": {"fg": "green"},
113
- "HTTP_NOT_MODIFIED": {"fg": "cyan"},
114
- "HTTP_BAD_REQUEST": {"fg": "red", "opts": ("bold",)},
115
- "HTTP_NOT_FOUND": {"fg": "yellow"},
116
- "HTTP_SERVER_ERROR": {"fg": "magenta", "opts": ("bold",)},
117
- "MIGRATE_HEADING": {"fg": "cyan", "opts": ("bold",)},
118
- "MIGRATE_LABEL": {"opts": ("bold",)},
119
- },
120
- LIGHT_PALETTE: {
121
- "ERROR": {"fg": "red", "opts": ("bold",)},
122
- "SUCCESS": {"fg": "green", "opts": ("bold",)},
123
- "WARNING": {"fg": "yellow", "opts": ("bold",)},
124
- "NOTICE": {"fg": "red"},
125
- "SQL_FIELD": {"fg": "green", "opts": ("bold",)},
126
- "SQL_COLTYPE": {"fg": "green"},
127
- "SQL_KEYWORD": {"fg": "blue"},
128
- "SQL_TABLE": {"opts": ("bold",)},
129
- "HTTP_INFO": {"opts": ("bold",)},
130
- "HTTP_SUCCESS": {},
131
- "HTTP_REDIRECT": {"fg": "green", "opts": ("bold",)},
132
- "HTTP_NOT_MODIFIED": {"fg": "green"},
133
- "HTTP_BAD_REQUEST": {"fg": "red", "opts": ("bold",)},
134
- "HTTP_NOT_FOUND": {"fg": "red"},
135
- "HTTP_SERVER_ERROR": {"fg": "magenta", "opts": ("bold",)},
136
- "MIGRATE_HEADING": {"fg": "cyan", "opts": ("bold",)},
137
- "MIGRATE_LABEL": {"opts": ("bold",)},
138
- },
139
- }
140
- DEFAULT_PALETTE = DARK_PALETTE
141
-
142
-
143
- def parse_color_setting(config_string):
144
- """Parse a DJANGO_COLORS environment variable to produce the system palette
145
-
146
- The general form of a palette definition is:
147
-
148
- "palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option"
149
-
150
- where:
151
- palette is a named palette; one of 'light', 'dark', or 'nocolor'.
152
- role is a named style used by Django
153
- fg is a foreground color.
154
- bg is a background color.
155
- option is a display options.
156
-
157
- Specifying a named palette is the same as manually specifying the individual
158
- definitions for each role. Any individual definitions following the palette
159
- definition will augment the base palette definition.
160
-
161
- Valid roles:
162
- 'error', 'success', 'warning', 'notice', 'sql_field', 'sql_coltype',
163
- 'sql_keyword', 'sql_table', 'http_info', 'http_success',
164
- 'http_redirect', 'http_not_modified', 'http_bad_request',
165
- 'http_not_found', 'http_server_error', 'migrate_heading',
166
- 'migrate_label'
167
-
168
- Valid colors:
169
- 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
170
-
171
- Valid options:
172
- 'bold', 'underscore', 'blink', 'reverse', 'conceal', 'noreset'
173
- """
174
- if not config_string:
175
- return PALETTES[DEFAULT_PALETTE]
176
-
177
- # Split the color configuration into parts
178
- parts = config_string.lower().split(";")
179
- palette = PALETTES[NOCOLOR_PALETTE].copy()
180
- for part in parts:
181
- if part in PALETTES:
182
- # A default palette has been specified
183
- palette.update(PALETTES[part])
184
- elif "=" in part:
185
- # Process a palette defining string
186
- definition = {}
187
-
188
- # Break the definition into the role,
189
- # plus the list of specific instructions.
190
- # The role must be in upper case
191
- role, instructions = part.split("=")
192
- role = role.upper()
193
-
194
- styles = instructions.split(",")
195
- styles.reverse()
196
-
197
- # The first instruction can contain a slash
198
- # to break apart fg/bg.
199
- colors = styles.pop().split("/")
200
- colors.reverse()
201
- fg = colors.pop()
202
- if fg in color_names:
203
- definition["fg"] = fg
204
- if colors and colors[-1] in color_names:
205
- definition["bg"] = colors[-1]
206
-
207
- # All remaining instructions are options
208
- opts = tuple(s for s in styles if s in opt_dict)
209
- if opts:
210
- definition["opts"] = opts
211
-
212
- # The nocolor palette has all available roles.
213
- # Use that palette as the basis for determining
214
- # if the role is valid.
215
- if role in PALETTES[NOCOLOR_PALETTE] and definition:
216
- palette[role] = definition
217
-
218
- # If there are no colors specified, return the empty palette.
219
- if palette == PALETTES[NOCOLOR_PALETTE]:
220
- return None
221
- return palette
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- plain=plain.cli:cli
3
-