aboutsummaryrefslogtreecommitdiff
blob: 39665f8abb1b272313d48d0d8b49987169e50b33 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/python
#
# Copyright 2004 Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright 2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#
# $Header$

import sys
import gentoolkit

try:
	import portage.output as output
except ImportError:
	import output


def print_error(s):
	"""Prints an error string to stderr."""
	sys.stderr.write(output.red("!!! ") + s + "\n")

def print_info(lv, s, line_break = True):
	"""Prints an informational string to stdout."""
	if gentoolkit.Config["verbosityLevel"] >= lv:
		sys.stdout.write(s)
		if line_break:
			sys.stdout.write("\n")

def print_warn(s):
	"""Print a warning string to stderr."""
	sys.stderr.write("!!! " + s + "\n")
	
def die(err, s):
	"""Print an error string and die with an error code."""
	print_error(s)
	sys.exit(-err)

# Colour settings

def cpv(s):
	"""Print a category/package-<version> string."""
	return output.green(s)

def slot(s):
	"""Print a slot string"""
	return output.bold(s)
	
def useflag(s):
	"""Print a USE flag strign"""
	return output.blue(s)

def useflagon(s):
	"""Print an enabled USE flag string"""
	# FIXME: Collapse into useflag with parameter
	return output.red(s)

def useflagoff(s):
	"""Print a disabled USE flag string"""
	# FIXME: Collapse into useflag with parameter
	return output.blue(s)
	
def maskflag(s):
	"""Print a masking flag string"""
	return output.red(s)

def installedflag(s):
	"""Print an installed flag string"""
	return output.bold(s)
	
def number(s):
	"""Print a number string"""
	return output.turquoise(s)

def pkgquery(s):
	"""Print a package query string."""
	return output.bold(s)

def regexpquery(s):
	"""Print a regular expression string"""
	return output.bold(s)

def path(s):
	"""Print a file or directory path string"""
	return output.bold(s)

def path_symlink(s):
	"""Print a symlink string."""
	return output.turquoise(s)

def productname(s):
	"""Print a product name string, i.e. the program name."""
	return output.turquoise(s)
	
def globaloption(s):
	"""Print a global option string, i.e. the program global options."""
	return output.yellow(s)

def localoption(s):
	"""Print a local option string, i.e. the program local options."""
	return output.green(s)

def command(s):
	"""Print a program command string."""
	return output.green(s)
	
def section(s):
	"""Print a string as a section header."""
	return output.turquoise(s)	

def subsection(s):
	"""Print a string as a subsection header."""
	return output.turquoise(s)
	
def emph(s):
	"""Print a string as emphasized."""
	return output.bold(s)