bracex 3.2.2__tar.gz → 3.2.3__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 (30) hide show
  1. {bracex-3.2.2 → bracex-3.2.3}/PKG-INFO +1 -1
  2. {bracex-3.2.2 → bracex-3.2.3}/bracex/__init__.py +2 -1
  3. {bracex-3.2.2 → bracex-3.2.3}/bracex/__meta__.py +1 -1
  4. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/about/changelog.md +5 -0
  5. {bracex-3.2.2 → bracex-3.2.3}/tests/brace-cases.txt +6 -0
  6. {bracex-3.2.2 → bracex-3.2.3}/tests/brace-results.txt +10 -1
  7. {bracex-3.2.2 → bracex-3.2.3}/tests/generate.sh +2 -1
  8. {bracex-3.2.2 → bracex-3.2.3}/tests/test_brace.py +12 -7
  9. {bracex-3.2.2 → bracex-3.2.3}/.gitignore +0 -0
  10. {bracex-3.2.2 → bracex-3.2.3}/.pyspelling.yml +0 -0
  11. {bracex-3.2.2 → bracex-3.2.3}/LICENSE.md +0 -0
  12. {bracex-3.2.2 → bracex-3.2.3}/README.md +0 -0
  13. {bracex-3.2.2 → bracex-3.2.3}/bracex/__main__.py +0 -0
  14. {bracex-3.2.2 → bracex-3.2.3}/bracex/py.typed +0 -0
  15. {bracex-3.2.2 → bracex-3.2.3}/docs/src/dictionary/en-custom.txt +0 -0
  16. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/.snippets/abbr.md +0 -0
  17. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/.snippets/links.md +0 -0
  18. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/.snippets/refs.md +0 -0
  19. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/about/contributing.md +0 -0
  20. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/about/development.md +0 -0
  21. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/about/license.md +0 -0
  22. {bracex-3.2.2 → bracex-3.2.3}/docs/src/markdown/index.md +0 -0
  23. {bracex-3.2.2 → bracex-3.2.3}/docs/theme/announce.html +0 -0
  24. {bracex-3.2.2 → bracex-3.2.3}/hatch_build.py +0 -0
  25. {bracex-3.2.2 → bracex-3.2.3}/pyproject.toml +0 -0
  26. {bracex-3.2.2 → bracex-3.2.3}/tests/__init__.py +0 -0
  27. {bracex-3.2.2 → bracex-3.2.3}/tests/test_main.py +0 -0
  28. {bracex-3.2.2 → bracex-3.2.3}/tests/test_versions.py +0 -0
  29. {bracex-3.2.2 → bracex-3.2.3}/tools/pycon.py +0 -0
  30. {bracex-3.2.2 → bracex-3.2.3}/zensical.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bracex
3
- Version: 3.2.2
3
+ Version: 3.2.3
4
4
  Summary: Bash style brace expander.
5
5
  Project-URL: Homepage, https://github.com/facelessuser/bracex
6
6
  Author-email: Isaac Muse <Isaac.Muse@gmail.com>
@@ -299,7 +299,8 @@ class ExpandBrace:
299
299
  try:
300
300
  escaped = next(i)
301
301
  except StopIteration:
302
- escaped = ''
302
+ # Like Bash, a backslash with nothing after it to escape is kept as is.
303
+ return c
303
304
  return c + escaped if self.keep_escapes else escaped
304
305
 
305
306
  def squash(self, a: Iterable[str], b: Iterable[str]) -> Iterator[str]:
@@ -193,5 +193,5 @@ def parse_version(ver: str) -> Version:
193
193
  return Version(major, minor, micro, release, pre, post, dev)
194
194
 
195
195
 
196
- __version_info__ = Version(3, 2, 2, "final")
196
+ __version_info__ = Version(3, 2, 3, "final")
197
197
  __version__ = __version_info__._get_canonical()
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## 3.2.3
4
+
5
+ - **FIX**: Keep a trailing backslash that has nothing to escape, such as in `{a,b}\`, like Bash 5.3 does. It was
6
+ previously dropped unless `keep_escapes` was enabled.
7
+
3
8
  ## 3.2.2
4
9
 
5
10
  - **FIX**: Match Bash 5.3 for groups that contain a top level `..` but are not valid sequences. If the group starts
@@ -362,3 +362,9 @@ x{{1..3}..b}y
362
362
  {1..3{a,b}}{c,d}
363
363
  {a,{b}..c}
364
364
  {x,{b}..c,y}
365
+ {a,b,c}\\
366
+ a\\
367
+ \\
368
+ a{b,c\\
369
+ _\\{_\\,}_\\
370
+ _\\\\{_\\\\,}_\\\\
@@ -1433,4 +1433,13 @@ A{b,{d,e},{f,g}}Z
1433
1433
  [{b}..c]><><><><{x,{b}..c,y}
1434
1434
  [x]
1435
1435
  [{b}..c]
1436
- [y]><><><><
1436
+ [y]><><><><{a,b,c}\
1437
+ [a\]
1438
+ [b\]
1439
+ [c\]><><><><a\
1440
+ [a\]><><><><\
1441
+ [\]><><><><a{b,c\
1442
+ [a{b,c\]><><><><_\{_\,}_\
1443
+ [_{_,}_\]><><><><_\\{_\\,}_\\
1444
+ [_\_\_\]
1445
+ [_\_\]><><><><
@@ -16,7 +16,8 @@ cat brace-cases.txt | \
16
16
  if [ "${case:0:1}" = "#" ]; then
17
17
  continue;
18
18
  fi;
19
- b="$($BASH -c 'for c in '"$case"'; do echo "[$c]"; done')"
19
+ # The case is evaluated as an argument so it can end with a backslash, which would otherwise escape what follows.
20
+ b="$($BASH -c 'eval "set -- $1"; for c in "$@"; do echo "[$c]"; done' _ "$case")"
20
21
  echo "$case"
21
22
  echo -n "$b><><><><";
22
23
  done > brace-results.txt
@@ -113,9 +113,13 @@ class TestBraces:
113
113
  ['{b..k..2}', ['b', 'd', 'f', 'h', 'j']]
114
114
  ]
115
115
 
116
- error_cases = [
117
- # This would fail in bash, but we won't fail because we aren't Bash
118
- ['{a,b,c}\\', ['a', 'b', 'c']]
116
+ trailing_backslash_cases = [
117
+ # Bash keeps a backslash that has nothing after it to escape: [pattern, result, result keeping escapes]
118
+ ['{a,b,c}\\', ['a\\', 'b\\', 'c\\'], ['a\\', 'b\\', 'c\\']],
119
+ ['a\\', ['a\\'], ['a\\']],
120
+ ['\\', ['\\'], ['\\']],
121
+ ['a{b,c\\', ['a{b,c\\'], ['a{b,c\\']],
122
+ ['_\\{_\\,}_\\', ['_{_,}_\\'], ['_\\{_\\,}_\\']]
119
123
  ]
120
124
 
121
125
  @staticmethod
@@ -147,11 +151,12 @@ class TestBraces:
147
151
  print('TEST: ', result, '<=^=>', goal, '\n')
148
152
  cls.assert_equal(result, goal)
149
153
 
150
- @pytest.mark.parametrize("case", error_cases)
151
- def test_internal_errors(self, case):
152
- """Test trailing escape."""
154
+ @pytest.mark.parametrize("case", trailing_backslash_cases)
155
+ def test_trailing_backslash(self, case):
156
+ """Test that a trailing backslash is kept, with or without keeping escapes."""
153
157
 
154
- self.eval_brace_cases(case)
158
+ self.assert_equal(bracex.expand(case[0]), case[1])
159
+ self.assert_equal(bracex.expand(case[0], keep_escapes=True), case[2])
155
160
 
156
161
  @pytest.mark.parametrize("case", dollar_cases)
157
162
  def test_dollar_expand(self, case):
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