aboutsummaryrefslogtreecommitdiffhomepage
path: root/waftools/inflector.py
blob: 184c74a3bfa928b678d3a629a0d5e6df21b4ccf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import re

def _underscore(word):
    """ Converts a word "into_it_s_underscored_version"
    Convert any "CamelCased" or "ordinary Word" into an
    "underscored_word"."""

    return  re.sub('[^A-Z^a-z^0-9]+', '_', \
            re.sub('([a-z\d])([A-Z])', '\\1_\\2', \
            re.sub('([A-Z]+)([A-Z][a-z])', '\\1_\\2', re.sub('::', '/', word)))).lower()

def storage_key(dep):
    return _underscore(dep)

def define_key(dep):
    return ("have_" + storage_key(dep)).upper()

def define_dict(dep):
    return {'define_name': define_key(dep)}

def storage_dict(dep):
    return {'uselib_store': storage_key(dep)}