linode-cli 5.48.4__tar.gz → 5.49.0__tar.gz

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 (58) hide show
  1. linode_cli-5.49.0/MANIFEST.in +2 -0
  2. {linode_cli-5.48.4/linode_cli.egg-info → linode_cli-5.49.0}/PKG-INFO +16 -7
  3. {linode_cli-5.48.4 → linode_cli-5.49.0/linode_cli.egg-info}/PKG-INFO +16 -7
  4. {linode_cli-5.48.4 → linode_cli-5.49.0}/linode_cli.egg-info/SOURCES.txt +5 -3
  5. linode_cli-5.49.0/linode_cli.egg-info/requires.txt +22 -0
  6. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/__init__.py +7 -16
  7. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/arg_helpers.py +8 -183
  8. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/baked/colors.py +22 -12
  9. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/baked/operation.py +121 -18
  10. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/baked/request.py +24 -3
  11. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/completion.py +0 -13
  12. linode_cli-5.49.0/linodecli/configuration/__init__.py +23 -0
  13. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/configuration/auth.py +118 -28
  14. linode_cli-5.48.4/linodecli/configuration/__init__.py → linode_cli-5.49.0/linodecli/configuration/config.py +150 -27
  15. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/configuration/helpers.py +73 -87
  16. linode_cli-5.49.0/linodecli/data-3 +0 -0
  17. linode_cli-5.49.0/linodecli/help_pages.py +307 -0
  18. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/helpers.py +10 -24
  19. linode_cli-5.49.0/linodecli/plugins/__init__.py +5 -0
  20. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/metadata.py +10 -4
  21. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/obj/__init__.py +2 -175
  22. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/obj/helpers.py +17 -0
  23. linode_cli-5.49.0/linodecli/plugins/obj/list.py +168 -0
  24. linode_cli-5.48.4/linodecli/plugins/__init__.py → linode_cli-5.49.0/linodecli/plugins/plugins.py +80 -34
  25. linode_cli-5.49.0/linodecli/version.py +5 -0
  26. linode_cli-5.49.0/pyproject.toml +65 -0
  27. linode_cli-5.49.0/setup.py +3 -0
  28. linode_cli-5.48.4/MANIFEST.in +0 -5
  29. linode_cli-5.48.4/baked_version +0 -1
  30. linode_cli-5.48.4/linode-cli.sh +0 -137
  31. linode_cli-5.48.4/linode_cli.egg-info/requires.txt +0 -10
  32. linode_cli-5.48.4/linodecli/data-3 +0 -0
  33. linode_cli-5.48.4/pyproject.toml +0 -20
  34. linode_cli-5.48.4/requirements.txt +0 -7
  35. linode_cli-5.48.4/setup.py +0 -105
  36. {linode_cli-5.48.4 → linode_cli-5.49.0}/LICENSE +0 -0
  37. {linode_cli-5.48.4 → linode_cli-5.49.0}/README.md +0 -0
  38. {linode_cli-5.48.4 → linode_cli-5.49.0}/linode_cli.egg-info/dependency_links.txt +0 -0
  39. {linode_cli-5.48.4 → linode_cli-5.49.0}/linode_cli.egg-info/entry_points.txt +0 -0
  40. {linode_cli-5.48.4 → linode_cli-5.49.0}/linode_cli.egg-info/top_level.txt +0 -0
  41. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/__main__.py +0 -0
  42. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/api_request.py +0 -0
  43. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/baked/__init__.py +0 -0
  44. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/baked/response.py +0 -0
  45. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/cli.py +0 -0
  46. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/oauth-landing-page.html +0 -0
  47. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/output.py +0 -0
  48. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/overrides.py +0 -0
  49. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/firewall-editor.py +0 -0
  50. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/get-kubeconfig.py +0 -0
  51. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/image-upload.py +0 -0
  52. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/obj/buckets.py +0 -0
  53. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/obj/config.py +0 -0
  54. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/obj/objects.py +0 -0
  55. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/obj/website.py +0 -0
  56. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/region-table.py +0 -0
  57. {linode_cli-5.48.4 → linode_cli-5.49.0}/linodecli/plugins/ssh.py +0 -0
  58. {linode_cli-5.48.4 → linode_cli-5.49.0}/setup.cfg +0 -0
@@ -0,0 +1,2 @@
1
+ include linodecli/data-3
2
+ include linodecli/oauth-landing-page.html
@@ -1,11 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linode-cli
3
- Version: 5.48.4
4
- Summary: CLI for the Linode API
5
- Home-page: https://www.linode.com/docs/api/
6
- Author: Linode
7
- Author-email: developers@linode.com
8
- License: BSD 3-Clause License
3
+ Version: 5.49.0
4
+ Summary: The official command-line interface for interacting with the Linode API.
5
+ Author-email: "Akamai Technologies Inc." <developers@linode.com>
6
+ License: BSD-3-Clause
9
7
  Requires-Python: >=3.8
10
8
  Description-Content-Type: text/markdown
11
9
  License-File: LICENSE
@@ -15,9 +13,20 @@ Requires-Dist: PyYAML
15
13
  Requires-Dist: packaging
16
14
  Requires-Dist: rich
17
15
  Requires-Dist: urllib3<3
18
- Requires-Dist: linode-metadata
16
+ Requires-Dist: linode-metadata>=0.3.0
19
17
  Provides-Extra: obj
20
18
  Requires-Dist: boto3; extra == "obj"
19
+ Provides-Extra: dev
20
+ Requires-Dist: pylint>=2.17.4; extra == "dev"
21
+ Requires-Dist: pytest>=7.3.1; extra == "dev"
22
+ Requires-Dist: black>=23.1.0; extra == "dev"
23
+ Requires-Dist: isort>=5.12.0; extra == "dev"
24
+ Requires-Dist: autoflake>=2.0.1; extra == "dev"
25
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
26
+ Requires-Dist: requests-mock==1.12.1; extra == "dev"
27
+ Requires-Dist: boto3-stubs[s3]; extra == "dev"
28
+ Requires-Dist: build>=0.10.0; extra == "dev"
29
+ Requires-Dist: twine>=4.0.2; extra == "dev"
21
30
 
22
31
  # linode-cli (lin)
23
32
 
@@ -1,11 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linode-cli
3
- Version: 5.48.4
4
- Summary: CLI for the Linode API
5
- Home-page: https://www.linode.com/docs/api/
6
- Author: Linode
7
- Author-email: developers@linode.com
8
- License: BSD 3-Clause License
3
+ Version: 5.49.0
4
+ Summary: The official command-line interface for interacting with the Linode API.
5
+ Author-email: "Akamai Technologies Inc." <developers@linode.com>
6
+ License: BSD-3-Clause
9
7
  Requires-Python: >=3.8
10
8
  Description-Content-Type: text/markdown
11
9
  License-File: LICENSE
@@ -15,9 +13,20 @@ Requires-Dist: PyYAML
15
13
  Requires-Dist: packaging
16
14
  Requires-Dist: rich
17
15
  Requires-Dist: urllib3<3
18
- Requires-Dist: linode-metadata
16
+ Requires-Dist: linode-metadata>=0.3.0
19
17
  Provides-Extra: obj
20
18
  Requires-Dist: boto3; extra == "obj"
19
+ Provides-Extra: dev
20
+ Requires-Dist: pylint>=2.17.4; extra == "dev"
21
+ Requires-Dist: pytest>=7.3.1; extra == "dev"
22
+ Requires-Dist: black>=23.1.0; extra == "dev"
23
+ Requires-Dist: isort>=5.12.0; extra == "dev"
24
+ Requires-Dist: autoflake>=2.0.1; extra == "dev"
25
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
26
+ Requires-Dist: requests-mock==1.12.1; extra == "dev"
27
+ Requires-Dist: boto3-stubs[s3]; extra == "dev"
28
+ Requires-Dist: build>=0.10.0; extra == "dev"
29
+ Requires-Dist: twine>=4.0.2; extra == "dev"
21
30
 
22
31
  # linode-cli (lin)
23
32
 
@@ -1,10 +1,7 @@
1
1
  LICENSE
2
2
  MANIFEST.in
3
3
  README.md
4
- baked_version
5
- linode-cli.sh
6
4
  pyproject.toml
7
- requirements.txt
8
5
  setup.py
9
6
  linode_cli.egg-info/PKG-INFO
10
7
  linode_cli.egg-info/SOURCES.txt
@@ -19,10 +16,12 @@ linodecli/arg_helpers.py
19
16
  linodecli/cli.py
20
17
  linodecli/completion.py
21
18
  linodecli/data-3
19
+ linodecli/help_pages.py
22
20
  linodecli/helpers.py
23
21
  linodecli/oauth-landing-page.html
24
22
  linodecli/output.py
25
23
  linodecli/overrides.py
24
+ linodecli/version.py
26
25
  linodecli/baked/__init__.py
27
26
  linodecli/baked/colors.py
28
27
  linodecli/baked/operation.py
@@ -30,17 +29,20 @@ linodecli/baked/request.py
30
29
  linodecli/baked/response.py
31
30
  linodecli/configuration/__init__.py
32
31
  linodecli/configuration/auth.py
32
+ linodecli/configuration/config.py
33
33
  linodecli/configuration/helpers.py
34
34
  linodecli/plugins/__init__.py
35
35
  linodecli/plugins/firewall-editor.py
36
36
  linodecli/plugins/get-kubeconfig.py
37
37
  linodecli/plugins/image-upload.py
38
38
  linodecli/plugins/metadata.py
39
+ linodecli/plugins/plugins.py
39
40
  linodecli/plugins/region-table.py
40
41
  linodecli/plugins/ssh.py
41
42
  linodecli/plugins/obj/__init__.py
42
43
  linodecli/plugins/obj/buckets.py
43
44
  linodecli/plugins/obj/config.py
44
45
  linodecli/plugins/obj/helpers.py
46
+ linodecli/plugins/obj/list.py
45
47
  linodecli/plugins/obj/objects.py
46
48
  linodecli/plugins/obj/website.py
@@ -0,0 +1,22 @@
1
+ openapi3
2
+ requests
3
+ PyYAML
4
+ packaging
5
+ rich
6
+ urllib3<3
7
+ linode-metadata>=0.3.0
8
+
9
+ [dev]
10
+ pylint>=2.17.4
11
+ pytest>=7.3.1
12
+ black>=23.1.0
13
+ isort>=5.12.0
14
+ autoflake>=2.0.1
15
+ pytest-mock>=3.10.0
16
+ requests-mock==1.12.1
17
+ boto3-stubs[s3]
18
+ build>=0.10.0
19
+ twine>=4.0.2
20
+
21
+ [obj]
22
+ boto3
@@ -15,24 +15,20 @@ from rich.table import Table
15
15
  from linodecli import plugins
16
16
 
17
17
  from .arg_helpers import (
18
- action_help,
19
18
  bake_command,
20
- help_with_ops,
21
19
  register_args,
22
20
  register_plugin,
23
21
  remove_plugin,
24
22
  )
25
23
  from .cli import CLI
26
- from .completion import bake_completions, get_completions
24
+ from .completion import get_completions
27
25
  from .configuration import ENV_TOKEN_NAME
26
+ from .help_pages import print_help_action, print_help_default
28
27
  from .helpers import handle_url_overrides
29
28
  from .output import OutputMode
29
+ from .version import __version__
30
30
 
31
- # this might not be installed at the time of building
32
- try:
33
- VERSION = version("linode-cli")
34
- except:
35
- VERSION = "building"
31
+ VERSION = __version__
36
32
 
37
33
  BASE_URL = "https://api.linode.com/v4"
38
34
 
@@ -113,7 +109,7 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
113
109
  if not parsed.command:
114
110
  # print version info and exit - but only if no command was given
115
111
  print(f"linode-cli {VERSION}")
116
- print(f"Built off spec version {cli.spec_version}")
112
+ print(f"Built from spec version {cli.spec_version}")
117
113
  sys.exit(0)
118
114
  else:
119
115
  # something else might want to parse version
@@ -155,7 +151,7 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
155
151
  # handle a help for the CLI
156
152
  if parsed.command is None or (parsed.command is None and parsed.help):
157
153
  parser.print_help()
158
- help_with_ops(cli.ops, cli.config)
154
+ print_help_default(cli.ops, cli.config)
159
155
  sys.exit(0)
160
156
 
161
157
  # configure
@@ -209,11 +205,6 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
209
205
  cli.config.remove_user(parsed.action)
210
206
  sys.exit(0)
211
207
 
212
- # special command to bake shell completion script
213
- if parsed.command == "bake-bash":
214
- bake_completions(cli.ops)
215
- sys.exit(0)
216
-
217
208
  # check for plugin invocation
218
209
  if parsed.command not in cli.ops and parsed.command in plugins.available(
219
210
  cli.config
@@ -257,6 +248,6 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
257
248
 
258
249
  if parsed.command is not None and parsed.action is not None:
259
250
  if parsed.help:
260
- action_help(cli, parsed.command, parsed.action)
251
+ print_help_action(cli, parsed.command, parsed.action)
261
252
  sys.exit(0)
262
253
  cli.handle_command(parsed.command, parsed.action, args)
@@ -5,19 +5,17 @@ Argument parser for the linode CLI
5
5
 
6
6
  import os
7
7
  import sys
8
- import textwrap
9
8
  from importlib import import_module
10
9
 
11
10
  import requests
12
11
  import yaml
13
- from rich import box
14
- from rich import print as rprint
15
- from rich.table import Table
16
12
 
17
13
  from linodecli import plugins
18
-
19
- from .completion import bake_completions
20
- from .helpers import pagination_args_shared, register_args_shared
14
+ from linodecli.helpers import (
15
+ pagination_args_shared,
16
+ register_args_shared,
17
+ register_debug_arg,
18
+ )
21
19
 
22
20
 
23
21
  def register_args(parser):
@@ -141,12 +139,10 @@ def register_args(parser):
141
139
  action="store_true",
142
140
  help="Prints version information and exits.",
143
141
  )
144
- parser.add_argument(
145
- "--debug", action="store_true", help="Enable verbose HTTP debug output."
146
- )
147
142
 
148
143
  pagination_args_shared(parser)
149
144
  register_args_shared(parser)
145
+ register_debug_arg(parser)
150
146
 
151
147
  return parser
152
148
 
@@ -180,7 +176,7 @@ def register_plugin(module, config, ops):
180
176
  msg = "Plugin name conflicts with CLI operation - registration failed."
181
177
  return msg, 12
182
178
 
183
- if plugin_name in plugins.available_local:
179
+ if plugin_name in plugins.AVAILABLE_LOCAL:
184
180
  msg = "Plugin name conflicts with internal CLI plugin - registration failed."
185
181
  return msg, 13
186
182
 
@@ -222,7 +218,7 @@ def remove_plugin(plugin_name, config):
222
218
  """
223
219
  Remove a plugin
224
220
  """
225
- if plugin_name in plugins.available_local:
221
+ if plugin_name in plugins.AVAILABLE_LOCAL:
226
222
  msg = f"{plugin_name} is bundled with the CLI and cannot be removed"
227
223
  return msg, 13
228
224
 
@@ -247,176 +243,6 @@ def remove_plugin(plugin_name, config):
247
243
  return f"Plugin {plugin_name} removed", 0
248
244
 
249
245
 
250
- # pylint: disable=too-many-locals
251
- def help_with_ops(ops, config):
252
- """
253
- Prints help output with options from the API spec
254
- """
255
-
256
- # Environment variables overrides
257
- print("\nEnvironment variables:")
258
- env_variables = {
259
- "LINODE_CLI_TOKEN": "A Linode Personal Access Token for the CLI to make requests with. "
260
- "If specified, the configuration step will be skipped.",
261
- "LINODE_CLI_CA": "The path to a custom Certificate Authority file to verify "
262
- "API requests against.",
263
- "LINODE_CLI_API_HOST": "Overrides the target host for API requests. "
264
- "(e.g. 'api.linode.com')",
265
- "LINODE_CLI_API_VERSION": "Overrides the target Linode API version for API requests. "
266
- "(e.g. 'v4beta')",
267
- "LINODE_CLI_API_SCHEME": "Overrides the target scheme used for API requests. "
268
- "(e.g. 'https')",
269
- }
270
-
271
- table = Table(show_header=True, header_style="", box=box.SQUARE)
272
- table.add_column("Name")
273
- table.add_column("Description")
274
-
275
- for k, v in env_variables.items():
276
- table.add_row(k, v)
277
-
278
- rprint(table)
279
-
280
- # commands to manage CLI users (don't call out to API)
281
- print("\nCLI user management commands:")
282
- um_commands = [["configure", "set-user", "show-users"], ["remove-user"]]
283
- table = Table(show_header=False)
284
- for cmd in um_commands:
285
- table.add_row(*cmd)
286
- rprint(table)
287
-
288
- # commands to manage plugins (don't call out to API)
289
- print("\nCLI Plugin management commands:")
290
- pm_commands = [["register-plugin", "remove-plugin"]]
291
- table = Table(show_header=False)
292
- for cmd in pm_commands:
293
- table.add_row(*cmd)
294
- rprint(table)
295
-
296
- # other CLI commands
297
- print("\nOther CLI commands:")
298
- other_commands = [["completion"]]
299
- table = Table(show_header=False)
300
- for cmd in other_commands:
301
- table.add_row(*cmd)
302
- rprint(table)
303
-
304
- # commands generated from the spec (call the API directly)
305
- print("\nAvailable commands:")
306
-
307
- content = list(sorted(ops.keys()))
308
- proc = []
309
- for i in range(0, len(content), 3):
310
- proc.append(content[i : i + 3])
311
- if content[i + 3 :]:
312
- proc.append(content[i + 3 :])
313
-
314
- table = Table(show_header=False)
315
- for cmd in proc:
316
- table.add_row(*cmd)
317
- rprint(table)
318
-
319
- # plugins registered to the CLI (do arbitrary things)
320
- if plugins.available(config):
321
- # only show this if there are any available plugins
322
- print("Available plugins:")
323
-
324
- plugin_content = list(plugins.available(config))
325
- plugin_proc = []
326
-
327
- for i in range(0, len(plugin_content), 3):
328
- plugin_proc.append(plugin_content[i : i + 3])
329
- if plugin_content[i + 3 :]:
330
- plugin_proc.append(plugin_content[i + 3 :])
331
-
332
- plugin_table = Table(show_header=False)
333
- for plugin in plugin_proc:
334
- plugin_table.add_row(*plugin)
335
- rprint(plugin_table)
336
-
337
- print("\nTo reconfigure, call `linode-cli configure`")
338
- print(
339
- "For comprehensive documentation,"
340
- "visit https://www.linode.com/docs/api/"
341
- )
342
-
343
-
344
- def action_help(cli, command, action): # pylint: disable=too-many-branches
345
- """
346
- Prints help relevant to the command and action
347
- """
348
- try:
349
- op = cli.find_operation(command, action)
350
- except ValueError:
351
- return
352
- print(f"linode-cli {command} {action}", end="")
353
-
354
- for param in op.params:
355
- pname = param.name.upper()
356
- print(f" [{pname}]", end="")
357
-
358
- print()
359
- print(op.summary)
360
-
361
- if op.docs_url:
362
- rprint(f"API Documentation: [link={op.docs_url}]{op.docs_url}[/link]")
363
-
364
- if len(op.samples) > 0:
365
- print()
366
- print(f"Example Usage{'s' if len(op.samples) > 1 else ''}: ")
367
-
368
- rprint(
369
- *[
370
- # Indent all samples for readability; strip and trailing newlines
371
- textwrap.indent(v.get("source").rstrip(), " ")
372
- for v in op.samples
373
- ],
374
- sep="\n\n",
375
- )
376
-
377
- print()
378
- if op.method == "get" and op.action == "list":
379
- filterable_attrs = [
380
- attr for attr in op.response_model.attrs if attr.filterable
381
- ]
382
-
383
- if filterable_attrs:
384
- print("You may filter results with:")
385
- for attr in filterable_attrs:
386
- print(f" --{attr.name}")
387
- print(
388
- "Additionally, you may order results using --order-by and --order."
389
- )
390
- return
391
- if op.args:
392
- print("Arguments:")
393
- for arg in sorted(op.args, key=lambda s: not s.required):
394
- if arg.read_only:
395
- continue
396
- is_required = (
397
- "(required) "
398
- if op.method in {"post", "put"} and arg.required
399
- else ""
400
- )
401
-
402
- extensions = []
403
-
404
- if arg.format == "json":
405
- extensions.append("JSON")
406
-
407
- if arg.nullable:
408
- extensions.append("nullable")
409
-
410
- if arg.is_parent:
411
- extensions.append("conflicts with children")
412
-
413
- suffix = (
414
- f" ({', '.join(extensions)})" if len(extensions) > 0 else ""
415
- )
416
-
417
- print(f" --{arg.path}: {is_required}{arg.description}{suffix}")
418
-
419
-
420
246
  def bake_command(cli, spec_loc):
421
247
  """
422
248
  Handle a bake command from args
@@ -436,4 +262,3 @@ def bake_command(cli, spec_loc):
436
262
  sys.exit(2)
437
263
 
438
264
  cli.bake(spec)
439
- bake_completions(cli.ops)
@@ -1,11 +1,22 @@
1
1
  """
2
- Applies shell color escapes for pretty printing
2
+ Applies shell color escapes for pretty printing.
3
3
  """
4
4
 
5
5
  import os
6
6
  import platform
7
7
 
8
+ CLEAR_COLOR = "\x1b[0m"
9
+ COLOR_CODE_MAP = {
10
+ "red": "\x1b[31m",
11
+ "green": "\x1b[32m",
12
+ "yellow": "\x1b[33m",
13
+ "black": "\x1b[30m",
14
+ "white": "\x1b[40m",
15
+ }
16
+
17
+
8
18
  DO_COLORS = True
19
+
9
20
  # !! Windows compatibility for ANSI color codes !!
10
21
  #
11
22
  # If we're running on windows, we need to run the "color" command to enable
@@ -30,21 +41,20 @@ if platform.system() == "Windows":
30
41
  DO_COLORS = False
31
42
 
32
43
 
33
- CLEAR_COLOR = "\x1b[0m"
34
- COLOR_CODE_MAP = {
35
- "red": "\x1b[31m",
36
- "green": "\x1b[32m",
37
- "yellow": "\x1b[33m",
38
- "black": "\x1b[30m",
39
- "white": "\x1b[40m",
40
- }
41
-
42
-
43
- def colorize_string(string, color):
44
+ def colorize_string(string: str, color: str) -> str:
44
45
  """
45
46
  Returns the requested string, wrapped in ANSI color codes to colorize it as
46
47
  requested. On platforms where colors are not supported, this just returns
47
48
  the string passed into it.
49
+
50
+ :param string: The content to colorize.
51
+ :type string: str
52
+ :param color: The color to colorize the string with.
53
+ (one of red, green, yellow, black, white)
54
+ :type color: str
55
+
56
+ :returns: The colorized string.
57
+ :rtype: string
48
58
  """
49
59
  if not DO_COLORS:
50
60
  return string