Example #1
0
from mcmod import Plugin, register_plugin
import os


class SetupProjectDirectories(Plugin):
    def __init__(self):
        Plugin.__init__(self, "mcmod.createproject.setup", 0)
        self.name = "SetupProjectDirectories"
        self.title = "Create Workspace"
        self.description = "This plugin will do the initial directory setup for "\
            "a new project."
        self.author = "edmiester777"
        self.version = "0.0.1"
        self.status_text = "Setting up environment..."

    def exec_hook(self, directory, runtimeconfig):
        downloadsDir = os.path.join(directory,
                                    runtimeconfig["DownloadsDirectory"])
        forgeDir = os.path.join(directory, runtimeconfig["ForgeDirectory"])
        if not os.path.exists(directory):
            os.makedirs(directory)
        if not os.path.exists(downloadsDir):
            os.makedirs(downloadsDir)
        if not os.path.exists(forgeDir):
            os.makedirs(forgeDir)
        return True


# Registering this plugin...
register_plugin(SetupProjectDirectories())
    def exec_hook(self, directory, runtimeconfig):
        url = runtimeconfig["MinecraftForgeUrl"]
        file_name = os.path.join(directory,
                                 runtimeconfig["DownloadsDirectory"],
                                 "forge.zip")
        u = urllib2.urlopen(url)
        f = open(file_name, 'wb')
        meta = u.info()
        file_size = int(meta.getheaders("Content-Length")[0])
        self.logger.debug('Downloading "%s" -> "%s"... Size: %s' %
                          (url, file_name, file_size))
        file_size_dl = 0
        block_sz = 8192
        while True:
            buffer = u.read(block_sz)
            if not buffer:
                break

            file_size_dl += len(buffer)
            f.write(buffer)
            self.status_text = "Downloading Minecraft Forge... %3.2f%%" % (
                file_size_dl * 100 / file_size)

        f.close()
        return True


# Registering this plugin...
register_plugin(CreateProjectDownloadForge())
        with ZipFile(self._java_src_path, "r") as zf_ref:
            # getting namelist
            namelist = [name for name in zf_ref.namelist() if name.endswith(".java")]
            self._java_namelist = namelist
            for name in namelist:
                file_path = os.path.join(self._java_src_extract_path, name)
                if not os.path.exists(file_path):
                    self.status_text = "Extracting %s..." % (name)
                    self.logger.debug("Extracting %s..." % (name))
                    zf_ref.extract(name, path=self._java_src_extract_path)

    ##
    # Parse the files in the namelist.
    def _parse_src(self):
        i = 0
        for name in self._java_namelist:
            i += 1
            file = os.path.join(self._java_src_extract_path, name)
            msg = "Parsing %s (%s/%s)..." % (name, i, len(self._java_namelist))
            self.status_text = msg
            self.logger.debug(msg)
            with open(file, 'r') as javafile:
                src = javafile.read()
                ast = parse(src)
                clsdescriptor = JavaFileRepresentation(ast)
                print clsdescriptor
        

# Registering this plugin...
register_plugin(ParseJavaSource())
Example #4
0
class CreateProjectExtractForge(Plugin):
    def __init__(self):
        Plugin.__init__(self, "mcmod.createproject.setup", 20)
        self.name = "CreateProjectExtractForge"
        self.title = "Extract Minecraft Forge"
        self.description = "Plugin to handle extracting forge to the desired destination."
        self.author = "edmiester777"
        self.version = "0.0.1"
        self.status_text = "Unzipping Minecraft Forge..."

    def exec_hook(self, directory, runtimeconfig):
        forge_file = os.path.join(directory,
                                  runtimeconfig["DownloadsDirectory"],
                                  "forge.zip")
        target_dir = os.path.join(directory, runtimeconfig["ForgeDirectory"])
        with ZipFile(forge_file, "r") as zip_ref:
            zip_ref.extractall(target_dir)

        if not os.name == 'nt':
            self.logger.debug("Attempting to make gradlew executable.")
            gradlew = os.path.join(directory, runtimeconfig["ForgeDirectory"],
                                   "gradlew")
            st = os.stat(gradlew)
            os.chmod(gradlew, st.st_mode | stat.S_IEXEC)
        return True


# Registering this plugin...
register_plugin(CreateProjectExtractForge())
Example #5
0
#########################################################################

from mcmod import Plugin, register_plugin
from mcmodplugin.helper import gradle_helper
import os
from zipfile import ZipFile


class CreateProjectSetupDecompWorkspace(Plugin):
    def __init__(self):
        Plugin.__init__(self, "mcmod.createproject.setup", 30)
        self.name = "CreateProjectSetupDecompWorkspace"
        self.title = "Setup Decompiled Workspace"
        self.description = "Plugin to handle setting up a decompiled minecraft forge workspace."
        self.author = "edmiester777"
        self.version = "0.0.1"
        self.status_text = "Working on it..."

    def exec_hook(self, directory, runtimeconfig):
        gradle_helper.runTarget(directory, runtimeconfig, "setupDevWorkspace",
                                self.update_status)
        return True

    def update_status(self, status):
        self.logger.debug('>>> %s' % (status))
        self.status_text = status


# Registering this plugin...
register_plugin(CreateProjectSetupDecompWorkspace())