當前位置: 首頁>>代碼示例>>Python>>正文


Python Logger.warn方法代碼示例

本文整理匯總了Python中zanatalib.logger.Logger.warn方法的典型用法代碼示例。如果您正苦於以下問題:Python Logger.warn方法的具體用法?Python Logger.warn怎麽用?Python Logger.warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在zanatalib.logger.Logger的用法示例。


在下文中一共展示了Logger.warn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: glossary_push

# 需要導入模塊: from zanatalib.logger import Logger [as 別名]
# 或者: from zanatalib.logger.Logger import warn [as 別名]
        command_type = project_config['project_type']
    else:
        log.error("The project type is unknown")
        sys.exit(1)

    if dir_option:
        #Keep dir option for publican/po pull
        if command_options.has_key('dir'):
            output_folder = command_options['dir'][0]['value']

        if command_options.has_key('dstdir'):
            output_folder = command_options['dstdir'][0]['value']
    else:
        #Disable dir option for generic pull command
        if command_options.has_key('dir'):
            log.warn("dir option is disabled in pull command, please use --transdir, or specify value in zanata.xml")
                     
        if command_options.has_key('dstdir'):
            log.warn("dstdir option is changed to transdir option for generic pull command")
            output_folder = command_options['dstdir'][0]['value']
    
    if command_options.has_key('noskeletons'):
        skeletons = False

    outpath = create_outpath(command_options, output_folder)

    zanatacmd.pull_command(zanata, locale_map, project_id, iteration_id, filelist, lang_list, outpath, command_type, skeletons)

def glossary_push(command_options, args):
    """
    Usage: zanata glossary push [OPTIONS] GLOSSARY_POFILE
開發者ID:joycec,項目名稱:zanata-python-client,代碼行數:33,代碼來源:zanata.py

示例2: __init__

# 需要導入模塊: from zanatalib.logger import Logger [as 別名]
# 或者: from zanatalib.logger.Logger import warn [as 別名]
class PublicanUtility:
    def __init__(self):
        self.log = Logger()

    def create_txtflow(self, pofile):
        """
        Convert the content of the pot file to a list of text flow.
        @return: the dictionary object of textflow
        """
        textflows = []
        for entry in pofile:
            reflist = []
            if entry.msgctxt:
                self.log.warn("encountered msgctxt; not currently supported")
            m = hashlib.md5()
            m.update(entry.msgid.encode('utf-8'))
            textflowId = m.hexdigest()
            """
            "extensions":[{"object-type":"pot-entry-header","context":"context",
            "references":["fff"],"extractedComment":"extractedComment",
            "flags":["java-format"]}]
            """
            extracted_comment = entry.comment
            references = entry.occurrences
            for ref in references:
                node = ref[0]+":"+ref[1]
                reflist.append(node)
            flags = entry.flags
            
            #extensions_single_comment = [{'object-type':'comment','value':'test','space':'preserve'}]
            #extensions_pot_entry_header = [{"object-type":"pot-entry-header","context":"context","references":["fff"],"extractedComment":"extractedComment","flags":["java-format"]}]

            extensions=[{'object-type':'comment','value':extracted_comment,'space':'preserve'}, {"object-type":"pot-entry-header","context":"","references":reflist,"extractedComment":'',"flags":flags}]

            textflow = {'id': textflowId, 'lang':'en-US', 'content':entry.msgid, 'extensions':extensions, 'revision':1}
            textflows.append(textflow)
        return textflows
    
    def create_txtflowtarget(self, pofile):
        """
        Convert the content of the po file to a list of textflowtarget.
        @return: the dictionary object of textflow
        """
        obs_list=pofile.obsolete_entries()
        textflowtargets = []
        
        for entry in pofile:
            if entry in obs_list:
                continue
            m = hashlib.md5()
            m.update(entry.msgid.encode('utf-8'))
            textflowId = m.hexdigest()
            comment = entry.comment
            
            if entry.msgstr:
                state = "Approved"
            else:
                state = "New"
            #need judge for fuzzy state
            
            #create extensions
            extensions = [{"object-type":"comment","value":comment,"space":"preserve"}]
            
            # {"resId":"782f49c4e93c32403ba0b51821b38b90","state":"Approved","translator":{"email":"id","name":"name"},"content":"title:
            # ttff","extensions":[{"object-type":"comment","value":"testcomment","space":"preserve"}]}
            # Diable the translator to avoid issues on server side
            textflowtarget = {'resId': textflowId, 'state': state, 'content':entry.msgstr,'extensions':extensions}
            
            #Temporary fill in the admin info for translator to pass the validation, waiting for server side change
            textflowtargets.append(textflowtarget)
        
        return textflowtargets

    def create_extensions(self, pofile, object_type):
        """
        "extensions":[{"object-type":"po-header","comment":"comment_value", "entries":[{"key":"h1","value":"v1"}]}]
        "extensions":[{"object-type":"po-target-header", "comment":"comment_value", "entries":[{"key":"ht","value":"vt1"}]}]
        """
        entries = []
        metadatas = pofile.ordered_metadata()
        for item in metadatas:
            entry = {"key":item[0], "value":item[1]}
            entries.append(entry)
       
        extensions = [{"object-type":object_type,"comment":pofile.header, "entries":entries}]
        return extensions

    def create_pofile(self, path):
        """
        Convert the po file to a pofile object in polib.
        @return: pofile object
        """
        try:
            po = polib.pofile(path)
        except Exception:
            self.log.error("Can not processing the po file")
            sys.exit()

        return po

#.........這裏部分代碼省略.........
開發者ID:seanf,項目名稱:zanata-python-client,代碼行數:103,代碼來源:publicanutil.py


注:本文中的zanatalib.logger.Logger.warn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。