edq-utils 0.1.4__tar.gz → 0.1.5__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.

Potentially problematic release.


This version of edq-utils might be problematic. Click here for more details.

Files changed (105) hide show
  1. {edq_utils-0.1.4 → edq_utils-0.1.5}/PKG-INFO +1 -1
  2. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/__init__.py +1 -1
  3. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/net.py +27 -2
  4. edq_utils-0.1.5/edq/util/parse.py +33 -0
  5. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq_utils.egg-info/PKG-INFO +1 -1
  6. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq_utils.egg-info/SOURCES.txt +1 -0
  7. {edq_utils-0.1.4 → edq_utils-0.1.5}/.github/workflows/main.yml +0 -0
  8. {edq_utils-0.1.4 → edq_utils-0.1.5}/.gitignore +0 -0
  9. {edq_utils-0.1.4 → edq_utils-0.1.5}/.mypy.ini +0 -0
  10. {edq_utils-0.1.4 → edq_utils-0.1.5}/.pylintrc +0 -0
  11. {edq_utils-0.1.4 → edq_utils-0.1.5}/LICENSE +0 -0
  12. {edq_utils-0.1.4 → edq_utils-0.1.5}/README.md +0 -0
  13. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/__init__.py +0 -0
  14. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/config/__init__.py +0 -0
  15. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/config/list.py +0 -0
  16. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/http/__init__.py +0 -0
  17. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/http/exchange-server.py +0 -0
  18. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/http/send-exchange.py +0 -0
  19. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/http/verify-exchanges.py +0 -0
  20. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/testing/__init__.py +0 -0
  21. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/testing/cli-test.py +0 -0
  22. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/cli/version.py +0 -0
  23. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/core/__init__.py +0 -0
  24. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/core/argparser.py +0 -0
  25. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/core/argparser_test.py +0 -0
  26. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/core/config.py +0 -0
  27. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/core/config_test.py +0 -0
  28. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/core/log.py +0 -0
  29. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/core/version.py +0 -0
  30. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/procedure/__init__.py +0 -0
  31. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/procedure/verify_exchanges.py +0 -0
  32. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/py.typed +0 -0
  33. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/__init__.py +0 -0
  34. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/asserts.py +0 -0
  35. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/cli.py +0 -0
  36. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/cli_test.py +0 -0
  37. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/httpserver.py +0 -0
  38. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/httpserver_test.py +0 -0
  39. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/run.py +0 -0
  40. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/data/configs/empty/edq-config.json +0 -0
  41. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/data/configs/simple-1/edq-config.json +0 -0
  42. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/data/configs/simple-2/edq-config.json +0 -0
  43. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/data/configs/value-number/edq-config.json +0 -0
  44. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/config/list/config_list_base.txt +0 -0
  45. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/config/list/config_list_config_value_number.txt +0 -0
  46. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/config/list/config_list_ignore_config.txt +0 -0
  47. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/config/list/config_list_no_config.txt +0 -0
  48. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/config/list/config_list_show_origin.txt +0 -0
  49. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/config/list/config_list_skip_header.txt +0 -0
  50. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/help_base.txt +0 -0
  51. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/platform_skip.txt +0 -0
  52. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/cli/tests/version_base.txt +0 -0
  53. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple.httpex.json +0 -0
  54. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_anchor.httpex.json +0 -0
  55. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_file.httpex.json +0 -0
  56. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_file_binary.httpex.json +0 -0
  57. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_file_get_params.httpex.json +0 -0
  58. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_file_multiple.httpex.json +0 -0
  59. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_file_name.httpex.json +0 -0
  60. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_file_post_multiple.httpex.json +0 -0
  61. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_file_post_params.httpex.json +0 -0
  62. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_headers.httpex.json +0 -0
  63. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_jsonresponse_dict.httpex.json +0 -0
  64. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_jsonresponse_list.httpex.json +0 -0
  65. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_params.httpex.json +0 -0
  66. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_post.httpex.json +0 -0
  67. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_post_params.httpex.json +0 -0
  68. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_post_urlparams.httpex.json +0 -0
  69. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/simple_urlparams.httpex.json +0 -0
  70. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/specialcase_listparams_explicit.httpex.json +0 -0
  71. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/exchanges/specialcase_listparams_url.httpex.json +0 -0
  72. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/files/a.txt +0 -0
  73. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/testdata/http/files/tiny.png +0 -0
  74. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/testing/unittest.py +0 -0
  75. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/__init__.py +0 -0
  76. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/dirent.py +0 -0
  77. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/dirent_test.py +0 -0
  78. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/hash.py +0 -0
  79. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/hash_test.py +0 -0
  80. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/json.py +0 -0
  81. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/json_test.py +0 -0
  82. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/pyimport.py +0 -0
  83. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/pyimport_test.py +0 -0
  84. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/reflection.py +0 -0
  85. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/time.py +0 -0
  86. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq/util/time_test.py +0 -0
  87. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq_utils.egg-info/dependency_links.txt +0 -0
  88. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq_utils.egg-info/requires.txt +0 -0
  89. {edq_utils-0.1.4 → edq_utils-0.1.5}/edq_utils.egg-info/top_level.txt +0 -0
  90. {edq_utils-0.1.4 → edq_utils-0.1.5}/pyproject.toml +0 -0
  91. {edq_utils-0.1.4 → edq_utils-0.1.5}/requirements-dev.txt +0 -0
  92. {edq_utils-0.1.4 → edq_utils-0.1.5}/requirements.txt +0 -0
  93. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/build_site.sh +0 -0
  94. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/check_all.sh +0 -0
  95. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/check_lint.sh +0 -0
  96. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/check_python_version.sh +0 -0
  97. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/check_strict_types.sh +0 -0
  98. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/check_types.sh +0 -0
  99. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/gen_docs.sh +0 -0
  100. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/run_tests.sh +0 -0
  101. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/template/html/css/style.css +0 -0
  102. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/template/html/favicon.ico +0 -0
  103. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/template/html/images/favicon.png +0 -0
  104. {edq_utils-0.1.4 → edq_utils-0.1.5}/scripts/template/html/index.html +0 -0
  105. {edq_utils-0.1.4 → edq_utils-0.1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edq-utils
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Common utilities used by EduLinq Python projects.
5
5
  Author-email: Eriq Augustine <eriq@edulinq.org>
6
6
  License: MIT License
@@ -2,4 +2,4 @@
2
2
  General Python tools used by several EduLinq projects.
3
3
  """
4
4
 
5
- __version__ = '0.1.4'
5
+ __version__ = '0.1.5'
@@ -626,6 +626,22 @@ class HTTPExchange(edq.util.json.DictConverter):
626
626
 
627
627
  return HTTPExchange(**data)
628
628
 
629
+ @typing.runtime_checkable
630
+ class HTTPExchangeComplete(typing.Protocol):
631
+ """
632
+ A function that can be called after a request has been made (and exchange constructed).
633
+ """
634
+
635
+ def __call__(self,
636
+ exchange: HTTPExchange
637
+ ) -> str:
638
+ """
639
+ Called after an HTTP exchange has been completed.
640
+ """
641
+
642
+ _make_request_exchange_complete_func: typing.Union[HTTPExchangeComplete, None] = None # pylint: disable=invalid-name
643
+ """ If not None, call this func after make_request() has created its HTTPExchange. """
644
+
629
645
  def find_open_port(
630
646
  start_port: int = DEFAULT_START_PORT, end_port: int = DEFAULT_END_PORT,
631
647
  wait_time: float = DEFAULT_PORT_SEARCH_WAIT_SEC) -> int:
@@ -671,6 +687,7 @@ def make_request(method: str, url: str,
671
687
  http_exchange_extension: str = DEFAULT_HTTP_EXCHANGE_EXTENSION,
672
688
  add_http_prefix: bool = True,
673
689
  additional_requests_options: typing.Union[typing.Dict[str, typing.Any], None] = None,
690
+ exchange_complete_func: typing.Union[HTTPExchangeComplete, None] = None,
674
691
  **kwargs: typing.Any) -> typing.Tuple[requests.Response, str]:
675
692
  """
676
693
  Make an HTTP request and return the response object and text body.
@@ -713,7 +730,7 @@ def make_request(method: str, url: str,
713
730
  else:
714
731
  options['data'] = data
715
732
 
716
- logging.debug("Making %s request: '%s'.", method, url)
733
+ logging.debug("Making %s request: '%s' (options = %s).", method, url, options)
717
734
  response = requests.request(method, url, **options)
718
735
 
719
736
  body = response.text
@@ -726,9 +743,11 @@ def make_request(method: str, url: str,
726
743
 
727
744
  response.raise_for_status()
728
745
 
729
- if (output_dir is not None):
746
+ exchange = None
747
+ if ((output_dir is not None) or (exchange_complete_func is not None) or (_make_request_exchange_complete_func is not None)):
730
748
  exchange = HTTPExchange.from_response(response, headers_to_skip = headers_to_skip, params_to_skip = params_to_skip)
731
749
 
750
+ if ((output_dir is not None) and (exchange is not None)):
732
751
  path = os.path.abspath(os.path.join(output_dir, *exchange.get_url().split('/')))
733
752
 
734
753
  query = urllib.parse.urlencode(exchange.parameters)
@@ -744,6 +763,12 @@ def make_request(method: str, url: str,
744
763
  edq.util.dirent.mkdir(os.path.dirname(path))
745
764
  edq.util.json.dump_path(exchange, path, indent = 4, sort_keys = False)
746
765
 
766
+ if ((exchange_complete_func is not None) and (exchange is not None)):
767
+ exchange_complete_func(exchange)
768
+
769
+ if ((_make_request_exchange_complete_func is not None) and (exchange is not None)):
770
+ _make_request_exchange_complete_func(exchange) # pylint: disable=not-callable
771
+
747
772
  return response, body
748
773
 
749
774
  def make_get(url: str, **kwargs: typing.Any) -> typing.Tuple[requests.Response, str]:
@@ -0,0 +1,33 @@
1
+ import typing
2
+
3
+ BOOL_TRUE_STRINGS: typing.Set[str] = {
4
+ 'true', 't',
5
+ 'yes', 'y',
6
+ '1',
7
+ }
8
+
9
+ BOOL_FALSE_STRINGS: typing.Set[str] = {
10
+ 'false', 'f',
11
+ 'no', 'n',
12
+ '0',
13
+ }
14
+
15
+ def boolean(raw_text: typing.Union[str, bool]) -> bool:
16
+ """
17
+ Parse a boolean from a string using common string representations for true/false.
18
+ This function assumes the entire string is the boolean (not just a part of it).
19
+ If the string is not true or false, then raise an exception.
20
+ """
21
+
22
+ if (isinstance(raw_text, bool)):
23
+ return raw_text
24
+
25
+ text = str(raw_text).lower().strip()
26
+
27
+ if (text in BOOL_TRUE_STRINGS):
28
+ return True
29
+
30
+ if (text in BOOL_FALSE_STRINGS):
31
+ return False
32
+
33
+ raise ValueError(f"Could not convert text to boolean: '{raw_text}'.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edq-utils
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Common utilities used by EduLinq Python projects.
5
5
  Author-email: Eriq Augustine <eriq@edulinq.org>
6
6
  License: MIT License
@@ -78,6 +78,7 @@ edq/util/hash_test.py
78
78
  edq/util/json.py
79
79
  edq/util/json_test.py
80
80
  edq/util/net.py
81
+ edq/util/parse.py
81
82
  edq/util/pyimport.py
82
83
  edq/util/pyimport_test.py
83
84
  edq/util/reflection.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes