Editing Talk:List of XEPs

From JaWiki (Jabber/XMPP wiki)
Jump to: navigation, search

Warning: The database has been locked for maintenance, so you will not be able to save your edits right now. You may wish to copy and paste your text into a text file and save it for later.

The administrator who locked it offered this explanation: MediaWiki upgrading

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
== Скрипт для генерации и проверки списка ==
+
== Генерация списка ==
  
Требуется [[Python]] 3
+
Копипаст оригинального списка прогнать через этот скрипт:
  
  <nowiki>#! /usr/bin/env python3
+
  #! /usr/bin/env perl
# -*- coding: utf-8 -*-
+
 
+
while ( <> )
 
+
{
# input
+
split '\t';
XEPS_ORIG_URL = 'http://xmpp.org/extensions/xeps.xml'
+
XEPS_WIKI_URL_T = 'http://jawiki.ru/index.php?title={}&action=raw'
+
chop @_;
XEPS_WIKI_URL_PAGES = (
+
$xep = $_[0];
    'Список_расширений/0001—0049',
+
$name = $_[1];
    'Список_расширений/0050—0099',
+
$type = $_[2];
    'Список_расширений/0100—0149',
+
$status = $_[3];
    'Список_расширений/0150—0199',
+
$date = $_[4]; # ignored
    'Список_расширений/0200—0249',
+
    'Список_расширений/0250—0299'
+
# XEP -> template
)
+
$xep =~ /XEP-([0-9]{4})/;
 
+
$xep = "<nowiki>{{xep|$1}}</nowiki>";
 
+
import itertools
+
# add place for the russian translation
import re
+
$name = $name."&lt;br/&gt;'' ''";
import sys
+
import urllib.request
+
# type and status translation, according to [[Terms]]
import xml.etree.ElementTree as xml
+
%TypeTranslation =
 
+
(
 
+
"Historical", "Историческое",
def fetchUrl(url):
+
"Humorous", "Шуточное",
    return urllib.request.urlopen(url).read().decode('UTF-8')
+
"Informational", "Информационное",
 
+
"JIG Formation", "Формирование JIG",
 
+
"Procedural", "Процедурное",
def initXepList():
+
"Standards Track", "Основное"
    print('... Получение оригинального списка расширений... ', end='', file=sys.stderr)
+
);
    sys.stderr.flush()
+
%StatusTranslation =
    xeps_orig_xml = xml.XML(fetchUrl(XEPS_ORIG_URL))
+
(
    print('Готово.', file=sys.stderr)
+
"Active", "Действующее",
   
+
"Deferred", "Отложенное",
    xeps_orig = {}
+
"Deprecated", "Отменённое",
    for xep in xeps_orig_xml:
+
"Draft", "Черновик",
        number = xep.find('number').text
+
"Experimental", "Экспериментальное",
        xeps_orig[number] = {
+
"Final", "Окончательное",
            'name': xep.find('name').text,
+
"Obsolete", "Устаревшее",
            'abstract': xep.find('abstract').text,
+
"Proposed", "Предложенное",
            'type': xep.find('type').text.replace(' ', '_'),
+
"Rejected", "Отклонённое",
            'status': xep.find('status').text
+
"Retracted", "Отозванное"
        }
+
);
   
+
    for number in sorted(xeps_orig):
+
$typeTranslated = $TypeTranslation{$type};
        print(
+
$statusTranslated = $StatusTranslation{$status};
            '{{{{XepListItem|{number}|{name}|{abstract}|||{type}|{status}}}}}'
+
                .format(number=number, **xeps_orig[number])
+
# type, status links and classes
        )
+
$typeClass = 'type_'.$type;
 
+
$statusClass = 'status_'.$status;
 
+
$type = "<nowiki>[[XEP#Типы|$typeTranslated]]</nowiki>";
def main():
+
$status = "<nowiki>[[XEP#Статусы|$statusTranslated]]</nowiki>";
    print('... Получение списка расширений из ЯВики... ', end='')
+
$typeClass =~ s/ /_/g;
    xeps_wiki = itertools.chain(*(
+
$statusClass =~ s/ /_/g;
        fetchUrl(XEPS_WIKI_URL_T.format(urllib.parse.quote(page))).splitlines()
+
        for page in XEPS_WIKI_URL_PAGES
+
# outting table row
    ))
+
print "|-\n";
    print('Готово.')
+
print "|class='$typeClass $statusClass'| $xep || $name || $type || $status\n";
   
+
}
    xeps = {}
+
    for line in xeps_wiki:
+
        line = line[2:-2] # убираем двойные фигурные скобки по краям, если есть
+
        line = re.sub(r'\{\{.*?\}\}', '', line) # вырезаем вызовы викишаблонов, в них могут быть палки
+
        line = re.sub(r'\[\[.*?\]\]', '', line) # вырезаем викиссылки, в них могут быть палки
+
        parts = line.split('|')
+
        if parts[0] == 'XepListItem':
+
            xeps[parts[1]] = {
+
                'name': parts[2],
+
                'type': parts[6].replace('_', ' '),
+
                'status': parts[7]
+
            }
+
   
+
    print('... Прочитано %d расширений.' % len(xeps))
+
   
+
    print('... Получение оригинального списка расширений... ', end='')
+
    xeps_orig_xml = xml.XML(fetchUrl(XEPS_ORIG_URL))
+
    print('Готово.')
+
   
+
    xeps_orig = {}
+
    for xep in xeps_orig_xml:
+
        number = xep.find('number').text
+
        xeps_orig[number] = {
+
            'name': xep.find('name').text,
+
            'type': xep.find('type').text,
+
            'status': xep.find('status').text
+
        }
+
   
+
    differ = False
+
    for number in sorted(xeps_orig):
+
        if number not in xeps:
+
            differ = True
+
            print('[*] Новое расширение: XEP-' + number)
+
            print('\tНазвание: ' + xeps_orig[number]['name'])
+
            print('\tТип: ' + xeps_orig[number]['type'])
+
            print('\tСтатус: ' + xeps_orig[number]['status'])
+
        elif xeps[number] != xeps_orig[number]:
+
            differ = True
+
            print('[*] Различается XEP-' + number)
+
            if xeps[number]['name'] != xeps_orig[number]['name']:
+
                print('\tНазвание изменено с "{0}" на "{1}"'.format(xeps[number]['name'], xeps_orig[number]['name']))
+
            if xeps[number]['type'] != xeps_orig[number]['type']:
+
                print('\tТип изменён с "{0}" на "{1}"'.format(xeps[number]['type'], xeps_orig[number]['type']))
+
            if xeps[number]['status'] != xeps_orig[number]['status']:
+
                print('\tСтатус изменён с "{0}" на "{1}"'.format(xeps[number]['status'], xeps_orig[number]['status']))
+
   
+
    if not differ:
+
        print('[=] Различия не найдены.')
+
 
+
 
+
if __name__ == '__main__':
+
    #initXepList()
+
    main()</nowiki>
+

Please note that all contributions to JaWiki (Jabber/XMPP wiki) may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see JaWiki (Jabber/XMPP wiki):Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)