Talk:List of XEPs
From JaWiki (Jabber/XMPP wiki)
Revision as of 15:24, 23 October 2010 by Cblp.su (Talk | contribs) (→Проверка списка: текущая версия моего скрипта)
Генерация списка
Копипаст оригинального списка прогнать через этот скрипт:
#! /usr/bin/env perl
while ( <> )
{
split '\t';
chop @_;
$xep = $_[0];
$name = $_[1];
$type = $_[2];
$status = $_[3];
$date = $_[4]; # ignored
# XEP -> template
$xep =~ /XEP-([0-9]{4})/;
$xep = "{{xep|$1}}";
# add place for the russian translation
$name = $name."<hr/>";
# type and status translation, according to Terms
%TypeTranslation =
(
"Historical", "Историческое",
"Humorous", "Шуточное",
"Informational", "Информационное",
"JIG Formation", "Формирование JIG",
"Procedural", "Процедурное",
"Standards Track", "Основное"
);
%StatusTranslation =
(
"Active", "Действующее",
"Deferred", "Отложенное",
"Deprecated", "Отменённое",
"Draft", "Черновик",
"Experimental", "Экспериментальное",
"Final", "Окончательное",
"Obsolete", "Устаревшее",
"Proposed", "Предложенное",
"Rejected", "Отклонённое",
"Retracted", "Отозванное"
);
$typeTranslated = $TypeTranslation{$type};
$statusTranslated = $StatusTranslation{$status};
# type, status links and classes
$typeClass = 'type_'.$type;
$statusClass = 'status_'.$status;
$type = "[[XEP#Типы|$typeTranslated]]";
$status = "[[XEP#Статусы|$statusTranslated]]";
$typeClass =~ s/ /_/g;
$statusClass =~ s/ /_/g;
# outting table row
print "|- class='$typeClass $statusClass'\n| $xep || $name || $type || $status\n";
}
Проверка списка
Требуется Python 3
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # input XEPS_ORIG_URL = 'http://xmpp.org/includes/xeps-all.txt' XEPS_WIKI_URL = 'http://jawiki.ru/index.php?title=List_of_XEPs&action=raw&templates=expand' import re import urllib.request def fetchUrl(url): return str(urllib.request.urlopen(url).read(), 'UTF-8') def main(): print('... Получение списка расширений из ЯВики... ', end='') xeps_wiki = fetchUrl(XEPS_WIKI_URL).splitlines() print('Готово.') xeps = {} xeptype = None xepstatus = None for line in xeps_wiki: search = re.search("class='type_(.*?) status_(.*?)'", line) if search: xeptype = search.group(1).replace('_', ' ').strip() xepstatus = search.group(2).strip() continue search = re.search('xep-([0-9]{4}).*\|\|(.*)<hr', line) if search: xeps[search.group(1)] = { 'name': search.group(2).strip(), 'type': xeptype, 'status': xepstatus } print('... Прочитано %d расширений.' % len(xeps)) print('... Получение оригинального списка расширений... ', end='') xeps_orig = fetchUrl(XEPS_ORIG_URL).split('</tr>\n<tr') print('Готово.') differ = False for xepblock in xeps_orig: xepdetails = re.findall('<td[^>]*>(.*)</td>', xepblock) xepcode = xepdetails[0][55:59] xep_o = { 'name': xepdetails[1], 'type': xepdetails[2], 'status': xepdetails[3] } if xepcode not in xeps: differ = True print('[*] Новое расширение: XEP-' + xepcode) print('\tНазвание: ' + xep_o['name']) print('\tТип: ' + xep_o['type']) print('\tСтатус: ' + xep_o['status']) elif xep_o != xeps[xepcode]: differ = True print('[*] Различается XEP-' + xepcode) if xep_o['name'] != xeps[xepcode]['name']: print('\tНазвание изменено с "{0}" на "{1}"'.format(xeps[xepcode]['name'], xep_o['name'])) if xep_o['type'] != xeps[xepcode]['type']: print('\tТип изменён с "{0}" на "{1}"'.format(xeps[xepcode]['type'], xep_o['type'])) if xep_o['status'] != xeps[xepcode]['status']: print('\tСтатус изменён с "{0}" на "{1}"'.format(xeps[xepcode]['status'], xep_o['status'])) if not differ: print('[=] Различия не найдены.') if __name__ == '__main__': main()