def GetDefaultCommandAsMacro(cmd, charIndex, page, slot):
    from macro import Macro, MacroLine

    # Initialize the default macro to None,
    #  in case we don't find the desired command.
    defaultMacro = None

    # Try to get the default command from the local dictionary.
    defaultCommand = DEFAULTCOMMANDS.get(cmd)
    # If it's not one of the default commands here,
    #  check if it's a skill in the skillInfo dictionary
    #  and create a macro from that.
    if not defaultCommand:
        skillInfo = GetSkillInfo(cmd, False)
        if skillInfo:
            defaultMacro = Macro(charIndex, page, slot)
            defaultMacro.name = cmd
            defaultMacro.icon = skillInfo.icon
            if not defaultMacro.icon.startswith("SPELLICON_"):
                defaultMacro.icon = "icons/%s" % defaultMacro.icon
            defaultMacro.description = skillInfo.name
            defaultMacro.appendMacroLine(MacroLine(command="/skill %s" % cmd))
    else:
        defaultMacro = Macro(charIndex, page, slot)
        defaultMacro.name = defaultCommand.name
        defaultMacro.icon = defaultCommand.icon
        if not defaultMacro.icon.startswith("SPELLICON_"):
            defaultMacro.icon = "icons/%s" % defaultMacro.icon
        defaultMacro.description = defaultCommand.tooltip
        defaultMacro.appendMacroLine(MacroLine(command=defaultCommand.command))

    # Return the default macro.
    return defaultMacro
Beispiel #2
0
def GetDefaultCommandAsMacro(cmd, charIndex, page, slot):
    from macro import Macro, MacroLine

    # Initialize the default macro to None,
    #  in case we don't find the desired command.
    defaultMacro = None

    # Try to get the default command from the local dictionary.
    defaultCommand = DEFAULTCOMMANDS.get(cmd)
    # If it's not one of the default commands here,
    #  check if it's a skill in the skillInfo dictionary
    #  and create a macro from that.
    if not defaultCommand:
        skillInfo = GetSkillInfo(cmd, False)
        if skillInfo:
            defaultMacro = Macro(charIndex, page, slot)
            defaultMacro.name = cmd
            defaultMacro.icon = skillInfo.icon
            if not defaultMacro.icon.startswith('SPELLICON_'):
                defaultMacro.icon = 'icons/%s' % defaultMacro.icon
            defaultMacro.description = skillInfo.name
            defaultMacro.appendMacroLine(MacroLine(command='/skill %s' % cmd))
    else:
        defaultMacro = Macro(charIndex, page, slot)
        defaultMacro.name = defaultCommand.name
        defaultMacro.icon = defaultCommand.icon
        if not defaultMacro.icon.startswith('SPELLICON_'):
            defaultMacro.icon = 'icons/%s' % defaultMacro.icon
        defaultMacro.description = defaultCommand.tooltip
        defaultMacro.appendMacroLine(MacroLine(command=defaultCommand.command))

    # Return the default macro.
    return defaultMacro
Beispiel #3
0
    def createMacro(self):
        newMacro = Macro(self.charIndex, self.page, self.slot)
        newMacro.name = self.guiName.getValue()
        newMacro.description = self.guiToolTip.getValue()
        hotkey = self.guiHotkey.getValue()
        if hotkey == 'None':
            newMacro.hotkey = ''
        else:
            newMacro.hotkey = hotkey
        newMacro.icon = self.icon
        newMacro.waitAll = int(self.guiWaitAll.getValue()) == 1
        try:
            manualDelay = int(self.guiManualDelay.getValue)
            if manualDelay < 0:
                manualDelay = 0
        except:
            manualDelay = 0
        newMacro.manualDelay = manualDelay

        for lineIndex in xrange(10):
            lineCommand = self.guiLines[lineIndex].getValue().lstrip().rstrip()
            mandatory = int(self.guiMandatory[lineIndex].getValue()) == 1
            try:
                lineDelay = int(self.guiDelays[lineIndex].getValue())
                if lineDelay < 0:
                    lineDelay = 0
            except:
                lineDelay = 0
            if not lineCommand and not lineDelay:
                continue
            newMacroLine = MacroLine(lineCommand, mandatory, lineDelay)
            newMacro.insertMacroLine(lineIndex, newMacroLine)

        if newMacro.macroLineNum == 0:
            del newMacro
            return None

        return newMacro
 def createMacro(self):
     newMacro = Macro(self.charIndex,self.page,self.slot)
     newMacro.name = self.guiName.getValue()
     newMacro.description = self.guiToolTip.getValue()
     hotkey = self.guiHotkey.getValue()
     if hotkey == 'None':
         newMacro.hotkey = ''
     else:
         newMacro.hotkey = hotkey
     newMacro.icon = self.icon
     newMacro.waitAll = int(self.guiWaitAll.getValue()) == 1
     try:
         manualDelay = int(self.guiManualDelay.getValue)
         if manualDelay < 0:
             manualDelay = 0
     except:
         manualDelay = 0
     newMacro.manualDelay = manualDelay
     
     for lineIndex in xrange(10):
         lineCommand = self.guiLines[lineIndex].getValue().lstrip().rstrip()
         mandatory = int(self.guiMandatory[lineIndex].getValue()) == 1
         try:
             lineDelay = int(self.guiDelays[lineIndex].getValue())
             if lineDelay < 0:
                 lineDelay = 0
         except:
             lineDelay = 0
         if not lineCommand and not lineDelay:
             continue
         newMacroLine = MacroLine(lineCommand,mandatory,lineDelay)
         newMacro.insertMacroLine(lineIndex,newMacroLine)
     
     if newMacro.macroLineNum == 0:
         del newMacro
         return None
     
     return newMacro
  for i in range(len(line)):
    if not line[i].isspace():
      break
  return i

if len(sys.argv) != 3:
  raise Exception("invalid command line syntax: %s" % ' '.join(map(repr, sys.argv)))
(m4File,outFile) = sys.argv[1:]
assert outFile != m4File
m = Macro(m4File, computeSerialNumber=True)
for i in range(len(m.description)):
  para = m.description[i]
  if para[0][0].isspace():
    spaces = min(list(map(countSpaces, para)))
    if spaces > 1:
      m.description[i] = ['  ' + l[spaces:] for l in para]
url = "https://www.gnu.org/software/autoconf-archive/%s.html" % m.name
lineLen = max(len(url) + 2, 75)
m.url = "# %s\n# %s\n# %s" % ('=' * lineLen, (' ' * int((lineLen - len(url)) / 2)) + url, '=' * lineLen)
if m.__dict__.get("obsolete"):
  m.obsolete = "# OBSOLETE MACRO\n#\n" + '\n#\n'.join(map(formatParagraph, m.obsolete)) + "\n#\n"
else:
  m.obsolete = ""
m.synopsis = "\n".join([ "#   %s" % l for l in m.synopsis ])
m.description = '\n#\n'.join(map(formatParagraph, m.description))
m.authors = "\n".join(map(formatAuthor, m.authors))
m.license = '\n#\n'.join(map(formatParagraph, m.license))
m.body = '\n'.join(m.body)

writeFile(outFile, tmpl % m.__dict__)
Beispiel #6
0

if len(sys.argv) != 3:
    raise Exception("invalid command line syntax: %s" %
                    ' '.join(map(repr, sys.argv)))
(m4File, outFile) = sys.argv[1:]
assert outFile != m4File
m = Macro(m4File, computeSerialNumber=True)
for i in range(len(m.description)):
    para = m.description[i]
    if para[0][0].isspace():
        spaces = min(list(map(countSpaces, para)))
        if spaces > 1:
            m.description[i] = ['  ' + l[spaces:] for l in para]
url = "http://www.gnu.org/software/autoconf-archive/%s.html" % m.name
lineLen = max(len(url) + 2, 75)
m.url = "# %s\n# %s\n# %s" % ('=' * lineLen, (' ' * int(
    (lineLen - len(url)) / 2)) + url, '=' * lineLen)
if m.__dict__.get("obsolete"):
    m.obsolete = "# OBSOLETE MACRO\n#\n" + '\n#\n'.join(
        map(formatParagraph, m.obsolete)) + "\n#\n"
else:
    m.obsolete = ""
m.synopsis = "\n".join(["#   %s" % l for l in m.synopsis])
m.description = '\n#\n'.join(map(formatParagraph, m.description))
m.authors = "\n".join(map(formatAuthor, m.authors))
m.license = '\n#\n'.join(map(formatParagraph, m.license))
m.body = '\n'.join(m.body)

writeFile(outFile, tmpl % m.__dict__)
Beispiel #7
0
        return "@smallexample\n%s\n@end smallexample" % quoteTexi(
            '\n'.join(para))
    else:
        return quoteTexi('\n'.join(para))


def formatAuthor(a):
    assert a
    a["year"] = quoteTexi(a["year"])
    a["name"] = quoteTexi(a["name"])
    if "email" in a:
        a["email"] = quoteTexi(a["email"])
        return "Copyright @copyright{} %(year)s %(name)s @email{%(email)s}" % a
    else:
        return "Copyright @copyright{} %(year)s %(name)s" % a


if len(sys.argv) != 3:
    raise Exception("invalid command line syntax: %s" %
                    ' '.join(map(repr, sys.argv)))
(m4File, outFile) = sys.argv[1:]
assert outFile != m4File
m = Macro(m4File)
m.synopsis = "@smallexample\n%s\n@end smallexample" % "\n".join(
    map(quoteTexi, m.synopsis))
m.description = '\n\n'.join(map(formatParagraph, m.description))
m.description = m.description.replace("@end smallexample\n@smallexample", "\n")
m.authors = " @* ".join(["@w{%s}" % formatAuthor(a) for a in m.authors])
m.license = "\n\n".join(map(formatParagraph, m.license))
writeFile(outFile, tmpl % m.__dict__)