blob: 259a3520c5ddcde72cfcc252e1a9bfe95c731893 (
plain)
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
|
# R Overlay -- ebuild creation, ebuild class
# Copyright 2006-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
class Ebuild ( object ):
def __init__ ( self, content, header=None ):
"""Initializes an Ebuild that has text content and optionally a
header (text, too).
arguments:
* content --
* header --
"""
self.content = content
self.header = header
# --- end of __init__ (...) ---
def write ( self, fh, header=None ):
"""Write the ebuild into a file-like object.
arguments:
* fh -- file handle
"""
if not self.content:
raise Exception ( "ebuild is empty!" )
if header is None:
if not self.header is None:
fh.write ( self.header )
fh.write ( '\n' )
else:
fh.write ( header )
fh.write ( '\n' )
fh.write ( self.content )
fh.write ( '\n' )
# --- end of write_fh (...) ---
|