当前位置: 首页>>代码示例>>Python>>正文


Python Logger.info方法代码示例

本文整理汇总了Python中zanatalib.logger.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.info方法的具体用法?Python Logger.info怎么用?Python Logger.info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zanatalib.logger.Logger的用法示例。


在下文中一共展示了Logger.info方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_project_config

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
    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['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")
            project_config['locale_map'] = {}

            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)

        # Read <src-dir> and <trans-dir>
        if xmldoc.getElementsByTagName("src-dir"):
            node = xmldoc.getElementsByTagName("src-dir")[0]
            project_config['srcdir'] = getCombinedTextChildren(node)
        if xmldoc.getElementsByTagName("trans-dir"):
            node = xmldoc.getElementsByTagName("trans-dir")[0]
            project_config['transdir'] = getCombinedTextChildren(node)

        return dict((node, value.strip() if isinstance(value, str) else value)
                    for node, value in project_config.items() if value)
开发者ID:pkulev,项目名称:zanata-python-client,代码行数:56,代码来源:parseconfig.py

示例2: __init__

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
class ZanataCommand:
    def __init__(self):
        self.log = Logger()

    ##############################################
    ##
    ## Commands for interaction with zanata server 
    ##
    ############################################## 
    def check_project(self, zanataclient, command_options, project_config):
        project_id = ''
        iteration_id = ''
        if command_options.has_key('project_id'):
            project_id =  command_options['project_id'][0]['value'] 
        else:
            if project_config.has_key('project_id'):
                project_id = project_config['project_id']
        
        if command_options.has_key('project_version'):
            iteration_id = command_options['project_version'][0]['value'] 
        else:
            if project_config.has_key('project_version'):
                iteration_id = project_config['project_version']
        
        if not project_id:
            self.log.error("Please specify a valid project id in zanata.xml or with '--project-id' option")
            sys.exit(1)
        
        if not iteration_id:
            self.log.error("Please specify a valid version id in zanata.xml or with '--project-version' option")
            sys.exit(1)
        
        self.log.info("Project: %s"%project_id)
        self.log.info("Version: %s"%iteration_id)

        try:
            zanataclient.projects.get(project_id)
        except NoSuchProjectException, e:
            self.log.error(e.msg)
            sys.exit(1)
   
        try:
            zanataclient.projects.iterations.get(project_id, iteration_id)
            return project_id, iteration_id
        except NoSuchProjectException, e:
            self.log.error(e.msg)
            sys.exit(1)
开发者ID:seanf,项目名称:zanata-python-client,代码行数:49,代码来源:zanatacmd.py

示例3: read_project_config

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
    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
开发者ID:lcabral37,项目名称:zanata-python-client,代码行数:46,代码来源:parseconfig.py

示例4: str

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
            #Read the user-config file
            config.set_userconfig(path)

            try:
                server = config.get_server(url)
                if server:
                    user_name = config.get_config_value("username", "servers", server)
                    apikey = config.get_config_value("key", "servers", server)
            except Exception, e:
                log.info("Processing user-config file:%s" % str(e))
                break
            
            break

    if not (user_name, apikey):
        log.info("Can not find user-config file in home folder, current path or path in 'user-config' option")

    log.info("zanata server: %s" % url)

    #The value in commandline options will overwrite the value in user-config file
    if command_options.has_key('user_name'):
        user_name = command_options['user_name'][0]['value']

    if command_options.has_key('key'):
        apikey = command_options['key'][0]['value']

    return (user_name, apikey)

def get_version(url):
    #Retrieve the version of client
    version_number = ""
开发者ID:joycec,项目名称:zanata-python-client,代码行数:33,代码来源:zanata.py

示例5: PublicanUtility

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
                sys.exit(1)
        else:
            #get all the pot files from the template folder
            publicanutil = PublicanUtility()
            filelist = publicanutil.get_file_list(tmlfolder, ".pot")

            if not filelist:
                log.error("The template folder is empty")
                sys.exit(1)
            deletefiles = True

        if command_options.has_key('force'):
            force = True

        if project_type == 'podir':
            log.info("POT directory (originals):%s" % tmlfolder)
            folder = None
        elif project_type == 'gettext':
            log.info("PO directory (originals):%s" % tmlfolder)
            folder = tmlfolder

        if pushtrans is None:
            pushtrans = self.get_pushtrans(command_options)

        if deletefiles:
            zanatacmd.del_server_content(tmlfolder, project_id, version_id, filelist, force, project_type)

        if pushtrans:
            log.info("Send local translation: True")
            import_param = self.get_importparam(project_type, command_options,  project_config, folder)
            zanatacmd.push_command(filelist, tmlfolder, project_id, version_id, copytrans, plural_support, import_param)
开发者ID:candlepin,项目名称:zanata-python-client,代码行数:33,代码来源:pushcmd.py

示例6: __init__

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
class OptionsUtil:
    def __init__(self, options):
        self.command_options = options
        self.project_config = {}
        self.log = Logger()
        self.config = ZanataConfig()

    def apply_configfiles(self):
        url = self.apply_project_config()
        username, apikey = self.apply_user_config(url)

        # The value in commandline options will overwrite the value in user-config file
        if self.command_options.has_key("user_name"):
            username = self.command_options["user_name"][0]["value"]

        if self.command_options.has_key("key"):
            apikey = self.command_options["key"][0]["value"]

        self.log.info("zanata server: %s" % url)

        return url, username, apikey

    def apply_project_config(self):
        # Read the project configuration file using --project-config option
        config_file = [os.path.join(os.getcwd(), filename) for filename in ["zanata.xml", "flies.xml"]]

        if self.command_options.has_key("project_config"):
            config_file.append(self.command_options["project_config"][0]["value"])

        for path in config_file:
            if os.path.exists(path):
                self.log.info("Loading zanata project config from: %s" % path)
            self.project_config = self.config.read_project_config(path)
            break

        if not self.project_config:
            self.log.info("Can not find zanata.xml, please specify the path of zanata.xml")

        # process the url of server
        if self.project_config.has_key("project_url"):
            url = self.project_config["project_url"]

        # The value in options will override the value in project-config file
        if self.command_options.has_key("url"):
            self.log.info("Overriding url of server with command line option")
            url = self.command_options["url"][0]["value"]

        if not url or url.isspace():
            self.log.error("Please specify valid server url in zanata.xml or with '--url' option")
            sys.exit(1)

        url = self.trim_url(url)

        return url

    def trim_url(self, url):
        if " " in url or "\n" in url:
            self.log.info("Warning, the url which contains '\\n' or whitespace is not valid, please check zanata.xml")
        url = url.strip()

        if url[-1] == "/":
            url = url[:-1]

        return url

    def get_localemap(self):
        if self.project_config and self.project_config.has_key("locale_map"):
            locale_map = self.project_config["locale_map"]

        return locale_map

    def apply_user_config(self, url):
        user_name = ""
        apikey = ""
        # Try to read user-config file
        user_config = [
            os.path.join(os.path.expanduser("~") + "/.config", filename) for filename in ["zanata.ini", "flies.ini"]
        ]

        if self.command_options.has_key("user_config"):
            user_config.append(self.command_options["user_config"][0]["value"])

        for path in user_config:
            if os.path.exists(path):
                self.log.info("Loading zanata user config from: %s" % path)

            # Read the user-config file
            self.config.set_userconfig(path)

            try:
                server = self.config.get_server(url)
                if server:
                    user_name = self.config.get_config_value("username", "servers", server)
                    apikey = self.config.get_config_value("key", "servers", server)
            except Exception, e:
                self.log.info("Processing user-config file:%s" % str(e))
                break

            break

#.........这里部分代码省略.........
开发者ID:joycec,项目名称:zanata-python-client,代码行数:103,代码来源:optionsutil.py

示例7: str

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
            log.info("Loading zanata user config from: %s" % path)
            #Read the user-config file
            config.set_userconfig(path)
            try:
                server = config.get_server(url)
                if server:
                    user_name = config.get_config_value("username", "servers", server)
                    apikey = config.get_config_value("key", "servers", server)
            except Exception, e:
                log.info("Processing user-config file:%s" % str(e))
                break
            
            break

    if not (user_name, apikey):
        log.info("Can not find user-config file in home folder, current path or path in 'user-config' option")
        
    log.info("zanata server: %s" % url)

    #The value in commandline options will overwrite the value in user-config file
    if command_options.has_key('user_name'):
        user_name = command_options['user_name'][0]['value']

    if command_options.has_key('key'):
        apikey = command_options['key'][0]['value']

    return (user_name, apikey)

def get_version(url, command_options,headers=None):
    #Retrieve the version of client
    version_number = ""
开发者ID:jobava-zanata,项目名称:zanata-python-client,代码行数:33,代码来源:zanata.py

示例8: str

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
                # Read the user-config file
                config.set_userconfig(path)

                try:
                    server = config.get_server(url)
                    if server:
                        user_name = config.get_config_value("username", "servers", server)
                        apikey = config.get_config_value("key", "servers", server)
                except Exception, e:
                    log.info("Processing user-config file:%s" % str(e))
                    break

                break

        if not (user_name, apikey):
            log.info("Can not find user-config file in home folder, current path or path in 'user-config' option")

        # The value in commandline options will overwrite the value in user-config file
        if command_options.has_key("user_name"):
            user_name = command_options["user_name"][0]["value"]

        if command_options.has_key("key"):
            apikey = command_options["key"][0]["value"]

        return (user_name, apikey)

    def get_client_version(self, command_options):
        # Retrieve the version of client
        version_number = ""
        path = os.path.dirname(os.path.realpath(__file__))
        version_file = os.path.join(path, "VERSION-FILE")
开发者ID:jobava-zanata,项目名称:zanata-python-client,代码行数:33,代码来源:pushcmd.py

示例9: read_project_config

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]
    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]
            rc = ""

            for node in node.childNodes:
                if node.nodeType in ( node.TEXT_NODE, node.CDATA_SECTION_NODE):
                    rc = rc + node.data
            project_config['project_url'] = rc

        #Read the project id
        if xmldoc.getElementsByTagName("project"):
            node = xmldoc.getElementsByTagName("project")[0]
            rc = ""

            for node in node.childNodes:
                if node.nodeType in ( node.TEXT_NODE, node.CDATA_SECTION_NODE):
                    rc = rc + node.data
            project_config['project_id'] = rc
        
        #Read the project-version
        if xmldoc.getElementsByTagName("project-version"):
            node = xmldoc.getElementsByTagName("project-version")[0]
            rc = ""
        
            for node in node.childNodes:
                if node.nodeType in ( node.TEXT_NODE, node.CDATA_SECTION_NODE):
                    rc = rc + node.data
            project_config['project_version'] = rc

        if xmldoc.getElementsByTagName("python-client"):
            python_config = xmldoc.getElementsByTagName("python-client")[0]
            srcdir = python_config.getElementsByTagName("dir")
            rc = ""
            for folder in srcdir:
                for node in folder.childNodes:
                    if node.nodeType in ( node.TEXT_NODE, node.CDATA_SECTION_NODE):
                        rc = rc + node.data
            project_config['project_srcdir'] = rc

        #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 = {locale.getAttribute("map-from"):node.data}
                            project_config['locale_map'].update(locale_map)
                        else:
                            locale_map = {node.data:node.data}
                            project_config['locale_map'].update(locale_map)
        
        return project_config
开发者ID:seanf,项目名称:zanata-python-client,代码行数:66,代码来源:parseconfig.py

示例10: __init__

# 需要导入模块: from zanatalib.logger import Logger [as 别名]
# 或者: from zanatalib.logger.Logger import info [as 别名]

#.........这里部分代码省略.........
        """
        pofile = self.create_pofile(filepath)
        textflowtargets = self.create_txtflowtarget(pofile)
        #the function for extensions have not implemented yet
        extensions = self.create_extensions(pofile, "po-target-header")
        items = {'links':[],'extensions':extensions, 'textFlowTargets':textflowtargets}
        
        return json.dumps(items)

    def save_to_pofile(self, path, translations, pot):
        """
        Save PO file to path, based on json objects of pot and translations 
        @param translations: the json object of the content retrieved from server
        @param path: the po folder for output
        @param pot: the json object of the pot retrieved from server
        """
        po = polib.POFile(fpath=path)
        
        potcontent = json.loads(pot)
        # pylint: disable-msg=E1103
        textflows = potcontent.get('textFlows')
                
        if potcontent.get('extensions'):
            extensions = potcontent.get('extensions')[0]
            po.header = extensions.get('comment')     
            for item in extensions.get('entries'):
                po.metadata[item['key']]=item['value']                    
        else:
            raise InvalidPOTFileException("Error", "the extensions of Resource is empty")

        for textflow in textflows:
            if textflow.get('extensions'):
                poentry = polib.POEntry(occurrences=None)
                entry_list = textflow.get('extensions')
                for entry in entry_list:
                    if entry.get('object-type') == 'pot-entry-header':
                        #PotEntryHeader
                        #Check the references is not empty
                        if entry.get('references')!=[u'']:
                            for item in entry.get('references'):
                                #in some cases, entry contains more than one reference
                                if ' ' in item:
                                    reference = item.split(' ')
                                    ref_list = []
                                    for i in reference:
                                        ref = tuple(i.split(':'))
                                        ref_list.append(ref)
                                    poentry.occurrences= ref_list 
                                else:
                                    poentry.occurrences = [tuple(item.split(':'))]
                        else:
                            poentry.occurrences = None
                        #print poentry.occurrences
                        poentry.flags = entry.get('flags')  
                    
                    if entry.get('object-type') == 'comment':
                        #SimpleComment
                        poentry.comment = entry.get('value')
                         
                poentry.msgid = textflow.get('content')
                po.append(poentry)
            else:
                raise InvalidPOTFileException("Error", "the extensions of TextFlow is empty")
          
        #If the translation is exist, read the content of the po file
        if translations:
            content = json.loads(translations)
            """            
            "extensions":[{"object-type":"po-target-header", "comment":"comment_value", "entries":[{"key":"ht","value":"vt1"}]}]
            """
            if content.get('extensions'):
                ext = content.get('extensions')[0]
                header_comment = ext.get('comment')
                if header_comment:
                    po.header = header_comment
                for item in ext.get('entries'):
                    po.metadata[item['key']]=item['value']  
            
            targets = content.get('textFlowTargets')
                            
            """
            "extensions":[{"object-type":"comment","value":"testcomment","space":"preserve"}]
            """ 
            # copy any other stuff you need to transfer
            for message in po:
                for translation in targets:
                    if translation.get('extensions'):
                        extensions=translation.get('extensions')[0]
                        #if extensions:
                        #    ext_type = extensions.get('object-type')
                        #    comment = extensions.get('comment')
                        #    entries = extensions.get('value')
                    if self.hash_match(message, translation.get('resId')):
                        message.msgstr = translation.get('content')
                   
        # finally save resulting po to outpath as lang/myfile.po
       
        po.save()
        # pylint: disable-msg=E1103
        self.log.info("Writing po file to %s"%(path))
开发者ID:seanf,项目名称:zanata-python-client,代码行数:104,代码来源:publicanutil.py


注:本文中的zanatalib.logger.Logger.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。