Exemplo n.º 1
0
    def read_project_config(self, filename):
        log = Logger()

        if os.path.getsize(filename) == 0:
            log.info(
                'The project config file is empty, need command line options')
            return project_config

        xmldoc = minidom.parse(filename)

        # Read the project url
        if xmldoc.getElementsByTagName("url"):
            node = xmldoc.getElementsByTagName("url")[0]
            project_config['project_url'] = getCombinedTextChildren(node)

        # Read the project id
        if xmldoc.getElementsByTagName("project"):
            node = xmldoc.getElementsByTagName("project")[0]
            project_config['project_id'] = getCombinedTextChildren(node)

        # Read the project-version
        if xmldoc.getElementsByTagName("project-version"):
            node = xmldoc.getElementsByTagName("project-version")[0]
            project_config['project_version'] = getCombinedTextChildren(node)

        # Read the project-type
        if xmldoc.getElementsByTagName("project-type"):
            node = xmldoc.getElementsByTagName("project-type")[0]
            project_config['project_type'] = getCombinedTextChildren(node)

        # Read the locale map
        if xmldoc.getElementsByTagName("locales"):
            locales = xmldoc.getElementsByTagName("locales")[0]
            localelist = locales.getElementsByTagName("locale")

            for locale in localelist:
                for node in locale.childNodes:
                    if node.nodeType == node.TEXT_NODE:
                        if locale.getAttribute("map-from"):
                            locale_map = {
                                str(locale.getAttribute("map-from")):
                                str(node.data)
                            }
                        else:
                            locale_map = {str(node.data): str(node.data)}
                        project_config['locale_map'].update(locale_map)

        return project_config
Exemplo n.º 2
0
from zanatalib.logger import Logger
from zanatacmd import ZanataCommand
from parseconfig import ZanataConfig
from publicanutil import PublicanUtility
from optionsutil import OptionsUtil

from command import makeHandler
from command import strip_docstring
from command import parse_command_line
from command import handle_program
from pushcmd import PoPush
from pushcmd import PublicanPush
from pushcmd import GenericPush
from pullcmd import GenericPull

log = Logger()

option_sets = {
    'url': [
        dict(
            type='command',
            long=['--url'],
            metavar='URL',
        ),
    ],
    'user_name': [
        dict(
            type='command',
            long=['--username'],
            metavar='USERNAME',
        ),
 def __init__(self):
     self.log = Logger()
Exemplo n.º 4
0
 def __init__(self, options):
     self.command_options = options
     self.project_config = {}
     self.log = Logger()
     self.config = ZanataConfig()
Exemplo n.º 5
0
 def __init__(self, url, username=None, apikey=None, http_headers=None):
     self.log = Logger()
     self.zanata_resource = ZanataResource(url, username, apikey,
                                           http_headers)