3 # Author: Colomban Wendling <colomban@geany.org>
4 # License: GPL v2 or later
6 # Updates the `identifiers` entry in data/filetypes.python.
7 # Requires both Python 2 and 3.
11 file=data
/filedefs
/filetypes.python
16 python2
"$@" && python3
"$@"
19 # sort_filter [exclude...]
22 from sys import stdin; \
23 items=set(stdin.read().strip().split("\n")); \
24 exclude=['"$(for a in "$@
"; do printf "'%s', " "$a"; done)"']; \
25 print(" ".join(sorted([i for i in items if i not in exclude])))
29 keywords
=$
(py_2_and_3
-c 'from keyword import kwlist; print("\n".join(kwlist))')
30 builtins
=$
(py_2_and_3
-c 'print("\n".join(dir(__builtins__)))')
32 primary
=$
(echo "$keywords" | sort_filter
)
33 # builtins, but excluding keywords that are already listed in primary=
34 identifiers
=$
(echo "$builtins" | sort_filter
$primary)
36 sed -e "s/^primary=.*$/primary=$primary/" \
37 -e "s/^identifiers=.*$/identifiers=$identifiers/" \