Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: GitHub noreply@github.com Date: Sun, 21 May 2023 17:20:12 UTC Commit: 82502cfe987a9a5ef5da27d100e8d03b8352c14f https://github.com/geany/geany/commit/82502cfe987a9a5ef5da27d100e8d03b8352c1...
Log Message: ----------- Merge pull request #3488 from eht16/update_php_script_and_tags
Port create_php_tags to Python3 and generate new PHP tags file
Modified Paths: -------------- data/tags/std.php.tags scripts/create_php_tags.py
Modified: data/tags/std.php.tags 10332 lines changed, 3972 insertions(+), 6360 deletions(-) =================================================================== No diff available, check online
Modified: scripts/create_php_tags.py 26 lines changed, 11 insertions(+), 15 deletions(-) =================================================================== @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 # # Author: Enrico Tröger # License: GPL v2 or later @@ -9,10 +8,10 @@ # From those defintions all function tags are extracted and written # to ../data/tags/std.php.tags (relative to the script's location, not $CWD).
+import re from json import loads from os.path import dirname, join -from urllib2 import urlopen -import re +from urllib.request import urlopen
UPSTREAM_TAG_DEFINITION = 'http://doc.php.net/downloads/json/php_manual_en.json' @@ -32,14 +31,12 @@ TYPE_VARIABLE = 16384
-#---------------------------------------------------------------------- def normalize_name(name): """ Replace namespace separator with class separators, as Geany only understands the latter """ return name.replace('\', '::')
-#---------------------------------------------------------------------- def split_scope(name): """ Splits the scope from the member, and returns (scope, member). Returned scope is None if the name is not a member """ @@ -48,10 +45,9 @@ def split_scope(name): if sep_pos < 0: return None, name else: - return name[:sep_pos], name[sep_pos+2:] + return name[:sep_pos], name[sep_pos + 2:]
-#---------------------------------------------------------------------- def parse_and_create_php_tags_file(): # download upstream definition response = urlopen(UPSTREAM_TAG_DEFINITION) @@ -64,7 +60,7 @@ def parse_and_create_php_tags_file(): definitions = loads(html)
# generate tags - tag_list = list() + tag_list = [] for tag_name, tag_definition in definitions.items(): prototype_re = PROTOTYPE_RE.format(tag_name=re.escape(tag_name)) match = re.match(prototype_re, tag_definition['prototype']) @@ -81,24 +77,24 @@ def parse_and_create_php_tags_file(): # Also create a class tag when encountering a __construct() if tag_name == '__construct' and scope is not None: scope, tag_name = split_scope(scope) - tag_list.append((tag_name, TYPE_CLASS, None, arg_list, scope)) + tag_list.append((tag_name, TYPE_CLASS, None, arg_list, scope or ''))
# write tags script_dir = dirname(__file__) tags_file_path = join(script_dir, '..', 'data', 'tags', 'std.php.tags') - with open(tags_file_path, 'w') as tags_file: + with open(tags_file_path, 'w', encoding='iso-8859-1') as tags_file: tags_file.write('# format=tagmanager\n') for tag_name, tag_type, return_type, arg_list, scope in sorted(tag_list): - tag_line = '{}'.format(tag_name) - for attr, type in [(tag_type, TA_TYPE), + tag_line = f'{tag_name}' + for attr, type_ in [(tag_type, TA_TYPE), (arg_list, TA_ARGLIST), (return_type, TA_VARTYPE), (scope, TA_SCOPE)]: if attr is not None: - tag_line += '{type:c}{attr}'.format(type=type, attr=attr) + tag_line += f'{type_:c}{attr}'
tags_file.write(tag_line + '\n') - print(u'Created: {} with {} tags'.format(tags_file_path, len(tag_list))) + print(f'Created: {tags_file_path} with {len(tag_list)} tags')
if __name__ == '__main__':
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).