Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
3b11c726
Commit
3b11c726
authored
Jan 05, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: enable print_function in checkPythonSourceCodeAsJSON
This flags python2 style usage of print as a statement
parent
4029d75f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.py
...eItem/portal_components/extension.erp5.PythonCodeUtils.py
+21
-5
No files found.
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.PythonCodeUtils.py
View file @
3b11c726
from
six
import
string_types
as
basestring
from
six
import
string_types
as
basestring
import
re
import
json
import
json
from
Products.ERP5Type.Utils
import
checkPythonSourceCode
from
Products.ERP5Type.Utils
import
checkPythonSourceCode
match_PEP263
=
re
.
compile
(
r'^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)'
).
match
def
checkPythonSourceCodeAsJSON
(
self
,
data
,
REQUEST
=
None
):
def
checkPythonSourceCodeAsJSON
(
self
,
data
,
REQUEST
=
None
):
"""
"""
Check Python source suitable for Source Code Editor and return a JSON object
Check Python source suitable for Source Code Editor and return a JSON object
...
@@ -24,8 +29,19 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
...
@@ -24,8 +29,19 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
signature_parts
+=
[
data
[
'params'
]]
signature_parts
+=
[
data
[
'params'
]]
signature
=
", "
.
join
(
signature_parts
)
signature
=
", "
.
join
(
signature_parts
)
function_name
=
"function_name"
# keep the PEP263 magic comment
body
=
"def %s(%s):
\
n
%s"
%
(
function_name
,
pep263_comment
=
'#'
lines
=
data
[
'code'
].
splitlines
()
+
[
''
,
''
]
for
line
in
lines
[
0
],
lines
[
1
]:
m
=
match_PEP263
(
line
)
if
m
:
pep263_comment
=
'# coding='
+
m
.
groups
()[
0
]
break
body
=
"%s
\
n
"
\
"from __future__ import print_function
\
n
"
\
"def function_name(%s):
\
n
%s"
%
(
pep263_comment
,
signature
,
signature
,
indent
(
data
[
'code'
])
or
" pass"
)
indent
(
data
[
'code'
])
or
" pass"
)
else
:
else
:
...
@@ -34,7 +50,7 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
...
@@ -34,7 +50,7 @@ def checkPythonSourceCodeAsJSON(self, data, REQUEST=None):
message_list
=
checkPythonSourceCode
(
body
.
encode
(
'utf8'
),
data
.
get
(
'portal_type'
))
message_list
=
checkPythonSourceCode
(
body
.
encode
(
'utf8'
),
data
.
get
(
'portal_type'
))
for
message_dict
in
message_list
:
for
message_dict
in
message_list
:
if
is_script
:
if
is_script
:
message_dict
[
'row'
]
=
message_dict
[
'row'
]
-
2
message_dict
[
'row'
]
=
message_dict
[
'row'
]
-
4
else
:
else
:
message_dict
[
'row'
]
=
message_dict
[
'row'
]
-
1
message_dict
[
'row'
]
=
message_dict
[
'row'
]
-
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment