ENCODING "utf-8"
COMMENT "# Copyright (C) 2012 Tim Radvan"
NL "\n"
COMMENT "#"
NL "\n"
COMMENT "# This file is part of Kurt."
NL "\n"
COMMENT "#"
NL "\n"
COMMENT "# Kurt is free software: you can redistribute it and/or modify it under the"
NL "\n"
COMMENT "# terms of the GNU Lesser General Public License as published by the Free"
NL "\n"
COMMENT "# Software Foundation, either version 3 of the License, or (at your option) any"
NL "\n"
COMMENT "# later version."
NL "\n"
COMMENT "#"
NL "\n"
COMMENT "# Kurt is distributed in the hope that it will be useful, but WITHOUT ANY"
NL "\n"
COMMENT "# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR"
NL "\n"
COMMENT "# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more"
NL "\n"
COMMENT "# details."
NL "\n"
COMMENT "#"
NL "\n"
COMMENT "# You should have received a copy of the GNU Lesser General Public License"
NL "\n"
COMMENT "# along with Kurt. If not, see <http://www.gnu.org/licenses/>."
NL "\n"
NL "\n"
STRING "\"\"\"\nA Python module for reading and writing Scratch project files.\n\nScratch is created by the Lifelong Kindergarten Group at the MIT Media Lab.\nSee their website: http://scratch.mit.edu/\n\n\nClasses\n-------\n\nThe main interface:\n\n* :class:`Project`\n\nThe following :class:`Actors <Actor>` may be found on the project stage:\n\n* :class:`Stage`\n* :class:`Sprite`\n* :class:`Watcher`\n\nThe two :class:`Scriptables <Scriptable>` (:class:`Stage` and :class:`Sprite`)\nhave instances of the following contained in their attributes:\n\n* :class:`Variable`\n* :class:`List`\n\nScripts use the following classes:\n\n* :class:`Block`\n* :class:`Script`\n* :class:`Comment`\n* :class:`BlockType`\n\nMedia files use the following classes:\n\n* :class:`Costume`\n* :class:`Image`\n* :class:`Sound`\n* :class:`Waveform`\n\nFile Formats\n------------\n\nSupported file formats:\n\n    =============== =========== =========\n    Format Name     Description Extension\n    =============== =========== =========\n    ``\"scratch14\"`` Scratch 1.4 ``.sb``\n    ``\"scratch20\"`` Scratch 2.0 ``.sb2``\n    =============== =========== =========\n\nPass \"Format name\" as the argument to :attr:`Project.convert`.\n\nKurt provides a superset of the information in each individual format, but will\nonly convert features between a subset of formats.\n\n----\n\n\"\"\""
NEWLINE "\n"
NL "\n"
NAME "__version__"
OP "="
STRING "'2.0.7'"
NEWLINE "\n"
NL "\n"
NAME "from"
NAME "collections"
NAME "import"
NAME "OrderedDict"
NEWLINE "\n"
NAME "import"
NAME "re"
NEWLINE "\n"
NAME "import"
NAME "os"
NEWLINE "\n"
NAME "import"
NAME "random"
NEWLINE "\n"
NAME "try"
OP ":"
NEWLINE "\n"
INDENT "    "
NAME "from"
NAME "cStringIO"
NAME "import"
NAME "StringIO"
NEWLINE "\n"
DEDENT ""
NAME "except"
NAME "ImportError"
OP ":"
NEWLINE "\n"
INDENT "    "
NAME "from"
NAME "StringIO"
NAME "import"
NAME "StringIO"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "import"
NAME "PIL"
OP "."
NAME "Image"
NEWLINE "\n"
NAME "import"
NAME "wave"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Utils --#"
NL "\n"
NL "\n"
NAME "def"
NAME "_clean_filename"
OP "("
NAME "name"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"Strip non-alphanumeric characters to makes name safe to be used as\n    filename.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "re"
OP "."
NAME "sub"
OP "("
STRING "\"[^\\\\w .]\""
OP ","
STRING "\"\""
OP ","
NAME "name"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Project: main class --#"
NL "\n"
NL "\n"
DEDENT ""
NAME "class"
NAME "Project"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The main kurt class. Stores the contents of a project file.\n\n    Contents include global variables and lists, the :attr:`stage` and\n    :attr:`sprites`, each with their own :attr:`scripts`, :attr:`costumes`,\n    :attr:`sounds`, :attr:`variables` and :attr:`lists`.\n\n    A Project can be loaded from or saved to disk in a format which can be read\n    by a Scratch program or one of its derivatives.\n\n    Loading a project::\n\n        p = kurt.Project.load(\"tests/game.sb\")\n\n    Getting all the scripts::\n\n        for scriptable in p.sprites + [p.stage]:\n            for script in scriptable.scripts:\n                print script\n\n    Creating a new project::\n\n        p = kurt.Project()\n\n    Converting between formats::\n\n        p = kurt.Project.load(\"tests/game.sb\")\n        p.convert(\"scratch20\")\n        # []\n        p.save()\n        # 'tests/game.sb2'\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "name"
OP "="
STRING "u\"\""
NEWLINE "\n"
STRING "\"\"\"The name of the project.\n\n        May be displayed to the user. Doesn't have to match the filename in\n        :attr:`path`. May not be saved for some formats.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "path"
OP "="
NAME "None"
NEWLINE "\n"
STRING "\"\"\"The path to the project file.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "_plugin"
OP "="
NAME "None"
NEWLINE "\n"
STRING "\"\"\"The file format plugin used to load this project.\n\n        Get the current format using the :attr:`format` property. Use\n        :attr:`convert()` to change between formats.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "stage"
OP "="
NAME "Stage"
OP "("
NAME "self"
OP ")"
NEWLINE "\n"
STRING "\"\"\"The :class:`Stage`.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "sprites"
OP "="
OP "["
OP "]"
NEWLINE "\n"
STRING "\"\"\"List of :class:`Sprites <Sprite>`.\n\n        Use :attr:`get_sprite` to get a sprite by name.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "actors"
OP "="
OP "["
OP "]"
NEWLINE "\n"
STRING "\"\"\"List of each :class:`Actor` on the stage.\n\n        Includes :class:`Watchers <Watcher>` as well as :class:`Sprites\n        <Sprite>`.\n\n        Sprites in :attr:`sprites` but not in actors will be added to actors on\n        save.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "variables"
OP "="
OP "{"
OP "}"
NEWLINE "\n"
STRING "\"\"\":class:`dict` of global :class:`Variables <Variable>` by name.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "lists"
OP "="
OP "{"
OP "}"
NEWLINE "\n"
STRING "\"\"\":class:`dict` of global :class:`Lists <List>` by name.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "thumbnail"
OP "="
NAME "None"
NEWLINE "\n"
STRING "\"\"\"An :class:`Image` with a screenshot of the project.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "tempo"
OP "="
NUMBER "60"
NEWLINE "\n"
STRING "\"\"\"The tempo in BPM used for note blocks.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "notes"
OP "="
STRING "u\"Made with Kurt\\nhttp://github.com/blob8108/kurt\""
NEWLINE "\n"
STRING "\"\"\"Notes about the project, aka project comments.\n\n        Displayed on the website next to the project.\n\n        Line endings will be converted to ``\\\\n``.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "author"
OP "="
STRING "u\"\""
NEWLINE "\n"
STRING "\"\"\"The username of the project's author, eg. ``'blob8108'``.\"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"<%s.%s()>\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "get_sprite"
OP "("
NAME "self"
OP ","
NAME "name"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Get a sprite from :attr:`sprites` by name.\n\n        Returns None if the sprite isn't found.\n\n        \"\"\""
NEWLINE "\n"
NAME "for"
NAME "sprite"
NAME "in"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "sprite"
OP "."
NAME "name"
OP "=="
NAME "name"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "sprite"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "format"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The file format of the project.\n\n        :class:`Project` is mainly a universal representation, and so a project\n        has no specfic format. This is the format the project was loaded with.\n        To convert to a different format, use :attr:`save()`.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "_plugin"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_plugin"
OP "."
NAME "name"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "load"
OP "("
NAME "cls"
OP ","
NAME "path"
OP ","
NAME "format"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Load project from file.\n\n        Use ``format`` to specify the file format to use.\n\n        Path can be a file-like object, in which case format is required.\n        Otherwise, can guess the appropriate format from the extension.\n\n        If you pass a file-like object, you're responsible for closing the\n        file.\n\n        :param path:   Path or file pointer.\n        :param format: :attr:`KurtFileFormat.name` eg. ``\"scratch14\"``.\n                       Overrides the extension.\n\n        :raises: :class:`UnknownFormat` if the extension is unrecognised.\n        :raises: :py:class:`ValueError` if the format doesn't exist.\n\n        \"\"\""
NEWLINE "\n"
NAME "path_was_string"
OP "="
NAME "isinstance"
OP "("
NAME "path"
OP ","
NAME "basestring"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "path_was_string"
OP ":"
NEWLINE "\n"
INDENT "            "
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "format"
NAME "is"
NAME "None"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "plugin"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "get_plugin"
OP "("
NAME "extension"
OP "="
NAME "extension"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "plugin"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "raise"
NAME "UnknownFormat"
OP "("
NAME "extension"
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "fp"
OP "="
NAME "open"
OP "("
NAME "path"
OP ","
STRING "\"rb\""
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "fp"
OP "="
NAME "path"
NEWLINE "\n"
NAME "assert"
NAME "format"
OP ","
STRING "\"Format is required\""
NEWLINE "\n"
NAME "plugin"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "get_plugin"
OP "("
NAME "format"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "if"
NAME "not"
NAME "plugin"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"Unknown format %r\""
OP "%"
NAME "format"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "project"
OP "="
NAME "plugin"
OP "."
NAME "load"
OP "("
NAME "fp"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "path_was_string"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "fp"
OP "."
NAME "close"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "project"
OP "."
NAME "convert"
OP "("
NAME "plugin"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "isinstance"
OP "("
NAME "path"
OP ","
NAME "basestring"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "project"
OP "."
NAME "path"
OP "="
NAME "path"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "project"
OP "."
NAME "name"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "project"
OP "."
NAME "name"
OP "="
NAME "name"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "project"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new Project instance, deep-copying all the attributes.\"\"\""
NEWLINE "\n"
NAME "p"
OP "="
NAME "Project"
OP "("
OP ")"
NEWLINE "\n"
NAME "p"
OP "."
NAME "name"
OP "="
NAME "self"
OP "."
NAME "name"
NEWLINE "\n"
NAME "p"
OP "."
NAME "path"
OP "="
NAME "self"
OP "."
NAME "path"
NEWLINE "\n"
NAME "p"
OP "."
NAME "_plugin"
OP "="
NAME "self"
OP "."
NAME "_plugin"
NEWLINE "\n"
NAME "p"
OP "."
NAME "stage"
OP "="
NAME "self"
OP "."
NAME "stage"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
NAME "p"
OP "."
NAME "stage"
OP "."
NAME "project"
OP "="
NAME "p"
NEWLINE "\n"
NL "\n"
NAME "for"
NAME "sprite"
NAME "in"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "s"
OP "="
NAME "sprite"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
NAME "s"
OP "."
NAME "project"
OP "="
NAME "p"
NEWLINE "\n"
NAME "p"
OP "."
NAME "sprites"
OP "."
NAME "append"
OP "("
NAME "s"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "for"
NAME "actor"
NAME "in"
NAME "self"
OP "."
NAME "actors"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "isinstance"
OP "("
NAME "actor"
OP ","
NAME "Sprite"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "p"
OP "."
NAME "actors"
OP "."
NAME "append"
OP "("
NAME "p"
OP "."
NAME "get_sprite"
OP "("
NAME "actor"
OP "."
NAME "name"
OP ")"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "a"
OP "="
NAME "actor"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
NAME "if"
NAME "isinstance"
OP "("
NAME "a"
OP ","
NAME "Watcher"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "if"
NAME "isinstance"
OP "("
NAME "a"
OP "."
NAME "target"
OP ","
NAME "Project"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "a"
OP "."
NAME "target"
OP "="
NAME "p"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "a"
OP "."
NAME "target"
OP ","
NAME "Stage"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "a"
OP "."
NAME "target"
OP "="
NAME "p"
OP "."
NAME "stage"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "a"
OP "."
NAME "target"
OP "="
NAME "p"
OP "."
NAME "get_sprite"
OP "("
NAME "a"
OP "."
NAME "target"
OP "."
NAME "name"
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "p"
OP "."
NAME "actors"
OP "."
NAME "append"
OP "("
NAME "a"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "p"
OP "."
NAME "variables"
OP "="
NAME "dict"
OP "("
OP "("
NAME "n"
OP ","
NAME "v"
OP "."
NAME "copy"
OP "("
OP ")"
OP ")"
NAME "for"
OP "("
NAME "n"
OP ","
NAME "v"
OP ")"
NAME "in"
NAME "self"
OP "."
NAME "variables"
OP "."
NAME "items"
OP "("
OP ")"
OP ")"
NEWLINE "\n"
NAME "p"
OP "."
NAME "lists"
OP "="
NAME "dict"
OP "("
OP "("
NAME "n"
OP ","
NAME "l"
OP "."
NAME "copy"
OP "("
OP ")"
OP ")"
NAME "for"
OP "("
NAME "n"
OP ","
NAME "l"
OP ")"
NAME "in"
NAME "self"
OP "."
NAME "lists"
OP "."
NAME "items"
OP "("
OP ")"
OP ")"
NEWLINE "\n"
NAME "p"
OP "."
NAME "thumbnail"
OP "="
NAME "self"
OP "."
NAME "thumbnail"
NEWLINE "\n"
NAME "p"
OP "."
NAME "tempo"
OP "="
NAME "self"
OP "."
NAME "tempo"
NEWLINE "\n"
NAME "p"
OP "."
NAME "notes"
OP "="
NAME "self"
OP "."
NAME "notes"
NEWLINE "\n"
NAME "p"
OP "."
NAME "author"
OP "="
NAME "self"
OP "."
NAME "author"
NEWLINE "\n"
NAME "return"
NAME "p"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "convert"
OP "("
NAME "self"
OP ","
NAME "format"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Convert the project in-place to a different file format.\n\n        Returns a list of :class:`UnsupportedFeature` objects, which may give\n        warnings about the conversion.\n\n        :param format: :attr:`KurtFileFormat.name` eg. ``\"scratch14\"``.\n\n        :raises: :class:`ValueError` if the format doesn't exist.\n\n        \"\"\""
NEWLINE "\n"
NAME "self"
OP "."
NAME "_plugin"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "get_plugin"
OP "("
NAME "format"
OP ")"
NEWLINE "\n"
NAME "return"
NAME "list"
OP "("
NAME "self"
OP "."
NAME "_normalize"
OP "("
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "save"
OP "("
NAME "self"
OP ","
NAME "path"
OP "="
NAME "None"
OP ","
NAME "debug"
OP "="
NAME "False"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Save project to file.\n\n        :param path: Path or file pointer.\n\n                     If you pass a file pointer, you're responsible for closing\n                     it.\n\n                     If path is not given, the :attr:`path` attribute is used,\n                     usually the original path given to :attr:`load()`.\n\n                     If `path` has the extension of an existing plugin, the\n                     project will be converted using :attr:`convert`.\n                     Otherwise, the extension will be replaced with the\n                     extension of the current plugin.\n\n                     (Note that log output for the conversion will be printed\n                     to stdout. If you want to deal with the output, call\n                     :attr:`convert` directly.)\n\n                     If the path ends in a folder instead of a file, the\n                     filename is based on the project's :attr:`name`.\n\n        :param debug: If true, return debugging information from the format\n                      plugin instead of the path.\n\n        :raises: :py:class:`ValueError` if there's no path or name.\n\n        :returns: path to the saved file.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "p"
OP "="
NAME "self"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
NAME "plugin"
OP "="
NAME "p"
OP "."
NAME "_plugin"
NEWLINE "\n"
NL "\n"
COMMENT "# require path"
NL "\n"
NAME "p"
OP "."
NAME "path"
OP "="
NAME "path"
NAME "or"
NAME "self"
OP "."
NAME "path"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "p"
OP "."
NAME "path"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"path is required\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "if"
NAME "isinstance"
OP "("
NAME "p"
OP "."
NAME "path"
OP ","
NAME "basestring"
OP ")"
OP ":"
NEWLINE "\n"
COMMENT "# split path"
NL "\n"
INDENT "            "
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "p"
OP "."
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# get plugin from extension"
NL "\n"
NAME "if"
NAME "path"
OP ":"
COMMENT "# only if not using self.path"
NEWLINE "\n"
INDENT "                "
NAME "try"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "plugin"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "get_plugin"
OP "("
NAME "extension"
OP "="
NAME "extension"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "except"
NAME "ValueError"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "pass"
NEWLINE "\n"
NL "\n"
COMMENT "# build output path"
NL "\n"
DEDENT ""
DEDENT ""
NAME "if"
NAME "not"
NAME "name"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "name"
OP "="
NAME "_clean_filename"
OP "("
NAME "self"
OP "."
NAME "name"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "name"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"name is required\""
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "filename"
OP "="
NAME "name"
OP "+"
NAME "plugin"
OP "."
NAME "extension"
NEWLINE "\n"
NAME "p"
OP "."
NAME "path"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "join"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# open"
NL "\n"
NAME "fp"
OP "="
NAME "open"
OP "("
NAME "p"
OP "."
NAME "path"
OP ","
STRING "\"wb\""
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "fp"
OP "="
NAME "p"
OP "."
NAME "path"
NEWLINE "\n"
NAME "path"
OP "="
NAME "None"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "if"
NAME "not"
NAME "plugin"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"must convert project to a format before saving\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "for"
NAME "m"
NAME "in"
NAME "p"
OP "."
NAME "convert"
OP "("
NAME "plugin"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "print"
NAME "m"
NEWLINE "\n"
DEDENT ""
NAME "result"
OP "="
NAME "p"
OP "."
NAME "_save"
OP "("
NAME "fp"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "path"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "fp"
OP "."
NAME "close"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "result"
NAME "if"
NAME "debug"
NAME "else"
NAME "p"
OP "."
NAME "path"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_save"
OP "("
NAME "self"
OP ","
NAME "fp"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "_plugin"
OP "."
NAME "save"
OP "("
NAME "fp"
OP ","
NAME "self"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Convert the project to a standardised form for the current plugin.\n\n        Called after loading, before saving, and when converting to a new\n        format.\n\n        Yields UnsupportedFeature instances.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "unique_sprite_names"
OP "="
NAME "set"
OP "("
NAME "sprite"
OP "."
NAME "name"
NAME "for"
NAME "sprite"
NAME "in"
NAME "self"
OP "."
NAME "sprites"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "len"
OP "("
NAME "unique_sprite_names"
OP ")"
OP "<"
NAME "len"
OP "("
NAME "self"
OP "."
NAME "sprites"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"Sprite names must be unique\""
NEWLINE "\n"
NL "\n"
COMMENT "# sync self.sprites and self.actors"
NL "\n"
DEDENT ""
NAME "for"
NAME "sprite"
NAME "in"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "sprite"
NAME "not"
NAME "in"
NAME "self"
OP "."
NAME "actors"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "self"
OP "."
NAME "actors"
OP "."
NAME "append"
OP "("
NAME "sprite"
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "for"
NAME "actor"
NAME "in"
NAME "self"
OP "."
NAME "actors"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "isinstance"
OP "("
NAME "actor"
OP ","
NAME "Sprite"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "actor"
NAME "not"
NAME "in"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"Can't have sprite on stage that isn't in sprites\""
NEWLINE "\n"
NL "\n"
COMMENT "# normalize Scriptables"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "self"
OP "."
NAME "stage"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NAME "for"
NAME "sprite"
NAME "in"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "sprite"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# normalize actors"
NL "\n"
DEDENT ""
NAME "for"
NAME "actor"
NAME "in"
NAME "self"
OP "."
NAME "actors"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "not"
NAME "isinstance"
OP "("
NAME "actor"
OP ","
NAME "Scriptable"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "actor"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# make Watchers if needed"
NL "\n"
DEDENT ""
DEDENT ""
NAME "for"
NAME "thing"
NAME "in"
OP "["
NAME "self"
OP ","
NAME "self"
OP "."
NAME "stage"
OP "]"
OP "+"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "for"
OP "("
NAME "name"
OP ","
NAME "var"
OP ")"
NAME "in"
NAME "thing"
OP "."
NAME "variables"
OP "."
NAME "items"
OP "("
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "not"
NAME "var"
OP "."
NAME "watcher"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "var"
OP "."
NAME "watcher"
OP "="
NAME "kurt"
OP "."
NAME "Watcher"
OP "("
NAME "thing"
OP ","
NL "\n"
NAME "kurt"
OP "."
NAME "Block"
OP "("
STRING "\"var\""
OP ","
NAME "name"
OP ")"
OP ","
NAME "is_visible"
OP "="
NAME "False"
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "actors"
OP "."
NAME "append"
OP "("
NAME "var"
OP "."
NAME "watcher"
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "for"
OP "("
NAME "name"
OP ","
NAME "list_"
OP ")"
NAME "in"
NAME "thing"
OP "."
NAME "lists"
OP "."
NAME "items"
OP "("
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "not"
NAME "list_"
OP "."
NAME "watcher"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "list_"
OP "."
NAME "watcher"
OP "="
NAME "kurt"
OP "."
NAME "Watcher"
OP "("
NAME "thing"
OP ","
NL "\n"
NAME "kurt"
OP "."
NAME "Block"
OP "("
STRING "\"list\""
OP ","
NAME "name"
OP ")"
OP ","
NAME "is_visible"
OP "="
NAME "False"
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "actors"
OP "."
NAME "append"
OP "("
NAME "list_"
OP "."
NAME "watcher"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# notes - line endings"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "self"
OP "."
NAME "notes"
OP "="
NAME "self"
OP "."
NAME "notes"
OP "."
NAME "replace"
OP "("
STRING "\"\\r\\n\""
OP ","
STRING "\"\\n\""
OP ")"
OP "."
NAME "replace"
OP "("
STRING "\"\\r\""
OP ","
STRING "\"\\n\""
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# convert scripts"
NL "\n"
NAME "def"
NAME "convert_block"
OP "("
NAME "block"
OP ")"
OP ":"
NEWLINE "\n"
COMMENT "# convert block"
NL "\n"
INDENT "            "
NAME "try"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "isinstance"
OP "("
NAME "block"
OP "."
NAME "type"
OP ","
NAME "CustomBlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "if"
STRING "\"Custom Blocks\""
NAME "not"
NAME "in"
NAME "self"
OP "."
NAME "_plugin"
OP "."
NAME "features"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "raise"
NAME "BlockNotSupported"
OP "("
NL "\n"
STRING "\"%s doesn't support custom blocks\""
NL "\n"
OP "%"
NAME "self"
OP "."
NAME "_plugin"
OP "."
NAME "display_name"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "else"
OP ":"
COMMENT "# BlockType"
NEWLINE "\n"
INDENT "                    "
NAME "pbt"
OP "="
NAME "block"
OP "."
NAME "type"
OP "."
NAME "convert"
OP "("
NAME "self"
OP "."
NAME "_plugin"
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "except"
NAME "BlockNotSupported"
OP ","
NAME "err"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "err"
OP "."
NAME "message"
OP "+="
STRING "\". Caused by: %r\""
OP "%"
NAME "block"
NEWLINE "\n"
NAME "err"
OP "."
NAME "block"
OP "="
NAME "block"
NEWLINE "\n"
NAME "err"
OP "."
NAME "scriptable"
OP "="
NAME "scriptable"
NEWLINE "\n"
NAME "err"
OP "."
NAME "args"
OP "="
OP "("
NAME "err"
OP "."
NAME "message"
OP ","
OP ")"
NEWLINE "\n"
NAME "if"
NAME "getattr"
OP "("
NAME "block"
OP "."
NAME "type"
OP ","
STRING "'_workaround'"
OP ","
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "block"
OP "="
NAME "block"
OP "."
NAME "type"
OP "."
NAME "_workaround"
OP "("
NAME "block"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "block"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "raise"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "raise"
NEWLINE "\n"
NL "\n"
COMMENT "# convert args"
NL "\n"
DEDENT ""
DEDENT ""
NAME "args"
OP "="
OP "["
OP "]"
NEWLINE "\n"
NAME "for"
NAME "arg"
NAME "in"
NAME "block"
OP "."
NAME "args"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "Block"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "arg"
OP "="
NAME "convert_block"
OP "("
NAME "arg"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "list"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "arg"
OP "="
NAME "map"
OP "("
NAME "convert_block"
OP ","
NAME "arg"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "args"
OP "."
NAME "append"
OP "("
NAME "arg"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "block"
OP "."
NAME "args"
OP "="
NAME "args"
NEWLINE "\n"
NL "\n"
NAME "return"
NAME "block"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "for"
NAME "scriptable"
NAME "in"
OP "["
NAME "self"
OP "."
NAME "stage"
OP "]"
OP "+"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "for"
NAME "script"
NAME "in"
NAME "scriptable"
OP "."
NAME "scripts"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "isinstance"
OP "("
NAME "script"
OP ","
NAME "Script"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "script"
OP "."
NAME "blocks"
OP "="
NAME "map"
OP "("
NAME "convert_block"
OP ","
NAME "script"
OP "."
NAME "blocks"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# workaround unsupported features"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "for"
NAME "feature"
NAME "in"
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Feature"
OP "."
NAME "FEATURES"
OP "."
NAME "values"
OP "("
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "feature"
NAME "not"
NAME "in"
NAME "self"
OP "."
NAME "_plugin"
OP "."
NAME "features"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "for"
NAME "x"
NAME "in"
NAME "feature"
OP "."
NAME "workaround"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "yield"
NAME "UnsupportedFeature"
OP "("
NAME "feature"
OP ","
NAME "x"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# normalize supported features"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "for"
NAME "feature"
NAME "in"
NAME "self"
OP "."
NAME "_plugin"
OP "."
NAME "features"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "feature"
OP "."
NAME "normalize"
OP "("
NAME "self"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "get_broadcasts"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "def"
NAME "get_broadcasts"
OP "("
NAME "block"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "for"
OP "("
NAME "arg"
OP ","
NAME "insert"
OP ")"
NAME "in"
NAME "zip"
OP "("
NAME "block"
OP "."
NAME "args"
OP ","
NAME "block"
OP "."
NAME "type"
OP "."
NAME "inserts"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "Block"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "for"
NAME "b"
NAME "in"
NAME "get_broadcasts"
OP "("
NAME "arg"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "yield"
NAME "b"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "list"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "for"
NAME "arg_block"
NAME "in"
NAME "arg"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "for"
NAME "b"
NAME "in"
NAME "get_broadcasts"
OP "("
NAME "arg_block"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                            "
NAME "yield"
NAME "b"
NEWLINE "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "elif"
NAME "insert"
OP "."
NAME "kind"
OP "=="
STRING "\"broadcast\""
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "yield"
NAME "arg"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "for"
NAME "scriptable"
NAME "in"
OP "["
NAME "self"
OP "."
NAME "stage"
OP "]"
OP "+"
NAME "self"
OP "."
NAME "sprites"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "for"
NAME "script"
NAME "in"
NAME "scriptable"
OP "."
NAME "scripts"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "for"
NAME "block"
NAME "in"
NAME "script"
OP "."
NAME "blocks"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "for"
NAME "b"
NAME "in"
NAME "get_broadcasts"
OP "("
NAME "block"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "yield"
NAME "b"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
DEDENT ""
DEDENT ""
DEDENT ""
NAME "class"
NAME "UnsupportedFeature"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The plugin doesn't support this Feature.\n\n    Output once by Project.convert for each occurence of the feature.\n\n    \"\"\""
NEWLINE "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "feature"
OP ","
NAME "obj"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "feature"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Feature"
OP "."
NAME "get"
OP "("
NAME "feature"
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "obj"
OP "="
NAME "obj"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"<%s.%s(%s)>\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "unicode"
OP "("
NAME "self"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__str__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"UnsupportedFeature: %s\""
OP "%"
NAME "unicode"
OP "("
NAME "self"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__unicode__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "u\"%r: %r\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "feature"
OP "."
NAME "name"
OP ","
NAME "self"
OP "."
NAME "obj"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Errors --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "UnknownFormat"
OP "("
NAME "Exception"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The file extension is not recognised.\n\n    Raised when :class:`Project` can't find a valid format plugin to handle the\n    file extension.\n\n    \"\"\""
NEWLINE "\n"
NAME "pass"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
NAME "class"
NAME "UnknownBlock"
OP "("
NAME "Exception"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A :class:`Block` with the given command or type cannot be found.\n\n    Raised by :attr:`BlockType.get`.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
NAME "class"
NAME "BlockNotSupported"
OP "("
NAME "Exception"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The plugin doesn't support this Block.\n\n    Raised by :attr:`Block.convert` when it can't find a\n    :class:`PluginBlockType` for the given plugin.\n\n    \"\"\""
NEWLINE "\n"
NAME "pass"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
NAME "class"
NAME "VectorImageError"
OP "("
NAME "Exception"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"Tried to construct a raster image from a vector format image file.\n\n    You shouldn't usally get this error, because Feature(\"Vector Images\") will\n    give a warning instead when the Project is converted.\n\n    \"\"\""
NEWLINE "\n"
NAME "pass"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Actors & Scriptables --#"
NL "\n"
NL "\n"
DEDENT ""
NAME "class"
NAME "Actor"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"An object that goes on the project stage.\n\n    Subclasses include :class:`Watcher` or :class:`Sprite`.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
NAME "class"
NAME "Scriptable"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"Superclass for all scriptable objects.\n\n    Subclasses are :class:`Stage` and :class:`Sprite`.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "project"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "project"
OP "="
NAME "project"
NEWLINE "\n"
STRING "\"\"\"The :class:`Project` this belongs to.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "scripts"
OP "="
OP "["
OP "]"
NEWLINE "\n"
STRING "\"\"\"The contents of the scripting area.\n\n        List containing :class:`Scripts <Script>` and :class:`Comments\n        <Comment>`.\n\n        Will be sorted by y position on load/save.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "custom_blocks"
OP "="
OP "{"
OP "}"
NEWLINE "\n"
STRING "\"\"\"Scripts for custom blocks, indexed by :class:`CustomBlockType`.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "variables"
OP "="
OP "{"
OP "}"
NEWLINE "\n"
STRING "\"\"\":class:`dict` of :class:`Variables <Variable>` by name.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "lists"
OP "="
OP "{"
OP "}"
NEWLINE "\n"
STRING "\"\"\":class:`dict` of :class:`Lists <List>` by name.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "costumes"
OP "="
OP "["
OP "]"
NEWLINE "\n"
STRING "\"\"\"List of :class:`Costumes <Costume>`.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "sounds"
OP "="
OP "["
OP "]"
NEWLINE "\n"
STRING "\"\"\"List of :class:`Sounds <Sound>`.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "costume"
OP "="
NAME "None"
NEWLINE "\n"
STRING "\"\"\"The currently selected :class:`Costume`.\n\n        Defaults to the first costume in :attr:`self.costumes` on save.\n\n        If a sprite doesn't have a costume, a black 1x1 pixel square will be\n        used.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "volume"
OP "="
NUMBER "100"
NEWLINE "\n"
STRING "\"\"\"The volume in percent used for note and sound blocks.\"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
COMMENT "# costumes"
NL "\n"
INDENT "        "
NAME "if"
NAME "self"
OP "."
NAME "costume"
OP ":"
NEWLINE "\n"
COMMENT "# Make sure it's in costumes"
NL "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "costume"
NAME "not"
NAME "in"
NAME "self"
OP "."
NAME "costumes"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "self"
OP "."
NAME "costumes"
OP "."
NAME "append"
OP "("
NAME "self"
OP "."
NAME "costume"
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
COMMENT "# No costume!"
NL "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "costumes"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "self"
OP "."
NAME "costume"
OP "="
NAME "self"
OP "."
NAME "costumes"
OP "["
NUMBER "0"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "BLACK"
OP "="
OP "("
NUMBER "0"
OP ","
NUMBER "0"
OP ","
NUMBER "0"
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "costume"
OP "="
NAME "Costume"
OP "("
STRING "\"blank\""
OP ","
NAME "Image"
OP "."
NAME "new"
OP "("
OP "("
NUMBER "1"
OP ","
NUMBER "1"
OP ")"
OP ","
NAME "BLACK"
OP ")"
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "costumes"
OP "="
OP "["
NAME "self"
OP "."
NAME "costume"
OP "]"
NEWLINE "\n"
NL "\n"
COMMENT "# scripts"
NL "\n"
DEDENT ""
DEDENT ""
NAME "for"
NAME "script"
NAME "in"
NAME "self"
OP "."
NAME "scripts"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "script"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# sort scripts by y position"
NL "\n"
DEDENT ""
NAME "have_position"
OP "="
OP "["
NAME "s"
NAME "for"
NAME "s"
NAME "in"
NAME "self"
OP "."
NAME "scripts"
NAME "if"
NAME "s"
OP "."
NAME "pos"
OP "]"
NEWLINE "\n"
NAME "no_position"
OP "="
OP "["
NAME "s"
NAME "for"
NAME "s"
NAME "in"
NAME "self"
OP "."
NAME "scripts"
NAME "if"
NAME "not"
NAME "s"
OP "."
NAME "pos"
OP "]"
NEWLINE "\n"
NAME "have_position"
OP "."
NAME "sort"
OP "("
NAME "key"
OP "="
NAME "lambda"
NAME "s"
OP ":"
OP "("
NAME "s"
OP "."
NAME "pos"
OP "["
NUMBER "1"
OP "]"
OP ","
NAME "s"
OP "."
NAME "pos"
OP "["
NUMBER "0"
OP "]"
OP ")"
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "scripts"
OP "="
NAME "have_position"
OP "+"
NAME "no_position"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ","
NAME "o"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance, deep-copying all the attributes.\"\"\""
NEWLINE "\n"
NAME "if"
NAME "o"
NAME "is"
NAME "None"
OP ":"
NAME "o"
OP "="
NAME "self"
OP "."
NAME "__class__"
OP "("
NAME "self"
OP "."
NAME "project"
OP ")"
NEWLINE "\n"
NAME "o"
OP "."
NAME "scripts"
OP "="
OP "["
NAME "s"
OP "."
NAME "copy"
OP "("
OP ")"
NAME "for"
NAME "s"
NAME "in"
NAME "self"
OP "."
NAME "scripts"
OP "]"
NEWLINE "\n"
NAME "o"
OP "."
NAME "variables"
OP "="
NAME "dict"
OP "("
OP "("
NAME "n"
OP ","
NAME "v"
OP "."
NAME "copy"
OP "("
OP ")"
OP ")"
NAME "for"
OP "("
NAME "n"
OP ","
NAME "v"
OP ")"
NAME "in"
NAME "self"
OP "."
NAME "variables"
OP "."
NAME "items"
OP "("
OP ")"
OP ")"
NEWLINE "\n"
NAME "o"
OP "."
NAME "lists"
OP "="
NAME "dict"
OP "("
OP "("
NAME "n"
OP ","
NAME "l"
OP "."
NAME "copy"
OP "("
OP ")"
OP ")"
NAME "for"
OP "("
NAME "n"
OP ","
NAME "l"
OP ")"
NAME "in"
NAME "self"
OP "."
NAME "lists"
OP "."
NAME "items"
OP "("
OP ")"
OP ")"
NEWLINE "\n"
NAME "o"
OP "."
NAME "costumes"
OP "="
OP "["
NAME "c"
OP "."
NAME "copy"
OP "("
OP ")"
NAME "for"
NAME "c"
NAME "in"
NAME "self"
OP "."
NAME "costumes"
OP "]"
NEWLINE "\n"
NAME "o"
OP "."
NAME "sounds"
OP "="
OP "["
NAME "s"
OP "."
NAME "copy"
OP "("
OP ")"
NAME "for"
NAME "s"
NAME "in"
NAME "self"
OP "."
NAME "sounds"
OP "]"
NEWLINE "\n"
NAME "o"
OP "."
NAME "costume_index"
OP "="
NAME "self"
OP "."
NAME "costume_index"
NEWLINE "\n"
NAME "o"
OP "."
NAME "volume"
OP "="
NAME "self"
OP "."
NAME "volume"
NEWLINE "\n"
NAME "return"
NAME "o"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "costume_index"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The index of :attr:`costume` in :attr:`costumes`.\n\n        None if no costume is selected.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "costume"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "costumes"
OP "."
NAME "index"
OP "("
NAME "self"
OP "."
NAME "costume"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "costume_index"
OP "."
NAME "setter"
NEWLINE "\n"
NAME "def"
NAME "costume_index"
OP "("
NAME "self"
OP ","
NAME "index"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "index"
NAME "is"
NAME "None"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "costume"
OP "="
NAME "None"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "costume"
OP "="
NAME "self"
OP "."
NAME "costumes"
OP "["
NAME "index"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "parse"
OP "("
NAME "self"
OP ","
NAME "text"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Parse the given code and add it to :attr:`scripts`.\n\n        The syntax matches :attr:`Script.stringify()`. See :mod:`kurt.text` for\n        reference.\n\n        \"\"\""
NEWLINE "\n"
NAME "self"
OP "."
NAME "scripts"
OP "."
NAME "append"
OP "("
NAME "kurt"
OP "."
NAME "text"
OP "."
NAME "parse"
OP "("
NAME "text"
OP ","
NAME "self"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Stage"
OP "("
NAME "Scriptable"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"Represents the background of the project. The stage is similar to a\n    :class:`Sprite`, but has a fixed position. The stage has a fixed size of\n    ``480x360`` pixels.\n\n    The stage does not require a costume. If none is given, it is assumed to be\n    white (#FFF).\n\n    Not all formats have stage-specific variables and lists. Global variables\n    and lists are stored on the :class:`Project`.\n\n    :param project: The :class:`Project` this Stage belongs to.\n                    Note that you still need to set :attr:`Project.stage` to\n                    this Stage instance.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "name"
OP "="
STRING "\"Stage\""
NEWLINE "\n"
NAME "is_draggable"
OP "="
NAME "False"
NEWLINE "\n"
NAME "is_visible"
OP "="
NAME "True"
NEWLINE "\n"
NL "\n"
NAME "SIZE"
OP "="
OP "("
NUMBER "480"
OP ","
NUMBER "360"
OP ")"
NEWLINE "\n"
NAME "COLOR"
OP "="
OP "("
NUMBER "255"
OP ","
NUMBER "255"
OP ","
NUMBER "255"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "project"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "Scriptable"
OP "."
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "project"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "backgrounds"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Alias for :attr:`costumes`.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "self"
OP "."
NAME "costumes"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "backgrounds"
OP "."
NAME "setter"
NEWLINE "\n"
NAME "def"
NAME "backgrounds"
OP "("
NAME "self"
OP ","
NAME "value"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "costumes"
OP "="
NAME "value"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"<%s.%s()>\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "not"
NAME "self"
OP "."
NAME "costume"
NAME "and"
NAME "not"
NAME "self"
OP "."
NAME "costumes"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "costume"
OP "="
NAME "Costume"
OP "("
STRING "\"blank\""
OP ","
NAME "Image"
OP "."
NAME "new"
OP "("
NAME "self"
OP "."
NAME "SIZE"
OP ","
NAME "self"
OP "."
NAME "COLOR"
OP ")"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "Scriptable"
OP "."
NAME "_normalize"
OP "("
NAME "self"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Sprite"
OP "("
NAME "Scriptable"
OP ","
NAME "Actor"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A scriptable object displayed on the project stage. Can be moved and\n    rotated, unlike the :class:`Stage`.\n\n    Sprites require a :attr:`costume`, and will raise an error when saving\n    without one.\n\n    :param project: The :class:`Project` this Sprite belongs to.\n                    Note that you still need to add this sprite to\n                    :attr:`Project.sprites`.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "project"
OP ","
NAME "name"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "Scriptable"
OP "."
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "project"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "name"
OP "="
NAME "unicode"
OP "("
NAME "name"
OP ")"
NEWLINE "\n"
STRING "\"\"\"The name of the sprite, as referred to from scripts and displayed in\n        the Scratch interface.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "position"
OP "="
OP "("
NUMBER "0"
OP ","
NUMBER "0"
OP ")"
NEWLINE "\n"
STRING "\"\"\"The ``(x, y)`` position of the centre of the sprite in Scratch\n        co-ordinates.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "direction"
OP "="
NUMBER "90.0"
NEWLINE "\n"
STRING "\"\"\"The angle in degrees the sprite is rotated to.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "rotation_style"
OP "="
STRING "\"normal\""
NEWLINE "\n"
STRING "\"\"\"How the sprite's costume rotates with the sprite. Valid values are:\n\n        ``'normal'``\n            Continuous rotation with :attr:`direction`. The default.\n\n        ``'leftRight'``\n            Don't rotate. Instead, flip the costume for directions with x\n            component < 0. Useful for side-views.\n\n        ``'none'``\n            Don't rotate with direction.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "size"
OP "="
NUMBER "100.0"
NEWLINE "\n"
STRING "\"\"\"The scale factor of the sprite in percent. Defaults to 100.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "is_draggable"
OP "="
NAME "False"
NEWLINE "\n"
STRING "\"\"\"True if the sprite can be dragged using the mouse in the\n        player/presentation mode.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "is_visible"
OP "="
NAME "True"
NEWLINE "\n"
STRING "\"\"\"Whether the sprite is shown on the stage. False if the sprite is\n        hidden.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "Scriptable"
OP "."
NAME "_normalize"
OP "("
NAME "self"
OP ")"
NEWLINE "\n"
NAME "assert"
NAME "self"
OP "."
NAME "rotation_style"
NAME "in"
OP "("
STRING "\"normal\""
OP ","
STRING "\"leftRight\""
OP ","
STRING "\"none\""
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance, deep-copying all the attributes.\"\"\""
NEWLINE "\n"
NAME "o"
OP "="
NAME "self"
OP "."
NAME "__class__"
OP "("
NAME "self"
OP "."
NAME "project"
OP ","
NAME "self"
OP "."
NAME "name"
OP ")"
NEWLINE "\n"
NAME "Scriptable"
OP "."
NAME "copy"
OP "("
NAME "self"
OP ","
NAME "o"
OP ")"
NEWLINE "\n"
NAME "o"
OP "."
NAME "position"
OP "="
NAME "tuple"
OP "("
NAME "self"
OP "."
NAME "position"
OP ")"
NEWLINE "\n"
NAME "o"
OP "."
NAME "direction"
OP "="
NAME "self"
OP "."
NAME "direction"
NEWLINE "\n"
NAME "o"
OP "."
NAME "rotation_style"
OP "="
NAME "self"
OP "."
NAME "rotation_style"
NEWLINE "\n"
NAME "o"
OP "."
NAME "size"
OP "="
NAME "self"
OP "."
NAME "size"
NEWLINE "\n"
NAME "o"
OP "."
NAME "is_draggable"
OP "="
NAME "self"
OP "."
NAME "is_draggable"
NEWLINE "\n"
NAME "o"
OP "."
NAME "is_visible"
OP "="
NAME "self"
OP "."
NAME "is_visible"
NEWLINE "\n"
NAME "return"
NAME "o"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"<%s.%s(%r)>\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "self"
OP "."
NAME "name"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Watcher"
OP "("
NAME "Actor"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A monitor for displaying a data value on the stage.\n\n    Some formats won't save hidden watchers, and so their position won't be\n    remembered.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "target"
OP ","
NAME "block"
OP ","
NAME "style"
OP "="
STRING "\"normal\""
OP ","
NAME "is_visible"
OP "="
NAME "True"
OP ","
NL "\n"
NAME "pos"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "Actor"
OP "."
NAME "__init__"
OP "("
NAME "self"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "assert"
NAME "target"
NAME "is"
NAME "not"
NAME "None"
NEWLINE "\n"
NAME "self"
OP "."
NAME "target"
OP "="
NAME "target"
NEWLINE "\n"
STRING "\"\"\"The :attr:`Scriptable` or :attr:`Project` the watcher belongs to.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "block"
OP "="
NAME "block"
NEWLINE "\n"
STRING "\"\"\"The :attr:`Block` to evaluate on :attr:`target`.\n\n        For variables::\n\n            kurt.Block('readVariable', 'variable name')\n\n        For lists::\n\n            kurt.Block('contentsOfList:', 'list name')\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "style"
OP "="
NAME "str"
OP "("
NAME "style"
OP ")"
NEWLINE "\n"
STRING "\"\"\"How the watcher should appear.\n\n        Valid values:\n\n        ``'normal'``\n            The name of the data is displayed next to its value. The only\n            valid value for list watchers.\n\n        ``'large'``\n            The data is displayed in a larger font with no describing text.\n\n        ``'slider'``\n            Like the normal style, but displayed with a slider that can change\n            the variable's value. Not valid for reporter block watchers.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "pos"
OP "="
NAME "pos"
NEWLINE "\n"
STRING "\"\"\"``(x, y)`` position of the top-left of the watcher from the top-left\n        of the stage in pixels. None if not specified.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "is_visible"
OP "="
NAME "bool"
OP "("
NAME "is_visible"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Whether the watcher is displayed on the screen.\n\n        Some formats won't save hidden watchers, and so their position won't be\n        remembered.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "slider_min"
OP "="
NUMBER "0"
NEWLINE "\n"
STRING "\"\"\"Minimum value for slider. Only applies to ``\"slider\"`` style.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "slider_max"
OP "="
NUMBER "100"
NEWLINE "\n"
STRING "\"\"\"Maximum value for slider. Only applies to ``\"slider\"`` style.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "assert"
NAME "self"
OP "."
NAME "style"
NAME "in"
OP "("
STRING "\"normal\""
OP ","
STRING "\"large\""
OP ","
STRING "\"slider\""
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "value"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "value"
OP "."
NAME "watcher"
OP "="
NAME "self"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance with the same attributes.\"\"\""
NEWLINE "\n"
NAME "o"
OP "="
NAME "self"
OP "."
NAME "__class__"
OP "("
NAME "self"
OP "."
NAME "target"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "block"
OP "."
NAME "copy"
OP "("
OP ")"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "style"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "is_visible"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "pos"
OP ")"
NEWLINE "\n"
NAME "o"
OP "."
NAME "slider_min"
OP "="
NAME "self"
OP "."
NAME "slider_min"
NEWLINE "\n"
NAME "o"
OP "."
NAME "slider_max"
OP "="
NAME "self"
OP "."
NAME "slider_max"
NEWLINE "\n"
NAME "return"
NAME "o"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "kind"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The type of value to watch, based on :attr:`block`.\n\n        One of ``variable``, ``list``, or ``block``.\n\n        ``block`` watchers watch the value of a reporter block.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "block"
OP "."
NAME "type"
OP "."
NAME "has_command"
OP "("
STRING "'readVariable'"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
STRING "'variable'"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "block"
OP "."
NAME "type"
OP "."
NAME "has_command"
OP "("
STRING "'contentsOfList:'"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
STRING "'list'"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
STRING "'block'"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "value"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return the :class:`Variable` or :class:`List` to watch.\n\n        Returns ``None`` if it's a block watcher.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'variable'"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "target"
OP "."
NAME "variables"
OP "["
NAME "self"
OP "."
NAME "block"
OP "."
NAME "args"
OP "["
NUMBER "0"
OP "]"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'list'"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "target"
OP "."
NAME "lists"
OP "["
NAME "self"
OP "."
NAME "block"
OP "."
NAME "args"
OP "["
NUMBER "0"
OP "]"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "r"
OP "="
STRING "\"%s.%s(%r, %r\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "self"
OP "."
NAME "target"
OP ","
NAME "self"
OP "."
NAME "block"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "style"
OP "!="
STRING "\"normal\""
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", style=%r\""
OP "%"
NAME "self"
OP "."
NAME "style"
NEWLINE "\n"
DEDENT ""
NAME "if"
NAME "not"
NAME "self"
OP "."
NAME "is_visible"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", is_visible=False\""
NEWLINE "\n"
DEDENT ""
NAME "if"
NAME "self"
OP "."
NAME "pos"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", pos=%s\""
OP "%"
NAME "repr"
OP "("
NAME "self"
OP "."
NAME "pos"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "r"
OP "+="
STRING "\")\""
NEWLINE "\n"
NAME "return"
NAME "r"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Variables --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Variable"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A memory value used in scripts.\n\n    There are both :attr:`global variables <Project.variables>` and\n    :attr:`sprite-specific variables <Sprite.variables>`.\n\n    Some formats also have :attr:`stage-specific variables <Stage.variables>`.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "value"
OP "="
NUMBER "0"
OP ","
NAME "is_cloud"
OP "="
NAME "False"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "value"
OP "="
NAME "value"
NEWLINE "\n"
STRING "\"\"\"The value of the variable, usually a number or a string.\n\n        For some formats, variables can take list values, and :class:`List` is\n        not used.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "is_cloud"
OP "="
NAME "bool"
OP "("
NAME "is_cloud"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Whether the value of the variable is shared with other users.\n\n        For Scratch 2.0.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "watcher"
OP "="
NAME "None"
NEWLINE "\n"
STRING "\"\"\"The :class:`Watcher` instance displaying this Variable's value.\"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance with the same attributes.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "self"
OP "."
NAME "__class__"
OP "("
NAME "self"
OP "."
NAME "value"
OP ","
NAME "self"
OP "."
NAME "is_cloud"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "r"
OP "="
STRING "\"%s.%s(%r\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "value"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "is_cloud"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", is_cloud=%r\""
OP "%"
NAME "self"
OP "."
NAME "is_cloud"
NEWLINE "\n"
DEDENT ""
NAME "r"
OP "+="
STRING "\")\""
NEWLINE "\n"
NAME "return"
NAME "r"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "List"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A sequence of items used in scripts.\n\n    Each item takes a :class:`Variable`-like value.\n\n    Lists cannot be nested. However, for some formats, variables can take\n    list values, and this class is not used.\n\n    \"\"\""
NEWLINE "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "items"
OP "="
NAME "None"
OP ","
NAME "is_cloud"
OP "="
NAME "False"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "items"
OP "="
NAME "list"
OP "("
NAME "items"
OP ")"
NAME "if"
NAME "items"
NAME "else"
OP "["
OP "]"
NEWLINE "\n"
STRING "\"\"\"The items contained in the list. A Python list of unicode\n        strings.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "is_cloud"
OP "="
NAME "bool"
OP "("
NAME "is_cloud"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Whether the value of the list is shared with other users.\n\n        For Scratch 2.0.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "watcher"
OP "="
NAME "None"
NEWLINE "\n"
STRING "\"\"\"The :class:`Watcher` instance displaying this List's value.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "items"
OP "="
NAME "map"
OP "("
NAME "unicode"
OP ","
NAME "self"
OP "."
NAME "items"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance with the same attributes.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "self"
OP "."
NAME "__class__"
OP "("
NAME "self"
OP "."
NAME "items"
OP ","
NAME "self"
OP "."
NAME "is_cloud"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "r"
OP "="
STRING "\"<%s.%s(%i items)>\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "len"
OP "("
NAME "self"
OP "."
NAME "items"
OP ")"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "is_cloud"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", is_cloud=%r\""
OP "%"
NAME "self"
OP "."
NAME "is_cloud"
NEWLINE "\n"
DEDENT ""
NAME "r"
OP "+="
STRING "\")\""
NEWLINE "\n"
NAME "return"
NAME "r"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Color --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Color"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A 24-bit RGB color value.\n\n    Accepts tuple or hexcode arguments::\n\n        >>> kurt.Color('#f08')\n        kurt.Color(255, 0, 136)\n\n        >>> kurt.Color((255, 0, 136))\n        kurt.Color(255, 0, 136)\n\n        >>> kurt.Color('#f0ffee')\n        kurt.Color(240, 255, 238)\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "r"
OP ","
NAME "g"
OP "="
NAME "None"
OP ","
NAME "b"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "g"
NAME "is"
NAME "None"
NAME "and"
NAME "b"
NAME "is"
NAME "None"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "isinstance"
OP "("
NAME "r"
OP ","
NAME "Color"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "r"
OP "="
NAME "r"
OP "."
NAME "value"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "r"
OP ","
NAME "basestring"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "not"
NAME "r"
OP "."
NAME "startswith"
OP "("
STRING "\"#\""
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"invalid color hexcode: %r\""
OP "%"
NAME "r"
NEWLINE "\n"
DEDENT ""
NAME "r"
OP "="
NAME "r"
OP "["
NUMBER "1"
OP ":"
OP "]"
NEWLINE "\n"
NAME "if"
NAME "len"
OP "("
NAME "r"
OP ")"
OP "=="
NUMBER "3"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "r"
OP "="
NAME "r"
OP "["
NUMBER "0"
OP "]"
OP "+"
NAME "r"
OP "["
NUMBER "0"
OP "]"
OP "+"
NAME "r"
OP "["
NUMBER "1"
OP "]"
OP "+"
NAME "r"
OP "["
NUMBER "1"
OP "]"
OP "+"
NAME "r"
OP "["
NUMBER "2"
OP "]"
OP "+"
NAME "r"
OP "["
NUMBER "2"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "split"
OP "="
OP "("
NAME "r"
OP "["
NUMBER "0"
OP ":"
NUMBER "2"
OP "]"
OP ","
NAME "r"
OP "["
NUMBER "2"
OP ":"
NUMBER "4"
OP "]"
OP ","
NAME "r"
OP "["
NUMBER "4"
OP ":"
NUMBER "6"
OP "]"
OP ")"
NEWLINE "\n"
NAME "r"
OP "="
OP "["
NAME "int"
OP "("
NAME "x"
OP ","
NUMBER "16"
OP ")"
NAME "for"
NAME "x"
NAME "in"
NAME "split"
OP "]"
NEWLINE "\n"
DEDENT ""
OP "("
NAME "r"
OP ","
NAME "g"
OP ","
NAME "b"
OP ")"
OP "="
NAME "r"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "self"
OP "."
NAME "r"
OP "="
NAME "int"
OP "("
NAME "r"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Red component, 0-255\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "g"
OP "="
NAME "int"
OP "("
NAME "g"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Green component, 0-255\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "b"
OP "="
NAME "int"
OP "("
NAME "b"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Blue component, 0-255\"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "value"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return ``(r, g, b)`` tuple.\"\"\""
NEWLINE "\n"
NAME "return"
OP "("
NAME "self"
OP "."
NAME "r"
OP ","
NAME "self"
OP "."
NAME "g"
OP ","
NAME "self"
OP "."
NAME "b"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "value"
OP "."
NAME "setter"
NEWLINE "\n"
NAME "def"
NAME "value"
OP "("
NAME "self"
OP ","
NAME "value"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
OP "("
NAME "self"
OP "."
NAME "r"
OP ","
NAME "self"
OP "."
NAME "g"
OP ","
NAME "self"
OP "."
NAME "b"
OP ")"
OP "="
NAME "value"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__eq__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "isinstance"
OP "("
NAME "other"
OP ","
NAME "Color"
OP ")"
NAME "and"
NAME "self"
OP "."
NAME "value"
OP "=="
NAME "other"
OP "."
NAME "value"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__ne__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "not"
NAME "self"
OP "=="
NAME "other"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__iter__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "iter"
OP "("
NAME "self"
OP "."
NAME "value"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"%s.%s(%s)\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "repr"
OP "("
NAME "self"
OP "."
NAME "value"
OP ")"
OP "."
NAME "strip"
OP "("
STRING "\"()\""
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "stringify"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Returns the color value in hexcode format.\n\n        eg. ``'#ff1056'``\n\n        \"\"\""
NEWLINE "\n"
NAME "hexcode"
OP "="
STRING "\"#\""
NEWLINE "\n"
NAME "for"
NAME "x"
NAME "in"
NAME "self"
OP "."
NAME "value"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "part"
OP "="
NAME "hex"
OP "("
NAME "x"
OP ")"
OP "["
NUMBER "2"
OP ":"
OP "]"
NEWLINE "\n"
NAME "if"
NAME "len"
OP "("
NAME "part"
OP ")"
OP "<"
NUMBER "2"
OP ":"
NAME "part"
OP "="
STRING "\"0\""
OP "+"
NAME "part"
NEWLINE "\n"
NAME "hexcode"
OP "+="
NAME "part"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "hexcode"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "random"
OP "("
NAME "cls"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "f"
OP "="
NAME "lambda"
OP ":"
NAME "random"
OP "."
NAME "randint"
OP "("
NUMBER "0"
OP ","
NUMBER "255"
OP ")"
NEWLINE "\n"
NAME "return"
NAME "cls"
OP "("
NAME "f"
OP "("
OP ")"
OP ","
NAME "f"
OP "("
OP ")"
OP ","
NAME "f"
OP "("
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- BlockTypes --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Insert"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The specification for an argument to a :class:`BlockType`.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "SHAPE_DEFAULTS"
OP "="
OP "{"
NL "\n"
STRING "'number'"
OP ":"
NUMBER "0"
OP ","
NL "\n"
STRING "'number-menu'"
OP ":"
NUMBER "0"
OP ","
NL "\n"
STRING "'stack'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'color'"
OP ":"
NAME "Color"
OP "("
STRING "'#f00'"
OP ")"
OP ","
NL "\n"
STRING "'inline'"
OP ":"
STRING "'nil'"
OP ","
COMMENT "# Can't be empty"
NL "\n"
OP "}"
NEWLINE "\n"
NL "\n"
NAME "SHAPE_FMTS"
OP "="
OP "{"
NL "\n"
STRING "'number'"
OP ":"
STRING "'(%s)'"
OP ","
NL "\n"
STRING "'string'"
OP ":"
STRING "'[%s]'"
OP ","
NL "\n"
STRING "'readonly-menu'"
OP ":"
STRING "'[%s v]'"
OP ","
NL "\n"
STRING "'number-menu'"
OP ":"
STRING "'(%s v)'"
OP ","
NL "\n"
STRING "'color'"
OP ":"
STRING "'[%s]'"
OP ","
NL "\n"
STRING "'boolean'"
OP ":"
STRING "'<%s>'"
OP ","
NL "\n"
STRING "'stack'"
OP ":"
STRING "'\\n    %s\\n'"
OP ","
NL "\n"
STRING "'inline'"
OP ":"
STRING "'%s'"
OP ","
NL "\n"
STRING "'block'"
OP ":"
STRING "'{%s}'"
OP ","
NL "\n"
OP "}"
NEWLINE "\n"
NL "\n"
NAME "KIND_OPTIONS"
OP "="
OP "{"
NL "\n"
STRING "'attribute'"
OP ":"
OP "["
STRING "'x position'"
OP ","
STRING "'y position'"
OP ","
STRING "'direction'"
OP ","
STRING "'costume #'"
OP ","
NL "\n"
STRING "'size'"
OP ","
STRING "'volume'"
OP "]"
OP ","
NL "\n"
STRING "'backdrop'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'booleanSensor'"
OP ":"
OP "["
STRING "'button pressed'"
OP ","
STRING "'A connected'"
OP ","
STRING "'B connected'"
OP ","
NL "\n"
STRING "'C connected'"
OP ","
STRING "'D connected'"
OP "]"
OP ","
NL "\n"
STRING "'broadcast'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'costume'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'direction'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'drum'"
OP ":"
NAME "range"
OP "("
NUMBER "1"
OP ","
NUMBER "18"
OP ")"
OP ","
NL "\n"
STRING "'effect'"
OP ":"
OP "["
STRING "'color'"
OP ","
STRING "'fisheye'"
OP ","
STRING "'whirl'"
OP ","
STRING "'pixelate'"
OP ","
STRING "'mosaic'"
OP ","
NL "\n"
STRING "'brightness'"
OP ","
STRING "'ghost'"
OP "]"
OP ","
NL "\n"
STRING "'instrument'"
OP ":"
NAME "range"
OP "("
NUMBER "1"
OP ","
NUMBER "21"
OP ")"
OP ","
NL "\n"
STRING "'key'"
OP ":"
OP "["
STRING "'0'"
OP ","
STRING "'1'"
OP ","
STRING "'2'"
OP ","
STRING "'3'"
OP ","
STRING "'4'"
OP ","
STRING "'5'"
OP ","
STRING "'6'"
OP ","
STRING "'7'"
OP ","
STRING "'8'"
OP ","
STRING "'9'"
OP ","
STRING "'a'"
OP ","
STRING "'b'"
OP ","
NL "\n"
STRING "'c'"
OP ","
STRING "'d'"
OP ","
STRING "'e'"
OP ","
STRING "'f'"
OP ","
STRING "'g'"
OP ","
STRING "'h'"
OP ","
STRING "'i'"
OP ","
STRING "'j'"
OP ","
STRING "'k'"
OP ","
STRING "'l'"
OP ","
STRING "'m'"
OP ","
STRING "'n'"
OP ","
STRING "'o'"
OP ","
NL "\n"
STRING "'p'"
OP ","
STRING "'q'"
OP ","
STRING "'r'"
OP ","
STRING "'s'"
OP ","
STRING "'t'"
OP ","
STRING "'u'"
OP ","
STRING "'v'"
OP ","
STRING "'w'"
OP ","
STRING "'x'"
OP ","
STRING "'y'"
OP ","
STRING "'z'"
OP ","
STRING "'space'"
OP ","
NL "\n"
STRING "'left arrow'"
OP ","
STRING "'right arrow'"
OP ","
STRING "'up arrow'"
OP ","
STRING "'down arrow'"
OP "]"
OP ","
NL "\n"
STRING "'list'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'listDeleteItem'"
OP ":"
OP "["
STRING "'last'"
OP ","
STRING "'all'"
OP "]"
OP ","
NL "\n"
STRING "'listItem'"
OP ":"
OP "["
STRING "'last'"
OP ","
STRING "'random'"
OP "]"
OP ","
NL "\n"
STRING "'mathOp'"
OP ":"
OP "["
STRING "'abs'"
OP ","
STRING "'floor'"
OP ","
STRING "'ceiling'"
OP ","
STRING "'sqrt'"
OP ","
STRING "'sin'"
OP ","
STRING "'cos'"
OP ","
STRING "'tan'"
OP ","
NL "\n"
STRING "'asin'"
OP ","
STRING "'acos'"
OP ","
STRING "'atan'"
OP ","
STRING "'ln'"
OP ","
STRING "'log'"
OP ","
STRING "'e ^'"
OP ","
STRING "'10 ^'"
OP "]"
OP ","
NL "\n"
STRING "'motorDirection'"
OP ":"
OP "["
STRING "'this way'"
OP ","
STRING "'that way'"
OP ","
STRING "'reverse'"
OP "]"
OP ","
NL "\n"
STRING "'note'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'rotationStyle'"
OP ":"
OP "["
STRING "'left-right'"
OP ","
STRING "\"don't rotate\""
OP ","
STRING "'all around'"
OP "]"
OP ","
NL "\n"
STRING "'sensor'"
OP ":"
OP "["
STRING "'slider'"
OP ","
STRING "'light'"
OP ","
STRING "'sound'"
OP ","
STRING "'resistance-A'"
OP ","
STRING "'resistance-B'"
OP ","
NL "\n"
STRING "'resistance-C'"
OP ","
STRING "'resistance-D'"
OP "]"
OP ","
NL "\n"
STRING "'sound'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'spriteOnly'"
OP ":"
OP "["
STRING "'myself'"
OP "]"
OP ","
NL "\n"
STRING "'spriteOrMouse'"
OP ":"
OP "["
STRING "'mouse-pointer'"
OP "]"
OP ","
NL "\n"
STRING "'spriteOrStage'"
OP ":"
OP "["
STRING "'Stage'"
OP "]"
OP ","
NL "\n"
STRING "'stageOrThis'"
OP ":"
OP "["
STRING "'Stage'"
OP "]"
OP ","
COMMENT "# ? TODO"
NL "\n"
STRING "'stop'"
OP ":"
OP "["
STRING "'all'"
OP ","
STRING "'this script'"
OP ","
STRING "'other scripts in sprite'"
OP "]"
OP ","
NL "\n"
STRING "'timeAndDate'"
OP ":"
OP "["
STRING "'year'"
OP ","
STRING "'month'"
OP ","
STRING "'date'"
OP ","
STRING "'day of week'"
OP ","
STRING "'hour'"
OP ","
NL "\n"
STRING "'minute'"
OP ","
STRING "'second'"
OP "]"
OP ","
NL "\n"
STRING "'touching'"
OP ":"
OP "["
STRING "'mouse-pointer'"
OP ","
STRING "'edge'"
OP "]"
OP ","
NL "\n"
STRING "'triggerSensor'"
OP ":"
OP "["
STRING "'loudness'"
OP ","
STRING "'timer'"
OP ","
STRING "'video motion'"
OP "]"
OP ","
NL "\n"
STRING "'var'"
OP ":"
OP "["
OP "]"
OP ","
NL "\n"
STRING "'videoMotionType'"
OP ":"
OP "["
STRING "'motion'"
OP ","
STRING "'direction'"
OP "]"
OP ","
NL "\n"
STRING "'videoState'"
OP ":"
OP "["
STRING "'off'"
OP ","
STRING "'on'"
OP ","
STRING "'on-flipped'"
OP "]"
OP ","
NL "\n"
OP "}"
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "shape"
OP ","
NAME "kind"
OP "="
NAME "None"
OP ","
NAME "default"
OP "="
NAME "None"
OP ","
NAME "name"
OP "="
NAME "None"
OP ","
NL "\n"
NAME "unevaluated"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "shape"
OP "="
NAME "shape"
NEWLINE "\n"
STRING "\"\"\"What kind of values this argument accepts.\n\n        Shapes that accept a simple data value or a reporter block:\n\n        ``'number'``\n            An integer or float number. Defaults to ``0``.\n\n        ``'string'``\n            A unicode text value.\n\n        ``'readonly-menu'``\n            A choice of string value from a menu.\n\n            Some readonly inserts do not accept reporter blocks.\n\n        ``'number-menu'``\n            Either a number value, or a choice of special value from a menu.\n\n            Defaults to ``0``.\n\n        ``'color'``\n            A :class:`Color` value. Defaults to a random color.\n\n        Shapes that only accept blocks with the corresponding :attr:`shape`:\n\n        ``'boolean'``\n            Accepts a boolean block.\n\n        ``'stack'``\n            Accepts a list of stack blocks. Defaults to ``[]``.\n\n            The block is rendered with a \"mouth\" into which blocks can be\n            inserted.\n\n        Special shapes:\n\n        ``'inline'``\n            Not actually an insert -- used for variable and list reporters.\n\n        ``'block'``\n            Used for the argument to the \"define ...\" hat block.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "kind"
OP "="
NAME "kind"
NEWLINE "\n"
STRING "\"\"\"Valid arguments for a \"menu\"-shaped insert. Default is ``None``.\n\n        Valid values include:\n\n        * ``'attribute'``\n        * ``'booleanSensor'``\n        * ``'broadcast'``\n        * ``'costume'``\n        * ``'direction'``\n        * ``'drum'``\n        * ``'effect'``\n        * ``'instrument'``\n        * ``'key'``\n        * ``'list'``\n        * ``'listDeleteItem'``\n        * ``'listItem'``\n        * ``'mathOp'``\n        * ``'motorDirection'``\n        * ``'note'``\n        * ``'sensor'``\n        * ``'sound'``\n        * ``'spriteOrMouse'``\n        * ``'spriteOrStage'``\n        * ``'touching'``\n        * ``'var'``\n\n        Scratch 2.0-specific:\n\n        * ``'backdrop'``\n        * ``'rotationStyle'``\n        * ``'spriteOnly'``\n        * ``'stageOrThis'``\n        * ``'stop'``\n        * ``'timeAndDate'``\n        * ``'triggerSensor'``\n        * ``'videoMotionType'``\n        * ``'videoState'``\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "default"
OP "="
NAME "default"
NAME "or"
NAME "Insert"
OP "."
NAME "SHAPE_DEFAULTS"
OP "."
NAME "get"
OP "("
NAME "shape"
OP ","
NAME "None"
OP ")"
NEWLINE "\n"
STRING "\"\"\"The default value for the insert.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "if"
NAME "unevaluated"
NAME "is"
NAME "None"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "unevaluated"
OP "="
NAME "True"
NAME "if"
NAME "shape"
OP "=="
STRING "'stack'"
NAME "else"
NAME "False"
NEWLINE "\n"
DEDENT ""
NAME "self"
OP "."
NAME "unevaluated"
OP "="
NAME "unevaluated"
NEWLINE "\n"
STRING "\"\"\"True if the interpreter should evaluate the argument to the block.\n\n        Defaults to True for 'stack' inserts, False for all others.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "name"
OP "="
NAME "name"
NEWLINE "\n"
STRING "\"\"\"The name of the parameter to a :class:`CustomBlockType`.\n\n        Not used for :class:`BlockTypes <BlockType>`.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "r"
OP "="
STRING "\"%s.%s(%r\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "self"
OP "."
NAME "shape"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "kind"
OP "!="
NAME "None"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", %r\""
OP "%"
NAME "self"
OP "."
NAME "kind"
NEWLINE "\n"
DEDENT ""
NAME "if"
NAME "self"
OP "."
NAME "default"
OP "!="
NAME "Insert"
OP "."
NAME "SHAPE_DEFAULTS"
OP "."
NAME "get"
OP "("
NAME "self"
OP "."
NAME "shape"
OP ","
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", default=%r\""
OP "%"
NAME "self"
OP "."
NAME "default"
NEWLINE "\n"
DEDENT ""
NAME "if"
NAME "self"
OP "."
NAME "unevaluated"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", unevaluated=%r\""
OP "%"
NAME "self"
OP "."
NAME "unevaluated"
NEWLINE "\n"
DEDENT ""
NAME "if"
NAME "self"
OP "."
NAME "name"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", name=%r\""
OP "%"
NAME "self"
OP "."
NAME "name"
NEWLINE "\n"
DEDENT ""
NAME "r"
OP "+="
STRING "\")\""
NEWLINE "\n"
NAME "return"
NAME "r"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__eq__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "isinstance"
OP "("
NAME "other"
OP ","
NAME "Insert"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "for"
NAME "name"
NAME "in"
OP "("
STRING "\"shape\""
OP ","
STRING "\"kind\""
OP ","
STRING "\"default\""
OP ","
STRING "\"unevaluated\""
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "getattr"
OP "("
NAME "self"
OP ","
NAME "name"
OP ")"
OP "!="
NAME "getattr"
OP "("
NAME "other"
OP ","
NAME "name"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "return"
NAME "False"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "True"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "def"
NAME "__ne__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "not"
NAME "self"
OP "=="
NAME "other"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "Insert"
OP "("
NAME "self"
OP "."
NAME "shape"
OP ","
NAME "self"
OP "."
NAME "kind"
OP ","
NAME "self"
OP "."
NAME "default"
OP ","
NAME "self"
OP "."
NAME "name"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "unevaluated"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "stringify"
OP "("
NAME "self"
OP ","
NAME "value"
OP "="
NAME "None"
OP ","
NAME "block_plugin"
OP "="
NAME "False"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "value"
NAME "is"
NAME "None"
NAME "or"
OP "("
NAME "value"
NAME "is"
NAME "False"
NAME "and"
NAME "self"
OP "."
NAME "shape"
OP "=="
STRING "\"boolean\""
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "value"
OP "="
NAME "self"
OP "."
NAME "default"
NEWLINE "\n"
NAME "if"
NAME "value"
NAME "is"
NAME "None"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "value"
OP "="
STRING "\"\""
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "if"
NAME "isinstance"
OP "("
NAME "value"
OP ","
NAME "Block"
OP ")"
OP ":"
COMMENT "# use block's shape"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "value"
OP "."
NAME "stringify"
OP "("
NAME "block_plugin"
OP ","
NAME "in_insert"
OP "="
NAME "True"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "hasattr"
OP "("
NAME "value"
OP ","
STRING "\"stringify\""
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "value"
OP "="
NAME "value"
OP "."
NAME "stringify"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "value"
OP ","
NAME "list"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "value"
OP "="
STRING "\"\\n\""
OP "."
NAME "join"
OP "("
NAME "block"
OP "."
NAME "stringify"
OP "("
NAME "block_plugin"
OP ")"
NAME "for"
NAME "block"
NAME "in"
NAME "value"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "if"
NAME "self"
OP "."
NAME "shape"
OP "=="
STRING "'stack'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "value"
OP "="
NAME "value"
OP "."
NAME "replace"
OP "("
STRING "\"\\n\""
OP ","
STRING "\"\\n    \""
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "if"
NAME "block_plugin"
NAME "or"
NAME "self"
OP "."
NAME "shape"
NAME "in"
STRING "'stack'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "value"
OP "="
NAME "Insert"
OP "."
NAME "SHAPE_FMTS"
OP "."
NAME "get"
OP "("
NAME "self"
OP "."
NAME "shape"
OP ","
STRING "'%s'"
OP ")"
OP "%"
OP "("
NAME "value"
OP ","
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "shape"
OP "=="
STRING "'string'"
NAME "or"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'broadcast'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "value"
OP "="
NAME "unicode"
OP "("
NAME "value"
OP ")"
NEWLINE "\n"
NAME "if"
STRING "\"'\""
NAME "in"
NAME "value"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "value"
OP "="
STRING "'\"%s\"'"
OP "%"
NAME "value"
OP "."
NAME "replace"
OP "("
STRING "'\"'"
OP ","
STRING "'\\\\\"'"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "value"
OP "="
STRING "\"'%s'\""
OP "%"
NAME "value"
OP "."
NAME "replace"
OP "("
STRING "\"'\""
OP ","
STRING "\"\\\\'\""
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "value"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "options"
OP "("
NAME "self"
OP ","
NAME "scriptable"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a list of valid options to a menu insert, given a\n        Scriptable for context.\n\n        Mostly complete, excepting 'attribute'.\n\n        \"\"\""
NEWLINE "\n"
NAME "options"
OP "="
NAME "list"
OP "("
NAME "Insert"
OP "."
NAME "KIND_OPTIONS"
OP "."
NAME "get"
OP "("
NAME "self"
OP "."
NAME "kind"
OP ","
OP "["
OP "]"
OP ")"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "scriptable"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'var'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "options"
OP "+="
NAME "scriptable"
OP "."
NAME "variables"
OP "."
NAME "keys"
OP "("
OP ")"
NEWLINE "\n"
NAME "options"
OP "+="
NAME "scriptable"
OP "."
NAME "project"
OP "."
NAME "variables"
OP "."
NAME "keys"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'list'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "options"
OP "+="
NAME "scriptable"
OP "."
NAME "lists"
OP "."
NAME "keys"
OP "("
OP ")"
NEWLINE "\n"
NAME "options"
OP "+="
NAME "scriptable"
OP "."
NAME "project"
OP "."
NAME "lists"
OP "."
NAME "keys"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'costume'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "options"
OP "+="
OP "["
NAME "c"
OP "."
NAME "name"
NAME "for"
NAME "c"
NAME "in"
NAME "scriptable"
OP "."
NAME "costumes"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'backdrop'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "options"
OP "+="
OP "["
NAME "c"
OP "."
NAME "name"
NAME "for"
NAME "c"
NAME "in"
NAME "scriptable"
OP "."
NAME "project"
OP "."
NAME "stage"
OP "."
NAME "costumes"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'sound'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "options"
OP "+="
OP "["
NAME "c"
OP "."
NAME "name"
NAME "for"
NAME "c"
NAME "in"
NAME "scriptable"
OP "."
NAME "sounds"
OP "]"
NEWLINE "\n"
NAME "options"
OP "+="
OP "["
NAME "c"
OP "."
NAME "name"
NAME "for"
NAME "c"
NAME "in"
NAME "scriptable"
OP "."
NAME "project"
OP "."
NAME "stage"
OP "."
NAME "sounds"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
NAME "in"
OP "("
STRING "'spriteOnly'"
OP ","
STRING "'spriteOrMouse'"
OP ","
STRING "'spriteOrStage'"
OP ","
NL "\n"
STRING "'touching'"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "options"
OP "+="
OP "["
NAME "s"
OP "."
NAME "name"
NAME "for"
NAME "s"
NAME "in"
NAME "scriptable"
OP "."
NAME "project"
OP "."
NAME "sprites"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'attribute'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "pass"
COMMENT "# TODO"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "kind"
OP "=="
STRING "'broadcast'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "options"
OP "+="
NAME "list"
OP "("
NAME "set"
OP "("
NAME "scriptable"
OP "."
NAME "project"
OP "."
NAME "get_broadcasts"
OP "("
OP ")"
OP ")"
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "options"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "BaseBlockType"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"Base for :class:`BlockType` and :class:`PluginBlockType`.\n\n    Defines common attributes.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "SHAPE_FMTS"
OP "="
OP "{"
NL "\n"
STRING "'reporter'"
OP ":"
STRING "'(%s)'"
OP ","
NL "\n"
STRING "'boolean'"
OP ":"
STRING "'<%s>'"
OP ","
NL "\n"
OP "}"
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "shape"
OP ","
NAME "parts"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "shape"
OP "="
NAME "shape"
NEWLINE "\n"
STRING "\"\"\"The shape of the block. Valid values:\n\n        ``'stack'``\n            The default. Can connect to blocks above and below. Appear\n            jigsaw-shaped.\n\n        ``'cap'``\n            Stops the script executing after this block. No blocks can be\n            connected below them.\n\n        ``'hat'``\n            A block that starts a script, such as by responding to an event.\n            Can connect to blocks below.\n\n        ``'reporter'``\n            Return a value. Can be placed into insert slots of other blocks as\n            an argument to that block. Appear rounded.\n\n        ``'boolean'``\n            Like reporter blocks, but return a true/false value. Appear\n            hexagonal.\n\n        \"C\"-shaped blocks with \"mouths\" for stack blocks, such as ``\"doIf\"``,\n        are specified by adding ``Insert('stack')`` to the end of\n        :attr:`parts`.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "parts"
OP "="
NAME "parts"
NEWLINE "\n"
STRING "\"\"\"A list describing the text and arguments of the block.\n\n        Contains strings, which are part of the text displayed on the block,\n        and :class:`Insert` instances, which are arguments to the block.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "text"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The text displayed on the block.\n\n        String containing ``\"%s\"`` in place of inserts.\n\n        eg. ``'say %s for %s secs'``\n\n        \"\"\""
NEWLINE "\n"
NAME "parts"
OP "="
OP "["
OP "("
STRING "\"%s\""
NAME "if"
NAME "isinstance"
OP "("
NAME "p"
OP ","
NAME "Insert"
OP ")"
NAME "else"
NAME "p"
OP ")"
NAME "for"
NAME "p"
NAME "in"
NAME "self"
OP "."
NAME "parts"
OP "]"
NEWLINE "\n"
NAME "parts"
OP "="
OP "["
OP "("
STRING "\"%%\""
NAME "if"
NAME "p"
OP "=="
STRING "\"%\""
NAME "else"
NAME "p"
OP ")"
NAME "for"
NAME "p"
NAME "in"
NAME "parts"
OP "]"
COMMENT "# escape percent"
NEWLINE "\n"
NAME "return"
STRING "\"\""
OP "."
NAME "join"
OP "("
NAME "parts"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "inserts"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The type of each argument to the block.\n\n        List of :class:`Insert` instances.\n\n        \"\"\""
NEWLINE "\n"
NAME "return"
OP "["
NAME "p"
NAME "for"
NAME "p"
NAME "in"
NAME "self"
OP "."
NAME "parts"
NAME "if"
NAME "isinstance"
OP "("
NAME "p"
OP ","
NAME "Insert"
OP ")"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "defaults"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Default values for block inserts. (See :attr:`Block.args`.)\"\"\""
NEWLINE "\n"
NAME "return"
OP "["
NAME "i"
OP "."
NAME "default"
NAME "for"
NAME "i"
NAME "in"
NAME "self"
OP "."
NAME "inserts"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "stripped_text"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The :attr:`text`, with spaces and inserts removed.\n\n        Used by :class:`BlockType.get` to look up blocks.\n\n        \"\"\""
NEWLINE "\n"
NAME "return"
NAME "BaseBlockType"
OP "."
NAME "_strip_text"
OP "("
NL "\n"
NAME "self"
OP "."
NAME "text"
OP "%"
NAME "tuple"
OP "("
OP "("
NAME "i"
OP "."
NAME "default"
NAME "if"
NAME "i"
OP "."
NAME "shape"
OP "=="
STRING "'inline'"
NAME "else"
STRING "'%s'"
OP ")"
NL "\n"
NAME "for"
NAME "i"
NAME "in"
NAME "self"
OP "."
NAME "inserts"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "staticmethod"
NEWLINE "\n"
NAME "def"
NAME "_strip_text"
OP "("
NAME "text"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Returns text with spaces and inserts removed.\"\"\""
NEWLINE "\n"
NAME "text"
OP "="
NAME "re"
OP "."
NAME "sub"
OP "("
STRING "r'[ ,?:]|%s'"
OP ","
STRING "\"\""
OP ","
NAME "text"
OP "."
NAME "lower"
OP "("
OP ")"
OP ")"
NEWLINE "\n"
NAME "for"
NAME "chr"
NAME "in"
STRING "\"-%\""
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "new_text"
OP "="
NAME "text"
OP "."
NAME "replace"
OP "("
NAME "chr"
OP ","
STRING "\"\""
OP ")"
NEWLINE "\n"
NAME "if"
NAME "new_text"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "text"
OP "="
NAME "new_text"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "text"
OP "."
NAME "lower"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"<%s.%s(%r shape=%r)>\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "text"
OP "%"
NAME "tuple"
OP "("
NAME "i"
OP "."
NAME "stringify"
OP "("
NAME "None"
OP ")"
NAME "for"
NAME "i"
NAME "in"
NAME "self"
OP "."
NAME "inserts"
OP ")"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "shape"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "stringify"
OP "("
NAME "self"
OP ","
NAME "args"
OP "="
NAME "None"
OP ","
NAME "block_plugin"
OP "="
NAME "False"
OP ","
NAME "in_insert"
OP "="
NAME "False"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "args"
NAME "is"
NAME "None"
OP ":"
NAME "args"
OP "="
NAME "self"
OP "."
NAME "defaults"
NEWLINE "\n"
NAME "args"
OP "="
NAME "list"
OP "("
NAME "args"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "r"
OP "="
NAME "self"
OP "."
NAME "text"
OP "%"
NAME "tuple"
OP "("
NAME "i"
OP "."
NAME "stringify"
OP "("
NAME "args"
OP "."
NAME "pop"
OP "("
NUMBER "0"
OP ")"
OP ","
NAME "block_plugin"
OP ")"
NL "\n"
NAME "for"
NAME "i"
NAME "in"
NAME "self"
OP "."
NAME "inserts"
OP ")"
NEWLINE "\n"
NAME "for"
NAME "insert"
NAME "in"
NAME "self"
OP "."
NAME "inserts"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "insert"
OP "."
NAME "shape"
OP "=="
STRING "'stack'"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "r"
OP "+"
STRING "\"end\""
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "fmt"
OP "="
NAME "BaseBlockType"
OP "."
NAME "SHAPE_FMTS"
OP "."
NAME "get"
OP "("
NAME "self"
OP "."
NAME "shape"
OP ","
STRING "\"%s\""
OP ")"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "block_plugin"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "fmt"
OP "="
STRING "\"%s\""
NAME "if"
NAME "fmt"
OP "=="
STRING "\"%s\""
NAME "else"
STRING "\"(%s)\""
NEWLINE "\n"
DEDENT ""
NAME "if"
NAME "in_insert"
NAME "and"
NAME "fmt"
OP "=="
STRING "\"%s\""
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "fmt"
OP "="
STRING "\"{%s}\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "return"
NAME "fmt"
OP "%"
NAME "r"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "has_insert"
OP "("
NAME "self"
OP ","
NAME "shape"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Returns True if any of the inserts have the given shape.\"\"\""
NEWLINE "\n"
NAME "for"
NAME "insert"
NAME "in"
NAME "self"
OP "."
NAME "inserts"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "insert"
OP "."
NAME "shape"
OP "=="
NAME "shape"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "True"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "False"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "BlockType"
OP "("
NAME "BaseBlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The specification for a type of :class:`Block`.\n\n    These are initialiased by :class:`Kurt` by combining\n    :class:`PluginBlockType` objects from individual format plugins to\n    create a single :class:`BlockType` for each command.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__getstate__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"lambda functions are not pickleable so drop them.\"\"\""
NEWLINE "\n"
NAME "copy"
OP "="
NAME "self"
OP "."
NAME "__dict__"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
NAME "copy"
OP "["
STRING "'_workaround'"
OP "]"
OP "="
NAME "None"
NEWLINE "\n"
NAME "return"
NAME "copy"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "pbt"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "isinstance"
OP "("
NAME "pbt"
OP ","
NAME "basestring"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "raise"
NAME "ValueError"
OP "("
STRING "\"Invalid argument. Did you mean `BlockType.get`?\""
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "self"
OP "."
NAME "_plugins"
OP "="
NAME "OrderedDict"
OP "("
OP "["
OP "("
NAME "pbt"
OP "."
NAME "format"
OP ","
NAME "pbt"
OP ")"
OP "]"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Stores :class:`PluginBlockType` objects for each plugin name.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "_workaround"
OP "="
NAME "None"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_add_conversion"
OP "("
NAME "self"
OP ","
NAME "plugin"
OP ","
NAME "pbt"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Add a new PluginBlockType conversion.\n\n        If the plugin already exists, do nothing.\n\n        \"\"\""
NEWLINE "\n"
NAME "assert"
NAME "self"
OP "."
NAME "shape"
OP "=="
NAME "pbt"
OP "."
NAME "shape"
NEWLINE "\n"
NAME "assert"
NAME "len"
OP "("
NAME "self"
OP "."
NAME "inserts"
OP ")"
OP "=="
NAME "len"
OP "("
NAME "pbt"
OP "."
NAME "inserts"
OP ")"
NEWLINE "\n"
NAME "for"
OP "("
NAME "i"
OP ","
NAME "o"
OP ")"
NAME "in"
NAME "zip"
OP "("
NAME "self"
OP "."
NAME "inserts"
OP ","
NAME "pbt"
OP "."
NAME "inserts"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "assert"
NAME "i"
OP "."
NAME "shape"
OP "=="
NAME "o"
OP "."
NAME "shape"
NEWLINE "\n"
NAME "assert"
NAME "i"
OP "."
NAME "kind"
OP "=="
NAME "o"
OP "."
NAME "kind"
NEWLINE "\n"
NAME "assert"
NAME "i"
OP "."
NAME "unevaluated"
OP "=="
NAME "o"
OP "."
NAME "unevaluated"
NEWLINE "\n"
DEDENT ""
NAME "if"
NAME "plugin"
NAME "not"
NAME "in"
NAME "self"
OP "."
NAME "_plugins"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "_plugins"
OP "["
NAME "plugin"
OP "]"
OP "="
NAME "pbt"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "convert"
OP "("
NAME "self"
OP ","
NAME "plugin"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a :class:`PluginBlockType` for the given plugin name.\n\n        If plugin is ``None``, return the first registered plugin.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "plugin"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "plugin"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "get_plugin"
OP "("
NAME "plugin"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "plugin"
OP "."
NAME "name"
NAME "in"
NAME "self"
OP "."
NAME "_plugins"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "self"
OP "."
NAME "_plugins"
OP "["
NAME "plugin"
OP "."
NAME "name"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "err"
OP "="
NAME "BlockNotSupported"
OP "("
STRING "\"%s doesn't have %r\""
OP "%"
NL "\n"
OP "("
NAME "plugin"
OP "."
NAME "display_name"
OP ","
NAME "self"
OP ")"
OP ")"
NEWLINE "\n"
NAME "err"
OP "."
NAME "block_type"
OP "="
NAME "self"
NEWLINE "\n"
NAME "raise"
NAME "err"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "conversions"
OP "["
NUMBER "0"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "conversions"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return the list of :class:`PluginBlockType` instances.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "self"
OP "."
NAME "_plugins"
OP "."
NAME "values"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "has_conversion"
OP "("
NAME "self"
OP ","
NAME "plugin"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return True if the plugin supports this block.\"\"\""
NEWLINE "\n"
NAME "plugin"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "get_plugin"
OP "("
NAME "plugin"
OP ")"
NEWLINE "\n"
NAME "return"
NAME "plugin"
OP "."
NAME "name"
NAME "in"
NAME "self"
OP "."
NAME "_plugins"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "has_command"
OP "("
NAME "self"
OP ","
NAME "command"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Returns True if any of the plugins have the given command.\"\"\""
NEWLINE "\n"
NAME "for"
NAME "pbt"
NAME "in"
NAME "self"
OP "."
NAME "_plugins"
OP "."
NAME "values"
OP "("
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "pbt"
OP "."
NAME "command"
OP "=="
NAME "command"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "True"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "False"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "shape"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "convert"
OP "("
OP ")"
OP "."
NAME "shape"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "parts"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "convert"
OP "("
OP ")"
OP "."
NAME "parts"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "get"
OP "("
NAME "cls"
OP ","
NAME "block_type"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a :class:`BlockType` instance from the given parameter.\n\n        * If it's already a BlockType instance, return that.\n\n        * If it exactly matches the command on a :class:`PluginBlockType`,\n          return the corresponding BlockType.\n\n        * If it loosely matches the text on a PluginBlockType, return the\n          corresponding BlockType.\n\n        * If it's a PluginBlockType instance, look for and return the\n          corresponding BlockType.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "isinstance"
OP "("
NAME "block_type"
OP ","
OP "("
NAME "BlockType"
OP ","
NAME "CustomBlockType"
OP ")"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "block_type"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "if"
NAME "isinstance"
OP "("
NAME "block_type"
OP ","
NAME "PluginBlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "block_type"
OP "="
NAME "block_type"
OP "."
NAME "command"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "block"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "block_by_command"
OP "("
NAME "block_type"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "block"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "block"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "blocks"
OP "="
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "blocks_by_text"
OP "("
NAME "block_type"
OP ")"
NEWLINE "\n"
NAME "for"
NAME "block"
NAME "in"
NAME "blocks"
OP ":"
COMMENT "# check the blocks' commands map to unique blocks"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "kurt"
OP "."
NAME "plugin"
OP "."
NAME "Kurt"
OP "."
NAME "block_by_command"
OP "("
NL "\n"
NAME "block"
OP "."
NAME "convert"
OP "("
OP ")"
OP "."
NAME "command"
OP ")"
OP "!="
NAME "blocks"
OP "["
NUMBER "0"
OP "]"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "raise"
NAME "ValueError"
OP "("
NL "\n"
STRING "\"ambigious block text %r, use one of %r instead\""
OP "%"
NL "\n"
OP "("
NAME "block_type"
OP ","
OP "["
NAME "b"
OP "."
NAME "convert"
OP "("
OP ")"
OP "."
NAME "command"
NAME "for"
NAME "b"
NAME "in"
NAME "blocks"
OP "]"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "if"
NAME "blocks"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "blocks"
OP "["
NUMBER "0"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "raise"
NAME "UnknownBlock"
OP ","
NAME "repr"
OP "("
NAME "block_type"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__eq__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "isinstance"
OP "("
NAME "other"
OP ","
NAME "BlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "shape"
OP "=="
NAME "other"
OP "."
NAME "shape"
NAME "and"
NAME "self"
OP "."
NAME "inserts"
OP "=="
NAME "other"
OP "."
NAME "inserts"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "for"
NAME "plugin"
NAME "in"
NAME "self"
OP "."
NAME "_plugins"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "if"
NAME "plugin"
NAME "in"
NAME "other"
OP "."
NAME "_plugins"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "return"
NAME "self"
OP "."
NAME "_plugins"
OP "["
NAME "plugin"
OP "]"
OP "=="
NAME "other"
OP "."
NAME "_plugins"
OP "["
NAME "plugin"
OP "]"
NEWLINE "\n"
DEDENT ""
DEDENT ""
DEDENT ""
DEDENT ""
NAME "return"
NAME "False"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__ne__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "not"
NAME "self"
OP "=="
NAME "other"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_add_workaround"
OP "("
NAME "self"
OP ","
NAME "workaround"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "_workaround"
OP "="
NAME "workaround"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "PluginBlockType"
OP "("
NAME "BaseBlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"Holds plugin-specific :class:`BlockType` attributes.\n\n    For each block concept, :class:`Kurt` builds a single BlockType that\n    references a corresponding PluginBlockType for each plugin that\n    supports that block.\n\n    Note that whichever plugin is loaded first takes precedence.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "category"
OP ","
NAME "shape"
OP ","
NAME "command"
OP ","
NAME "parts"
OP ","
NAME "match"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "BaseBlockType"
OP "."
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "shape"
OP ","
NAME "parts"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "format"
OP "="
NAME "None"
NEWLINE "\n"
STRING "\"\"\"The format plugin the block belongs to.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "command"
OP "="
NAME "command"
NEWLINE "\n"
STRING "\"\"\"The method name from the source code, used to identify the block.\n\n        eg. ``'say:duration:elapsed:from:'``\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "category"
OP "="
NAME "category"
NEWLINE "\n"
STRING "\"\"\"Where the block is found in the interface.\n\n        The same blocks may have different categories in different formats.\n\n        Possible values include::\n\n            'motion', 'looks', 'sound', 'pen', 'control', 'events', 'sensing',\n            'operators', 'data', 'variables', 'list', 'more blocks', 'motor',\n            'sensor', 'wedo', 'midi', 'obsolete'\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "_match"
OP "="
NAME "match"
NEWLINE "\n"
STRING "\"\"\"String -- equivalent command from other plugin.\n\n        The plugin containing the command to match against must have been\n        registered first.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "__class__"
OP "("
NAME "self"
OP "."
NAME "category"
OP ","
NAME "self"
OP "."
NAME "shape"
OP ","
NAME "self"
OP "."
NAME "command"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "parts"
OP ","
NAME "self"
OP "."
NAME "_match"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__eq__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "isinstance"
OP "("
NAME "other"
OP ","
NAME "BlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "shape"
OP "=="
NAME "other"
OP "."
NAME "shape"
NAME "and"
NAME "self"
OP "."
NAME "inserts"
OP "=="
NAME "other"
OP "."
NAME "inserts"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "for"
NAME "t"
NAME "in"
NAME "self"
OP "."
NAME "_plugins"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "if"
NAME "t"
NAME "in"
NAME "other"
OP "."
NAME "_plugins"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "return"
NAME "True"
NEWLINE "\n"
DEDENT ""
DEDENT ""
DEDENT ""
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "other"
OP ","
NAME "PluginBlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "for"
NAME "name"
NAME "in"
OP "("
STRING "\"shape\""
OP ","
STRING "\"inserts\""
OP ","
STRING "\"command\""
OP ","
STRING "\"format\""
OP ","
STRING "\"category\""
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                 "
NAME "if"
NAME "getattr"
OP "("
NAME "self"
OP ","
NAME "name"
OP ")"
OP "!="
NAME "getattr"
OP "("
NAME "other"
OP ","
NAME "name"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "return"
NAME "False"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "True"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "False"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "CustomBlockType"
OP "("
NAME "BaseBlockType"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A user-specified :class:`BlockType`.\n\n    The script defining the custom block starts with::\n\n        kurt.Block(\"procDef\", <CustomBlockType>)\n\n    And the scripts definining the block follow.\n\n    The same CustomBlockType instance can then be used in a block in another\n    script::\n\n        kurt.Block(<CustomBlocktype>, [args ...,])\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "shape"
OP ","
NAME "parts"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "BaseBlockType"
OP "."
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "shape"
OP ","
NAME "parts"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "is_atomic"
OP "="
NAME "False"
NEWLINE "\n"
STRING "\"\"\"True if the block should run without screen refresh.\"\"\""
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Scripts --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Block"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A statement in a graphical programming language. Blocks can connect\n    together to form sequences of commands, which are stored in a\n    :class:`Script`. Blocks perform different commands depending on their\n    type.\n\n    :param type:      A :class:`BlockType` instance, used to identify the\n                      command the block performs.\n                      Will also exact match a :attr:`command` or loosely match\n                      :attr:`text`.\n\n    :param ``*args``: List of the block's arguments. Arguments can be numbers,\n                      strings, Blocks, or lists of Blocks (for 'stack' shaped\n                      Inserts).\n\n    The following constructors are all equivalent::\n\n        >>> block = kurt.Block('say:duration:elapsed:from:', 'Hello!', 2)\n        >>> block = kurt.Block('say %s for %s secs', 'Hello!', 2)\n        >>> block = kurt.Block('sayforsecs', 'Hello!', 2)\n\n    Using BlockType::\n\n        >>> block.type\n        <kurt.BlockType('say [Hello!] for (2) secs', 'stack')>\n        >>> block.args\n        ['Hello!', 2]\n        >>> block2 = kurt.Block(block.type, 'Goodbye!', 5)\n        >>> block.stringify()\n        'say [Hello!] for (2) secs'\n        >>> block2.stringify()\n        'say [Goodbye!] for (5) secs'\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "block_type"
OP ","
OP "*"
NAME "args"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "type"
OP "="
NAME "BlockType"
OP "."
NAME "get"
OP "("
NAME "block_type"
OP ")"
NEWLINE "\n"
STRING "\"\"\":class:`BlockType` instance. The command this block performs.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "args"
OP "="
OP "["
OP "]"
NEWLINE "\n"
STRING "\"\"\"List of arguments to the block.\n\n        The block's parameters are found in :attr:`type.inserts\n        <BlockType.inserts>`. Default values come from :attr:`type.defaults\n        <BlockType.defaults`.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "comment"
OP "="
STRING "\"\""
NEWLINE "\n"
STRING "\"\"\"The text of the comment attached to the block. Empty if no comment\n        is attached.\n\n        Comments can only be attached to stack blocks.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "if"
NAME "self"
OP "."
NAME "type"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "args"
OP "="
NAME "self"
OP "."
NAME "type"
OP "."
NAME "defaults"
OP "["
OP ":"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "for"
NAME "i"
NAME "in"
NAME "xrange"
OP "("
NAME "len"
OP "("
NAME "args"
OP ")"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "i"
OP "<"
NAME "len"
OP "("
NAME "self"
OP "."
NAME "args"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "self"
OP "."
NAME "args"
OP "["
NAME "i"
OP "]"
OP "="
NAME "args"
OP "["
NAME "i"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "self"
OP "."
NAME "args"
OP "."
NAME "append"
OP "("
NAME "args"
OP "["
NAME "i"
OP "]"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "self"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "type"
OP "="
NAME "BlockType"
OP "."
NAME "get"
OP "("
NAME "self"
OP "."
NAME "type"
OP ")"
NEWLINE "\n"
NAME "inserts"
OP "="
NAME "list"
OP "("
NAME "self"
OP "."
NAME "type"
OP "."
NAME "inserts"
OP ")"
NEWLINE "\n"
NAME "args"
OP "="
OP "["
OP "]"
NEWLINE "\n"
NAME "for"
NAME "arg"
NAME "in"
NAME "self"
OP "."
NAME "args"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "insert"
OP "="
NAME "inserts"
OP "."
NAME "pop"
OP "("
NUMBER "0"
OP ")"
NAME "if"
NAME "inserts"
NAME "else"
NAME "None"
NEWLINE "\n"
NAME "if"
NAME "insert"
NAME "and"
NAME "insert"
OP "."
NAME "shape"
NAME "in"
OP "("
STRING "'number'"
OP ","
STRING "'number-menu'"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "basestring"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "try"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "arg"
OP "="
NAME "float"
OP "("
NAME "arg"
OP ")"
NEWLINE "\n"
NAME "arg"
OP "="
NAME "int"
OP "("
NAME "arg"
OP ")"
NAME "if"
NAME "int"
OP "("
NAME "arg"
OP ")"
OP "=="
NAME "arg"
NAME "else"
NAME "arg"
NEWLINE "\n"
DEDENT ""
NAME "except"
NAME "ValueError"
OP ":"
NEWLINE "\n"
INDENT "                        "
NAME "pass"
NEWLINE "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "args"
OP "."
NAME "append"
OP "("
NAME "arg"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "self"
OP "."
NAME "args"
OP "="
NAME "args"
NEWLINE "\n"
NAME "self"
OP "."
NAME "comment"
OP "="
NAME "unicode"
OP "("
NAME "self"
OP "."
NAME "comment"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new Block instance with the same attributes.\"\"\""
NEWLINE "\n"
NAME "args"
OP "="
OP "["
OP "]"
NEWLINE "\n"
NAME "for"
NAME "arg"
NAME "in"
NAME "self"
OP "."
NAME "args"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "Block"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "arg"
OP "="
NAME "arg"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "list"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "arg"
OP "="
OP "["
NAME "b"
OP "."
NAME "copy"
OP "("
OP ")"
NAME "for"
NAME "b"
NAME "in"
NAME "arg"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "args"
OP "."
NAME "append"
OP "("
NAME "arg"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "Block"
OP "("
NAME "self"
OP "."
NAME "type"
OP ","
OP "*"
NAME "args"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__eq__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
OP "("
NL "\n"
NAME "isinstance"
OP "("
NAME "other"
OP ","
NAME "Block"
OP ")"
NAME "and"
NL "\n"
NAME "self"
OP "."
NAME "type"
OP "=="
NAME "other"
OP "."
NAME "type"
NAME "and"
NL "\n"
NAME "self"
OP "."
NAME "args"
OP "=="
NAME "other"
OP "."
NAME "args"
NL "\n"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__ne__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "not"
NAME "self"
OP "=="
NAME "other"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "string"
OP "="
STRING "\"%s.%s(%s, \""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NL "\n"
NAME "repr"
OP "("
NAME "self"
OP "."
NAME "type"
OP "."
NAME "convert"
OP "("
OP ")"
OP "."
NAME "command"
NAME "if"
NAME "isinstance"
OP "("
NAME "self"
OP "."
NAME "type"
OP ","
NL "\n"
NAME "BlockType"
OP ")"
NAME "else"
NAME "self"
OP "."
NAME "type"
OP ")"
OP ")"
NEWLINE "\n"
NAME "for"
NAME "arg"
NAME "in"
NAME "self"
OP "."
NAME "args"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "Block"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "string"
OP "="
NAME "string"
OP "."
NAME "rstrip"
OP "("
STRING "\"\\n\""
OP ")"
NEWLINE "\n"
NAME "string"
OP "+="
STRING "\"\\n    %s,\\n\""
OP "%"
NAME "repr"
OP "("
NAME "arg"
OP ")"
OP "."
NAME "replace"
OP "("
STRING "\"\\n\""
OP ","
STRING "\"\\n    \""
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "isinstance"
OP "("
NAME "arg"
OP ","
NAME "list"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "if"
NAME "string"
OP "."
NAME "endswith"
OP "("
STRING "\"\\n\""
OP ")"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "string"
OP "+="
STRING "\"    \""
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "string"
OP "+="
STRING "\" \""
NEWLINE "\n"
DEDENT ""
NAME "string"
OP "+="
STRING "\"[\\n\""
NEWLINE "\n"
NAME "for"
NAME "block"
NAME "in"
NAME "arg"
OP ":"
NEWLINE "\n"
INDENT "                    "
NAME "string"
OP "+="
STRING "\"    \""
NEWLINE "\n"
NAME "string"
OP "+="
NAME "repr"
OP "("
NAME "block"
OP ")"
OP "."
NAME "replace"
OP "("
STRING "\"\\n\""
OP ","
STRING "\"\\n    \""
OP ")"
NEWLINE "\n"
NAME "string"
OP "+="
STRING "\",\\n\""
NEWLINE "\n"
DEDENT ""
NAME "string"
OP "+="
STRING "\"    ], \""
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "string"
OP "+="
NAME "repr"
OP "("
NAME "arg"
OP ")"
OP "+"
STRING "\", \""
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "string"
OP "="
NAME "string"
OP "."
NAME "rstrip"
OP "("
STRING "\" \""
OP ")"
OP "."
NAME "rstrip"
OP "("
STRING "\",\""
OP ")"
NEWLINE "\n"
NAME "return"
NAME "string"
OP "+"
STRING "\")\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "stringify"
OP "("
NAME "self"
OP ","
NAME "block_plugin"
OP "="
NAME "False"
OP ","
NAME "in_insert"
OP "="
NAME "False"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "s"
OP "="
NAME "self"
OP "."
NAME "type"
OP "."
NAME "stringify"
OP "("
NAME "self"
OP "."
NAME "args"
OP ","
NAME "block_plugin"
OP ","
NAME "in_insert"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "comment"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "i"
OP "="
NAME "s"
OP "."
NAME "index"
OP "("
STRING "\"\\n\""
OP ")"
NAME "if"
STRING "\"\\n\""
NAME "in"
NAME "s"
NAME "else"
NAME "len"
OP "("
NAME "s"
OP ")"
NEWLINE "\n"
NAME "indent"
OP "="
STRING "\"\\n\""
OP "+"
STRING "\" \""
OP "*"
NAME "i"
OP "+"
STRING "\" // \""
NEWLINE "\n"
NAME "comment"
OP "="
STRING "\" // \""
OP "+"
NAME "self"
OP "."
NAME "comment"
OP "."
NAME "replace"
OP "("
STRING "\"\\n\""
OP ","
NAME "indent"
OP ")"
NEWLINE "\n"
NAME "s"
OP "="
NAME "s"
OP "["
OP ":"
NAME "i"
OP "]"
OP "+"
NAME "comment"
OP "+"
NAME "s"
OP "["
NAME "i"
OP ":"
OP "]"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "s"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Script"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A single sequence of blocks. Each :class:`Scriptable` can have many\n    Scripts.\n\n    The first block, ``self.blocks[0]`` is usually a \"when\" block, eg. an\n    EventHatMorph.\n\n    Scripts implement the ``list`` interface, so can be indexed directly, eg.\n    ``script[0]``. All other methods like ``append`` also work.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "blocks"
OP "="
NAME "None"
OP ","
NAME "pos"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "blocks"
OP "="
NAME "blocks"
NAME "or"
OP "["
OP "]"
NEWLINE "\n"
NAME "self"
OP "."
NAME "blocks"
OP "="
NAME "list"
OP "("
NAME "self"
OP "."
NAME "blocks"
OP ")"
NEWLINE "\n"
STRING "\"\"\"The list of :class:`Blocks <Block>`.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "pos"
OP "="
NAME "tuple"
OP "("
NAME "pos"
OP ")"
NAME "if"
NAME "pos"
NAME "else"
NAME "None"
NEWLINE "\n"
STRING "\"\"\"``(x, y)`` position from the top-left of the script area in\n        pixels.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "pos"
OP "="
NAME "self"
OP "."
NAME "pos"
NEWLINE "\n"
NAME "self"
OP "."
NAME "blocks"
OP "="
NAME "list"
OP "("
NAME "self"
OP "."
NAME "blocks"
OP ")"
NEWLINE "\n"
NAME "for"
NAME "block"
NAME "in"
NAME "self"
OP "."
NAME "blocks"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "block"
OP "."
NAME "_normalize"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance with the same attributes.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "self"
OP "."
NAME "__class__"
OP "("
OP "["
NAME "b"
OP "."
NAME "copy"
OP "("
OP ")"
NAME "for"
NAME "b"
NAME "in"
NAME "self"
OP "."
NAME "blocks"
OP "]"
OP ","
NL "\n"
NAME "tuple"
OP "("
NAME "self"
OP "."
NAME "pos"
OP ")"
NAME "if"
NAME "self"
OP "."
NAME "pos"
NAME "else"
NAME "None"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__eq__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
OP "("
NL "\n"
NAME "isinstance"
OP "("
NAME "other"
OP ","
NAME "Script"
OP ")"
NAME "and"
NL "\n"
NAME "self"
OP "."
NAME "blocks"
OP "=="
NAME "other"
OP "."
NAME "blocks"
NL "\n"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__ne__"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "not"
NAME "self"
OP "=="
NAME "other"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "r"
OP "="
STRING "\"%s.%s([\\n\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ")"
NEWLINE "\n"
NAME "for"
NAME "block"
NAME "in"
NAME "self"
OP "."
NAME "blocks"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\"    \""
OP "+"
NAME "repr"
OP "("
NAME "block"
OP ")"
OP "."
NAME "replace"
OP "("
STRING "\"\\n\""
OP ","
STRING "\"\\n    \""
OP ")"
OP "+"
STRING "\",\\n\""
NEWLINE "\n"
DEDENT ""
NAME "r"
OP "="
NAME "r"
OP "."
NAME "rstrip"
OP "("
OP ")"
OP "."
NAME "rstrip"
OP "("
STRING "\",\""
OP ")"
OP "+"
STRING "\"]\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "pos"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", pos=%r\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "pos"
OP ","
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "r"
OP "+"
STRING "\")\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "stringify"
OP "("
NAME "self"
OP ","
NAME "block_plugin"
OP "="
NAME "False"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"\\n\""
OP "."
NAME "join"
OP "("
NAME "block"
OP "."
NAME "stringify"
OP "("
NAME "block_plugin"
OP ")"
NL "\n"
NAME "for"
NAME "block"
NAME "in"
NAME "self"
OP "."
NAME "blocks"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# Pretend to be a list"
NL "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__getattr__"
OP "("
NAME "self"
OP ","
NAME "name"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "name"
OP "."
NAME "startswith"
OP "("
STRING "'__'"
OP ")"
NAME "and"
NAME "name"
OP "."
NAME "endswith"
OP "("
STRING "'__'"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "super"
OP "("
NAME "Script"
OP ","
NAME "self"
OP ")"
OP "."
NAME "__getattr__"
OP "("
NAME "name"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "getattr"
OP "("
NAME "self"
OP "."
NAME "blocks"
OP ","
NAME "name"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__iter__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "iter"
OP "("
NAME "self"
OP "."
NAME "blocks"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__len__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "len"
OP "("
NAME "self"
OP "."
NAME "blocks"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__getitem__"
OP "("
NAME "self"
OP ","
NAME "index"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "blocks"
OP "["
NAME "index"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__setitem__"
OP "("
NAME "self"
OP ","
NAME "index"
OP ","
NAME "value"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "blocks"
OP "["
NAME "index"
OP "]"
OP "="
NAME "value"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__delitem__"
OP "("
NAME "self"
OP ","
NAME "index"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "del"
NAME "self"
OP "."
NAME "blocks"
OP "["
NAME "index"
OP "]"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Comment"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A free-floating comment in :attr:`Scriptable.scripts`.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "text"
OP ","
NAME "pos"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "text"
OP "="
NAME "unicode"
OP "("
NAME "text"
OP ")"
NEWLINE "\n"
STRING "\"\"\"The text of the comment.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "pos"
OP "="
NAME "tuple"
OP "("
NAME "pos"
OP ")"
NAME "if"
NAME "pos"
NAME "else"
NAME "None"
NEWLINE "\n"
STRING "\"\"\"``(x, y)`` position from the top-left of the script area in\n        pixels.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "__class__"
OP "("
NAME "self"
OP "."
NAME "text"
OP ","
NAME "tuple"
OP "("
NAME "self"
OP "."
NAME "pos"
OP ")"
NAME "if"
NAME "self"
OP "."
NAME "pos"
NAME "else"
NAME "None"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "r"
OP "="
STRING "\"%s.%s(%r\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "self"
OP "."
NAME "text"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "pos"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "r"
OP "+="
STRING "\", pos=%r\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "pos"
OP ","
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "r"
OP "+"
STRING "\")\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "stringify"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"// \""
OP "+"
NAME "self"
OP "."
NAME "text"
OP "."
NAME "replace"
OP "("
STRING "\"\\n\""
OP ","
STRING "\"\\n// \""
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "_normalize"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "pos"
OP "="
NAME "self"
OP "."
NAME "pos"
NEWLINE "\n"
NAME "self"
OP "."
NAME "text"
OP "="
NAME "unicode"
OP "("
NAME "self"
OP "."
NAME "text"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Costumes --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Costume"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"Describes the look of a sprite.\n\n    The raw image data is stored in :attr:`image`.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "name"
OP ","
NAME "image"
OP ","
NAME "rotation_center"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "name"
OP "="
NAME "unicode"
OP "("
NAME "name"
OP ")"
NEWLINE "\n"
STRING "\"\"\"Name used by scripts to refer to this Costume.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "if"
NAME "not"
NAME "rotation_center"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "rotation_center"
OP "="
OP "("
NAME "int"
OP "("
NAME "image"
OP "."
NAME "width"
OP "/"
NUMBER "2"
OP ")"
OP ","
NAME "int"
OP "("
NAME "image"
OP "."
NAME "height"
OP "/"
NUMBER "2"
OP ")"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "self"
OP "."
NAME "rotation_center"
OP "="
NAME "tuple"
OP "("
NAME "rotation_center"
OP ")"
NEWLINE "\n"
STRING "\"\"\"``(x, y)`` position from the top-left corner of the point about\n        which the image rotates.\n\n        Defaults to the center of the image.\n\n        \"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "image"
OP "="
NAME "image"
NEWLINE "\n"
STRING "\"\"\"An :class:`Image` instance containing the raw image data.\"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance with the same attributes.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "Costume"
OP "("
NAME "self"
OP "."
NAME "name"
OP ","
NAME "self"
OP "."
NAME "image"
OP ","
NAME "self"
OP "."
NAME "rotation_center"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "load"
OP "("
NAME "self"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Load costume from image file.\n\n        Uses :attr:`Image.load`, but will set the Costume's name based on the\n        image filename.\n\n        \"\"\""
NEWLINE "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NAME "return"
NAME "Costume"
OP "("
NAME "name"
OP ","
NAME "Image"
OP "."
NAME "load"
OP "("
NAME "path"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "save"
OP "("
NAME "self"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Save the costume to an image file at the given path.\n\n        Uses :attr:`Image.save`, but if the path ends in a folder instead of a\n        file, the filename is based on the costume's :attr:`name`.\n\n        The image format is guessed from the extension. If path has no\n        extension, the image's :attr:`format` is used.\n\n        :returns: Path to the saved file.\n\n        \"\"\""
NEWLINE "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "filename"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "filename"
OP "="
NAME "_clean_filename"
OP "("
NAME "self"
OP "."
NAME "name"
OP ")"
NEWLINE "\n"
NAME "path"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "join"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "self"
OP "."
NAME "image"
OP "."
NAME "save"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "resize"
OP "("
NAME "self"
OP ","
NAME "size"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Resize :attr:`image` in-place.\"\"\""
NEWLINE "\n"
NAME "self"
OP "."
NAME "image"
OP "="
NAME "self"
OP "."
NAME "image"
OP "."
NAME "resize"
OP "("
NAME "size"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"<%s.%s name=%r rotation_center=%d,%d at 0x%X>\""
OP "%"
OP "("
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "self"
OP "."
NAME "name"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "rotation_center"
OP "["
NUMBER "0"
OP "]"
OP ","
NAME "self"
OP "."
NAME "rotation_center"
OP "["
NUMBER "1"
OP "]"
OP ","
NAME "id"
OP "("
NAME "self"
OP ")"
NL "\n"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__getattr__"
OP "("
NAME "self"
OP ","
NAME "name"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "name"
NAME "in"
OP "("
STRING "'width'"
OP ","
STRING "'height'"
OP ","
STRING "'size'"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "getattr"
OP "("
NAME "self"
OP "."
NAME "image"
OP ","
NAME "name"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "super"
OP "("
NAME "Costume"
OP ","
NAME "self"
OP ")"
OP "."
NAME "__getattr__"
OP "("
NAME "name"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Image"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The contents of an image file.\n\n    Constructing from raw file contents::\n\n        Image(file_contents, \"JPEG\")\n\n    Constructing from a :class:`PIL.Image.Image` instance::\n\n        pil_image = PIL.Image.new(\"RGBA\", (480, 360))\n        Image(pil_image)\n\n    Loading from file path::\n\n        Image.load(\"path/to/image.jpg\")\n\n    Images are immutable. If you want to modify an image, get a\n    :class:`PIL.Image.Image` instance from :attr:`pil_image`, modify that, and\n    use it to construct a new Image. Modifying images in-place may break\n    things.\n\n    The reason for having multiple constructors is so that kurt can implement\n    lazy loading of image data -- in many cases, a PIL image will never need to\n    be created.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "contents"
OP ","
NAME "format"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "_path"
OP "="
NAME "None"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_pil_image"
OP "="
NAME "None"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_contents"
OP "="
NAME "None"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_format"
OP "="
NAME "None"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_size"
OP "="
NAME "None"
NEWLINE "\n"
NAME "if"
NAME "isinstance"
OP "("
NAME "contents"
OP ","
NAME "PIL"
OP "."
NAME "Image"
OP "."
NAME "Image"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "_pil_image"
OP "="
NAME "contents"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "_contents"
OP "="
NAME "contents"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_format"
OP "="
NAME "Image"
OP "."
NAME "image_format"
OP "("
NAME "format"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "__getstate__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "isinstance"
OP "("
NAME "self"
OP "."
NAME "_pil_image"
OP ","
NAME "PIL"
OP "."
NAME "Image"
OP "."
NAME "Image"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "copy"
OP "="
NAME "self"
OP "."
NAME "__dict__"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
NAME "copy"
OP "["
STRING "'_pil_image'"
OP "]"
OP "="
OP "{"
NL "\n"
STRING "'data'"
OP ":"
NAME "self"
OP "."
NAME "_pil_image"
OP "."
NAME "tobytes"
OP "("
OP ")"
OP ","
NL "\n"
STRING "'size'"
OP ":"
NAME "self"
OP "."
NAME "_pil_image"
OP "."
NAME "size"
OP ","
NL "\n"
STRING "'mode'"
OP ":"
NAME "self"
OP "."
NAME "_pil_image"
OP "."
NAME "mode"
OP "}"
NEWLINE "\n"
NAME "return"
NAME "copy"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "self"
OP "."
NAME "__dict__"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__setstate__"
OP "("
NAME "self"
OP ","
NAME "data"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "__dict__"
OP "."
NAME "update"
OP "("
NAME "data"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "_pil_image"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "self"
OP "."
NAME "_pil_image"
OP "="
NAME "PIL"
OP "."
NAME "Image"
OP "."
NAME "frombytes"
OP "("
OP "**"
NAME "self"
OP "."
NAME "_pil_image"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# Properties"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "pil_image"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"A :class:`PIL.Image.Image` instance containing the image data.\"\"\""
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "self"
OP "."
NAME "_pil_image"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "_format"
OP "=="
STRING "\"SVG\""
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "raise"
NAME "VectorImageError"
OP "("
STRING "\"can't rasterise vector images\""
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "self"
OP "."
NAME "_pil_image"
OP "="
NAME "PIL"
OP "."
NAME "Image"
OP "."
NAME "open"
OP "("
NAME "StringIO"
OP "("
NAME "self"
OP "."
NAME "contents"
OP ")"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "self"
OP "."
NAME "_pil_image"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "contents"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The raw file contents as a string.\"\"\""
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "self"
OP "."
NAME "_contents"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "_path"
OP ":"
NEWLINE "\n"
COMMENT "# Read file into memory so we don't run out of file descriptors"
NL "\n"
INDENT "                "
NAME "f"
OP "="
NAME "open"
OP "("
NAME "self"
OP "."
NAME "_path"
OP ","
STRING "\"rb\""
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_contents"
OP "="
NAME "f"
OP "."
NAME "read"
OP "("
OP ")"
NEWLINE "\n"
NAME "f"
OP "."
NAME "close"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "_pil_image"
OP ":"
NEWLINE "\n"
COMMENT "# Write PIL image to string"
NL "\n"
INDENT "                "
NAME "f"
OP "="
NAME "StringIO"
OP "("
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_pil_image"
OP "."
NAME "save"
OP "("
NAME "f"
OP ","
NAME "self"
OP "."
NAME "format"
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_contents"
OP "="
NAME "f"
OP "."
NAME "getvalue"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "self"
OP "."
NAME "_contents"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "format"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The format of the image file.\n\n        An uppercase string corresponding to the\n        :attr:`PIL.ImageFile.ImageFile.format` attribute.  Valid values include\n        ``\"JPEG\"`` and ``\"PNG\"``.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "_format"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_format"
NEWLINE "\n"
DEDENT ""
NAME "elif"
NAME "self"
OP "."
NAME "pil_image"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "pil_image"
OP "."
NAME "format"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "extension"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The extension of the image's :attr:`format` when written to file.\n\n        eg ``\".png\"``\n\n        \"\"\""
NEWLINE "\n"
NAME "return"
NAME "Image"
OP "."
NAME "image_extension"
OP "("
NAME "self"
OP "."
NAME "format"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "size"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"``(width, height)`` in pixels.\"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "_size"
NAME "and"
NAME "not"
NAME "self"
OP "."
NAME "_pil_image"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_size"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "pil_image"
OP "."
NAME "size"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "width"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "size"
OP "["
NUMBER "0"
OP "]"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "height"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
NAME "self"
OP "."
NAME "size"
OP "["
NUMBER "1"
OP "]"
NEWLINE "\n"
NL "\n"
COMMENT "# Methods"
NL "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "load"
OP "("
NAME "cls"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Load image from file.\"\"\""
NEWLINE "\n"
NAME "assert"
NAME "os"
OP "."
NAME "path"
OP "."
NAME "exists"
OP "("
NAME "path"
OP ")"
OP ","
STRING "\"No such file: %r\""
OP "%"
NAME "path"
NEWLINE "\n"
NL "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "image"
OP "="
NAME "Image"
OP "("
NAME "None"
OP ")"
NEWLINE "\n"
NAME "image"
OP "."
NAME "_path"
OP "="
NAME "path"
NEWLINE "\n"
NAME "image"
OP "."
NAME "_format"
OP "="
NAME "Image"
OP "."
NAME "image_format"
OP "("
NAME "extension"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "return"
NAME "image"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "convert"
OP "("
NAME "self"
OP ","
OP "*"
NAME "formats"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return an Image instance with the first matching format.\n\n        For each format in ``*args``: If the image's :attr:`format` attribute\n        is the same as the format, return self, otherwise try the next format.\n\n        If none of the formats match, return a new Image instance with the\n        last format.\n\n        \"\"\""
NEWLINE "\n"
NAME "for"
NAME "format"
NAME "in"
NAME "formats"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "format"
OP "="
NAME "Image"
OP "."
NAME "image_format"
OP "("
NAME "format"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "format"
OP "=="
NAME "format"
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "return"
NAME "self"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_convert"
OP "("
NAME "format"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "_convert"
OP "("
NAME "self"
OP ","
NAME "format"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new Image instance with the given format.\n\n        Returns self if the format is already the same.\n\n        \"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "format"
OP "=="
NAME "format"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "image"
OP "="
NAME "Image"
OP "("
NAME "self"
OP "."
NAME "pil_image"
OP ")"
NEWLINE "\n"
NAME "image"
OP "."
NAME "_format"
OP "="
NAME "format"
NEWLINE "\n"
NAME "return"
NAME "image"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "def"
NAME "save"
OP "("
NAME "self"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Save image to file path.\n\n        The image format is guessed from the extension. If path has no\n        extension, the image's :attr:`format` is used.\n\n        :returns: Path to the saved file.\n\n        \"\"\""
NEWLINE "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "if"
NAME "not"
NAME "name"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"name is required\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "if"
NAME "extension"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "format"
OP "="
NAME "Image"
OP "."
NAME "image_format"
OP "("
NAME "extension"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "format"
OP "="
NAME "self"
OP "."
NAME "format"
NEWLINE "\n"
NAME "filename"
OP "="
NAME "name"
OP "+"
NAME "self"
OP "."
NAME "extension"
NEWLINE "\n"
NAME "path"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "join"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "image"
OP "="
NAME "self"
OP "."
NAME "convert"
OP "("
NAME "format"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "image"
OP "."
NAME "_contents"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "f"
OP "="
NAME "open"
OP "("
NAME "path"
OP ","
STRING "\"wb\""
OP ")"
NEWLINE "\n"
NAME "f"
OP "."
NAME "write"
OP "("
NAME "image"
OP "."
NAME "_contents"
OP ")"
NEWLINE "\n"
NAME "f"
OP "."
NAME "close"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "image"
OP "."
NAME "pil_image"
OP "."
NAME "save"
OP "("
NAME "path"
OP ","
NAME "format"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "return"
NAME "path"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "new"
OP "("
NAME "self"
OP ","
NAME "size"
OP ","
NAME "fill"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new Image instance filled with a color.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "Image"
OP "("
NAME "PIL"
OP "."
NAME "Image"
OP "."
NAME "new"
OP "("
STRING "\"RGB\""
OP ","
NAME "size"
OP ","
NAME "fill"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "resize"
OP "("
NAME "self"
OP ","
NAME "size"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new Image instance with the given size.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "Image"
OP "("
NAME "self"
OP "."
NAME "pil_image"
OP "."
NAME "resize"
OP "("
NAME "size"
OP ","
NAME "PIL"
OP "."
NAME "Image"
OP "."
NAME "ANTIALIAS"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "paste"
OP "("
NAME "self"
OP ","
NAME "other"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new Image with the given image pasted on top.\n\n        This image will show through transparent areas of the given image.\n\n        \"\"\""
NEWLINE "\n"
NAME "r"
OP ","
NAME "g"
OP ","
NAME "b"
OP ","
NAME "alpha"
OP "="
NAME "other"
OP "."
NAME "pil_image"
OP "."
NAME "split"
OP "("
OP ")"
NEWLINE "\n"
NAME "pil_image"
OP "="
NAME "self"
OP "."
NAME "pil_image"
OP "."
NAME "copy"
OP "("
OP ")"
NEWLINE "\n"
NAME "pil_image"
OP "."
NAME "paste"
OP "("
NAME "other"
OP "."
NAME "pil_image"
OP ","
NAME "mask"
OP "="
NAME "alpha"
OP ")"
NEWLINE "\n"
NAME "return"
NAME "kurt"
OP "."
NAME "Image"
OP "("
NAME "pil_image"
OP ")"
NEWLINE "\n"
NL "\n"
COMMENT "# Static methods"
NL "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "staticmethod"
NEWLINE "\n"
NAME "def"
NAME "image_format"
OP "("
NAME "format_or_extension"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "format_or_extension"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "format"
OP "="
NAME "format_or_extension"
OP "."
NAME "lstrip"
OP "("
STRING "\".\""
OP ")"
OP "."
NAME "upper"
OP "("
OP ")"
NEWLINE "\n"
NAME "if"
NAME "format"
OP "=="
STRING "\"JPG\""
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "format"
OP "="
STRING "\"JPEG\""
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "format"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "staticmethod"
NEWLINE "\n"
NAME "def"
NAME "image_extension"
OP "("
NAME "format_or_extension"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "if"
NAME "format_or_extension"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "extension"
OP "="
NAME "format_or_extension"
OP "."
NAME "lstrip"
OP "("
STRING "\".\""
OP ")"
OP "."
NAME "lower"
OP "("
OP ")"
NEWLINE "\n"
NAME "if"
NAME "extension"
OP "=="
STRING "\"jpeg\""
OP ":"
NEWLINE "\n"
INDENT "                "
NAME "extension"
OP "="
STRING "\"jpg\""
NEWLINE "\n"
DEDENT ""
NAME "return"
STRING "\".\""
OP "+"
NAME "extension"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Sounds --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
DEDENT ""
NAME "class"
NAME "Sound"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"A sound a :class:`Scriptable` can play.\n\n    The raw sound data is stored in :attr:`waveform`.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "name"
OP ","
NAME "waveform"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "name"
OP "="
NAME "name"
NEWLINE "\n"
STRING "\"\"\"Name used by scripts to refer to this Sound.\"\"\""
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "waveform"
OP "="
NAME "waveform"
NEWLINE "\n"
STRING "\"\"\"A :class:`Waveform` instance containing the raw sound data.\"\"\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "copy"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a new instance with the same attributes.\"\"\""
NEWLINE "\n"
NAME "return"
NAME "Sound"
OP "("
NAME "self"
OP "."
NAME "name"
OP ","
NAME "self"
OP "."
NAME "waveform"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "load"
OP "("
NAME "self"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Load sound from wave file.\n\n        Uses :attr:`Waveform.load`, but will set the Waveform's name based on\n        the sound filename.\n\n        \"\"\""
NEWLINE "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NAME "return"
NAME "Sound"
OP "("
NAME "name"
OP ","
NAME "Waveform"
OP "."
NAME "load"
OP "("
NAME "path"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "save"
OP "("
NAME "self"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Save the sound to a wave file at the given path.\n\n        Uses :attr:`Waveform.save`, but if the path ends in a folder instead of\n        a file, the filename is based on the project's :attr:`name`.\n\n        :returns: Path to the saved file.\n\n        \"\"\""
NEWLINE "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "filename"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "filename"
OP "="
NAME "_clean_filename"
OP "("
NAME "self"
OP "."
NAME "name"
OP ")"
NEWLINE "\n"
NAME "path"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "join"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "return"
NAME "self"
OP "."
NAME "waveform"
OP "."
NAME "save"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "__repr__"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "return"
STRING "\"<%s.%s name=%r at 0x%X>\""
OP "%"
OP "("
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__module__"
OP ","
NL "\n"
NAME "self"
OP "."
NAME "__class__"
OP "."
NAME "__name__"
OP ","
NAME "self"
OP "."
NAME "name"
OP ","
NAME "id"
OP "("
NAME "self"
OP ")"
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "class"
NAME "Waveform"
OP "("
NAME "object"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "    "
STRING "\"\"\"The contents of a wave file. Only WAV format files are supported.\n\n    Constructing from raw file contents::\n\n        Sound(file_contents)\n\n    Loading from file path::\n\n        Sound.load(\"path/to/sound.wav\")\n\n    Waveforms are immutable.\n\n    \"\"\""
NEWLINE "\n"
NL "\n"
NAME "extension"
OP "="
STRING "\".wav\""
NEWLINE "\n"
NL "\n"
NAME "def"
NAME "__init__"
OP "("
NAME "self"
OP ","
NAME "contents"
OP ","
NAME "rate"
OP "="
NAME "None"
OP ","
NAME "sample_count"
OP "="
NAME "None"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
NAME "self"
OP "."
NAME "_path"
OP "="
NAME "None"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_contents"
OP "="
NAME "contents"
NEWLINE "\n"
NL "\n"
NAME "self"
OP "."
NAME "_rate"
OP "="
NAME "rate"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_sample_count"
OP "="
NAME "sample_count"
NEWLINE "\n"
NL "\n"
COMMENT "# Properties"
NL "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "contents"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The raw file contents as a string.\"\"\""
NEWLINE "\n"
NAME "if"
NAME "not"
NAME "self"
OP "."
NAME "_contents"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "if"
NAME "self"
OP "."
NAME "_path"
OP ":"
NEWLINE "\n"
COMMENT "# Read file into memory so we don't run out of file descriptors"
NL "\n"
INDENT "                "
NAME "f"
OP "="
NAME "open"
OP "("
NAME "self"
OP "."
NAME "_path"
OP ","
STRING "\"rb\""
OP ")"
NEWLINE "\n"
NAME "self"
OP "."
NAME "_contents"
OP "="
NAME "f"
OP "."
NAME "read"
OP "("
OP ")"
NEWLINE "\n"
NAME "f"
OP "."
NAME "close"
OP "("
OP ")"
NEWLINE "\n"
DEDENT ""
DEDENT ""
NAME "return"
NAME "self"
OP "."
NAME "_contents"
NEWLINE "\n"
NL "\n"
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "_wave"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Return a wave.Wave_read instance from the ``wave`` module.\"\"\""
NEWLINE "\n"
NAME "try"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "wave"
OP "."
NAME "open"
OP "("
NAME "StringIO"
OP "("
NAME "self"
OP "."
NAME "contents"
OP ")"
OP ")"
NEWLINE "\n"
DEDENT ""
NAME "except"
NAME "wave"
OP "."
NAME "Error"
OP ","
NAME "err"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "err"
OP "."
NAME "message"
OP "+="
STRING "\"\\nInvalid wave file: %s\""
OP "%"
NAME "self"
NEWLINE "\n"
NAME "err"
OP "."
NAME "args"
OP "="
OP "("
NAME "err"
OP "."
NAME "message"
OP ","
OP ")"
NEWLINE "\n"
NAME "raise"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "rate"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The sampling rate of the sound.\"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "_rate"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_rate"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_wave"
OP "."
NAME "getframerate"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "property"
NEWLINE "\n"
NAME "def"
NAME "sample_count"
OP "("
NAME "self"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"The number of samples in the sound.\"\"\""
NEWLINE "\n"
NAME "if"
NAME "self"
OP "."
NAME "_sample_count"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_sample_count"
NEWLINE "\n"
DEDENT ""
NAME "else"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "return"
NAME "self"
OP "."
NAME "_wave"
OP "."
NAME "getnframes"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
NL "\n"
COMMENT "# Methods"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
OP "@"
NAME "classmethod"
NEWLINE "\n"
NAME "def"
NAME "load"
OP "("
NAME "cls"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Load Waveform from file.\"\"\""
NEWLINE "\n"
NAME "assert"
NAME "os"
OP "."
NAME "path"
OP "."
NAME "exists"
OP "("
NAME "path"
OP ")"
OP ","
STRING "\"No such file: %r\""
OP "%"
NAME "path"
NEWLINE "\n"
NL "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "wave"
OP "="
NAME "Waveform"
OP "("
NAME "None"
OP ")"
NEWLINE "\n"
NAME "wave"
OP "."
NAME "_path"
OP "="
NAME "path"
NEWLINE "\n"
NAME "return"
NAME "wave"
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "def"
NAME "save"
OP "("
NAME "self"
OP ","
NAME "path"
OP ")"
OP ":"
NEWLINE "\n"
INDENT "        "
STRING "\"\"\"Save waveform to file path as a WAV file.\n\n        :returns: Path to the saved file.\n\n        \"\"\""
NEWLINE "\n"
OP "("
NAME "folder"
OP ","
NAME "filename"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "split"
OP "("
NAME "path"
OP ")"
NEWLINE "\n"
OP "("
NAME "name"
OP ","
NAME "extension"
OP ")"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "splitext"
OP "("
NAME "filename"
OP ")"
NEWLINE "\n"
NL "\n"
NAME "if"
NAME "not"
NAME "name"
OP ":"
NEWLINE "\n"
INDENT "            "
NAME "raise"
NAME "ValueError"
OP ","
STRING "\"name is required\""
NEWLINE "\n"
NL "\n"
DEDENT ""
NAME "path"
OP "="
NAME "os"
OP "."
NAME "path"
OP "."
NAME "join"
OP "("
NAME "folder"
OP ","
NAME "name"
OP "+"
NAME "self"
OP "."
NAME "extension"
OP ")"
NEWLINE "\n"
NAME "f"
OP "="
NAME "open"
OP "("
NAME "path"
OP ","
STRING "\"wb\""
OP ")"
NEWLINE "\n"
NAME "f"
OP "."
NAME "write"
OP "("
NAME "self"
OP "."
NAME "contents"
OP ")"
NEWLINE "\n"
NAME "f"
OP "."
NAME "close"
OP "("
OP ")"
NEWLINE "\n"
NL "\n"
NAME "return"
NAME "path"
NEWLINE "\n"
NL "\n"
NL "\n"
NL "\n"
COMMENT "#-- Import submodules --#"
NL "\n"
NL "\n"
DEDENT ""
DEDENT ""
NAME "import"
NAME "kurt"
OP "."
NAME "plugin"
NEWLINE "\n"
NAME "import"
NAME "kurt"
OP "."
NAME "text"
NEWLINE "\n"
NL "\n"
NAME "import"
NAME "kurt"
OP "."
NAME "scratch20"
NEWLINE "\n"
NAME "import"
NAME "kurt"
OP "."
NAME "scratch14"
NEWLINE "\n"
NL "\n"
ENDMARKER ""
