tdroadmap_merger/gettd.pl
changeset 25 7a2c092f0fbf
parent 24 8fb98cf0b1ac
child 26 74210f1577f9
equal deleted inserted replaced
24:8fb98cf0b1ac 25:7a2c092f0fbf
     7 
     7 
     8 
     8 
     9 my $target_url; #target url for the roadmap
     9 my $target_url; #target url for the roadmap
    10 my $tdomain; #tag for the domain to be use in csv file
    10 my $tdomain; #tag for the domain to be use in csv file
    11 my $csvfile; #output csv file name
    11 my $csvfile; #output csv file name
    12 my $authon= '';	; #does it require authorisation? default is false
    12 my $authon= '';	 #does it require authorisation? default is false
       
    13 
       
    14 my $ispackage;
    13 
    15 
    14 sub getpage
    16 sub getpage
    15 {
    17 {
    16 	#arguments
    18 	#arguments
    17 	($page,$host,$auth,$myfile)=@_;
    19 	($page,$host,$auth,$myfile)=@_;
   145 
   147 
   146 
   148 
   147 }
   149 }
   148 
   150 
   149 
   151 
       
   152 sub parse_category {
       
   153 
       
   154 	#arguments
       
   155 	($infile)=@_;
       
   156 
       
   157 	my @mylink;
       
   158 
       
   159 	$mypage=loadfile $infile;
       
   160 	$i=0;	
       
   161 	if ( $mypage =~ m/Pages in category(.*)\<\/table/sg) {
       
   162 		print "INFO - Category page found\n";
       
   163 		$mypage = $1;
       
   164 		while ($mypage =~ m /\<a href\=\"(\/wiki\/index\.php\/.*?)\"/g) {
       
   165 			
       
   166 			$mylink[$i] = $1;	
       
   167 			$i++;
       
   168 			
       
   169 		}
       
   170 	print "INFO - Found $i items in the category page\n"
       
   171 	}
       
   172 	return @mylink;
       
   173 }
       
   174 
       
   175 sub parse_bklog {
       
   176 	
       
   177 	#arguments
       
   178 	($infile,$outfile)=@_;
       
   179 	$mypkg=loadfile $infile;
       
   180 	open ( outputfile, ">>".$outfile);
       
   181 	open ( soutputfile, ">>"."summary_".$outfile);
       
   182 	
       
   183 	if ($mypkg =~ m/index\.php\/(.*?) HTTP/sg) {
       
   184 
       
   185 		$pagename = $1;
       
   186 		print "INFO -Processing Package $pagename \n";
       
   187 		$i=0;
       
   188 		#while ($mypkg =~ m/\<tr\>\<td\>(.*?)\<\/td\>/g) {
       
   189 		while ($mypkg =~ m/\<tr\>(.*?)\<\/tr/sg) {
       
   190 			$i++;
       
   191 			$myfeat= $1;
       
   192 			$myfeat =~ s/\<\/td\>/\t/sg;
       
   193 			$myfeat =~ s/\<.*?\>//sg;
       
   194 			$myfeat =~ s/\n//sg;
       
   195 			print outputfile "$pagename\t$myfeat\n";
       
   196 			
       
   197 		}
       
   198 
       
   199 	print soutputfile "$pagename\t$i\n";
       
   200 	
       
   201 	}
       
   202 
       
   203 
       
   204 
       
   205 
       
   206 }
       
   207 
   150 #help print
   208 #help print
   151 sub printhelp
   209 sub printhelp
   152 {
   210 {
   153 
   211 
   154 	print "\n\n version 0.3 
   212 	print "\n\n version 0.3 
   161 
   219 
   162 #process command line options
   220 #process command line options
   163 sub cmd_options
   221 sub cmd_options
   164 {
   222 {
   165 
   223 
   166 
       
   167   my $help;
   224   my $help;
   168 
   225 
   169 
   226 
   170   GetOptions('h' => \$help,'t=s'=> \$target_url, 'd=s' => \$tdomain , 'o=s' => \$csvfile, 'a' => \$authon);
   227   GetOptions('h' => \$help,'t=s'=> \$target_url, 'd=s' => \$tdomain , 'o=s' => \$csvfile, 'a' => \$authon , 'p' => \$ispackage);
   171 
   228 
   172   if ($help) {
   229   if ($help) {
   173     printhelp;
   230     printhelp;
   174   }
   231   }
   175 
   232 
   176   
   233  if ($ispackage) {
       
   234 
       
   235  	$tdomain =" ";
       
   236 	$target_url = "http://developer.symbian.org/wiki/index.php/Category:Package_Backlog";
       
   237 	
       
   238  }  
       
   239  
       
   240 
   177  if ( not $target_url) {
   241  if ( not $target_url) {
   178 
   242 
   179 	print "ERROR-missing arguments target url\n";
   243 	print "ERROR-missing arguments target url\n";
   180 	printhelp;	
   244 	printhelp;	
   181   } 
   245   } 
       
   246 
   182 
   247 
   183  if (not $tdomain){
   248  if (not $tdomain){
   184 	print "ERROR-missing arguments domain level\n";
   249 	print "ERROR-missing arguments domain level\n";
   185 	printhelp;
   250 	printhelp;
   186  }
   251  }
   193  }
   258  }
   194  print "\nINFO-output recorded in $csvfile \n";
   259  print "\nINFO-output recorded in $csvfile \n";
   195 
   260 
   196 
   261 
   197 
   262 
   198      
       
   199 
       
   200 
   263 
   201 
   264 
   202 }
   265 }
   203 #main
   266 #main
   204 $/ = " ";
   267 $/ = " ";
       
   268 $host1 = "developer.symbian.org";
       
   269 
   205 cmd_options();
   270 cmd_options();
   206 
   271 
   207 if ($authon) {
   272 if ($authon) {
   208 	#file containing login details from http cookie
   273 	#file containing login details from http cookie
   209 	$mycookie = loadfile("mycookie.txt");
   274 	$mycookie = loadfile("mycookie.txt");
   210 
   275 
   211 	$auth = "Cookie: " . $mycookie ;
   276 	$auth = "Cookie: " . $mycookie ;
   212 }
   277 }
   213 
   278 
   214 #foundation releases - add as required
   279 
   215 @releases=("Symbian\\^2","Symbian\\^3","Symbian\\^4");
   280 if ($ispackage) {
   216 
   281 	getpage($target_url, $host1, $auth, "debug.txt");
   217 
   282 	@bklog = parse_category("debug.txt");
   218 $host1 = "developer.symbian.org";
   283 	$i=0;
   219 
   284 	foreach (@bklog) {
   220 
   285 		getpage("http://".$host1.$_, $host1, $auth, "pkg".$i.".txt");
   221 
   286 		parse_bklog ("pkg".$i.".txt",$csvfile);
   222 
   287 		$i++;
   223 getpage($target_url, $host1, $auth, "debug.txt");
   288 		
   224 td_roadmap("debug.txt" , $csvfile, $tdomain ,@releases);
   289 	
       
   290 
       
   291 	}
       
   292 
       
   293 } else {
       
   294 
       
   295 	#foundation releases - add as required
       
   296 	@releases=("Symbian\\^2","Symbian\\^3","Symbian\\^4");
       
   297 
       
   298 	getpage($target_url, $host1, $auth, "debug.txt");
       
   299 	td_roadmap("debug.txt" , $csvfile, $tdomain ,@releases);
       
   300 }