| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
Debconf::Priority - priority level module |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
package Debconf::Priority; |
| 10 |
use warnings; |
| 11 |
use strict; |
| 12 |
use Debconf::Config; |
| 13 |
use base qw(Exporter); |
| 14 |
our @EXPORT_OK = qw(high_enough priority_valid priority_list); |
| 15 |
|
| 16 |
=head1 DESCRIPTION |
| 17 |
|
| 18 |
This module deals with the priorities of Questions. |
| 19 |
|
| 20 |
Currently known priorities are low, medium, high, and critical. |
| 21 |
|
| 22 |
=cut |
| 23 |
|
| 24 |
my %priorities=( |
| 25 |
'low' => 0, |
| 26 |
'medium' => 1, |
| 27 |
'high' => 2, |
| 28 |
'critical' => 3, |
| 29 |
); |
| 30 |
|
| 31 |
=head1 METHODS |
| 32 |
|
| 33 |
=over 4 |
| 34 |
|
| 35 |
=item high_enough |
| 36 |
|
| 37 |
Returns true iff the passed value is greater than or equal to the current |
| 38 |
priority level. Note that if an unknown priority is passed in, it is assumed |
| 39 |
to be higher. |
| 40 |
|
| 41 |
=cut |
| 42 |
|
| 43 |
sub high_enough { |
| 44 |
my $priority=shift; |
| 45 |
|
| 46 |
return 1 if ! exists $priorities{$priority}; |
| 47 |
return $priorities{$priority} >= $priorities{Debconf::Config->priority}; |
| 48 |
} |
| 49 |
|
| 50 |
=item priority_valid |
| 51 |
|
| 52 |
Returns true if the passed text is a valid priority. |
| 53 |
|
| 54 |
=cut |
| 55 |
|
| 56 |
sub priority_valid { |
| 57 |
my $priority=shift; |
| 58 |
|
| 59 |
return exists $priorities{$priority}; |
| 60 |
} |
| 61 |
|
| 62 |
=item priority_list |
| 63 |
|
| 64 |
Returns an ordered list of all allowed priorities. |
| 65 |
|
| 66 |
=cut |
| 67 |
|
| 68 |
sub priority_list { |
| 69 |
my @sorted = sort { $priorities{$a} <=> $priorities{$b} } keys %priorities; |
| 70 |
return @sorted; |
| 71 |
} |
| 72 |
|
| 73 |
=back |
| 74 |
|
| 75 |
=head1 AUTHOR |
| 76 |
|
| 77 |
Joey Hess <[email protected]> |
| 78 |
|
| 79 |
=cut |
| 80 |
|
| 81 |
1 |