summaryrefslogtreecommitdiffstats
path: root/utils.py
blob: fa76138e8a01ae8157c18dd923a5bf1143758199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python2
import collections

def get_os_name(name):
  try: return name.split(' ')[0].lower()
  except: pass

def select_with_attribute(iterable, attribute, result=True):
    return [value for value in iterable if (attribute in value) == result]

def get_contact_info(maintainer):
    if type(maintainer) is dict:
	return maintainer.popitem()
    else:
        return (maintainer, "%s@spline.de" % (maintainer))

def is_iterable(obj):
    if isinstance(obj, collections.Iterable):
       return True
    return False

filters = [
    ('select_with_attribute', select_with_attribute),
    ('get_os_name', get_os_name)
]

tests = [
    ('iterable', is_iterable)
]

globals = [
    ('get_contact_info', get_contact_info)
]