From 9dd9008756b7bc9a286eb9ddfbe8703607b3514c Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Tue, 21 May 2024 11:56:16 -0400 Subject: [PATCH 1/7] Add tabs indentation support --- lib/yaml/scanner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/yaml/scanner.py b/lib/yaml/scanner.py index de925b07..8b68bb42 100644 --- a/lib/yaml/scanner.py +++ b/lib/yaml/scanner.py @@ -773,7 +773,8 @@ def scan_to_next_token(self): self.forward() found = False while not found: - while self.peek() == ' ': + # TODO: Throw exception when mixing spaces and tabs + while self.peek() in [' ', "\t"]: self.forward() if self.peek() == '#': while self.peek() not in '\0\r\n\x85\u2028\u2029': From da545fc7b25f7c273a348b38e7ed2a5567dfbf9e Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Tue, 21 May 2024 12:49:45 -0400 Subject: [PATCH 2/7] Add tabs indentation support in block_scalar --- lib/yaml/scanner.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/yaml/scanner.py b/lib/yaml/scanner.py index 8b68bb42..ab4f6035 100644 --- a/lib/yaml/scanner.py +++ b/lib/yaml/scanner.py @@ -1092,7 +1092,7 @@ def scan_block_scalar_indicators(self, start_mark): def scan_block_scalar_ignored_line(self, start_mark): # See the specification for details. - while self.peek() == ' ': + while self.peek() in [' ', "\t"]: self.forward() if self.peek() == '#': while self.peek() not in '\0\r\n\x85\u2028\u2029': @@ -1109,8 +1109,8 @@ def scan_block_scalar_indentation(self): chunks = [] max_indent = 0 end_mark = self.get_mark() - while self.peek() in ' \r\n\x85\u2028\u2029': - if self.peek() != ' ': + while self.peek() in ' \t\r\n\x85\u2028\u2029': + if self.peek() not in [' ', "\t"]: chunks.append(self.scan_line_break()) end_mark = self.get_mark() else: @@ -1123,12 +1123,12 @@ def scan_block_scalar_breaks(self, indent): # See the specification for details. chunks = [] end_mark = self.get_mark() - while self.column < indent and self.peek() == ' ': + while self.column < indent and self.peek() in [' ', "\t"]: self.forward() while self.peek() in '\r\n\x85\u2028\u2029': chunks.append(self.scan_line_break()) end_mark = self.get_mark() - while self.column < indent and self.peek() == ' ': + while self.column < indent and self.peek() in [' ', "\t"]: self.forward() return chunks, end_mark From fc9b5b59b68be377c23bda2249d8e07717ff7779 Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Tue, 21 May 2024 13:00:54 -0400 Subject: [PATCH 3/7] Add fork info to README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 7d01da24..8a8f80c2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ +## About this fork + +This fork adds tabs indentation support to PyYAML. + +Use at your own risk. + +Please note I'm not checking if the content is mixing tabs and spaces (which should throw a warning or error). + +Why to use tabs for indentation? Sorry, but that's a very silly question 😡 + +--- + PyYAML ====== From e62e676455c94fe80cf339b36ad9bcb4d49aeedb Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Tue, 21 May 2024 13:17:16 -0400 Subject: [PATCH 4/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a8f80c2..c93820f7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This fork adds tabs indentation support to PyYAML. Use at your own risk. -Please note I'm not checking if the content is mixing tabs and spaces (which should throw a warning or error). +Please note I'm not checking if the content is mixing tabs and spaces (which should raise an exception). Why to use tabs for indentation? Sorry, but that's a very silly question 😡 From 3f684d7a022e2266e4cbf24987d481aebcb9935a Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Wed, 22 May 2024 07:37:45 -0400 Subject: [PATCH 5/7] Update setup.py --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c9b5dc6f..7750d458 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ -NAME = 'PyYAML' +NAME = 'PyYAML-tabs' VERSION = '6.0.1' -DESCRIPTION = "YAML parser and emitter for Python" +DESCRIPTION = "YAML parser and emitter for Python with tabs indentation support" LONG_DESCRIPTION = """\ YAML is a data serialization format designed for human readability and interaction with scripting languages. PyYAML is a YAML parser @@ -44,7 +44,7 @@ 'CI': 'https://github.com/yaml/pyyaml/actions', 'Documentation': 'https://pyyaml.org/wiki/PyYAMLDocumentation', 'Mailing lists': 'http://lists.sourceforge.net/lists/listinfo/yaml-core', - 'Source Code': 'https://github.com/yaml/pyyaml', + 'Source Code': 'https://github.com/kripper/pyyaml', } LIBYAML_CHECK = """ From 5baf71f3e8a934c0752bb50876d7580773e8561b Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Wed, 22 May 2024 10:43:02 -0400 Subject: [PATCH 6/7] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c93820f7..c3fe9eb2 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Please note I'm not checking if the content is mixing tabs and spaces (which sho Why to use tabs for indentation? Sorry, but that's a very silly question 😡 +Install with `pip install PyYAML_tabs` + --- PyYAML From 13f48ea6811bb4544142d5df3c4bb9429419d3bd Mon Sep 17 00:00:00 2001 From: Christopher Pereira Date: Mon, 27 May 2024 10:27:14 -0400 Subject: [PATCH 7/7] Update setup.py --- setup.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 7750d458..66d3e4e2 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,10 @@ -NAME = 'PyYAML-tabs' -VERSION = '6.0.1' +NAME = 'PyYAML_tabs' +VERSION = '6.0.3' DESCRIPTION = "YAML parser and emitter for Python with tabs indentation support" LONG_DESCRIPTION = """\ +This is a fork of PyYAML with tabs indentation support. + YAML is a data serialization format designed for human readability and interaction with scripting languages. PyYAML is a YAML parser and emitter for Python. @@ -19,7 +21,7 @@ LICENSE = "MIT" PLATFORMS = "Any" URL = "https://pyyaml.org/" -DOWNLOAD_URL = "https://pypi.org/project/PyYAML/" +DOWNLOAD_URL = "https://pypi.org/project/PyYAML_tabs/" CLASSIFIERS = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -40,11 +42,11 @@ "Topic :: Text Processing :: Markup", ] PROJECT_URLS = { - 'Bug Tracker': 'https://github.com/yaml/pyyaml/issues', - 'CI': 'https://github.com/yaml/pyyaml/actions', + 'Bug Tracker': 'https://github.com/kripper/pyyaml_tabs/issues', + 'CI': 'https://github.com/kripper/pyyaml_tabs/actions', 'Documentation': 'https://pyyaml.org/wiki/PyYAMLDocumentation', 'Mailing lists': 'http://lists.sourceforge.net/lists/listinfo/yaml-core', - 'Source Code': 'https://github.com/kripper/pyyaml', + 'Source Code': 'https://github.com/kripper/pyyaml_tabs', } LIBYAML_CHECK = """