File: Priority.pm

package info (click to toggle)
debconf 1.5.11etch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 3,364 kB
  • ctags: 714
  • sloc: perl: 8,347; sh: 286; makefile: 174; python: 117
file content (79 lines) | stat: -rw-r--r-- 1,234 bytes parent folder | download | duplicates (12)
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
#!/usr/bin/perl -w

=head1 NAME

Debconf::Priority - priority level module

=cut

package Debconf::Priority;
use strict;
use Debconf::Config;
use base qw(Exporter);
our @EXPORT_OK = qw(high_enough priority_valid priority_list);

=head1 DESCRIPTION

This module deals with the priorities of Questions.

Currently known priorities are low, medium, high, and critical.

=cut

my %priorities=(
	'low' => 0,
	'medium' => 1,
	'high' => 2,
	'critical' => 3,
);

=head1 METHODS

=over 4

=item high_enough

Returns true iff the passed value is greater than or equal to the current
priority level. Note that if an unknown priority is passed in, it is assumed
to be higher.

=cut

sub high_enough {
	my $priority=shift;

	return 1 if ! exists $priorities{$priority};
	return $priorities{$priority} >= $priorities{Debconf::Config->priority};
}

=item priority_valid

Returns true if the passed text is a valid priority.

=cut

sub priority_valid {
	my $priority=shift;

	return exists $priorities{$priority};
}

=item priority_list

Returns an ordered list of all allowed priorities.

=cut

sub priority_list {
	return sort { $priorities{$a} <=> $priorities{$b} } keys %priorities;
}

=back

=head1 AUTHOR

Joey Hess <joeyh@debian.org>

=cut

1