lilalo

annotate l3config.pm @ 26:916661a89335

Написал что нового в 0.2.3
author devi
date Thu Nov 03 17:53:03 2005 +0200 (2005-11-03)
parents 6d93c5f1d0e5
children 098664cf339c
rev   line source
devi@23 1 package l3config;
devi@23 2
devi@23 3 use Exporter;
devi@23 4 use Getopt::Long;
devi@23 5
devi@23 6 @ISA = ('Exporter');
devi@23 7 @EXPORT = qw(%Config &init_config);
devi@23 8
devi@23 9 our $Config_File = "labmaker.conf";
devi@23 10 our %Config = (
devi@23 11 "skip_empty" => "yes",
devi@23 12 "skip_interrupted" => "no",
devi@23 13 "skip_wrong" => "no",
devi@23 14 "editors" => ["vi", "pico", "ee", "vim"],
devi@23 15 "pagers" => ["more", "less", "zmore", "zless", "info",
devi@23 16 "man", "mc", "trafshow", "screen", "cfdisk",
devi@23 17 "trafshow-bsd", "yes", "lynx", "links", "centericq"
devi@23 18 ],
devi@23 19 "terminal" => ["mc"],
devi@23 20 "suppress_editors" => "yes",
devi@23 21 "suppress_pagers" => "yes",
devi@23 22 "suppress_terminal" => "yes",
devi@23 23
devi@23 24 "terminal_width" => 100,
devi@23 25 "terminal_height" => 100,
devi@23 26 "verbose" => "yes",
devi@23 27
devi@23 28 "head_lines" => 5,
devi@23 29 "tail_lines" => 5,
devi@23 30 "cache_head_lines" => 5,
devi@23 31 "cache_tail_lines" => 5,
devi@23 32 "skip_text" => "...",
devi@23 33 "show_time" => "yes",
devi@23 34 "show_diffs" => "yes",
devi@23 35 "show_comments" => "yes",
devi@23 36
devi@23 37 "input" => "/root/.labmaker",
devi@23 38 "diffs" => "",
devi@23 39 "input_mask" => "*.script",
devi@23 40 "encoding" => "utf-8",
devi@23 41
devi@23 42 "cache" => "/tmp/report.xml",
devi@25 43 "cache_stat" => "/tmp/.report.dat",
devi@23 44
devi@23 45 "output" => "/tmp/report.html",
devi@23 46 #"output" => "report.xml",
devi@23 47 "output_mask" => "INDEX",
devi@23 48 "output_format" => "html",
devi@23 49
devi@23 50 "signature" => "#lm:",
devi@23 51 "from" => "",
devi@23 52 "to" => "",
devi@23 53 "lab" => "",
devi@23 54 "keywords" => "linux command",
devi@23 55 "files_keywords" => "linux file",
devi@23 56
devi@23 57 comment_width => "300",
devi@23 58 time_width => "60",
devi@25 59
devi@25 60 "mode" => "daemon", # daemon | normal
devi@25 61 "daemon_sleep_interval" => "1",
devi@25 62 "detach" => "yes",
devi@25 63 "agent_pidfile" => "$ENV{HOME}/.labmaker/l3-agent.pid",
devi@23 64
devi@25 65 "l3-agent" => "l3-agent",
devi@25 66
devi@23 67 "course-name" => "",
devi@23 68 "course-code" => "",
devi@23 69 "course-date" => "",
devi@23 70 "course-center" => "",
devi@23 71 "course-trainer" => "",
devi@23 72 "course-student" => "",
devi@23 73 );
devi@23 74
devi@23 75 sub read_config_file
devi@23 76 {
devi@23 77 my $config = $_[0];
devi@23 78 my $filename = $_[1];
devi@23 79 open(CONFIG, "$filename")
devi@23 80 or return;
devi@23 81 while (<CONFIG>) {
devi@23 82 s/#.*//;
devi@23 83 next if /^\s*$/;
devi@23 84 my ($var, $val) = split /\s*=\s*/, $_, 2;
devi@23 85 $var =~ s/\s*//;
devi@23 86 $config->{$var} = $val;
devi@23 87 }
devi@23 88 close(CONFIG);
devi@23 89 }
devi@23 90
devi@23 91
devi@23 92 sub init_config
devi@23 93 {
devi@23 94 my %argv_config;
devi@23 95 my %file_config;
devi@23 96 read_config_file(\%file_config, $Config_File);
devi@23 97 GetOptions(\%argv_config, map "$_=s", keys %Config);
devi@23 98 %Config = (%Config, %file_config, %argv_config);
devi@23 99 }
devi@23 100