Beispiel #1
0
def read_rotation_data():
    rotations = []


    fully_supported = {}
    outdated = {}
    generated = {}

    for class_name_lower, spec_names in SUPPORTED_SPECS.iteritems():
        class_name = class_name_lower.title()
        for spec_name_lower in spec_names:
            spec_name = spec_name_lower.title()
            meta = parse_rotation_meta(class_name_lower, spec_name_lower)
            if "generated_from" in meta.keys():
                if class_name not in generated.keys():
                    generated[class_name] = []
                generated[class_name].append("%s (%s)" % (spec_name, meta["version"] ))
            elif meta["version"] == WOW_VERSION:
                if class_name not in fully_supported.keys():
                    fully_supported[class_name] = []
                fully_supported[class_name].append(spec_name)
            else:
                if class_name not in fully_supported.keys():
                    outdated[class_name] = []
                outdated[class_name].append("%s (%s)" % (spec_name, meta["version"] ))
    rotation_data = "**Fully Supported in %s:**\n\n" % WOW_VERSION
    if fully_supported.keys() == []:
        rotation_data = rotation_data + "None\n\n"
    else:
        for class_name in sorted(fully_supported.keys()):
            spec_names = sorted(fully_supported[class_name])
            rotation_data = "%s* %s: %s\n" % (rotation_data, class_name, ", ".join(spec_names))
        rotation_data = rotation_data + "\n"

    if len(outdated.keys()) > 0:
        rotation_data = rotation_data + "**Outdated Rotations:**\n\n"
        for class_name in sorted(outdated.keys()):
            spec_names = sorted(outdated[class_name])
            rotation_data = "%s* %s: %s\n" % (rotation_data, class_name, ", ".join(spec_names))
        rotation_data = rotation_data + "\n"

    if len(generated.keys()) > 0:
        rotation_data = rotation_data + "**Automatically Generated Rotations:**\n_(Might not be fully functional)_\n\n"
        for class_name in sorted(generated.keys()):
            spec_names = sorted(generated[class_name])
            rotation_data = "%s* %s: %s\n" % (rotation_data, class_name, ", ".join(spec_names))
        rotation_data = rotation_data + "\n"
    return rotation_data
Beispiel #2
0
    def __init__(self, class_name, validate=False, ignore_validation_errors=True):
        if class_name not in SUPPORTED_SPECS.keys():
            raise KpsError("Unknown class: '%s'" % class_name)
        self.class_name = class_name

        file_name = os.path.dirname(os.path.abspath(__file__)) + "/../rotations/" + class_name + ".lua"
        LOG.info("Parsing PlayerEnv in '%s'", file_name)
        line_nr = 0
        try:
            for line in open(file_name).read().split("\n"):
                line_nr = line_nr + 1
                # function kps.env.warlock.isHavocUnit(unit)
                match = re.match(r'.*function\s*kps\.env\..*\.([a-zA-Z]*)\(.*', line)
                if match:
                    function_name = match.group(1)

                    if function_name in self.keys():
                        LOG.warn("%s.lua:%3s - %s DUPLICATE of %s", class_name, line_nr, line, self[function_name])
                    else:
                        self[function_name] = line_nr
        except IOError,e:
            LOG.error("Couldn't parse '%s': %s", file_name, str(e))
Beispiel #3
0
    def __init__(self, class_name, validate=False, ignore_validation_errors=True):
        if class_name not in SUPPORTED_SPECS.keys():
            raise KpsError("Unknown class: '%s'" % class_name)
        self.class_name = class_name

        file_name = os.path.dirname(os.path.abspath(__file__)) + "/../rotations/" + class_name + ".lua"
        LOG.info("Parsing PlayerEnv in '%s'", file_name)
        line_nr = 0
        try:
            for line in open(file_name).read().split("\n"):
                line_nr = line_nr + 1
                # function kps.env.warlock.isHavocUnit(unit)
                match = re.match(r'.*function\s*kps\.env\..*\.([a-zA-Z]*)\(.*', line)
                if match:
                    function_name = match.group(1)

                    if function_name in self.keys():
                        LOG.warn("%s.lua:%3s - %s DUPLICATE of %s", class_name, line_nr, line, self[function_name])
                    else:
                        self[function_name] = line_nr
        except IOError,e:
            LOG.error("Couldn't parse '%s': %s", file_name, str(e))
Beispiel #4
0
 def __init__(self, class_name, validate=False, ignore_validation_errors=True):
     if class_name not in SUPPORTED_SPECS.keys():
         raise KpsError("Unknown class: '%s'" % class_name)
     self.class_name = class_name
     self.__player_spells = {}
     spell_ids_found = {}
     def is_spell_duplicate(spell_id, currentLine):
         if spell_id in spell_ids_found.keys():
             return int(spell_ids_found[spell_id])
         else:
             spell_ids_found[spell_id] = currentLine
             return 0
     file_name = os.path.dirname(os.path.abspath(__file__)) + "/../rotations/" + class_name + ".lua"
     LOG.info("Parsing PlayerSpells in '%s'", file_name)
     line_nr = 0
     try:
         for line in open(file_name).read().split("\n"):
             line_nr = line_nr + 1
             match = re.match(r'kps\.spells\..*\.([a-zA-Z]*)\s*.*kps.Spell.fromId\((\d*)\).*', line)
             if match:
                 spell_key = match.group(1)
                 spell_id = int(match.group(2))
                 if is_spell_duplicate(spell_id, line_nr) > 0:
                     LOG.warn("%s.lua:%3s - %s DUPLICATE OF %s", class_name, line_nr, line, is_spell_duplicate(spell_id,line_nr))
                     self.__player_spells[spell_key] = spell
                 else:
                     if ignore_validation_errors:
                         try:
                             spell = Spell(spell_id, "kps.spells.%s.%s" % (class_name, spell_key), validate=validate)
                             LOG.debug("%s", spell)
                         except SpellError:
                             LOG.warn("%s.lua:%3s - %s INVALID SPELL ID %d", class_name, line_nr, line, spell_id)
                     else:
                         spell = Spell(spell_id, "kps.spells.%s.%s" % (class_name, spell_key), validate=validate)
                         LOG.debug("%s", spell)
                     self[spell_key] = spell
     except IOError,e:
         LOG.error("Couldn't parse '%s': %s", file_name, str(e))
Beispiel #5
0
 def __init__(self, class_name, validate=False, ignore_validation_errors=True):
     if class_name not in SUPPORTED_SPECS.keys():
         raise KpsError("Unknown class: '%s'" % class_name)
     self.class_name = class_name
     self.__player_spells = {}
     spell_ids_found = {}
     def is_spell_duplicate(spell_id, currentLine):
         if spell_id in spell_ids_found.keys():
             return int(spell_ids_found[spell_id])
         else:
             spell_ids_found[spell_id] = currentLine
             return 0
     file_name = os.path.dirname(os.path.abspath(__file__)) + "/../rotations/" + class_name + "_spells.lua"
     LOG.info("Parsing PlayerSpells in '%s'", file_name)
     line_nr = 0
     try:
         for line in open(file_name).read().split("\n"):
             line_nr = line_nr + 1
             match = re.match(r'kps\.spells\..*\.([a-zA-Z]*)\s*.*kps.Spell.fromId\((\d*)\).*', line)
             if match:
                 spell_key = match.group(1)
                 spell_id = int(match.group(2))
                 if is_spell_duplicate(spell_id, line_nr) > 0:
                     LOG.warn("%s.lua:%3s - %s DUPLICATE OF %s", class_name, line_nr, line, is_spell_duplicate(spell_id,line_nr))
                     self.__player_spells[spell_key] = spell
                 else:
                     if ignore_validation_errors:
                         try:
                             spell = Spell(spell_id, "kps.spells.%s.%s" % (class_name, spell_key), validate=validate)
                             LOG.debug("%s", spell)
                         except SpellError:
                             LOG.warn("%s.lua:%3s - %s INVALID SPELL ID %d", class_name, line_nr, line, spell_id)
                     else:
                         spell = Spell(spell_id, "kps.spells.%s.%s" % (class_name, spell_key), validate=validate)
                         LOG.debug("%s", spell)
                     self[spell_key] = spell
     except IOError,e:
         LOG.error("Couldn't parse '%s': %s", file_name, str(e))
Beispiel #6
0
@version %s
]]--\n""" %(self.kps_class.title(), self.kps_spec.title(), os.path.basename(self.filename), WOW_VERSION)
            header += "local spells = kps.spells.%s\n" % self.kps_class
            header += "local env = kps.env.%s\n\n" % self.kps_class
        else:
            header = "\n--GENERATED FROM SIMCRAFT PROFILE '%s'" % os.path.basename(self.filename)
        rota = """kps.rotations.register("%s","%s",\n{\n""" % (self.kps_class.upper(),self.kps_spec.upper())
        for r in simc.convert_to_action_list():
            rota += "%s\n" % r
        rota += """}\n,"%s")""" % self.kps_title
        return header + "\n" + rota + "\n"

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='SimC 2 KPS Rotation Converter')
    parser.add_argument('-p','--simc-profile', dest="simc", help='SimC Profile', required=True)
    parser.add_argument('-c','--kps-class', dest="kps_class", help='KPS Class', required=True, choices=SUPPORTED_SPECS.keys())
    parser.add_argument('-s','--kps-spec', dest="kps_spec", help='KPS Spec', required=True)
    parser.add_argument('-t','--title', help='KPS Rotation Title', default=None)
    group = parser.add_mutually_exclusive_group()
    group.add_argument('-o','--output', help='Output file (omit to print to stdout)', default=None)
    group.add_argument('-a','--append', help='Append file (omit to print to stdout)', default=None)
    args = setup_logging_and_get_args(parser)
    meta = parse_rotation_meta(args.kps_class, args.kps_spec)
    if "generated_from" in meta.keys():
        simc = SimCraftProfile(args.simc, args.kps_class, args.kps_spec, args.title)
        if args.output:
            open(args.output,"w").write(str(simc))
        elif args.append:
            simc.show_header = False
            open(args.append,"a").write(str(simc))
        else:
Beispiel #7
0
import argparse
import spells
from kps import setup_logging_and_get_args
from config import SUPPORTED_SPECS

# ****************************************************************
# * Checks Class Rotation Spells for outdated and duplicate Spells
# ****************************************************************

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description=
        'Checks Class Rotation Spells for outdated and duplicate Spells')
    parser.add_argument('-l',
                        '--limit',
                        help='Limit Analysation to given KPS Class',
                        required=False,
                        default=None,
                        choices=SUPPORTED_SPECS.keys())
    args = setup_logging_and_get_args(parser)
    if args.limit:
        spells.PlayerSpells(args.limit,
                            validate=True,
                            ignore_validation_errors=False)
    else:
        for wow_class in SUPPORTED_SPECS.keys():
            spells.PlayerSpells(wow_class,
                                validate=True,
                                ignore_validation_errors=False)
Beispiel #8
0
            LOG.error("ERROR: Spell-ID %s not found for %s", spell_id,
                      class_name)
    for class_spell in sorted(class_spells):
        s += class_spell
    return s


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description='Loads Class Spells from Wowhead')
    parser.add_argument('-c',
                        '--class',
                        dest='class_name',
                        help='Set the class to scan',
                        required=True,
                        choices=SUPPORTED_SPECS.keys())
    parser.add_argument(
        '-a',
        '--cache-age',
        dest='cache_age',
        help=
        'Set the max cache age in seconds (by default the class data is cached)',
        required=False,
        default=DEFAULT_CACHE_AGE_IN_SECONDS)
    parser.add_argument(
        '-s',
        '--summarize',
        help='List all found spells and show which one were filtered',
        required=False,
        action="store_true")
    parser.add_argument('-o',
Beispiel #9
0
            header += "local spells = kps.spells.%s\n" % self.kps_class
            header += "local env = kps.env.%s\n\n" % self.kps_class
        else:
            header = "\n--GENERATED FROM SIMCRAFT PROFILE '%s'" % os.path.basename(self.filename)
        rota = """kps.rotations.register("%s","%s",\n{\n""" % (self.kps_class.upper(), self.kps_spec.upper())
        for r in simc.convert_to_action_list():
            rota += "%s\n" % r
        rota += """}\n,"%s")""" % self.kps_title
        return header + "\n" + rota + "\n"


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="SimC 2 KPS Rotation Converter")
    parser.add_argument("-p", "--simc-profile", dest="simc", help="SimC Profile", required=True)
    parser.add_argument(
        "-c", "--kps-class", dest="kps_class", help="KPS Class", required=True, choices=SUPPORTED_SPECS.keys()
    )
    parser.add_argument("-s", "--kps-spec", dest="kps_spec", help="KPS Spec", required=True)
    parser.add_argument("-t", "--title", help="KPS Rotation Title", default=None)
    group = parser.add_mutually_exclusive_group()
    group.add_argument("-o", "--output", help="Output file (omit to print to stdout)", default=None)
    group.add_argument("-a", "--append", help="Append file (omit to print to stdout)", default=None)
    args = setup_logging_and_get_args(parser)
    simc = SimCraftProfile(args.simc, args.kps_class, args.kps_spec, args.title)
    if args.output:
        open(args.output, "w").write(str(simc))
    elif args.append:
        simc.show_header = False
        open(args.append, "a").write(str(simc))
    else:
        print simc
Beispiel #10
0
            class_spells.append("kps.spells.%s.%s = kps.Spell.fromId(%s)\n" % (class_name, spell.key, spell.id))
        except:
            LOG.error("ERROR: Spell-ID %s not found for %s", spell_id, class_name)
    for spell_id in ADDITIONAL_SPELLS[class_name]:
        try:
            spell = Spell(spell_id)
            class_spells.append("kps.spells.%s.%s = kps.Spell.fromId(%s)\n" % (class_name, spell.key, spell.id))
        except:
            LOG.error("ERROR: Spell-ID %s not found for %s", spell_id, class_name)
    for class_spell in sorted(class_spells):
        s += class_spell
    return s

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Loads Class Spells from Wowhead')
    parser.add_argument('-c','--class', dest='class_name', help='Set the class to scan', required=True, choices=SUPPORTED_SPECS.keys())
    parser.add_argument('-a','--cache-age', dest='cache_age', help='Set the max cache age in seconds (by default the class data is cached)', required=False, default=DEFAULT_CACHE_AGE_IN_SECONDS)
    parser.add_argument('-s','--summarize', help='List all found spells and show which one were filtered', required=False, action="store_true")
    parser.add_argument('-o','--output', help='Output file (omit to print to stdout)', default=None)
    args = setup_logging_and_get_args(parser)
    spells = extract_json_from_html(load_html_page(THOTTBOT_IDS[args.class_name], args.cache_age))

    outp = summarize(spells, args.class_name) if args.summarize else generate_lua(spells,args.class_name)

    if args.output:
        open(args.output,"w").write(outp)
    else:
        print outp


Beispiel #11
0
    for spell in spells:
        if not is_filtered(spell)[0]:
            s += "kps.spells.%s.%s = kps.Spell.fromId(%s)\n" % (class_name, spell_key(spell["name"][1:]), spell["id"])
    for spell_id in ADDITIONAL_SPELLS[class_name]:
        try:
            spell = Spell(spell_id)
            s += "kps.spells.%s.%s = kps.Spell.fromId(%s)\n" % (class_name, spell.key, spell.id)
        except:
            LOG.error("ERROR: Spell-ID %s not found for %s", spell_id, class_name)
    return s + "\nkps.env." + class_name + " = {}\n" + ENV_FUNCTIONS[class_name] + "\n"


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Loads Class Spells from Wowhead")
    parser.add_argument(
        "-c", "--class", dest="class_name", help="Set the class to scan", required=True, choices=SUPPORTED_SPECS.keys()
    )
    parser.add_argument(
        "-a",
        "--cache-age",
        dest="cache_age",
        help="Set the max cache age in seconds (by default the class data is cached)",
        required=False,
        default=DEFAULT_CACHE_AGE_IN_SECONDS,
    )
    parser.add_argument(
        "-s",
        "--summarize",
        help="List all found spells and show which one were filtered",
        required=False,
        action="store_true",
Beispiel #12
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import spells
from kps import setup_logging_and_get_args
from config import SUPPORTED_SPECS

# ****************************************************************
# * Checks Class Rotation Spells for outdated and duplicate Spells
# ****************************************************************

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Checks Class Rotation Spells for outdated and duplicate Spells')
    parser.add_argument('-l','--limit', help='Limit Analysation to given KPS Class', required=False, default=None, choices=SUPPORTED_SPECS.keys())
    args = setup_logging_and_get_args(parser)
    if args.limit:
        spells.PlayerSpells(args.limit, validate=True, ignore_validation_errors=False)
    else:
        for wow_class in SUPPORTED_SPECS.keys():
            spells.PlayerSpells(wow_class, validate=True, ignore_validation_errors=False)
Beispiel #13
0
]]--

kps.spells.%s = {}

""" % (class_name.title(), class_name.title(), class_name)
    for spell in spells:
        if not is_filtered(spell)[0]:
            s += "kps.spells.%s.%s = kps.Spell.fromId(%s)\n" % (class_name,spell_key(spell["name"][1:]),spell["id"])
    for spell_id in ADDITIONAL_SPELLS[class_name]:
        spell = Spell(spell_id)
        s += "kps.spells.%s.%s = kps.Spell.fromId(%s)\n" % (class_name, spell.key, spell.id)
    return s + "\nkps.env." + class_name + " = {}\n" + ENV_FUNCTIONS[class_name] + "\n"

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Loads Class Spells from Wowhead')
    parser.add_argument('-c','--class', dest='class_name', help='Set the class to scan', required=True, choices=SUPPORTED_SPECS.keys())
    parser.add_argument('-a','--cache-age', dest='cache_age', help='Set the max cache age in seconds (by default the class data is cached)', required=False, default=DEFAULT_CACHE_AGE_IN_SECONDS)
    parser.add_argument('-s','--summarize', help='List all found spells and show which one were filtered', required=False, action="store_true")
    parser.add_argument('-o','--output', help='Output file (omit to print to stdout)', default=None)
    args = setup_logging_and_get_args(parser)
    spells = extract_json_from_html(load_html_page(THOTTBOT_IDS[args.class_name], args.cache_age))

    outp = summarize(spells, args.class_name) if args.summarize else generate_lua(spells,args.class_name)

    if args.output:
        open(args.output,"w").write(outp)
    else:
        print outp


Beispiel #14
0
def read_rotation_data():
    rotations = []

    fully_supported = {}
    untested_supported = {}
    outdated = {}
    generated = {}
    contributors = set()

    for class_name_lower, spec_names in SUPPORTED_SPECS.iteritems():
        class_name = class_name_lower.title()
        for spec_name_lower in spec_names:
            spec_name = spec_name_lower.title()
            meta = parse_rotation_meta(class_name_lower, spec_name_lower)
            if "generated_from" in meta.keys():
                if class_name not in generated.keys():
                    generated[class_name] = []
                generated[class_name].append("%s (%s)" %
                                             (spec_name, meta["version"]))
            elif meta["version"] == WOW_VERSION:
                if "untested" in meta.keys():
                    if class_name not in untested_supported.keys():
                        untested_supported[class_name] = []
                    untested_supported[class_name].append(spec_name)
                else:
                    if class_name not in fully_supported.keys():
                        fully_supported[class_name] = []
                    fully_supported[class_name].append(spec_name)
                if meta["author"] and len(meta["author"]) > 1:
                    contributors |= set(meta["authors"])

            else:
                if class_name not in outdated.keys():
                    outdated[class_name] = []
                outdated[class_name].append("%s (%s)" %
                                            (spec_name, meta["version"]))
    contributors.discard("kirk24788")
    rotation_data = "**Fully Supported in %s:**\n\n" % WOW_VERSION
    if fully_supported.keys() == []:
        rotation_data = rotation_data + "None\n\n"
    else:
        for class_name in sorted(fully_supported.keys()):
            spec_names = sorted(fully_supported[class_name])
            rotation_data = "%s* %s: %s\n" % (rotation_data, class_name,
                                              ", ".join(spec_names))
        rotation_data = rotation_data + "\n"

    if len(untested_supported.keys()) > 0:
        rotation_data = rotation_data + "**Untested Rotations in %s:**\n\n" % WOW_VERSION
        for class_name in sorted(untested_supported.keys()):
            spec_names = sorted(untested_supported[class_name])
            rotation_data = "%s* %s: %s\n" % (rotation_data, class_name,
                                              ", ".join(spec_names))
        rotation_data = rotation_data + "\n"

    if len(outdated.keys()) > 0:
        rotation_data = rotation_data + "**Outdated Rotations:**\n\n"
        for class_name in sorted(outdated.keys()):
            spec_names = sorted(outdated[class_name])
            rotation_data = "%s* %s: %s\n" % (rotation_data, class_name,
                                              ", ".join(spec_names))
        rotation_data = rotation_data + "\n"

    if len(generated.keys()) > 0:
        rotation_data = rotation_data + "**Automatically Generated Rotations:**\n_(Might not be fully functional)_\n\n"
        for class_name in sorted(generated.keys()):
            spec_names = sorted(generated[class_name])
            rotation_data = "%s* %s: %s\n" % (rotation_data, class_name,
                                              ", ".join(spec_names))
        rotation_data = rotation_data + "\n"

    if len(contributors) > 0:
        rotation_data = rotation_data + "**Special Thanks for contributing to the KPS rotations:**\n\n"
        for contributor in sorted(sorted(contributors)):
            rotation_data = "%s* %s\n" % (rotation_data, contributor)
        rotation_data = rotation_data + "\n"
    return rotation_data