File: setup_common.py

package info (click to toggle)
python-mysqldb 1.2.3-2.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 568 kB
  • ctags: 1,289
  • sloc: python: 2,725; ansic: 2,659; makefile: 46
file content (32 lines) | stat: -rw-r--r-- 951 bytes parent folder | download | duplicates (2)
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
from ConfigParser import SafeConfigParser

def get_metadata_and_options():
    config = SafeConfigParser()
    config.read(['metadata.cfg', 'site.cfg'])

    metadata = dict(config.items('metadata'))
    options = dict(config.items('options'))

    metadata['py_modules'] = filter(None, metadata['py_modules'].split('\n'))
    metadata['classifiers'] = filter(None, metadata['classifiers'].split('\n'))

    return metadata, options

def enabled(options, option):
    value = options[option]
    s = value.lower()
    if s in ('yes','true','1','y'):
        return True
    elif s in ('no', 'false', '0', 'n'):
        return False
    else:
        raise ValueError("Unknown value %s for option %s" % (value, option))

def create_release_file(metadata):
    rel = open("MySQLdb/release.py",'w')
    rel.write("""
__author__ = "%(author)s <%(author_email)s>"
version_info = %(version_info)s
__version__ = "%(version)s"
""" % metadata)
    rel.close()