Example #1
0
def indent_variables(document):
    """Returns a dictionary with some variables regarding document indenting."""
    return variables.update(document, {
        'indent-width': 2,
        'tab-width': 8,
        'indent-tabs': False,
        'document-tabs': True,
    })
Example #2
0
def indent_variables(document=None):
    """Return a dictionary with indentation preferences.

    If a document (a Frescobaldi/QTextDocument) is specified, the document
    variables are also read.

    For the variables and their default variables, see userguide/docvars.md.

    """
    s = QSettings()
    s.beginGroup("indent")
    nspaces = s.value("indent_spaces", 2, int)
    tabwidth = s.value("tab_width", 8, int)
    dspaces = s.value("document_spaces", 8, int)
    prefs = {
        'indent-tabs': nspaces == 0,
        'indent-width': 2 if nspaces == 0 else nspaces,
        'tab-width': tabwidth,
        'document-tabs': dspaces == 0,
        'document-tab-width': 8 if dspaces == 0 else dspaces,
    }
    return variables.update(document, prefs) if document else prefs
Example #3
0
def indent_variables(document=None):
    """Return a dictionary with indentation preferences.
    
    If a document (a Frescobaldi/QTextDocument) is specified, the document 
    variables are also read.
    
    For the variables and their default variables, see userguide/docvars.md.

    """
    s = QSettings()
    s.beginGroup("indent")
    nspaces = s.value("indent_spaces", 2, int)
    tabwidth = s.value("tab_width", 8, int)
    dspaces = s.value("document_spaces", 8, int)
    prefs = {
        'indent-tabs': nspaces == 0,
        'indent-width': 2 if nspaces == 0 else nspaces,
        'tab-width': tabwidth,
        'document-tabs': dspaces == 0,
        'document-tab-width': 8 if dspaces == 0 else dspaces,
    }
    return variables.update(document, prefs) if document else prefs
Example #4
0
def get_base_environment(variables=None, *args, **kw):
    """Create an environment suitable for building IMP modules"""
    #import colorizer
    # First make a dummy environment in order to evaluate all variables, since
    # env['wine'] will tell us which 'real' environment to create:
    env = Environment(tools=[], variables=variables)
    #variables.Update(env)
    newpath = env['ENV']['PATH']
    if env.get('path') is not None:
        newpath = env['path'] + os.path.pathsep + newpath
    envargs={'PATH':newpath}

#If the output is not a terminal, remove the colors
    if env['wine']:
        env = _WineEnvironment(variables=variables,
                              ENV = {'PATH':newpath},
                              *args, **kw)
    else:
        env = Environment(variables=variables,
                          ENV = {'PATH':newpath},
                          *args, **kw)
        #env['PYTHON'] = 'python'
    data.add(env)
    impvariables.update(env, variables)
    colors = {}
    colors['cyan']   = '\033[96m'
    colors['purple'] = '\033[95m'
    colors['blue']   = '\033[94m'
    colors['green']  = '\033[92m'
    colors['yellow'] = '\033[93m'
    colors['red']    = '\033[91m'
    colors['end']    = '\033[0m'
    env['IMP_COLORS']=colors
    if not env['color'] or "TERM" not in os.environ.keys()\
            or os.environ["TERM"] != "xterm":
        for key, value in colors.iteritems():
            colors[key] = ''
    if env['pretty']:
        compile_source_message = '%sCompiling %s$TARGET%s' % \
            (colors['blue'], colors['end'], colors['end'])

        compile_shared_source_message = '%sCompiling shared %s$TARGET%s' % \
            (colors['blue'], colors['end'], colors['end'])

        link_program_message = '%sLinking Program %s$TARGET%s' % \
            (colors['purple'], colors['end'], colors['end'])

        link_library_message = '%sLinking Static Library %s$TARGET%s' % \
            (colors['purple'], colors['end'], colors['end'])

        ranlib_library_message = '%sRanlib Library %s$TARGET%s' % \
            (colors['purple'], colors['end'], colors['end'])

        link_shared_library_message = '%sLinking Shared Library %s$TARGET%s' % \
            (colors['purple'], colors['end'], colors['end'])

        link_module_message = '%sLinking Shared Module %s$TARGET%s' % \
            (colors['purple'], colors['end'], colors['end'])

        java_library_message = '%sCreating Java Archive %s$TARGET%s' % \
            (colors['purple'], colors['end'], colors['end'])

        swig_message = '%sRunning swig on %s$TARGET%s' % \
            (colors['purple'], colors['end'], colors['end'])

        pretty={'CXXCOMSTR': compile_source_message,
                'CCCOMSTR': compile_source_message,
                'SHCCCOMSTR': compile_shared_source_message,
                'SHCXXCOMSTR': compile_shared_source_message,
                'ARCOMSTR': link_library_message,
                'RANLIBCOMSTR': ranlib_library_message,
                'SHLINKCOMSTR': link_shared_library_message,
                'LDMODCOMSTR': link_module_message,
                'LINKCOMSTR': link_program_message,
                'JARCOMSTR': java_library_message,
                'JAVACCOMSTR': compile_source_message,
                'SWIGCOMSTR': swig_message,}
        for p in pretty.keys():
            env[p]=pretty[p]
    if env['IMP_USE_PLATFORM_FLAGS']:
        _fix_include_path(env)
        _add_platform_flags(env)
    #col = colorizer.colorizer()
    #col.colorize(env)
    env['PYTHONPATH'] = '#/build/lib'
    if env.get('pythonpath', None):
        env['PYTHONPATH'] = os.path.pathsep.join(['#/build/lib']+[env['PYTHONPATH']])
    env['all_modules']=[]
    #env.Decider('MD5-timestamp')

    dependency.boost.configure_env_for_auto_link(env)

    # Make Modeller exetype variable available:
    if os.environ.has_key('EXECUTABLE_TYPESVN'):
        env['ENV']['EXECUTABLE_TYPESVN'] = os.environ['EXECUTABLE_TYPESVN']
    # Set empty variables in case the Modeller check fails:
    for mod in ('MODPY', 'EXETYPE'):
        env['MODELLER_' + mod] = ''
    for mod in ('CPPPATH', 'LIBPATH', 'LIBS'):
        env['MODELLER_' + mod] = []
    dependency.compilation.configure_check(env)
    dependency.nullptr.configure_check(env)
    if platform == 'aix':
        # Make sure compilers are in the PATH, so that Python's script for
        # building AIX extension modules can find them:
        e['ENV']['PATH'] += ':/usr/vac/bin'
    #print "cxx", env['CXXFLAGS']
    env.Prepend(CPPPATH=[Dir('#/build/include').abspath])
    env.Prepend(LIBPATH=[Dir('#/build/lib').abspath])
    env.Append(BUILDERS={'IMPRun': run.Run})
    # these should be in application, but...
    env.AddMethod(application.IMPApplication)
    env.AddMethod(application.IMPCPPExecutable)
    env.AddMethod(application.IMPCPPExecutables)
    env.AddMethod(application.IMPApplicationTest)
    env.AddMethod(application.IMPPythonExecutable)

    # these should be in systems
    env.AddMethod(biology.IMPSystem)

    # these should be in the module, but this seems to speed things up
    env.AddMethod(module.IMPModuleBuild)
    env.AddMethod(module.IMPModuleLib)
    env.AddMethod(module.IMPModuleInclude)
    env.AddMethod(module.IMPModuleData)
    env.AddMethod(module.IMPModulePython)
    env.AddMethod(module.IMPModuleTest)
    env.AddMethod(module.IMPModuleBuild)
    env.AddMethod(module.IMPModuleGetHeaders)
    env.AddMethod(module.IMPModuleGetExamples)
    env.AddMethod(module.IMPModuleGetExampleData)
    env.AddMethod(module.IMPModuleGetPythonTests)
    env.AddMethod(module.IMPModuleGetExpensivePythonTests)
    env.AddMethod(module.IMPModuleGetCPPTests)
    env.AddMethod(module.IMPModuleGetData)
    env.AddMethod(module.IMPModuleGetSources)
    env.AddMethod(module.IMPModuleGetPython)
    env.AddMethod(module.IMPModuleGetSwigFiles)
    env.AddMethod(module.IMPModuleGetBins)
    env.AddMethod(module.IMPModuleGetBenchmarks)
    env.AddMethod(module.IMPModuleBin)
    env.AddMethod(module.IMPModuleBenchmark)
    env.AddMethod(module.IMPModuleDoc)
    env.AddMethod(module.IMPModuleExamples)
    env.AddMethod(module.IMPModuleGetDocs)
    env.AddMethod(doc.IMPPublication)
    env.AddMethod(doc.IMPWebsite)
    env.AddMethod(doc.IMPStandardPublications)
    env.AddMethod(doc.IMPStandardLicense)
    env.Append(BUILDERS={'IMPModuleCPPTest': test.CPPTestHarness})
    env.Append(BUILDERS={'IMPModuleSWIG': module._swig.get_swig_action(env)})
    env.Append(BUILDERS={'IMPModulePatchSWIG': module._swig.PatchSwig})
    env.Append(BUILDERS={'IMPModuleSWIGPreface': module._swig.SwigPreface})
    env.Append(BUILDERS = {'IMPModuleVersionH': module._version_h.VersionH,
                           'IMPModuleConfigH': module._config_h.ConfigH,
                           'IMPModuleConfigCPP': module._config_h.ConfigCPP,
                           'IMPModuleLinkTest': module._link_test.LinkTest})
    if env.get('linkflags', None):
        env.Append(LINKFLAGS=env['linkflags'])
    return env