def find_russian_need_vowels(find_accents, cattype, direcfile, save,
    verbose, startFrom, upTo):
  if direcfile:
    processing_lines = []
    for line in codecs.open(direcfile, "r", encoding="utf-8"):
      line = line.strip()
      m = re.match(r"^(Page [^ ]+ )(.*?)(: .*?:) Processing: (\{\{.*?\}\})( <- \{\{.*?\}\} \(\{\{.*?\}\}\))$",
          line)
      if m:
        processing_lines.append(m.groups())

    for current, index in blib.iter_pages(processing_lines, startFrom, upTo,
        # key is the page name
        key = lambda x:x[1]):

      pagenum, pagename, tempname, repltext, rest = current

      def pagemsg(text):
        msg("Page %s(%s) %s: %s" % (pagenum, index, pagetitle, text))
      def check_template_for_missing_accent(pagetitle, index, template,
          ruparam, trparam):
        def output_line(directive):
          msg("* %s[[%s]]%s %s: <nowiki>%s%s</nowiki>" % (pagenum, pagename,
              tempname, directive, unicode(template), rest))
        return process_template(pagetitle, index, template, ruparam, trparam,
            output_line, find_accents, verbose)

      blib.process_links(save, verbose, "ru", "Russian", "pagetext", None,
          None, check_template_for_missing_accent,
          join_actions=join_changelog_notes, split_templates=None,
          pages_to_do=[(pagename, repltext)], quiet=True)
      if index % 100 == 0:
        output_stats(pagemsg)
  else:
    def check_template_for_missing_accent(pagetitle, index, template,
        ruparam, trparam):
      def pagemsg(text):
        msg("Page %s %s: %s" % (index, pagetitle, text))
      def output_line(directive):
        pagemsg("%s: %s" % (directive, unicode(template)))
      result = process_template(pagetitle, index, template, ruparam, trparam,
          output_line, find_accents, verbose)
      if index % 100 == 0:
        output_stats(pagemsg)
      return result

    blib.process_links(save, verbose, "ru", "Russian", cattype, startFrom,
        upTo, check_template_for_missing_accent,
        join_actions=join_changelog_notes, split_templates=None)
Esempio n. 2
0
def canon_links(save, verbose, cattype, startFrom, upTo, pages_to_do=[]):
  def process_param(pagetitle, index, template, param, paramtr):
    result = canon_param(pagetitle, index, template, param, paramtr,
        include_tempname_in_changelog=True)
    if getparam(template, "sc") == "Arab":
      tname = unicode(template.name)
      if show_template and result == False:
        msg("Page %s %s: %s.%s: Processing %s" % (index,
          pagetitle, tname, "sc", unicode(template)))
      msg("Page %s %s: %s.%s: Removing sc=Arab" % (index,
        pagetitle, tname, "sc"))
      oldtempl = "%s" % unicode(template)
      template.remove("sc")
      msg("Page %s %s: Replaced %s with %s" %
          (index, pagetitle, oldtempl, unicode(template)))
      newresult = ["remove %s.sc=Arab" % tname]
      if result != False:
        result = result + newresult
      else:
        result = newresult
    return result

  return blib.process_links(save, verbose, "ar", "Arabic", cattype,
      startFrom, upTo, process_param, sort_group_changelogs,
      pages_to_do=pages_to_do, split_templates=u"[,،/]")
Esempio n. 3
0
def canon_links(save, verbose, cattype, lang, longlang, script,
    translit_module, startFrom, upTo, pages_to_do=[]):
  if not isinstance(script, list):
    script = [script]
  def process_param(pagetitle, index, template, param, paramtr):
    result = canon_param(pagetitle, index, template, param, paramtr,
        translit_module, include_tempname_in_changelog=True)
    scvalue = getparam(template, "sc")
    if scvalue in script:
      tname = unicode(template.name)
      if show_template and result == False:
        msg("Page %s %s: %s.%s: Processing %s" % (index,
          pagetitle, tname, "sc", unicode(template)))
      msg("Page %s %s: %s.%s: Removing sc=%s" % (index,
        pagetitle, tname, "sc", scvalue))
      oldtempl = "%s" % unicode(template)
      template.remove("sc")
      msg("Page %s %s: Replaced %s with %s" %
          (index, pagetitle, oldtempl, unicode(template)))
      newresult = ["remove %s.sc=%s" % (tname, scvalue)]
      if result != False:
        result = result + newresult
      else:
        result = newresult
    return result

  return blib.process_links(save, verbose, lang, longlang, cattype,
      startFrom, upTo, process_param, sort_group_changelogs,
      pages_to_do=pages_to_do)
Esempio n. 4
0
def vocalize_links(save, verbose, cattype, startFrom, upTo):
  def process_param(pagetitle, index, template, param, paramtr):
    result = vocalize_param(pagetitle, index, template, param, paramtr)
    if isinstance(result, basestring):
      result = ["%s (%s)" % (result, template.name)]
    return result
  def join_actions(actions):
    return "vocalize links: %s" % '; '.join(actions)

  return blib.process_links(save, verbose, "ar", "Arabic", cattype,
      startFrom, upTo, process_param, join_actions)
Esempio n. 5
0
def vocalize_links(save, verbose, cattype, startFrom, upTo):
    def process_param(pagetitle, index, pagetext, template, tlang, param,
                      paramtr):
        result = vocalize_param(pagetitle, index, template, param, paramtr)
        if isinstance(result, basestring):
            result = ["%s (%s)" % (result, template.name)]
        return result

    def join_actions(actions):
        return "vocalize links: %s" % '; '.join(actions)

    return blib.process_links(save, verbose, "ar", "Arabic", cattype,
                              startFrom, upTo, process_param, join_actions)
Esempio n. 6
0
def process_links(save, verbose, cattype, startFrom, upTo):
  def do_process_param(pagetitle, index, template, param, paramtr):
    result = process_param(pagetitle, index, template, param, paramtr,
        include_tempname_in_changelog=True)
    if getparam(template, "sc") == "Arab":
      msg("Page %s %s: %s.%s: Removing sc=Arab" % (index, pagetitle,
        template.name, "sc"))
      oldtempl = "%s" % unicode(template)
      template.remove("sc")
      msg("Page %s %s: Replaced %s with %s" %
          (index, pagetitle, oldtempl, unicode(template)))
      newresult = ["remove %s.sc=Arab" % template.name]
      if isinstance(result, list):
        result = result + newresult
      else:
        result = newresult
    return result
  return blib.process_links(save, verbose, "ar", "Arabic", cattype,
      startFrom, upTo, do_process_param, sort_group_changelogs)
Esempio n. 7
0
def process_links(save, verbose, cattype, startFrom, upTo):
  def do_process_param(pagetitle, index, pagetext, template, templang, param, paramtr):
    result = process_param(pagetitle, index, template, param, paramtr,
        include_tempname_in_changelog=True)
    if getparam(template, "sc") == "Arab":
      msg("Page %s %s: %s.%s: Removing sc=Arab" % (index, pagetitle,
        template.name, "sc"))
      oldtempl = "%s" % unicode(template)
      template.remove("sc")
      msg("Page %s %s: Replaced %s with %s" %
          (index, pagetitle, oldtempl, unicode(template)))
      newresult = ["remove %s.sc=Arab" % template.name]
      if isinstance(result, list):
        result = result + newresult
      else:
        result = newresult
    return result
  return blib.process_links(save, verbose, "ar", "Arabic", cattype,
      startFrom, upTo, do_process_param, sort_group_changelogs)
Esempio n. 8
0
def canon_links(save, verbose, cattype, lang, longlang,
    startFrom, upTo, pages_to_do=[]):
  def process_param(pagetitle, index, pagetext, template, tlang, param, paramtr):
    def pagemsg(txt):
      msg("Page %s %s: %s" % (index, pagetitle, txt))

    def expand_text(tempcall):
      return blib.expand_text(tempcall, pagetitle, pagemsg, verbose)

    result = canon_param(pagetitle, index, template, tlang, param, paramtr,
        pagemsg, expand_text, include_tempname_in_changelog=True)
    scvalue = getparam(template, "sc")
    if scvalue:
      if isinstance(param, list):
        fromparam, toparam = param
      else:
        fromparam, toparam = (param, param)
      foreign = (pagetitle if fromparam == "page title" else
        getparam(template, fromparam))
      predicted_script = expand_text("{{#invoke:scripts/templates|findBestScript|%s|%s}}"
          % (foreign, tlang))
      if scvalue == predicted_script:
        tname = unicode(template.name)
        if show_template and result == False:
          pagemsg("%s.%s.%s: Processing %s" % (
            tname, tlang, "sc", unicode(template)))
        pagemsg("%s.%s.%s: Removing sc=%s" % (
          tname, tlang, "sc", scvalue))
        oldtempl = "%s" % unicode(template)
        template.remove("sc")
        pagemsg("Replaced %s with %s" % (oldtempl, unicode(template)))
        newresult = ["remove %s.%s.sc=%s" % (tname, tlang, scvalue)]
        if result != False:
          result = result + newresult
        else:
          result = newresult
    return result

  return blib.process_links(save, verbose, lang, longlang, cattype,
      startFrom, upTo, process_param, sort_group_changelogs,
      pages_to_do=pages_to_do)
Esempio n. 9
0
def canon_links(save, verbose, cattype, startFrom, upTo, pages_to_do=[]):
    def process_param(pagetitle, index, pagetext, template, tlang, param,
                      paramtr):
        result = canon_param(pagetitle,
                             index,
                             template,
                             param,
                             paramtr,
                             include_tempname_in_changelog=True)
        if getparam(template, "sc") == "Arab":
            tname = unicode(template.name)
            if show_template and result == False:
                msg("Page %s %s: %s.%s: Processing %s" %
                    (index, pagetitle, tname, "sc", unicode(template)))
            msg("Page %s %s: %s.%s: Removing sc=Arab" %
                (index, pagetitle, tname, "sc"))
            oldtempl = "%s" % unicode(template)
            template.remove("sc")
            msg("Page %s %s: Replaced %s with %s" %
                (index, pagetitle, oldtempl, unicode(template)))
            newresult = ["remove %s.sc=Arab" % tname]
            if result != False:
                result = result + newresult
            else:
                result = newresult
        return result

    return blib.process_links(save,
                              verbose,
                              "ar",
                              "Arabic",
                              cattype,
                              startFrom,
                              upTo,
                              process_param,
                              sort_group_changelogs,
                              pages_to_do=pages_to_do,
                              split_templates=u"[,،/]")