How to use the black.configure.Datum 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 / lib / python / black / configure / std.py View on Github external
# Otherwise return the value of the PATH environment variable.
        if black.configure.items.has_key("PATH"):
            pathItem = black.configure.items["PATH"]
            self.applicable = pathItem.Determine()
            if self.applicable:
                self.value = pathItem.Get()
        else:
            self.applicable = 1
            self.value = os.environ["PATH"].split(os.pathsep)
        self.determined = 1



#---- some MSVC configuration items

class MsvcInstallDir(Datum):
    def __init__(self, compilerVersion="vc6"):
        Datum.__init__(self, "msvcInstallDir",
            desc="the installation directory of Microsoft Visual %s" % (compilerVersion),
            serializeAs=[])
        self._compilerVersion = compilerVersion.lower()

    def _Determine_Sufficient(self):
        if self.value is None:
            raise ConfigureError("Could not determine %s. Do you have "\
                "Visual Studio installed? If so, then there is a bug in the "\
                "configure code or it has to be extended "\
                "for the weird way you setup your machine.\n" % self.desc)

    def _Determine_Do(self):
        if sys.platform.startswith("win"):
            self.applicable = 1
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
if perlBinDir:
                perlExe = os.path.join(perlBinDir, "perl")
                o = os.popen("%s -v" % perlExe)
                perlVersionDump = o.read()
                perlVersionMatch = re.compile("This is perl, v([0-9.]+)").\
                    search(perlVersionDump)
                if perlVersionMatch:
                    self.value = perlVersionMatch.group(1) 
                else:
                    self.value = None
            else:
                self.value = None
        self.determined = 1


class ActivePerlBuild(Datum):
    def __init__(self, name=None, desc=None,
                 # The id of the configuration item describing the perl
                 # installation in which to check for these modules.
                 perlBinDirItemName="perlBinDir"):
        self.perlBinDirItemName = perlBinDirItemName
        if name is None:
            name = "activePerlBuild"
        if desc is None:
            desc="the ActivePerl build number"
        Datum.__init__(self, name, desc)

    def _Determine_Do(self):
        if not black.configure.items.has_key(self.perlBinDirItemName):
            black.configure.items[self.perlBinDirItemName] = PerlBinDir()
        self.applicable = black.configure.items[self.perlBinDirItemName].Determine()
        if self.applicable:
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
def __init__(self):
        Datum.__init__(self, "systemDirs", desc="the system directories")
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
else:
                    self.value = pythonBinDir
            elif sys.platform == 'darwin':
                # foo/Python.framework/Versions/X.Y/bin -> foo
                self.value = dirname(dirname(dirname(dirname(pythonBinDir))))
            else:
                if basename(pythonBinDir) == "bin":
                    self.value = dirname(pythonBinDir)
                else:
                    self.value = pythonBinDir
        else:
            self.value = None
        self.determined = 1


class PerlInstallDir(Datum):
    def __init__(self):
        Datum.__init__(self, "perlInstallDir",
            desc="Perl installation directory")

    def _Determine_Sufficient(self):
        if self.value is None:
            raise ConfigureError("Could not determine %s. You have to "\
                "install Perl and put it on your path.\n" % self.desc)

    def _Determine_Do(self):
        self.applicable = 1
        if not black.configure.items.has_key("perlBinDir"):
            black.configure.items["perlBinDir"] = PerlBinDir()
        perlBinDir = black.configure.items["perlBinDir"].Get()
        if perlBinDir:
            self.value = os.path.dirname(perlBinDir)
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
class PythonVersion(Datum):
    def __init__(self):
        Datum.__init__(self, "pythonVersion", desc="the python version")

    def _Determine_Do(self):
        self.applicable = 1

        if not black.configure.items.has_key("pythonExeName"):
            black.configure.items["pythonExeName"] = PythonExeName()
        pythonExeName = black.configure.items["pythonExeName"].Get()
        o = os.popen('%s -c "import sys; sys.stdout.write(\'.\'.join(map(str, sys.version_info[:3])))"' % pythonExeName)
        self.value = o.read()
        self.determined = 1


class PerlBinDir(Datum):
    def __init__(self):
        Datum.__init__(self, "perlBinDir", desc="the Perl bin directory")

    def _Determine_Sufficient(self):
        if self.value is None:
            raise ConfigureError("Could not determine %s (could not find "\
                "perl on your path). You have to install Perl and put it on "\
                "your path.\n" % self.desc)

    def _Determine_Do(self):
        self.applicable = 1
        perlExe = tmShUtil.WhichFollowSymLinks('perl')
        if perlExe:
            self.value = os.path.dirname(perlExe)
        else:
            self.value = None
github Komodo / KomodoEdit / util / black / lib / python / black / configure / mozilla.py View on Github external
class SetMozBranch(SetEnvVar):
    def __init__(self):
        SetEnvVar.__init__(self, "MOZ_BRANCH")

    def _Determine_Do(self):
        self.applicable = 1
        if os.environ.has_key(self.name):
            self.value = os.environ[self.name]
        else:
            self.value = None  # default is the trunk
        self.determined = 1


class CreateMozconfig(Datum):
    def __init__(self):
        Datum.__init__(self, "createMozconfig",\
            desc="create the Mozilla Unix build configuration file "\
                 "(~/.mozconfig)",
            serializeAs=[]
        )
    
    def _Determine_Do(self):
        if not sys.platform.startswith("win"):
            self.applicable = 1
            self.value = os.path.expanduser("~/.mozconfig")
            # move an existing one out of the way
            if os.path.isfile(self.value):
                saveName = self.value + ".old"
                out.write("Moving existing '%s' to '%s'...\n" %\
                    (self.value, saveName))
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
def __init__(self):
        Datum.__init__(self, "perlBinDir", desc="the Perl bin directory")
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
black.configure.std.SystemDirs()
                systemDirs = black.configure.items["systemDirs"].Get()
                msvcrtdDll = tmShUtil.Which("msvcrtd.dll", systemDirs)
                msvcirtdDll = tmShUtil.Which("msvcirtd.dll", systemDirs)
                if not (msvcrtdDll and msvcirtdDll):
                    self.value = 0
                else:
                    self.value = 1
        else:
            self.applicable = 0
        self.determined = 1


#---- Python, Perl, PHP configuration items

class PythonExeName(Datum):
    def __init__(self):
        Datum.__init__(self, "pythonExeName",
            desc="the name of the Python executable")

    def _Determine_Do(self):
        self.applicable = 1
        if sys.platform.startswith("win"):
            if black.configure.items.has_key("buildType") and\
              black.configure.items["buildType"].Get() == "debug":
                self.value = "python_d.exe"
            else:
                self.value = "python.exe"
        else:
            self.value = "python"
        self.determined = 1
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
class PhpBinDir(Datum):
    def __init__(self):
        Datum.__init__(self, "phpBinDir", desc="the PHP bin directory")

    def _Determine_Do(self):
        self.applicable = 1
        phpExe = tmShUtil.WhichFollowSymLinks('php')
        if phpExe:
            self.value = os.path.dirname(phpExe)
        else:
            self.value = None
        self.determined = 1


class PythonBinDir(Datum):
    def __init__(self):
        Datum.__init__(self, "pythonBinDir", "the Python bin directory")

    def _Determine_Sufficient(self):
        if self.value is None:
            pythonExeName = black.configure.items["pythonExeName"].Get()
            raise ConfigureError("Could not determine %s (could not find %s "\
                "on your path). You have to install Python and put it on "\
                "your path.\n" % (self.desc, pythonExeName))

    def _Determine_Do(self):
        self.applicable = 1
        if not black.configure.items.has_key("pythonExeName"):
            black.configure.items["pythonExeName"] = PythonExeName()
        pythonExeName = black.configure.items["pythonExeName"].Get()
        pythonExe = tmShUtil.WhichFollowSymLinks(pythonExeName)
github Komodo / KomodoEdit / util / black / lib / python / black / configure / std.py View on Github external
if self.value is None:
            raise ConfigureError("Could not determine %s (could not find "\
                "perl on your path). You have to install Perl and put it on "\
                "your path.\n" % self.desc)

    def _Determine_Do(self):
        self.applicable = 1
        perlExe = tmShUtil.WhichFollowSymLinks('perl')
        if perlExe:
            self.value = os.path.dirname(perlExe)
        else:
            self.value = None
        self.determined = 1


class PhpBinDir(Datum):
    def __init__(self):
        Datum.__init__(self, "phpBinDir", desc="the PHP bin directory")

    def _Determine_Do(self):
        self.applicable = 1
        phpExe = tmShUtil.WhichFollowSymLinks('php')
        if phpExe:
            self.value = os.path.dirname(phpExe)
        else:
            self.value = None
        self.determined = 1


class PythonBinDir(Datum):
    def __init__(self):
        Datum.__init__(self, "pythonBinDir", "the Python bin directory")