[geany/geany] 498764: Refactor the Python identifiers update script for better flexibility

Colomban Wendling git-noreply at xxxxx
Sat Nov 14 22:52:58 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 14 Nov 2015 22:52:58 UTC
Commit:      498764bcafd7f4e95567e155a3c2313790401642
             https://github.com/geany/geany/commit/498764bcafd7f4e95567e155a3c2313790401642

Log Message:
-----------
Refactor the Python identifiers update script for better flexibility


Modified Paths:
--------------
    scripts/update-python-identifiers.sh

Modified: scripts/update-python-identifiers.sh
24 lines changed, 16 insertions(+), 8 deletions(-)
===================================================================
@@ -12,15 +12,23 @@ file=data/filetypes.python
 
 [ -f "$file" ]
 
-py2_builtins=$(python2 -c 'print("\n".join(dir(__builtins__)))')
-py3_builtins=$(python3 -c 'print("\n".join(dir(__builtins__)))')
+py_2_and_3() {
+  python2 "$@" && python3 "$@"
+}
 
-# merge Python 2 and 3 keywords but exclude the ones that are already listed primary=
-identifiers=$( (echo "$py2_builtins" && echo "$py3_builtins") | python -c '\
+# sort_filter [exclude...]
+sort_filter() {
+  python -c '\
 from sys import stdin; \
-builtins=set(stdin.read().strip().split("\n")); \
-exclude=["False", "None", "True", "exec"]; \
-print(" ".join(sorted([i for i in builtins if i not in exclude])))
-')
+items=set(stdin.read().strip().split("\n")); \
+exclude=['"$(for a in "$@"; do printf "'%s', " "$a"; done)"']; \
+print(" ".join(sorted([i for i in items if i not in exclude])))
+'
+}
+
+builtins=$(py_2_and_3 -c 'print("\n".join(dir(__builtins__)))')
+
+# builtins, but excluding keywords that are already listed in primary=
+identifiers=$(echo "$builtins" | sort_filter False None True exec)
 
 sed -e "s/^identifiers=.*$/identifiers=$identifiers/" -i "$file"



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list