lilalo

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