Constrói uma :class:`RespostaExtrairLogs` a partir do retorno
        informado.

        :param unicode retorno: Retorno da função ``ExtrairLogs``.
328906
def analisar(retorno):
        
        resposta = analisar_retorno(forcar_unicode(retorno),
                funcao='ExtrairLogs',
                classe_resposta=RespostaExtrairLogs,
                campos=RespostaSAT.CAMPOS + (
                        ('arquivoLog', unicode),
                    ),
                campos_alternativos=[
                        # se a extração dos logs falhar espera-se o padrão de
                        # campos no retorno...
                        RespostaSAT.CAMPOS,
                    ]
            )
        if resposta.EEEEE not in ('15000',):
            raise ExcecaoRespostaSAT(resposta)
        return resposta
1365896
def log(self, level, message, *args, **kwargs):
        
        extra = self.extras.copy()
        extra.update(kwargs.pop('extra', {}))

        kwargs['extra'] = extra
        self.logger.log(level, message, *args, **kwargs)
13445
def encode_quopri(msg):
    
    orig = msg.get_payload()
    encdata = _qencode(orig)
    msg.set_payload(encdata)
    msg['Content-Transfer-Encoding'] = 'quoted-printable'
1082388
def atualizar_software_sat(retorno):
        
        resposta = analisar_retorno(forcar_unicode(retorno),
                funcao='AtualizarSoftwareSAT')
        if resposta.EEEEE not in ('14000',):
            raise ExcecaoRespostaSAT(resposta)
        return resposta
1106417
def trocar_codigo_de_ativacao(self, novo_codigo_ativacao,
            opcao=constantes.CODIGO_ATIVACAO_REGULAR,
            codigo_emergencia=None):
        
        resp = self._http_post('trocarcodigodeativacao',
                novo_codigo_ativacao=novo_codigo_ativacao,
                opcao=opcao,
                codigo_emergencia=codigo_emergencia)
        conteudo = resp.json()
        return RespostaSAT.trocar_codigo_de_ativacao(conteudo.get('retorno'))
906813
def parse(self):
        """"""

        self.verbose = bool(self.re_verbose)
        self.unicode = bool(self.re_unicode)
        self.global_flag_swap = {
            "unicode": ((self.re_unicode is not None) if not _util.PY37 else False),
            "verbose": False
        }
        self.temp_global_flag_swap = {
            "unicode": False,
            "verbose": False
        }
        self.ascii = self.re_unicode is not None and not self.re_unicode
        if not self.unicode and not self.ascii:
            self.unicode = True

        new_pattern = []
        text = self.process_quotes(self.search.decode('latin-1') if self.is_bytes else self.search)

        i = _util.StringIter(text)
        iter(i)

        retry = True
        while retry:
            retry = False
            try:
                new_pattern = self.main_group(i)
            except GlobalRetryException:
                # Prevent a loop of retry over and over for a pattern like ((?u)(?a))
                # or (?-x:(?x))
                if self.temp_global_flag_swap['unicode']:
                    if self.global_flag_swap['unicode']:
                        raise LoopException('Global unicode flag recursion.')
                    else:
                        self.global_flag_swap["unicode"] = True
                if self.temp_global_flag_swap['verbose']:
                    if self.global_flag_swap['verbose']:
                        raise LoopException('Global verbose flag recursion.')
                    else:
                        self.global_flag_swap['verbose'] = True
                self.temp_global_flag_swap = {
                    "unicode": False,
                    "verbose": False
                }
                i.rewind(i.index)
                retry = True

        return "".join(new_pattern).encode('latin-1') if self.is_bytes else "".join(new_pattern)
940752
def _AddUnicodeMethod(unused_message_descriptor, cls):
  """"""

  def __unicode__(self):
    return text_format.MessageToString(self, as_utf8=True).decode('utf-8')
  cls.__unicode__ = __unicode__
996928
def get_token_from_utf8(self, lineno, col_offset):
    
    return self.get_token(lineno, self._line_numbers.from_utf8_col(lineno, col_offset))
1284823
def configurar_interface_de_rede(self, configuracao):
        
        resp = self._http_post('configurarinterfacederede',
                configuracao=configuracao.documento())
        conteudo = resp.json()
        return RespostaSAT.configurar_interface_de_rede(conteudo.get('retorno'))
336572
def _non_unicode_repr(objekt, context, maxlevels, level):
    
    repr_string, isreadable, isrecursive = pprint._safe_repr(objekt, context,
                                                             maxlevels, level)
    if repr_string.startswith('u"') or repr_string.startswith("u'"):
        repr_string = repr_string[1:]
    return repr_string, isreadable, isrecursive
397005
def bloquear_sat(retorno):
        
        resposta = analisar_retorno(forcar_unicode(retorno),
                funcao='BloquearSAT')
        if resposta.EEEEE not in ('16000',):
            raise ExcecaoRespostaSAT(resposta)
        return resposta
486132
def _make_reserved_tokens_re(reserved_tokens):
  """"""
  if not reserved_tokens:
    return None
  escaped_tokens = [_re_escape(rt) for rt in reserved_tokens]
  pattern = "(%s)" % "|".join(escaped_tokens)
  reserved_tokens_re = _re_compile(pattern)
  return reserved_tokens_re
623488
def _unicode(ctx, text):
    
    text = conversions.to_string(text, ctx)
    if len(text) == 0:
        raise ValueError("Text can't be empty")
    return ord(text[0])
979283
def by_issn(issn):
    
    # monkeypatched to allow search in NTK's Aleph
    old_url = aleph.ALEPH_URL
    aleph.ALEPH_URL = NTK_ALEPH_URL
    records = aleph.getISSNsXML(issn, base="STK02")
    aleph.ALEPH_URL = old_url

    # process all records
    for record in records:
        marc = MARCXMLRecord(record)

        # following values were requested by @bjackova in
        # https://github.com/WebArchivCZ/WA-KAT/issues/66
        additional_info = {
            "222": marc.get("222", None),
            "PER": marc.get("PER", None),
            "776": marc.get("776", None),
            "008": marc.get("008", None),
            "alt_end_date": ""  # just reminder that it is filled later
        }
        additional_info = {
            key: val
            for key, val in additional_info.iteritems()
            if val
        }

        # check whether there is alternative date in 008
        alt_end_date = None
        alt_creation_date = None
        if additional_info["008"]:
            # 131114c20139999xr-q||p|s||||||---a0eng-c -> 2013
            alt_creation_date = additional_info["008"][7:11]

            # 131114c20139999xr-q||p|s||||||---a0eng-c -> 9999
            alt_end_date = additional_info["008"][11:15]
            if alt_end_date in ["9999", "****"]:
                alt_creation_date += "-"  # library convention is xxxx-
                alt_end_date = None

            additional_info["alt_end_date"] = alt_end_date

        # parse author
        author = Author.parse_author(marc)

        model = Model(
            url=_first_or_none(
                marc.get("856u")
            ),
            conspect=_first_or_none(
                marc.get("072a")
            ),
            annotation_tags=_first_or_none(
                marc.get("520a")
            ),
            periodicity=_first_or_none(
                marc.get("310a")
            ),
            title_tags=_first_or_none(
                marc.get("222a")
            ),
            subtitle_tags=_first_or_none(
                marc.get("245b")
            ),
            place_tags=remove_hairs(
                _first_or_none(marc.get("260a")) or ""
            ),
            author_tags=author._asdict() if author else None,
            publisher_tags=remove_hairs(
                (
                    _first_or_none(marc.get("260b")) or
                    _first_or_none(marc.get("264b")) or
                    "",
                ),
                ", "
            ),
            creation_dates=_first_or_none(
                marc.get("260c", [alt_creation_date])
            ),
            lang_tags=_first_or_none(
                marc.get("040b")
            ),
            keyword_tags=marc.get("650a07"),
            source_info=_first_or_none(
                marc.get("500a")
            ),
            original_xml=record,
            additional_info=additional_info,
        )

        yield _add_source(model)
869218
def po_to_unicode(po_obj):
    
    po_text = po_obj.__str__()
    if type(po_text) != types.UnicodeType:
        po_text = po_text.decode('utf-8')
    
    return po_text
211444
def _unicode_output(cursor, name, default_type, size, precision, scale):
    '''
    
    '''
    if default_type in (cx_Oracle.STRING, cx_Oracle.LONG_STRING,
                        cx_Oracle.FIXED_CHAR, cx_Oracle.CLOB):
        return cursor.var(six.text_type, size, cursor.arraysize)
37134
def format_log(ret):
    '''
    
    '''
    msg = ''
    if isinstance(ret, dict):
        # Looks like the ret may be a valid state return
        if 'changes' in ret:
            # Yep, looks like a valid state return
            chg = ret['changes']
            if not chg:
                if ret['comment']:
                    msg = ret['comment']
                else:
                    msg = 'No changes made for {0[name]}'.format(ret)
            elif isinstance(chg, dict):
                if 'diff' in chg:
                    if isinstance(chg['diff'], six.string_types):
                        msg = 'File changed:\n{0}'.format(chg['diff'])
                if all([isinstance(x, dict) for x in six.itervalues(chg)]):
                    if all([('old' in x and 'new' in x)
                            for x in six.itervalues(chg)]):
                        msg = 'Made the following changes:\n'
                        for pkg in chg:
                            old = chg[pkg]['old']
                            if not old and old not in (False, None):
                                old = 'absent'
                            new = chg[pkg]['new']
                            if not new and new not in (False, None):
                                new = 'absent'
                            # This must be able to handle unicode as some package names contain
                            # non-ascii characters like "Français" or "Español". See Issue #33605.
                            msg += '\'{0}\' changed from \'{1}\' to \'{2}\'\n'.format(pkg, old, new)
            if not msg:
                msg = six.text_type(ret['changes'])
            if ret['result'] is True or ret['result'] is None:
                log.info(msg)
            else:
                log.error(msg)
    else:
        # catch unhandled data
        log.info(six.text_type(ret))