Compare commits

..

No commits in common. "db2096cfbb17b0c581f9d93dcff5f4b6c8888df5" and "4e12094fc60889f1ec4b9c76f63958584e6bac60" have entirely different histories.

5 changed files with 19 additions and 148 deletions

View File

@ -1,22 +0,0 @@
From 1519a4f917aed4ad3a1f975e4451791ea84f1b32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Vejn=C3=A1r?= <vejnar.martin@gmail.com>
Date: Sun, 9 Sep 2018 14:07:30 +0200
Subject: [PATCH] Add .vscode and .pytest_cache to .gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index 6317d70..ae02791 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@ __pycache__/
.tox/
*.pyc
.cache/
+.vscode/
+.pytest_cache/
--
2.27.0

View File

@ -1,24 +0,0 @@
From 056ef47a8797334d2af737c910527e4bdf6746ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Vejn=C3=A1r?= <vejnar.martin@gmail.com>
Date: Sun, 28 Oct 2018 13:37:00 +0100
Subject: [PATCH] Avoid annoying SystemExit breaks in vscode
---
test/test.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test/test.py b/test/test.py
index 0884253..21bffd8 100644
--- a/test/test.py
+++ b/test/test.py
@@ -94,4 +94,6 @@ def _main():
return 1 if failed or not succeeded else 0
if __name__ == '__main__':
- sys.exit(_main())
+ r = _main()
+ if r:
+ sys.exit(r)
--
2.27.0

View File

@ -1,48 +0,0 @@
From dffef385459c3bd49c33fd69b759485016a7f0b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Vejn=C3=A1r?= <vejnar.martin@gmail.com>
Date: Sat, 27 Oct 2018 21:47:28 +0200
Subject: [PATCH] Fix datetime serialization
---
pytoml/writer.py | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/pytoml/writer.py b/pytoml/writer.py
index 6eaf5d7..2d8afb5 100644
--- a/pytoml/writer.py
+++ b/pytoml/writer.py
@@ -48,13 +48,6 @@ def _escape_id(s):
def _format_list(v):
return '[{0}]'.format(', '.join(_format_value(obj) for obj in v))
-# Formula from:
-# https://docs.python.org/2/library/datetime.html#datetime.timedelta.total_seconds
-# Once support for py26 is dropped, this can be replaced by td.total_seconds()
-def _total_seconds(td):
- return ((td.microseconds
- + (td.seconds + td.days * 24 * 3600) * 10**6) / 10.0**6)
-
def _format_value(v):
if isinstance(v, bool):
return 'true' if v else 'false'
@@ -69,7 +62,7 @@ def _format_value(v):
return _escape_string(v)
elif isinstance(v, datetime.datetime):
offs = v.utcoffset()
- offs = _total_seconds(offs) // 60 if offs is not None else 0
+ offs = int(offs.total_seconds()) // 60 if offs is not None else 0
if offs == 0:
suffix = 'Z'
@@ -79,7 +72,7 @@ def _format_value(v):
else:
suffix = '-'
offs = -offs
- suffix = '{0}{1:.02}{2:.02}'.format(suffix, offs // 60, offs % 60)
+ suffix = '{0}{1:02}:{2:02}'.format(suffix, offs // 60, offs % 60)
if v.microsecond:
return v.strftime('%Y-%m-%dT%H:%M:%S.%f') + suffix
--
2.27.0

View File

@ -1,34 +0,0 @@
From 09b300acf1142fec5de429d3521c09afad0832c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Vejn=C3=A1r?= <vejnar.martin@gmail.com>
Date: Sat, 27 Oct 2018 21:57:01 +0200
Subject: [PATCH] Reject invalid escapes in strings
Fixes `invalid-escape` test.
---
pytoml/parser.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pytoml/parser.py b/pytoml/parser.py
index 6d4d483..b4f7646 100644
--- a/pytoml/parser.py
+++ b/pytoml/parser.py
@@ -180,13 +180,13 @@ _ws_re = re.compile(r'[ \t]*')
def _p_ws(s):
s.expect_re(_ws_re)
-_escapes = { 'b': '\b', 'n': '\n', 'r': '\r', 't': '\t', '"': '"', '\'': '\'',
- '\\': '\\', '/': '/', 'f': '\f' }
+_escapes = { 'b': '\b', 'n': '\n', 'r': '\r', 't': '\t', '"': '"',
+ '\\': '\\', 'f': '\f' }
_basicstr_re = re.compile(r'[^"\\\000-\037]*')
_short_uni_re = re.compile(r'u([0-9a-fA-F]{4})')
_long_uni_re = re.compile(r'U([0-9a-fA-F]{8})')
-_escapes_re = re.compile('[bnrt"\'\\\\/f]')
+_escapes_re = re.compile(r'[btnfr\"\\]')
_newline_esc_re = re.compile('\n[ \t\n]*')
def _p_basicstr_content(s, content=_basicstr_re):
res = []
--
2.27.0

View File

@ -2,15 +2,11 @@
Name: python-%{github_name}
Version: 0.1.18
Release: 7
Release: 2
Summary: Parser for TOML
License: MIT
URL: https://github.com/avakar/%{github_name}
Source0: https://github.com/avakar/%{github_name}/archive/v%{version}/%{github_name}-%{version}.tar.gz
Patch0: Add-.vscode-and-.pytest_cache-to-.gitignore.patch
Patch1: Fix-datetime-serialization.patch
Patch2: Reject-invalid-escapes-in-strings.patch
Patch3: Avoid-annoying-SystemExit-breaks-in-vscode.patch
BuildArch: noarch
%global my_description \
@ -20,6 +16,16 @@ strict parser and writer for TOML files.
%description
%{my_description}
%package -n python2-%{github_name}
Summary: %{summary}
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python2-setuptools
%{?python_provide:%python_provide python2-%{github_name}}
%description -n python2-%{github_name}
%{my_description}
%package -n python3-%{github_name}
Summary: %{summary}
BuildArch: noarch
@ -34,11 +40,19 @@ BuildRequires: python3-setuptools
%autosetup -p1 -n %{github_name}-%{version}
%build
%py2_build
%py3_build
%install
%py2_install
%py3_install
%files -n python2-%{github_name}
%doc README.md
%license LICENSE
%{python2_sitelib}/%{github_name}-%{version}*-py%{python2_version}.egg-info/
%{python2_sitelib}/%{github_name}/
%files -n python3-%{github_name}
%doc README.md
%license LICENSE
@ -46,20 +60,5 @@ BuildRequires: python3-setuptools
%{python3_sitelib}/%{github_name}/
%changelog
* Fri Dec 29 2023 fandehui <fandehui@xfusion.com> - 0.1.18-7
- Avoid annoying SystemExit breaks in vscode
* Fri Dec 29 2023 fandehui <fandehui@xfusion.com> - 0.1.18-6
- Reject invalid escapes in strings
* Fri Dec 29 2023 fandehui <fandehui@xfusion.com> - 0.1.18-5
- Fix datetime serialization
* Mon Dec 11 2023 fandehui <fandehui@xfusion.com> - 0.1.18-4
- Add .vscode and .pytest_cache to .gitignore
* Thu Oct 22 2020 wutao <wutao61@huawei.com> - 0.1.18-3
- delete python2 modules
* Tue Dec 3 2019 mengxian <mengxian@huawei.com> - 0.1.18-2
- Package init