How to use the black.configure.ImportProjectConfig function in black

To help you get started, we’ve selected a few black examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Komodo / KomodoEdit / util / black / bk.py View on Github external
bk configure [options...]

        This will configure the Black build system for the current
        project (%(name)s). Subsequent "bk" commands will
        use this configuration for doing their work.

    Options:
"""
        # if the project is configured then use that information
        if not blackFile:
            out.write(template % {"name":"current project ()"})
            out.write("        \n")
        else:
            try:
                projectConfig = black.configure.ImportProjectConfig(
                    blackFileName, blackFile)
            except ImportError:
                projectConfig = None
            if projectConfig and hasattr(projectConfig, "name"):
                name = "project '%s'" % projectConfig.name
            else:
                name = ""
            out.write(template % {"name":name})

            items = black.configure.Items(blackFile.configuration)
            for name, item in items.items():
                if hasattr(item, "optionHelp") and item.optionHelp:
                    out.write(item.optionHelp)
            out.write("\n\n")
github Komodo / KomodoEdit / util / black / bk.py View on Github external
def do_run(self, argv):
        """run the application for the current project
        
        bk run [arguments to application]
        """
        global blackFile, blackFileName
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'run' with no project "\
                "configuration: no Blackfile.py was found")
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'run' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1

        # There can be no default "run" command. A project must override
        # this.
        if HasOverride(blackFile, "run"):
            return RunOverride(blackFile, projectConfig, "run", argv)
        else:
            out.startErrorItem()
            if hasattr(projectConfig, "name"):
                name = "project '%s'" % projectConfig.name
github Komodo / KomodoEdit / util / black / bk.py View on Github external
def do_upload(self, argv):
        """upload built packages to staging area

        bk upload 

        This is a total HACK just for Komodo -- the only user of Black,
        so that is okay.
        """
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'upload' with no project "\
                "configuration: no Blackfile.py was found")
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'upload' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1

        # There can be no default "upload" command. A project must override
        # this.
        if HasOverride(blackFile, "upload"):
            return RunOverride(blackFile, projectConfig, "upload", argv)
        else:
            out.startErrorItem()
            if hasattr(projectConfig, "name"):
                name = "project '%s'" % projectConfig.name
github Komodo / KomodoEdit / util / black / bk.py View on Github external
def do_clean(self, argv):
        """clean what is currently configured to be built
        
        bk clean [optional args depending on configuration]
        """
        global blackFile, blackFileName
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'clean' with no project "\
                "configuration: no Blackfile.py was found")
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'clean' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1

        # Currently Black has no knowledge of how to clean a project. However,
        # it can invoke a custom clean procedure as expressed in
        # the commandOverrides['clean'] variable in the project Blackfile.py.
        if HasOverride(blackFile, "clean"):
            return RunOverride(blackFile, projectConfig, "clean", argv)
        else:
            out.startErrorItem()
            out.write("warning: Black currently does not know how to "\
github Komodo / KomodoEdit / util / black / bk.py View on Github external
def do_cleanprefs(self, argv):
        """clean Komodo/Mozilla prefs

            bk cleanprefs []

        This is a total HACK just for Komodo -- the only user of Black,
        so that is okay.
        """
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'cleanprefs' with no project "\
                "configuration: no Blackfile.py was found")
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'cleanprefs' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1

        # There can be no default "cleanprefs" command. A project must override
        # this.
        if HasOverride(blackFile, "cleanprefs"):
            return RunOverride(blackFile, projectConfig, "cleanprefs", argv)
        else:
            out.startErrorItem()
            if hasattr(projectConfig, "name"):
                name = "project '%s'" % projectConfig.name
github Komodo / KomodoEdit / util / black / bk.py View on Github external
def do_image(self, argv):
        """create the install image

            bk image []

        This is a total HACK just for Komodo -- the only user of Black,
        so that is okay.
        """
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'image' with no project "\
                "configuration: no Blackfile.py was found")
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'image' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1

        # There can be no default "image" command. A project must override
        # this.
        if HasOverride(blackFile, "image"):
            return RunOverride(blackFile, projectConfig, "image", argv)
        else:
            out.startErrorItem()
            if hasattr(projectConfig, "name"):
                name = "project '%s'" % projectConfig.name
github Komodo / KomodoEdit / util / black / bk.py View on Github external
def do_package(self, argv):
        """package up bits
        
        bk package []
        """
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'package' with no project "\
                "configuration: no Blackfile.py was found")
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'package' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1

        # There can be no default "package" command. A project must override
        # this.
        if HasOverride(blackFile, "package"):
            return RunOverride(blackFile, projectConfig, "package", argv)
        else:
            out.startErrorItem()
            if hasattr(projectConfig, "name"):
                name = "project '%s'" % projectConfig.name
github Komodo / KomodoEdit / util / black / bk.py View on Github external
def do_start(self, argv):
        """run a command in the configured environment"""
        global blackFile
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'start' with no project "\
                "configuration: no Blackfile.py was found")

        # import the project configure module
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'start' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1
        
        quotedArgs = []
        args = argv[1:]
        if args[0] == "-v":
            verbose = True
            del args[0]
        else:
            verbose = False
        for arg in args:
github Komodo / KomodoEdit / util / black / bk.py View on Github external
This is basically a shortcut for doing a single build with
            a specific configuration, e.g.:
                bk build --conf-with-somefeature
            "--" can be used to terminate the list of configuration args,
            e.g.
                bk build --conf-a-conf-arg -- --conf-not-a-conf-arg

            "build args" are all passed to the underlying build process.
        """
        global blackFile, blackFileName
        # die if there is no project configuration
        if not blackFile:
            raise black.BlackError("attempted 'build' with no project "\
                "configuration: no Blackfile.py was found")
        try:
            projectConfig = black.configure.ImportProjectConfig(
                blackFileName, blackFile)
        except ImportError:
            out.startErrorItem()
            out.write("error: Attempted 'build' command without having "\
                      "configured. You must first configure your project.\n")
            out.endErrorItem()
            return 1

        # look for configuration args
        # XXX this will fail for configuration options that take arguments
        #     and where the argument is seperated from the option with
        #     whitespace
        newConfArgs = []
        newArgv = []
        STATE_COMMAND_NAME, STATE_CONF_ARGS, STATE_BUILD_ARGS = range(3)
        state = STATE_COMMAND_NAME