def package(self):
        """Packages this project's files."""
        def call_or_die(cmd, shell=False):
            exit = subprocess.call(cmd, shell=shell)
            if exit != 0:
                print cmd % "Command failed: %s"
                print "Failed to package project %s.  Aborting." % project.name
                sys.exit(PACKAGE_FAILED)

        if project.package_command is not None:
            call_or_die(project.package_command, shell=True)
            return True
        else:
            ## Collect and package the matching .class files for this project.
            # Start by building a list of all of the source files of each type.
            client_dir = os.path.join(self.dir, "src", "client")
            client_sources = self.collect_files(client_dir)

            server_dir = os.path.join(self.dir, "src", "server")
            server_sources = self.collect_files(server_dir)

            common_dir = os.path.join(self.dir, "src", "common")
            common_sources = self.collect_files(common_dir)

            # Common sources just get added to both sides.
            client_sources.update(common_sources)
            server_sources.update(common_sources)

            # Translate the source files into their matching class files,
            # taking obfuscation into account.
            client_classes = self.map_to_class(client_sources)
            server_classes = self.map_to_class(server_sources, server=True)

            # Package up the client files.
            os.chdir(MCP_REOBF_CLIENT)
            client_package = self.get_package_file()
            client_created = False
            if client_classes:
                if os.path.exists(client_package):
                    os.remove(client_package)
                self.zip(client_package, client_classes, clean=True)
                client_created = True

            # And then the server files.
            os.chdir(MCP_REOBF_SERVER)
            server_package = self.get_package_file(server=True)
            server_created = False
            if server_classes:
                if os.path.exists(server_package):
                    os.remove(server_package)
                self.zip(server_package, server_classes, clean=True)
                server_created = True

            # If we haven't created either package yet, we won't, so bail out.
            if not (client_created or server_created):
                print "Nothing to package."
                return False


            ## Collect and package resource files.
            # Common first, so they can be overridden.
            common_resources = os.path.join(self.dir, "resources", "common")
            if os.path.isdir(common_resources):
                # To package these, we just change to the appropriate directory
                # and let the shell and zip command find everything in it.
                os.chdir(common_resources)
                if client_created:
                    self.zip(client_package)
                if server_created:
                    self.zip(server_package)

            client_resources = os.path.join(self.dir, "resources", "client")
            if os.path.isdir(client_resources):
                os.chdir(client_resources)
                if client_created:
                    self.zip(client_package)

            server_resources = os.path.join(self.dir, "resources", "server")
            if os.path.isdir(server_resources):
                os.chdir(server_resources)
                if server_created:
                    self.zip(server_package)


            ## Collect and package source files
            # Unless we shouldn't, in which case we're done.
            if self.hide_source:
                return True

            # Common first, so they can be overridden.
            common_source = os.path.join(self.dir, "src", "common")
            if os.path.isdir(common_source) and os.listdir(common_source):
                # To package these, we just change to the appropriate directory
                # and let the shell and zip command find everything in it.
                os.chdir(common_source)
                if client_created:
                    self.zip(client_package)
                if server_created:
                    self.zip(server_package)

            client_source = os.path.join(self.dir, "src", "client")
            if os.path.isdir(client_source) and os.listdir(client_source):
                os.chdir(client_source)
                if client_created:
                    self.zip(client_package)

            server_source = os.path.join(self.dir, "src", "server")
            if os.path.isdir(server_source) and os.listdir(server_source):
                os.chdir(server_source)
                if server_created:
                    self.zip(server_package)

            return True
dataset/ETHPy150Open FunnyMan3595/mcp_rebuild/rebuild.py/Project.package/swapped operands of `%`