import json


AST_CATEGORY_ORDER = [
    ("unusual", 10000),
    ("important", 1000),
    ("good", 100),
    ("mundane", 10),
    ("drafter", 1),
]

AST_SCORE_CATEGORIES = {
    "unusual": [
        "AsyncFor",
        "AsyncFunctionDef",
        "AsyncWith",
        "Assert",
        "AnnAssign",
        "Await",
        "BitAnd",
        "BitOr",
        "BitXor",
        "Break",
        "Bytes",
        "ClassDef",
        "Continue",
        "Del",
        "Dict",
        "DictComp",
        "Ellipsis",
        "ExceptHandler",
        "ExtSlice",
        "FunctionType",
        "GeneratorExp",
        "Global",
        "Import",
        "ImportFrom",
        "IfExp",
        "Invert",
        "LShift",
        "Lambda",
        "ListComp",
        "MatMult",
        "Match",
        "MatchAs",
        "MatchClass",
        "MatchMapping",
        "MatchOr",
        "MatchSequence",
        "MatchSingleton",
        "MatchStar",
        "MatchValue",
        "Mod",
        "NamedExpr",
        "Nonlocal",
        "RShift",
        "Raise",
        "Set",
        "SetComp",
        "Try",
        "TryStar",
        "Tuple",
        "TypeIgnore",
        "With",
        "Yield",
        "YieldFrom",
        "Starred",
        "FormattedValue",
        "JoinedStr",
    ],
    "important": ["FunctionDef", "For", "If", "Return", "While"],
    "good": [
        "Add",
        "And",
        "Assign",
        "AugAssign",
        "BinOp",
        "BoolOp",
        "Compare",
        "Div",
        "Eq",
        "FloorDiv",
        "Gt",
        "GtE",
        "In",
        "Index",
        "Is",
        "IsNot",
        "Lt",
        "LtE",
        "Mult",
        "Not",
        "NotEq",
        "NotIn",
        "Or",
        "Pow",
        "Slice",
        "Sub",
        "Subscript",
        "UAdd",
        "USub",
        "UnaryOp",
        "Attribute",
        "Call",
    ],
    "mundane": ["Constant", "Expr", "List", "NameConstant", "Num", "Pass", "Str"],
    "drafter": [],
}

SCORE_NAME_CATEGORIES = {
    "unusual": [],
    "important": ["Argument"],
    "good": [],
    "mundane": [
        "MatPlotLibPlot",
        "NumberedList",
        "BulletedList",
        "CheckBox",
        "Download",
        "FileUpload",
        "SelectBox",
        "Table",
        "TextBox",
        "TextArea",
        "Button",
        "Header",
        "HorizontalRule",
        "Image",
        "LineBreak",
        "Link",
        "Picture",
    ],
    "drafter": [
        "Box",
        "Div",
        "Division",
        "Pre",
        "PreformattedText",
        "Row",
        "Span",
        "SubmitButton",
        "Text",
    ],
}
NAME_SCORE_CATEGORIES = {
    name: category
    for category, names in SCORE_NAME_CATEGORIES.items()
    for name in names
}
# 'AugLoad', 'AugStore', 'Delete', 'Expression', 'Load', 'Store'
# [  'alias', 'arg', 'arguments', 'auto', 'boolop', 'cmpop', 'comprehension', 'contextmanager', 'copy_location', 'dump', 'excepthandler', 'expr', 'expr_context', 'fix_missing_locations', 'get_docstring', 'get_source_segment', 'increment_lineno', 'iter_child_nodes', 'iter_fields', 'keyword', 'literal_eval', 'main', 'match_case', 'mod', 'nullcontext', 'operator', 'parse', 'pattern', 'slice', 'stmt', 'sys', 'type_ignore', 'unaryop', 'unparse', 'walk', 'withitem']
