lilalo

diff l3config.pm @ 24:4b86595adb4b

Написал что нового в 0.2.2
author devi
date Wed Nov 02 19:25:39 2005 +0200 (2005-11-02)
parents
children ba4d6515b8fd
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/l3config.pm	Wed Nov 02 19:25:39 2005 +0200
     1.3 @@ -0,0 +1,92 @@
     1.4 +package l3config;
     1.5 +
     1.6 +use Exporter;
     1.7 +use Getopt::Long;
     1.8 +
     1.9 +@ISA = ('Exporter');
    1.10 +@EXPORT = qw(%Config &init_config);
    1.11 +
    1.12 +our $Config_File = "labmaker.conf";
    1.13 +our %Config = (
    1.14 +		"skip_empty" 			=> 	"yes",
    1.15 +		"skip_interrupted" 		=>	"no",
    1.16 +		"skip_wrong" 			=>	"no",
    1.17 +		"editors"			=>	["vi", "pico", "ee", "vim"],
    1.18 +		"pagers"			=>	["more", "less", "zmore", "zless", "info", 
    1.19 +							"man", "mc", "trafshow", "screen", "cfdisk",
    1.20 +							"trafshow-bsd", "yes", "lynx", "links", "centericq"
    1.21 +							],
    1.22 +		"terminal"			=>	["mc"],
    1.23 +		"suppress_editors"		=>	"yes",
    1.24 +		"suppress_pagers"		=>	"yes",
    1.25 +		"suppress_terminal"		=>	"yes",
    1.26 +
    1.27 +		"terminal_width"		=> 	100,
    1.28 +		"terminal_height"		=> 	100,
    1.29 +		"verbose"			=>	"yes",
    1.30 +
    1.31 +		"head_lines"			=> 	5,
    1.32 +		"tail_lines"			=>	5,
    1.33 +		"cache_head_lines"			=> 	5,
    1.34 +		"cache_tail_lines"			=>	5,
    1.35 +		"skip_text"			=>	"...",
    1.36 +		"show_time"			=>	"yes",
    1.37 +		"show_diffs"			=>	"yes",
    1.38 +		"show_comments"			=>	"yes",
    1.39 +
    1.40 +		"input"				=>	"/root/.labmaker",
    1.41 +		"diffs"				=>	"",
    1.42 +		"input_mask"			=>	"*.script",
    1.43 +		"encoding"			=> 	"utf-8",
    1.44 +
    1.45 +		"cache"				=>	"/tmp/report.xml",
    1.46 +
    1.47 +		"output"			=>	"/tmp/report.html",
    1.48 +		#"output"			=>	"report.xml",
    1.49 +		"output_mask"			=>	"INDEX",
    1.50 +		"output_format"			=>	"html",
    1.51 +
    1.52 +		"signature"			=>	"#lm:",
    1.53 +		"from"				=>	"",
    1.54 +		"to"				=>	"",
    1.55 +		"lab"				=>	"",
    1.56 +		"keywords"			=>	"linux command",
    1.57 +		"files_keywords"		=>	"linux file",
    1.58 +		
    1.59 +		comment_width			=>	"300",
    1.60 +		time_width			=>	"60",
    1.61 +
    1.62 +		"course-name" => "", 
    1.63 +		"course-code" => "", 
    1.64 +		"course-date" => "", 
    1.65 +		"course-center" => "", 
    1.66 +		"course-trainer" => "", 
    1.67 +		"course-student" => "", 
    1.68 +		);
    1.69 +
    1.70 +sub read_config_file
    1.71 +{
    1.72 +	my $config = $_[0];
    1.73 +	my $filename = $_[1];
    1.74 +	open(CONFIG, "$filename")
    1.75 +		or return;
    1.76 +	while (<CONFIG>) {
    1.77 +		s/#.*//;
    1.78 +		next if /^\s*$/;
    1.79 +		my ($var, $val) =  split /\s*=\s*/, $_, 2;
    1.80 +		$var =~ s/\s*//;
    1.81 +		$config->{$var} = $val;
    1.82 +	}
    1.83 +	close(CONFIG);
    1.84 +}
    1.85 +
    1.86 +
    1.87 +sub init_config
    1.88 +{
    1.89 +	my %argv_config;
    1.90 +	my %file_config;
    1.91 +	read_config_file(\%file_config, $Config_File);
    1.92 +	GetOptions(\%argv_config, map "$_=s", keys %Config);
    1.93 +	%Config = (%Config, %file_config, %argv_config);
    1.94 +}
    1.95 +