# Path: common/pywikibot_utils.py
# def site_matrix():
# def proofread_info(lang):
# def get_all_lang(family):
# def safe_put(page, text, comment):


import os
import sys 
import pywikibot
from common import pywikibot_utils
# -*- coding: utf-8 -*-                                                        


def gen_lang(dict_name, result):
    for family in dict_name:
        for lang in dict_name[family]:
            result.add(lang)

def gen_all_lang():
    result = set()

    for lang in pywikibot_utils.get_all_lang('wikisource'):
        result.add(lang)

    return result

def name_from_ns(namespaces, ns):
    return namespaces[ns][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'


# Path: common/pywikibot_utils.py
# def site_matrix():
# def proofread_info(lang):
# def get_all_lang(family):
# def safe_put(page, text, comment):


# Path: utils/gen_namespace.py
import os
import sys 
import pywikibot
from common import pywikibot_utils

# -*- coding: utf-8 -*-                                                        


def gen_lang(dict_name, result):
    for family in dict_name:
        for lang in dict_name[family]:
            result.add(lang)

def gen_all_lang():
    result = set()

    for lang in pywikibot_utils.get_all_lang('wikisource'):
        result.add(lang)

    return result

def name_from_ns(namespaces, ns):
    return namespaces[ns][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']