File: testTemplateVariables

package info (click to toggle)
gnump3d 2.9.3-1sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,420 kB
  • ctags: 366
  • sloc: perl: 10,649; sh: 188; makefile: 147
file content (98 lines) | stat: -rwxr-xr-x 1,983 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/perl -w
# Test that no templates use undefined variables.

use File::Find;

#
#  A list of variables we can support
#
my %VALID_KEY;
$VALID_KEY{ 'VERSION' } = 1;
$VALID_KEY{ 'RELEASE' } = 1;
$VALID_KEY{ 'HOSTNAME' } = 1;
$VALID_KEY{ 'HEADER' } = 1;
$VALID_KEY{ 'DIRECTORY' } = 1;
$VALID_KEY{ 'BANNER' } = 1;
$VALID_KEY{ 'HEADING' } = 1;
$VALID_KEY{ 'TEXT' } = 1;
$VALID_KEY{ 'ERROR_MESSAGE' } = 1;
$VALID_KEY{ 'PLAYLISTS' } = 1;
$VALID_KEY{ 'SONGS' } = 1;
$VALID_KEY{ 'DIRECTORIES' } = 1;
$VALID_KEY{ 'MOVIES' } = 1;
$VALID_KEY{ 'TITLE' } = 1;


#
# Specialise plugin values.
$VALID_KEY{ 'BUG_REPORT_URL' } = 1;
$VALID_KEY{ 'PLAY_RESULTS' } = 1;
$VALID_KEY{ 'TERMS' } = 1;
$VALID_KEY{ 'RESULTS' } = 1;
$VALID_KEY{ 'SELECT_COMBO' } = 1;
$VALID_KEY{ 'GENRE_COMBO' } = 1;
$VALID_KEY{ 'USER_AGENT' } = 1;
$VALID_KEY{ 'connected_address' } = 1;
$VALID_KEY{ 'REQUEST' } = 1;
$VALID_KEY{ 'host' } = 1;
$VALID_KEY{ 'OSNAME' } = 1;
$VALID_KEY{ 'BUG_CONFIG' } = 1;
$VALID_KEY{ 'MOST_POPULAR_SONGS' } = 1;
$VALID_KEY{ 'MOST_POPULAR_DIRS' } = 1;
$VALID_KEY{ 'MOST_ACTIVE_CLIENTS' } = 1;
$VALID_KEY{ 'MOST_POPULAR_USER_AGENTS' } = 1;


#
#  Do the search
#
my $START = "../templates/";
find({ wanted => \&process, no_chdir => '1' }, $START);


#
#
#
sub process( $ )
{
  my $file = $File::Find::name;

  # Ignore directories
  return if ( -d $file );

  # And images
  return if ( $file =~ /\.jpg$/ );
  return if ( $file =~ /\.gif$/ );
  return if ( $file =~ /\.png$/ );
  return if ( $file =~ /\.ini$/ );

  # And CVS files.
  return if ( $file =~ /CVS/ );

  # Read in the file.
  open( FILY, "<$file" ) or die "Cannot open $file - $!";
  my @LINES  = <FILY>;
  close( FILY );

  #
  # Look for illegal values.
  #
  foreach my $line ( @LINES )
  {
    while( $line =~ /(.*)\$([a-zA-Z-_]+)(.*)/ )
    {
      my $key = $2;
      if (! $VALID_KEY{ $key } ) 
      {
	print "Unknown key $key found in $file\n";
	exit 1;
      }
      $line = $2;
    }
  }
  return 1;
}



exit( 0 );