Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: third_party/buildbot_7_12/buildbot/steps/package/rpm/rpmspec.py

Issue 12207158: Bye bye buildbot 0.7.12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Dan Radez <dradez+buildbot@redhat.com>
2 # Steve 'Ashcrow' Milner <smilner+buildbot@redhat.com>
3 #
4 # This software may be freely redistributed under the terms of the GNU
5 # general public license.
6 #
7 # You should have received a copy of the GNU General Public License
8 # along with this program; if not, write to the Free Software
9 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
10 """
11 library to populate parameters from and rpmspec file into a memory structure
12 """
13
14
15 from buildbot.steps.shell import ShellCommand
16
17
18 class RpmSpec(ShellCommand):
19 """
20 read parameters out of an rpm spec file
21 """
22
23 import re
24 import types
25
26 #initialize spec info vars and get them from the spec file
27 n_regex = re.compile('^Name:[ ]*([^\s]*)')
28 v_regex = re.compile('^Version:[ ]*([0-9\.]*)')
29
30 def __init__(self, specfile=None, **kwargs):
31 """
32 Creates the RpmSpec object.
33
34 @type specfile: str
35 @param specfile: the name of the specfile to get the package
36 name and version from
37 @type kwargs: dict
38 @param kwargs: All further keyword arguments.
39 """
40 self.specfile = specfile
41 self._pkg_name = None
42 self._pkg_version = None
43 self._loaded = False
44
45 def load(self):
46 """
47 call this function after the file exists to populate properties
48 """
49 # If we are given a string, open it up else assume it's something we
50 # can call read on.
51 if type(self.specfile) == self.types.StringType:
52 f = open(self.specfile, 'r')
53 else:
54 f = self.specfile
55
56 for line in f:
57 if self.v_regex.match(line):
58 self._pkg_version = self.v_regex.match(line).group(1)
59 if self.n_regex.match(line):
60 self._pkg_name = self.n_regex.match(line).group(1)
61 f.close()
62 self._loaded = True
63
64 # Read-only properties
65 loaded = property(lambda self: self._loaded)
66 pkg_name = property(lambda self: self._pkg_name)
67 pkg_version = property(lambda self: self._pkg_version)
OLDNEW
« no previous file with comments | « third_party/buildbot_7_12/buildbot/steps/package/rpm/rpmlint.py ('k') | third_party/buildbot_7_12/buildbot/steps/python.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698