Exemple #1
0
def gen_ws_category(langs):
    text  = u'# -*- coding: utf-8 -*-\n'
    text += u'# auto-generated by %s, do not edit manually.\n\n' % sys.argv[0]

    # yes, old is very special...
    text += u"""\
domain_urls = {
    'old': (
        104,
        "Proofread",
        "Validated",
        "Without_text",
        "Problematic",
        ),
"""

    for lang in langs:
        pfi = pywikibot_utils.proofread_info(lang)
        format_dict = {}
        format_dict['code'] = lang
        pfns = pfi['proofreadnamespaces']
        format_dict['page_ns'] = pfns['page']['id']
        levels = pfi['proofreadqualitylevels']
        pfns = pfi['proofreadnamespaces']
        # FIXME: it'll better to generate a dictionnary rather than a list
        # but we need to fix all namespace first.
        for level in levels:
            cat = level['category'].replace(u' ', u'_')
            if level['id'] == 0:
                format_dict['Without_text'] = cat
            elif level['id'] == 1:
                format_dict['Not_proofread'] = cat
            elif level['id'] == 2:
                format_dict['Problematic'] = cat
            elif level['id'] == 3:
                format_dict['Proofread'] = cat
            elif level['id'] == 4:
                format_dict['Validated'] = cat

        text += u"""\
    '%(code)s': (
        %(page_ns)d,
        "%(Proofread)s",
        "%(Validated)s",
        "%(Without_text)s",
        "%(Problematic)s",
        ),
""" % format_dict


    text += u"}\n"

    return text
def gen_ws_category(langs):
    text = u'# -*- coding: utf-8 -*-\n'
    text += u'# auto-generated by %s, do not edit manually.\n\n' % sys.argv[0]

    # yes, old is very special...
    text += u"""\
domain_urls = {
    'old': (
        104,
        "Proofread",
        "Validated",
        "Without_text",
        "Problematic",
        ),
"""

    for lang in langs:
        pfi = pywikibot_utils.proofread_info(lang)
        format_dict = {}
        format_dict['code'] = lang
        pfns = pfi['proofreadnamespaces']
        format_dict['page_ns'] = pfns['page']['id']
        levels = pfi['proofreadqualitylevels']
        pfns = pfi['proofreadnamespaces']
        # FIXME: it'll better to generate a dictionnary rather than a list
        # but we need to fix all namespace first.
        for level in levels:
            cat = level['category'].replace(u' ', u'_')
            if level['id'] == 0:
                format_dict['Without_text'] = cat
            elif level['id'] == 1:
                format_dict['Not_proofread'] = cat
            elif level['id'] == 2:
                format_dict['Problematic'] = cat
            elif level['id'] == 3:
                format_dict['Proofread'] = cat
            elif level['id'] == 4:
                format_dict['Validated'] = cat

        text += u"""\
    '%(code)s': (
        %(page_ns)d,
        "%(Proofread)s",
        "%(Validated)s",
        "%(Without_text)s",
        "%(Problematic)s",
        ),
""" % format_dict

    text += u"}\n"

    return text
def gen_namespace(lang):
    site = pywikibot.Site(lang, 'wikisource')
    text = u'namespaces["wikisource"]["' + lang + '"] = {\n'

    namespaces = site.namespaces()
    for ns in namespaces:
        for name in namespaces[ns]:
            if name:
                text += u'    "' + name + u'" : ' + unicode(ns) + u',\n'
    text += u'}\n'

    data = pywikibot_utils.proofread_info(lang)['proofreadnamespaces']

    text += u'index["wikisource"]["' + lang + '"] = '
    text += u'"' + name_from_ns(namespaces, data[u'index'][u'id']) + u'"\n'

    text += u'page["wikisource"]["' + lang + '"] = '
    text += u'"' + name_from_ns(namespaces, data[u'page'][u'id']) + u'"\n'

    return text
Exemple #4
0
def gen_namespace(lang):
    site = pywikibot.Site(lang, 'wikisource')
    text = u'namespaces["wikisource"]["' + lang + '"] = {\n'
    
    namespaces = site.namespaces()
    for ns in namespaces:
        for name in namespaces[ns]:
            if name:
                text += u'    "' + name + u'" : ' + unicode(ns) + u',\n'
    text += u'}\n'

    data = pywikibot_utils.proofread_info(lang)['proofreadnamespaces']

    text += u'index["wikisource"]["' + lang + '"] = '
    text += u'"' + name_from_ns(namespaces, data[u'index'][u'id']) + u'"\n'

    text += u'page["wikisource"]["' + lang + '"] = '
    text += u'"' + name_from_ns(namespaces, data[u'page'][u'id']) + u'"\n'

    return text