MythTV master
makeopts.py
Go to the documentation of this file.
1# smolt - Fedora hardware profiler
2#
3# Copyright (C) 2009 Sebastian Pipping <sebastian@pipping.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18
19from builtins import str
20from builtins import object
21import re
22import portage
23
24SHORT_PARA_PATTERN = '-[CfIOW]\\s+\\S+|-[jl](\\s+[^-]\\S*)?|-[^-]\\S+'
25LONG_PARA_PATTERN = '--\\S+|--\\S+=\\S+'
26PARA_PATTERN = re.compile('(%s|%s)\\b' % (SHORT_PARA_PATTERN, LONG_PARA_PATTERN))
27
28class MakeOpts(object):
29 def __init__(self, value=None):
30 """
31 >>> m = MakeOpts("-C dir -f file -I dir -o file -W file -j 3 -l 4 -j -j3 -l --always-make")
32 >>> m.get()
33 ['-C dir', '-f file', '-I dir', '-W file', '-j 3', '-l 4', '-j', '-j3', '-l', '--always-make']
34 """
35 if value is None:
36 value = portage.settings['MAKEOPTS']
37 self._makeopts = self._parse(value)
38
39 def _parse(self, flags):
40 list = []
41 for m in re.finditer(PARA_PATTERN, flags):
42 text = re.sub('\\s{2,}', ' ', m.group()) # Normalize whitespace
43 list.append(text)
44 return list
45
46 def get(self):
47 return self._makeopts
48
49 def serialize(self):
50 return self._makeopts
51
52 def dump(self):
53 print('MAKEOPTS: ' + str(self.get()))
54 print()
55
56
57if __name__ == '__main__':
58 import doctest
59 doctest.testmod(verbose=True)
static void print(const QList< uint > &raw_minimas, const QList< uint > &raw_maximas, const QList< float > &minimas, const QList< float > &maximas)