Hello community,
here is the log from the commit of package python-pscript for
openSUSE:Leap:15.2 checked in at 2020-03-09 18:10:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/python-pscript (Old)
and /work/SRC/openSUSE:Leap:15.2/.python-pscript.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pscript"
Mon Mar 9 18:10:40 2020 rev:5 rq:776937 version:0.7.3
Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/python-pscript/python-pscript.changes
2020-01-15 15:51:42.263538099 +0100
+++
/work/SRC/openSUSE:Leap:15.2/.python-pscript.new.26092/python-pscript.changes
2020-03-09 18:10:42.245139673 +0100
@@ -1,0 +2,18 @@
+Fri Jan 17 17:08:17 CET 2020 - Matej Cepl <[email protected]>
+
+- Update to 0.7.3:
+ - add examples in the wild
+ - Reflect AST changes in Python 3.8.
+ - use markdown for pypi long_description
+- Remove python-faulthandler BR (it is optional and the package
+ is Python 2-only, in Python 3 the module is in the standard
+ library).
+
+-------------------------------------------------------------------
+Fri May 24 12:20:38 UTC 2019 - [email protected]
+
+- version update to 0.7.1
+ * fix style error
+ * Quicker op_equals
+
+-------------------------------------------------------------------
Old:
----
pscript-0.7.0.tar.gz
New:
----
pscript-0.7.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pscript.spec ++++++
--- /var/tmp/diff_new_pack.9Ed5uy/_old 2020-03-09 18:10:42.485140016 +0100
+++ /var/tmp/diff_new_pack.9Ed5uy/_new 2020-03-09 18:10:42.485140016 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-pscript
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,12 +18,12 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pscript
-Version: 0.7.0
+Version: 0.7.3
Release: 0
Summary: Python to JavaScript compiler
License: BSD-2-Clause
Group: Development/Languages/Python
-Url: https://github.com/flexxui/pscript
+URL: https://github.com/flexxui/pscript
Source:
https://files.pythonhosted.org/packages/source/p/pscript/pscript-%{version}.tar.gz
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
@@ -31,7 +31,6 @@
# SECTION test requirements
BuildRequires: %{python_module invoke}
BuildRequires: %{python_module pytest}
-BuildRequires: python-faulthandler
# /SECTION
BuildArch: noarch
++++++ pscript-0.7.0.tar.gz -> pscript-0.7.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/PKG-INFO new/pscript-0.7.3/PKG-INFO
--- old/pscript-0.7.0/PKG-INFO 2018-11-08 16:25:25.000000000 +0100
+++ new/pscript-0.7.3/PKG-INFO 2019-12-16 17:05:35.163452400 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: pscript
-Version: 0.7.0
+Version: 0.7.3
Summary: Python to JavaScript compiler.
Home-page: http://pscript.readthedocs.io
Author: Almar Klein and contributors
@@ -10,19 +10,13 @@
Description: PScript
========
-
- .. image:: https://travis-ci.org/flexxui/pscript.svg
- :target: https://travis-ci.org/flexxui/pscript
-
-
- .. image::
https://readthedocs.org/projects/pscript/badge/?version=latest
- :target: https://pscript.readthedocs.org
-
+ [](https://travis-ci.org/flexxui/pscript)
+ [](https://pscript.readthedocs.org)
PScript is a Python to JavaScript compiler, and is also the name of
the subset
of Python that this compiler supports. It was developed as a part of
- `Flexx <https://flexx.app>`_ (as `flexx.pyscript`) and is now
represented
+ [Flexx](https://flexx.app) (as `flexx.pyscript`) and is now represented
by its own project. Although it is still an important part of Flexx,
it can
also be useful by itself.
@@ -44,10 +38,10 @@
```py
from pscript import py2js
-
+
def foo(a, b=2):
print(a - b)
-
+
print(py2js(foo))
```
@@ -71,10 +65,22 @@
(e.g. ``async`` and ``await``) do not work in Internet Explorer.
+ PScript in the wild
+ -------------------
+
+ To give an idea of what PScript can do, here are some examples in the
wild:
+
+ * Obviously, everything built in Flexx uses PScript, see e.g. [these
examples](https://flexx.readthedocs.io/en/stable/examples/)
+ * The front-end of [TimeTurtle.app](https://timeturtle.app) is built
in Python using PScript.
+
+ *Let us know if you know more!*
+
+
License
-------
PScript makes use of the liberal 2-clause BSD license. See LICENSE for
details.
+
Keywords: Python,JavaScript,compiler,transpiler
Platform: any
Classifier: Development Status :: 4 - Beta
@@ -92,3 +98,4 @@
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Provides: pscript
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/README.md new/pscript-0.7.3/README.md
--- old/pscript-0.7.0/README.md 2018-09-05 14:35:01.000000000 +0200
+++ new/pscript-0.7.3/README.md 2019-12-16 12:33:06.000000000 +0100
@@ -29,10 +29,10 @@
```py
from pscript import py2js
-
+
def foo(a, b=2):
print(a - b)
-
+
print(py2js(foo))
```
@@ -56,6 +56,17 @@
(e.g. ``async`` and ``await``) do not work in Internet Explorer.
+PScript in the wild
+-------------------
+
+To give an idea of what PScript can do, here are some examples in the wild:
+
+* Obviously, everything built in Flexx uses PScript, see e.g. [these
examples](https://flexx.readthedocs.io/en/stable/examples/)
+* The front-end of [TimeTurtle.app](https://timeturtle.app) is built in Python
using PScript.
+
+*Let us know if you know more!*
+
+
License
-------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript/__init__.py
new/pscript-0.7.3/pscript/__init__.py
--- old/pscript-0.7.0/pscript/__init__.py 2018-11-08 16:23:18.000000000
+0100
+++ new/pscript-0.7.3/pscript/__init__.py 2019-12-16 17:04:38.000000000
+0100
@@ -17,7 +17,7 @@
when correct, but error reporting may not be very Pythonic.
The most important functions you need to know about are
-:func:`py2js <pscript.py2js>` and
+:func:`py2js <pscript.py2js>` and
:func:`evalpy <pscript.evalpy>`.
In principal you do not need knowledge of JavaScript to write PScript
code, though it does help in corner cases.
@@ -32,7 +32,7 @@
Python, to allow user-defined interaction to be flexible, fast, and
stand-alone.
-This resulted in the following two main goals:
+This resulted in the following two main goals:
* To make writing JavaScript easier and less frustrating, by letting
people write it with the Python syntax and builtins, and fixing some
@@ -74,7 +74,7 @@
The empty list and dict evaluate to false (whereas in JS it's
true), and ``isinstance()`` just works (whereas JS' ``typeof`` is
-broken).
+broken).
Deep comparisons are supported (e.g. for ``==`` and ``in``), so you can
compare two lists or dicts, or even a structure of nested
@@ -135,7 +135,7 @@
have a negative impact on performance in tight loops (in comparison to
writing the JS by hand). The recommended approach is to write
performance critical code in pure JavaScript
-(using :func:`RawJS <pscript.RawJS>`) if necessary.
+(using :func:`RawJS <pscript.RawJS>`) if necessary.
.. _pscript-overload:
@@ -144,7 +144,7 @@
----------------------------------------------
To improve the performance of critical code, it's possible to disable
-some of the overloading that make PScript more Pythonic. This increases
+some of the overloading that make PScript more Pythonic. This increases
the speed of code, but it also makes it more like JavaScript.
To use this feature, write ``PSCRIPT_OVERLOAD = False``. Any code that
@@ -169,7 +169,7 @@
-------
This is an overview of the language features that PScript
-supports/lacks.
+supports/lacks.
Not currently supported:
@@ -239,7 +239,7 @@
"""
-__version__ = '0.7.0'
+__version__ = '0.7.3'
import sys
import logging
@@ -268,13 +268,13 @@
# flake8: noqa
if ok:
-
+
from .parser0 import Parser0, JSError
from .parser1 import Parser1
from .parser2 import Parser2
from .parser3 import Parser3
from .base import *
-
+
from .functions import py2js, evaljs, evalpy, JSString
from .functions import script2js, js_rename, create_js_module
from .stdlib import get_full_std_lib, get_all_std_names
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript/commonast.py
new/pscript-0.7.3/pscript/commonast.py
--- old/pscript-0.7.0/pscript/commonast.py 2018-08-09 23:31:52.000000000
+0200
+++ new/pscript-0.7.3/pscript/commonast.py 2019-12-16 17:04:14.000000000
+0100
@@ -7,10 +7,6 @@
https://github.com/almarklein/commonast
"""
-# Notes:
-# Python 3.6 introduced ast.Constant, which seems to be added so that 3d
-# party code can use it, but ast.parse does not produce it afaik.
-
from __future__ import print_function, absolute_import
import sys
@@ -20,6 +16,7 @@
pyversion = sys.version_info
NoneType = None.__class__
+_Ellipsis = Ellipsis
if pyversion >= (3, ):
basestring = str # noqa
@@ -825,6 +822,20 @@
## Literals
+ def _convert_Constant(self, n):
+ val = n.value
+ if val is None or val is True or val is False:
+ return NameConstant(val)
+ if isinstance(val, (int, float, complex)):
+ return Num(val)
+ if isinstance(val, str):
+ return Str(val)
+ if isinstance(val, bytes):
+ return Bytes(val)
+ if val is _Ellipsis:
+ return Ellipsis()
+ raise RuntimeError('Cannot convert %s constants.' % type(val).__name__)
+
def _convert_Num(self, n):
if pyversion < (3, ) and str(n.n).startswith('-'):
# -4 is a unary sub on 4, dont forget complex numbers
@@ -904,7 +915,18 @@
return Attribute(self._convert(n.value), n.attr)
def _convert_Subscript(self, n):
- return Subscript(self._convert(n.value), self._convert(n.slice))
+ return Subscript(self._convert(n.value),
self._convert_index_like(n.slice))
+
+ def _convert_index_like(self, n):
+ c = self._convert
+ if isinstance(n, (ast.Slice, ast.Index, ast.ExtSlice, ast.Ellipsis)):
+ return c(n) # Python < 3.8 (and also 3.8 on Windows?)
+ elif isinstance(n, ast.Num):
+ return Index(c(n))
+ else:
+ assert isinstance(n, ast.Tuple)
+ dims = [self._convert_index_like(x) for x in n.elts]
+ return ExtSlice(dims)
def _convert_Index(self, n):
return Index(self._convert(n.value))
@@ -918,8 +940,7 @@
return Slice(c(n.lower), c(n.upper), step)
def _convert_ExtSlice(self, n):
- c = self._convert
- return ExtSlice([c(x) for x in n.dims])
+ return ExtSlice([self._convert_index_like(x) for x in n.dims])
## Expressions
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript/parser1.py
new/pscript-0.7.3/pscript/parser1.py
--- old/pscript-0.7.0/pscript/parser1.py 2018-11-08 16:21:21.000000000
+0100
+++ new/pscript-0.7.3/pscript/parser1.py 2019-03-08 14:00:40.000000000
+0100
@@ -848,7 +848,7 @@
return []
if node.root and node.root == '__future__':
return [] # stuff to help the parser
- if node.root is 'time':
+ if node.root == 'time':
return [] # PScript natively supports time() and perf_counter()
raise JSError('PScript does not support imports.')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript/stdlib.py
new/pscript-0.7.3/pscript/stdlib.py
--- old/pscript-0.7.0/pscript/stdlib.py 2018-10-25 13:22:51.000000000 +0200
+++ new/pscript-0.7.3/pscript/stdlib.py 2019-03-08 14:00:02.000000000 +0100
@@ -42,7 +42,7 @@
_update_deps(FUNCTIONS[dep], function_deps, method_deps)
for dep in list(method_deps):
_update_deps(METHODS[dep], function_deps, method_deps)
-
+
return nargs, sorted(function_deps), sorted(method_deps)
def _update_deps(code, function_deps, method_deps):
@@ -93,7 +93,7 @@
def get_full_std_lib(indent=0):
""" Get the code for the full PScript standard library.
-
+
The given indent specifies how many sets of 4 spaces to prepend.
If the full stdlib is made available in JavaScript, multiple
snippets of code can be transpiled without inlined stdlib parts by
@@ -349,7 +349,7 @@
for (i=0; i<iter.length; i++) {res.push([i, iter[i]]);}
return res;
}"""
-
+
FUNCTIONS['zip'] = """function () { // nargs: 2 3 4 5 6 7 8 9
var i, j, tup, arg, args = [], res = [], len = 1e20;
for (i=0; i<arguments.length; i++) {
@@ -375,7 +375,7 @@
if ((typeof iter==="object") && (!Array.isArray(iter))) {iter =
Object.keys(iter);}
var comp = function (a, b) {a = key(a); b = key(b);
if (a<b) {return -1;} if (a>b) {return 1;} return 0;};
- comp = Boolean(key) ? comp : undefined;
+ comp = Boolean(key) ? comp : undefined;
iter = iter.slice().sort(comp);
if (reverse) iter.reverse();
return iter;
@@ -404,6 +404,13 @@
}"""
FUNCTIONS['op_equals'] = """function op_equals (a, b) { // nargs: 2
+ var a_type = typeof a;
+ // If a (or b actually) is of type string, number or boolean, we don't need
+ // to do all the other type checking below.
+ if (a_type === "string" || a_type === "boolean" || a_type === "number") {
+ return a == b;
+ }
+
if (a == null || b == null) {
} else if (Array.isArray(a) && Array.isArray(b)) {
var i = 0, iseq = a.length == b.length;
@@ -463,7 +470,7 @@
METHODS['extend'] = """function (x) { // nargs: 1
if (!Array.isArray(this)) return this.KEY.apply(this, arguments);
- this.push.apply(this, x);
+ this.push.apply(this, x);
}"""
METHODS['insert'] = """function (i, x) { // nargs: 2
@@ -488,7 +495,7 @@
if (!Array.isArray(this)) return this.KEY.apply(this, arguments);
var comp = function (a, b) {a = key(a); b = key(b);
if (a<b) {return -1;} if (a>b) {return 1;} return 0;};
- comp = Boolean(key) ? comp : undefined;
+ comp = Boolean(key) ? comp : undefined;
this.sort(comp);
if (reverse) this.reverse();
}"""
@@ -539,14 +546,14 @@
stop = Math.min(this.length, ((stop < 0) ? this.length + stop : stop));
if (Array.isArray(this)) {
var count = 0;
- for (var i=0; i<this.length; i++) {
+ for (var i=0; i<this.length; i++) {
if (FUNCTION_PREFIXop_equals(this[i], x)) {count+=1;}
} return count;
} else if (this.constructor == String) {
var count = 0, i = start;
while (i >= 0 && i < stop) {
i = this.indexOf(x, i);
- if (i < 0) break;
+ if (i < 0) break;
count += 1;
i += Math.max(1, x.length);
} return count;
@@ -764,7 +771,7 @@
METHODS['join'] = """function (x) { // nargs: 1
if (this.constructor !== String) return this.KEY.apply(this, arguments);
- return x.join(this); // call join on the list instead of the string.
+ return x.join(this); // call join on the list instead of the string.
}"""
METHODS['ljust'] = """function (w, fill) { // nargs: 1 2
@@ -793,7 +800,7 @@
var i1 = this.indexOf(sep);
if (i1 < 0) return [this.slice(0), '', '']
var i2 = i1 + sep.length;
- return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
+ return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
}"""
METHODS['replace'] = """function (s1, s2, count) { // nargs: 2 3
@@ -844,7 +851,7 @@
var i1 = this.lastIndexOf(sep);
if (i1 < 0) return ['', '', this.slice(0)]
var i2 = i1 + sep.length;
- return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
+ return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
}"""
METHODS['rsplit'] = """function (sep, count) { // nargs: 1 2
@@ -965,7 +972,7 @@
'FUNCTION_PREFIX', FUNCTION_PREFIX).replace(
'METHOD_PREFIX', METHOD_PREFIX).replace(
', )', ')')
-
+
for key in FUNCTIONS:
FUNCTIONS[key] = re.subn(r'METHOD_PREFIX(.+?)\(',
r'METHOD_PREFIX\1.call(', FUNCTIONS[key])[0]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript.egg-info/PKG-INFO
new/pscript-0.7.3/pscript.egg-info/PKG-INFO
--- old/pscript-0.7.0/pscript.egg-info/PKG-INFO 2018-11-08 16:25:24.000000000
+0100
+++ new/pscript-0.7.3/pscript.egg-info/PKG-INFO 2019-12-16 17:05:34.000000000
+0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: pscript
-Version: 0.7.0
+Version: 0.7.3
Summary: Python to JavaScript compiler.
Home-page: http://pscript.readthedocs.io
Author: Almar Klein and contributors
@@ -10,19 +10,13 @@
Description: PScript
========
-
- .. image:: https://travis-ci.org/flexxui/pscript.svg
- :target: https://travis-ci.org/flexxui/pscript
-
-
- .. image::
https://readthedocs.org/projects/pscript/badge/?version=latest
- :target: https://pscript.readthedocs.org
-
+ [](https://travis-ci.org/flexxui/pscript)
+ [](https://pscript.readthedocs.org)
PScript is a Python to JavaScript compiler, and is also the name of
the subset
of Python that this compiler supports. It was developed as a part of
- `Flexx <https://flexx.app>`_ (as `flexx.pyscript`) and is now
represented
+ [Flexx](https://flexx.app) (as `flexx.pyscript`) and is now represented
by its own project. Although it is still an important part of Flexx,
it can
also be useful by itself.
@@ -44,10 +38,10 @@
```py
from pscript import py2js
-
+
def foo(a, b=2):
print(a - b)
-
+
print(py2js(foo))
```
@@ -71,10 +65,22 @@
(e.g. ``async`` and ``await``) do not work in Internet Explorer.
+ PScript in the wild
+ -------------------
+
+ To give an idea of what PScript can do, here are some examples in the
wild:
+
+ * Obviously, everything built in Flexx uses PScript, see e.g. [these
examples](https://flexx.readthedocs.io/en/stable/examples/)
+ * The front-end of [TimeTurtle.app](https://timeturtle.app) is built
in Python using PScript.
+
+ *Let us know if you know more!*
+
+
License
-------
PScript makes use of the liberal 2-clause BSD license. See LICENSE for
details.
+
Keywords: Python,JavaScript,compiler,transpiler
Platform: any
Classifier: Development Status :: 4 - Beta
@@ -92,3 +98,4 @@
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Provides: pscript
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript_legacy/__init__.py
new/pscript-0.7.3/pscript_legacy/__init__.py
--- old/pscript-0.7.0/pscript_legacy/__init__.py 2018-11-08
16:25:24.000000000 +0100
+++ new/pscript-0.7.3/pscript_legacy/__init__.py 2019-12-16
17:05:34.000000000 +0100
@@ -18,7 +18,7 @@
when correct, but error reporting may not be very Pythonic.
The most important functions you need to know about are
-:func:`py2js <pscript.py2js>` and
+:func:`py2js <pscript.py2js>` and
:func:`evalpy <pscript.evalpy>`.
In principal you do not need knowledge of JavaScript to write PScript
code, though it does help in corner cases.
@@ -33,7 +33,7 @@
Python, to allow user-defined interaction to be flexible, fast, and
stand-alone.
-This resulted in the following two main goals:
+This resulted in the following two main goals:
* To make writing JavaScript easier and less frustrating, by letting
people write it with the Python syntax and builtins, and fixing some
@@ -75,7 +75,7 @@
The empty list and dict evaluate to false (whereas in JS it's
true), and ``isinstance()`` just works (whereas JS' ``typeof`` is
-broken).
+broken).
Deep comparisons are supported (e.g. for ``==`` and ``in``), so you can
compare two lists or dicts, or even a structure of nested
@@ -136,7 +136,7 @@
have a negative impact on performance in tight loops (in comparison to
writing the JS by hand). The recommended approach is to write
performance critical code in pure JavaScript
-(using :func:`RawJS <pscript.RawJS>`) if necessary.
+(using :func:`RawJS <pscript.RawJS>`) if necessary.
.. _pscript-overload:
@@ -145,7 +145,7 @@
----------------------------------------------
To improve the performance of critical code, it's possible to disable
-some of the overloading that make PScript more Pythonic. This increases
+some of the overloading that make PScript more Pythonic. This increases
the speed of code, but it also makes it more like JavaScript.
To use this feature, write ``PSCRIPT_OVERLOAD = False``. Any code that
@@ -170,7 +170,7 @@
-------
This is an overview of the language features that PScript
-supports/lacks.
+supports/lacks.
Not currently supported:
@@ -242,7 +242,7 @@
from __future__ import print_function, absolute_import, with_statement,
unicode_literals, division
-__version__ = '0.7.0'
+__version__ = '0.7.3'
import sys
import logging
@@ -271,13 +271,13 @@
# flake8: noqa
if ok:
-
+
from .parser0 import Parser0, JSError
from .parser1 import Parser1
from .parser2 import Parser2
from .parser3 import Parser3
from .base import *
-
+
from .functions import py2js, evaljs, evalpy, JSString
from .functions import script2js, js_rename, create_js_module
from .stdlib import get_full_std_lib, get_all_std_names
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript_legacy/commonast.py
new/pscript-0.7.3/pscript_legacy/commonast.py
--- old/pscript-0.7.0/pscript_legacy/commonast.py 2018-08-09
23:31:52.000000000 +0200
+++ new/pscript-0.7.3/pscript_legacy/commonast.py 2019-12-16
17:04:14.000000000 +0100
@@ -7,10 +7,6 @@
https://github.com/almarklein/commonast
"""
-# Notes:
-# Python 3.6 introduced ast.Constant, which seems to be added so that 3d
-# party code can use it, but ast.parse does not produce it afaik.
-
from __future__ import print_function, absolute_import
import sys
@@ -20,6 +16,7 @@
pyversion = sys.version_info
NoneType = None.__class__
+_Ellipsis = Ellipsis
if pyversion >= (3, ):
basestring = str # noqa
@@ -825,6 +822,20 @@
## Literals
+ def _convert_Constant(self, n):
+ val = n.value
+ if val is None or val is True or val is False:
+ return NameConstant(val)
+ if isinstance(val, (int, float, complex)):
+ return Num(val)
+ if isinstance(val, str):
+ return Str(val)
+ if isinstance(val, bytes):
+ return Bytes(val)
+ if val is _Ellipsis:
+ return Ellipsis()
+ raise RuntimeError('Cannot convert %s constants.' % type(val).__name__)
+
def _convert_Num(self, n):
if pyversion < (3, ) and str(n.n).startswith('-'):
# -4 is a unary sub on 4, dont forget complex numbers
@@ -904,7 +915,18 @@
return Attribute(self._convert(n.value), n.attr)
def _convert_Subscript(self, n):
- return Subscript(self._convert(n.value), self._convert(n.slice))
+ return Subscript(self._convert(n.value),
self._convert_index_like(n.slice))
+
+ def _convert_index_like(self, n):
+ c = self._convert
+ if isinstance(n, (ast.Slice, ast.Index, ast.ExtSlice, ast.Ellipsis)):
+ return c(n) # Python < 3.8 (and also 3.8 on Windows?)
+ elif isinstance(n, ast.Num):
+ return Index(c(n))
+ else:
+ assert isinstance(n, ast.Tuple)
+ dims = [self._convert_index_like(x) for x in n.elts]
+ return ExtSlice(dims)
def _convert_Index(self, n):
return Index(self._convert(n.value))
@@ -918,8 +940,7 @@
return Slice(c(n.lower), c(n.upper), step)
def _convert_ExtSlice(self, n):
- c = self._convert
- return ExtSlice([c(x) for x in n.dims])
+ return ExtSlice([self._convert_index_like(x) for x in n.dims])
## Expressions
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript_legacy/parser1.py
new/pscript-0.7.3/pscript_legacy/parser1.py
--- old/pscript-0.7.0/pscript_legacy/parser1.py 2018-11-08 16:25:24.000000000
+0100
+++ new/pscript-0.7.3/pscript_legacy/parser1.py 2019-12-16 17:05:34.000000000
+0100
@@ -851,7 +851,7 @@
return []
if node.root and node.root == '__future__':
return [] # stuff to help the parser
- if node.root is 'time':
+ if node.root == 'time':
return [] # PScript natively supports time() and perf_counter()
raise JSError('PScript does not support imports.')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/pscript_legacy/stdlib.py
new/pscript-0.7.3/pscript_legacy/stdlib.py
--- old/pscript-0.7.0/pscript_legacy/stdlib.py 2018-11-08 16:25:24.000000000
+0100
+++ new/pscript-0.7.3/pscript_legacy/stdlib.py 2019-12-16 17:05:34.000000000
+0100
@@ -45,7 +45,7 @@
_update_deps(FUNCTIONS[dep], function_deps, method_deps)
for dep in list(method_deps):
_update_deps(METHODS[dep], function_deps, method_deps)
-
+
return nargs, sorted(function_deps), sorted(method_deps)
def _update_deps(code, function_deps, method_deps):
@@ -96,7 +96,7 @@
def get_full_std_lib(indent=0):
""" Get the code for the full PScript standard library.
-
+
The given indent specifies how many sets of 4 spaces to prepend.
If the full stdlib is made available in JavaScript, multiple
snippets of code can be transpiled without inlined stdlib parts by
@@ -352,7 +352,7 @@
for (i=0; i<iter.length; i++) {res.push([i, iter[i]]);}
return res;
}"""
-
+
FUNCTIONS['zip'] = """function () { // nargs: 2 3 4 5 6 7 8 9
var i, j, tup, arg, args = [], res = [], len = 1e20;
for (i=0; i<arguments.length; i++) {
@@ -378,7 +378,7 @@
if ((typeof iter==="object") && (!Array.isArray(iter))) {iter =
Object.keys(iter);}
var comp = function (a, b) {a = key(a); b = key(b);
if (a<b) {return -1;} if (a>b) {return 1;} return 0;};
- comp = Boolean(key) ? comp : undefined;
+ comp = Boolean(key) ? comp : undefined;
iter = iter.slice().sort(comp);
if (reverse) iter.reverse();
return iter;
@@ -407,6 +407,13 @@
}"""
FUNCTIONS['op_equals'] = """function op_equals (a, b) { // nargs: 2
+ var a_type = typeof a;
+ // If a (or b actually) is of type string, number or boolean, we don't need
+ // to do all the other type checking below.
+ if (a_type === "string" || a_type === "boolean" || a_type === "number") {
+ return a == b;
+ }
+
if (a == null || b == null) {
} else if (Array.isArray(a) && Array.isArray(b)) {
var i = 0, iseq = a.length == b.length;
@@ -466,7 +473,7 @@
METHODS['extend'] = """function (x) { // nargs: 1
if (!Array.isArray(this)) return this.KEY.apply(this, arguments);
- this.push.apply(this, x);
+ this.push.apply(this, x);
}"""
METHODS['insert'] = """function (i, x) { // nargs: 2
@@ -491,7 +498,7 @@
if (!Array.isArray(this)) return this.KEY.apply(this, arguments);
var comp = function (a, b) {a = key(a); b = key(b);
if (a<b) {return -1;} if (a>b) {return 1;} return 0;};
- comp = Boolean(key) ? comp : undefined;
+ comp = Boolean(key) ? comp : undefined;
this.sort(comp);
if (reverse) this.reverse();
}"""
@@ -542,14 +549,14 @@
stop = Math.min(this.length, ((stop < 0) ? this.length + stop : stop));
if (Array.isArray(this)) {
var count = 0;
- for (var i=0; i<this.length; i++) {
+ for (var i=0; i<this.length; i++) {
if (FUNCTION_PREFIXop_equals(this[i], x)) {count+=1;}
} return count;
} else if (this.constructor == String) {
var count = 0, i = start;
while (i >= 0 && i < stop) {
i = this.indexOf(x, i);
- if (i < 0) break;
+ if (i < 0) break;
count += 1;
i += Math.max(1, x.length);
} return count;
@@ -767,7 +774,7 @@
METHODS['join'] = """function (x) { // nargs: 1
if (this.constructor !== String) return this.KEY.apply(this, arguments);
- return x.join(this); // call join on the list instead of the string.
+ return x.join(this); // call join on the list instead of the string.
}"""
METHODS['ljust'] = """function (w, fill) { // nargs: 1 2
@@ -796,7 +803,7 @@
var i1 = this.indexOf(sep);
if (i1 < 0) return [this.slice(0), '', '']
var i2 = i1 + sep.length;
- return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
+ return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
}"""
METHODS['replace'] = """function (s1, s2, count) { // nargs: 2 3
@@ -847,7 +854,7 @@
var i1 = this.lastIndexOf(sep);
if (i1 < 0) return ['', '', this.slice(0)]
var i2 = i1 + sep.length;
- return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
+ return [this.slice(0, i1), this.slice(i1, i2), this.slice(i2)];
}"""
METHODS['rsplit'] = """function (sep, count) { // nargs: 1 2
@@ -968,7 +975,7 @@
'FUNCTION_PREFIX', FUNCTION_PREFIX).replace(
'METHOD_PREFIX', METHOD_PREFIX).replace(
', )', ')')
-
+
for key in FUNCTIONS:
FUNCTIONS[key] = re.subn(r'METHOD_PREFIX(.+?)\(',
r'METHOD_PREFIX\1.call(', FUNCTIONS[key])[0]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pscript-0.7.0/setup.py new/pscript-0.7.3/setup.py
--- old/pscript-0.7.0/setup.py 2018-08-10 09:38:57.000000000 +0200
+++ new/pscript-0.7.3/setup.py 2019-12-16 12:44:02.000000000 +0100
@@ -37,31 +37,6 @@
return NS['__version__'], NS['__doc__']
-def get_readme_as_rst(filename):
- lines = []
- for line in open(filename, 'rb').read().decode().splitlines():
- lines.append(line)
- # Convert links, images, and images with links
- i1, i2 = line.find('['), line.find(']')
- i3, i4 = line.find('(', i2), line.find(')', i2)
- i5, i6 = line.find('(', i4), line.find(')', i4+1)
- if '[Documentation Status' in line:
- line.find('x')
- if i1 >=0 and i2 > i1 and i3 == i2 + 1 and i4 > i3:
- text, link = line[i1+1:i2], line[i3+1:i4]
- if i1 == 1 and line[0] == '!':
- # Image
- lines[-1] = '\n.. image:: %s\n' % link
- elif i1 == 0 and line.startswith('[![') and i5 == i4 + 2 and i6 >
i5:
- # Image with link
- link2 = line[i5+1:i6]
- lines[-1] = '\n.. image:: %s\n :target: %s\n' % (link,
link2)
- else:
- # RST link: `link text </the/link>`_
- lines[-1] = '%s`%s <%s>`_%s' % (line[:i1], text, link,
line[i4+1:])
- return '\n'.join(lines)
-
-
def package_tree(pkgroot):
subdirs = [os.path.relpath(i[0], THIS_DIR).replace(os.path.sep, '.')
for i in os.walk(os.path.join(THIS_DIR, pkgroot))
@@ -72,7 +47,7 @@
def copy_for_legacy_python(src_dir, dest_dir):
from translate_to_legacy import LegacyPythonTranslator
# Dirs and files to explicitly not translate
- skip = ['tests/python_sample.py',
+ skip = ['tests/python_sample.py',
'tests/python_sample2.py',
'tests/python_sample3.py']
# Make a fresh copy of the package
@@ -94,8 +69,7 @@
# Get version and docstring (i.e. long description)
version, doc = get_version_and_doc(os.path.join(THIS_DIR, name, '__init__.py'))
-if os.path.isfile(os.path.join(THIS_DIR, 'README.md')):
- doc = get_readme_as_rst(os.path.join(THIS_DIR, 'README.md'))
+doc = open(os.path.join(THIS_DIR, 'README.md'), "rb").read().decode()
# Support for legacy Python: we install a second package with the
# translated code. We generate that code when we can. We use
@@ -119,6 +93,7 @@
keywords="Python, JavaScript, compiler, transpiler",
description=description,
long_description=doc,
+ long_description_content_type="text/markdown",
platforms='any',
provides=[name],
install_requires=[],