File: setup_win_common.py

package info (click to toggle)
pygame 1.9.1release%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 7,280 kB
  • ctags: 6,685
  • sloc: ansic: 41,205; python: 21,987; cpp: 537; objc: 196; php: 92; sh: 77; makefile: 41
file content (45 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
39
40
41
42
43
44
45
# -*- encoding: utf-8 -*-

# module setup_win_common.py

"""A module for reading the information common to all Windows setups.

Exports read and get_definitions.
"""

path = 'Setup_Win_Common.in'

class Definition(object):
    def __init__(self, name, value):
        self.name = name
        self.value = value

def read():
    """Return the contents of the Windows Common Setup as a string"""

    setup_in = open(path)
    try:
        return setup_in.read()
    finally:
        setup_in.close()

def get_definitions():
    """Return a list of definitions in the Windows Common Setup

    Each macro definition object has a 'name' and 'value' attribute.
    """
    import re
    
    setup_in = open(path)
    try:
        deps = []
        match = re.compile(r'([a-zA-Z0-9_]+) += +(.+)$').match
        for line in setup_in:
            m = match(line)
            if m is not None:
                deps.append(Definition(m.group(1), m.group(2)))
        return deps
    finally:
        setup_in.close()

__all__= ['read', 'get_dependencies']