tdroadmap_merger/gettd.pl
author victorp@symbian.org
Fri, 31 Jul 2009 16:22:41 +0100
changeset 25 7a2c092f0fbf
parent 24 8fb98cf0b1ac
child 26 74210f1577f9
permissions -rw-r--r--
update to roadmap merger to support package backlog analysis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     1
#!/usr/bin/perl
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     2
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     3
 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     4
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     5
use IO::Socket; 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     6
use Getopt::Long;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     7
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
     8
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
     9
my $target_url; #target url for the roadmap
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
    10
my $tdomain; #tag for the domain to be use in csv file
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
    11
my $csvfile; #output csv file name
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
    12
my $authon= '';	 #does it require authorisation? default is false
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
    13
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
    14
my $ispackage;
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    15
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    16
sub getpage
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    17
{
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    18
	#arguments
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    19
	($page,$host,$auth,$myfile)=@_;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    20
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    21
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    22
	#output file
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    23
	open ( outputfile, ">".$myfile);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    24
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    25
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    26
	$port = "http(80)";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    27
	$getmess = "GET " . $page ." HTTP/1.1\n" . $auth;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    28
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
    29
	print "INFO - sending message - $getmess\n";
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    30
	print outputfile "$getmess\n\n";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    31
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    32
	$sock = IO::Socket::INET->new 	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    33
		(
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    34
		 PeerAddr => $host,   PeerPort => $port,  Proto => 'tcp', 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    35
		) ;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    36
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    37
 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    38
	print $sock "$getmess\n\n";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    39
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    40
 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    41
	while(<$sock>) {
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    42
 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    43
	  print outputfile $_;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    44
 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    45
	}	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    46
  	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    47
	close ($sock);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    48
	close (outputfile);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    49
}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    50
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    51
sub prntfeatures 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    52
{
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    53
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    54
	($release,$package,$features,$myfile,$domain)=@_;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    55
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    56
	$features = $features."<dt";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    57
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    58
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    59
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    60
	while ( $features =~ /dt\>(.*?)\<\/dt(.*?)\<dt/sg  ){
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    61
		$myfeat = $1;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    62
		$subfeat =$2;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    63
		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    64
		$myfeat =~ s/\n/ /sg;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    65
		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    66
		pos($features) = pos($features) -2;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    67
		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    68
		$mystr="";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    69
		while ( $subfeat =~ /\<dd\>(.*?)\<\/dd\>/sg) {
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    70
			$mysubfeat = $mysubfeat.$mystr.$1;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    71
			$mystr = " & ";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    72
		}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    73
		undef $mystr;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    74
	$mysubfeat =~ s/,/ /sg;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    75
	$mysubfeat =~ s/\n//sg;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    76
	$mysubfeat =~ s/\<.*?\>//sg;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    77
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    78
	$release =~ s/\\//sg;	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    79
	print $myfile " $release, $domain, $package, $myfeat, $mysubfeat\n";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    80
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    81
	$mysubfeat = "";	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    82
	}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    83
		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    84
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    85
}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    86
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    87
sub loadfile
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    88
{
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    89
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    90
	$/ = " ";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    91
	#arguments
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    92
	($myfile)=@_;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    93
	open ( inputfile, "<".$myfile);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    94
	my $contents = do { local $/;  <inputfile> };
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    95
	close(inputfile);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    96
	return $contents;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    97
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    98
}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
    99
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   100
sub td_roadmap
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   101
{
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   102
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   103
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   104
	#arguments
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   105
	($infile,$outfile,$domain,@releases)=@_;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   106
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   107
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   108
	$roadmap=loadfile $infile;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   109
	open ( outputfile, ">>".$outfile);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   110
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   111
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   112
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   113
	foreach (@releases) {
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   114
		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   115
		$exp="\\<h2\\>.*?\\>".$_;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   116
		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   117
		if ($roadmap =~ m /($exp)/sg) { 
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   118
			print "PASS - Found entry for $_ \n";
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   119
			$relroad =$';	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   120
			
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   121
			if ($relroad =~ m /(.*?)\<h2/sg) { $relroad =$1;}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   122
			$i=0;	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   123
			while ($relroad=~ m/\<h3\>.*\>(.*?)\<.*<\/h3/g) {
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   124
				$package = $1;		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   125
				$ppos[$i]= pos($relroad);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   126
				$pname[$i]= $package;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   127
				$i++;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   128
			}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   129
			for ( $i=0;$i<($#ppos); $i++){
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   130
				$features= substr ($relroad, $ppos[$i],$ppos[$i+1]-$ppos[$i]);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   131
				prntfeatures($_,$pname[$i],$features,outputfile,$domain);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   132
			}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   133
			$features= substr ($relroad, $ppos[$i]);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   134
		
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   135
			prntfeatures($_,$pname[$i],$features,outputfile,$domain);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   136
			@ppos ="";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   137
			@pname ="";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   138
			undef ($features);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   139
		}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   140
			 	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   141
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   142
	}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   143
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   144
	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   145
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   146
	close (outputfile);
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   147
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   148
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   149
}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   150
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   151
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   152
sub parse_category {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   153
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   154
	#arguments
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   155
	($infile)=@_;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   156
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   157
	my @mylink;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   158
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   159
	$mypage=loadfile $infile;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   160
	$i=0;	
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   161
	if ( $mypage =~ m/Pages in category(.*)\<\/table/sg) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   162
		print "INFO - Category page found\n";
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   163
		$mypage = $1;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   164
		while ($mypage =~ m /\<a href\=\"(\/wiki\/index\.php\/.*?)\"/g) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   165
			
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   166
			$mylink[$i] = $1;	
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   167
			$i++;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   168
			
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   169
		}
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   170
	print "INFO - Found $i items in the category page\n"
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   171
	}
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   172
	return @mylink;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   173
}
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   174
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   175
sub parse_bklog {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   176
	
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   177
	#arguments
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   178
	($infile,$outfile)=@_;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   179
	$mypkg=loadfile $infile;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   180
	open ( outputfile, ">>".$outfile);
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   181
	open ( soutputfile, ">>"."summary_".$outfile);
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   182
	
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   183
	if ($mypkg =~ m/index\.php\/(.*?) HTTP/sg) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   184
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   185
		$pagename = $1;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   186
		print "INFO -Processing Package $pagename \n";
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   187
		$i=0;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   188
		#while ($mypkg =~ m/\<tr\>\<td\>(.*?)\<\/td\>/g) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   189
		while ($mypkg =~ m/\<tr\>(.*?)\<\/tr/sg) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   190
			$i++;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   191
			$myfeat= $1;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   192
			$myfeat =~ s/\<\/td\>/\t/sg;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   193
			$myfeat =~ s/\<.*?\>//sg;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   194
			$myfeat =~ s/\n//sg;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   195
			print outputfile "$pagename\t$myfeat\n";
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   196
			
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   197
		}
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   198
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   199
	print soutputfile "$pagename\t$i\n";
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   200
	
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   201
	}
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   202
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   203
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   204
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   205
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   206
}
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   207
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   208
#help print
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   209
sub printhelp
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   210
{
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   211
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   212
	print "\n\n version 0.3 
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   213
	\ngettd.pl -t=url -d=domain \nrequired parameters:\n\t -t url containing the technology domain roadmap\n\t -d the technology domain name
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   214
	\n Optional parameters\n\t-o filename ,the output is logged into the output.csv file by default\n\t-h for help
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   215
	\n\t-a setup authorisation by cookie follow instructions in http://developer.symbian.org/wiki/index.php/Roadmap_merger_script#Cookies";
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   216
	exit;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   217
}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   218
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   219
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   220
#process command line options
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   221
sub cmd_options
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   222
{
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   223
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   224
  my $help;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   225
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   226
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   227
  GetOptions('h' => \$help,'t=s'=> \$target_url, 'd=s' => \$tdomain , 'o=s' => \$csvfile, 'a' => \$authon , 'p' => \$ispackage);
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   228
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   229
  if ($help) {
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   230
    printhelp;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   231
  }
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   232
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   233
 if ($ispackage) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   234
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   235
 	$tdomain =" ";
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   236
	$target_url = "http://developer.symbian.org/wiki/index.php/Category:Package_Backlog";
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   237
	
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   238
 }  
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   239
 
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   240
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   241
 if ( not $target_url) {
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   242
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   243
	print "ERROR-missing arguments target url\n";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   244
	printhelp;	
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   245
  } 
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   246
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   247
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   248
 if (not $tdomain){
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   249
	print "ERROR-missing arguments domain level\n";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   250
	printhelp;
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   251
 }
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   252
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   253
 	print "\nINFO-downloading $target_url with label $tdomain\n";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   254
  
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   255
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   256
 if (not $csvfile) {
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   257
	$csvfile="output.csv";
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   258
 }
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   259
 print "\nINFO-output recorded in $csvfile \n";
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   260
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   261
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   262
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   263
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   264
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   265
}
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   266
#main
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   267
$/ = " ";
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   268
$host1 = "developer.symbian.org";
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   269
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   270
cmd_options();
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   271
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   272
if ($authon) {
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   273
	#file containing login details from http cookie
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   274
	$mycookie = loadfile("mycookie.txt");
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   275
24
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   276
	$auth = "Cookie: " . $mycookie ;
8fb98cf0b1ac remove authentication as default, added -a option for cookies
victorp@symbian.org
parents: 23
diff changeset
   277
}
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   278
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   279
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   280
if ($ispackage) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   281
	getpage($target_url, $host1, $auth, "debug.txt");
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   282
	@bklog = parse_category("debug.txt");
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   283
	$i=0;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   284
	foreach (@bklog) {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   285
		getpage("http://".$host1.$_, $host1, $auth, "pkg".$i.".txt");
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   286
		parse_bklog ("pkg".$i.".txt",$csvfile);
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   287
		$i++;
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   288
		
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   289
	
23
dbe87093a3ca adding roadmap_merger script - first version
victorp@symbian.org
parents:
diff changeset
   290
25
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   291
	}
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   292
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   293
} else {
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   294
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   295
	#foundation releases - add as required
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   296
	@releases=("Symbian\\^2","Symbian\\^3","Symbian\\^4");
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   297
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   298
	getpage($target_url, $host1, $auth, "debug.txt");
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   299
	td_roadmap("debug.txt" , $csvfile, $tdomain ,@releases);
7a2c092f0fbf update to roadmap merger to support package backlog analysis
victorp@symbian.org
parents: 24
diff changeset
   300
}