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