common/tools/csvToSysDef.pl
changeset 341 2ba361491037
parent 340 aee074ee2646
child 344 348670fc497a
equal deleted inserted replaced
340:aee074ee2646 341:2ba361491037
     4 
     4 
     5 use FindBin;
     5 use FindBin;
     6 use lib "$FindBin::Bin/lib";
     6 use lib "$FindBin::Bin/lib";
     7 
     7 
     8 use XML::Parser;
     8 use XML::Parser;
     9 use Data::Dumper;
       
    10 use Text::CSV;
     9 use Text::CSV;
    11 
    10 
    12 my $sourcesCSV = shift or die "First arg must be source csv file";
    11 my $sourcesCSV = shift or die "First arg must be source csv file";
    13 my $backupBaseDir = shift or die "Second arg must be path to tree of package_definitions to use if not found in the source packages";
    12 my $backupBaseDir = shift or die "Second arg must be path to tree of package_definitions to use if not found in the source packages";
    14 shift and die "No more than two arguments please";
    13 shift and die "No more than two arguments please";
    76 		# Merge into output Tree
    75 		# Merge into output Tree
    77 		mergeTrees($outTree->[0], $pkgTree->[0]);
    76 		mergeTrees($outTree->[0], $pkgTree->[0]);
    78 	}
    77 	}
    79 }
    78 }
    80 
    79 
    81 #print Data::Dumper->Dump([$outTree->[0]], ["tree"]);
       
    82 
       
    83 # Output total tree
    80 # Output total tree
    84 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    81 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    85 printTree($outTree->[0]);
    82 printTree($outTree->[0]);
    86 print "\n";
    83 print "\n";
    87 
    84 
   104 		$extraChildTag =~ s{^main::}{};
   101 		$extraChildTag =~ s{^main::}{};
   105 		
   102 		
   106 		if ($extraChildTag =~ m{^(SystemDefinition|systemModel)$})
   103 		if ($extraChildTag =~ m{^(SystemDefinition|systemModel)$})
   107 		{
   104 		{
   108 			# Should be merged if there's already one there
   105 			# Should be merged if there's already one there
   109 #			warn "Always merge $extraChildTag";
       
   110 			# Look for a namesake in the base
   106 			# Look for a namesake in the base
   111 			$mergeIt = matchTag($baseTree->{Kids}, $extraChild, undef);
   107 			$mergeIt = matchTag($baseTree->{Kids}, $extraChild, undef);
   112 		}
   108 		}
   113 		elsif ($extraChildTag =~ m{layer|block|package|collection|component})
   109 		elsif ($extraChildTag =~ m{layer|block|package|collection|component})
   114 		{
   110 		{
   115 			# Should be merged if there is another tag with the same "name" attribute
   111 			# Should be merged if there is another tag with the same "name" attribute
   116 #			warn "Sometimes merge $extraChildTag";
       
   117 			# Look for a namesake in the base
   112 			# Look for a namesake in the base
   118 			$mergeIt = matchTag($baseTree->{Kids}, $extraChild, "name");
   113 			$mergeIt = matchTag($baseTree->{Kids}, $extraChild, "name");
   119 		}
   114 		}
   120 
   115 
   121 		if ($mergeIt)
   116 		if ($mergeIt)