Skip to content
Snippets Groups Projects
Select Git revision
  • 3e488108b6eae019c03ca40670c003a98d626c0f
  • master default protected
  • feature/particle_state_generation_with_variable_box_size
  • feature/add-fft-interface
  • feature/expose-rnumber-from-simulations
  • feature/forcing-unit-test
  • feature/dealias-check2
  • bugfix/check_field_exists
  • feature/dealias-check
  • v3.x
  • feature/particles-vectorization
  • 6.2.4
  • 6.2.3
  • 6.2.2
  • 6.2.1
  • 6.2.0
  • 6.1.0
  • 6.0.0
  • 5.8.1
  • 5.8.0
  • 5.7.2
  • 5.7.1
  • 5.7.0
  • 5.6.0
  • 5.5.1
  • 5.5.0
  • 5.4.7
  • 5.4.6
  • 5.4.5
  • 5.4.4
  • 5.4.3
31 results

spline_n1.cpp

Blame
  • checkuse.py 1.52 KiB
    #! /usr/bin/env python
    
    #
    # Check order of use statements
    #
    
    import sys
    import string
    
    ###
    
    def parse_use_statements(fn):
        f = open(fn, 'r')
        l = f.readline()
        start_parse = False
        stop_parse = False
        in_interface = False
        module_name = None
        use_statements = [ ]
        while l and not stop_parse:
            s = map(string.lower, map(string.strip, l.split()))
            if len(s) > 0:
                if s[0] == 'module' and not start_parse:
                    start_parse = True
                    module_name = s[1]
                elif start_parse:
                    if s[0] == 'interface':
                        in_interface = True
                    elif s[0] == 'endinterface' or ( s[0] == 'end' and s[1] == 'interface' ):
                        in_interface = False
                    if s[0] == 'use' and not in_interface:
                        use_statements += [ s[1] ]
                    elif s[0] == 'contains':
                        stop_parse = True
            l = f.readline()
        f.close()
        return module_name, use_statements
    
    ###
    
    def check_deps(deplist, name, used=None):
        if used is None:
            used = set()
    
        for mod in deplist[name]:
            if mod in used:
                print 'In module %s: Module %s should be included earlier.' % ( name, mod )
            if mod in deplist:
                for depmod in deplist[mod]:
                    used.add(depmod)
    
    
    ###
    
    deplist = { }
    for fn in sys.argv[1:]:
        name, use = parse_use_statements(fn)
        if name is not None:
            deplist[name] = use
    
    for mod in deplist.keys():
        check_deps(deplist, mod)