-
Notifications
You must be signed in to change notification settings - Fork 7
/
py_release_check.py
executable file
·76 lines (66 loc) · 1.98 KB
/
py_release_check.py
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
#!/usr/bin/env python
# This file checkes the filename lengths of all files in a directory.
# Any files over 32 characters in length must be shortened.
import sys
from string import *
import os
# --- ------
# GOOD
def process_string( p_string ):
p_string = translate( p_string, maketrans( "#()\\;<>:\"\'.,", " " ) )
words = split( p_string )
for a in words:
if (( -1 != find( a, "$g_" ) )&
( -1 == find( p_string, "$HTTP_COOKIE_VARS" ) )&
( -1 == find( p_string, "_include_" ) )&
( -1 == find( p_string, "_cookie" ) )&
( -1 == find( p_string, "_enum_" ) )&
( -1 == find( p_string, "_color" ) )&
( -1 == find( p_string, "g_html_tags" ) )&
( -1 == find( p_string, "g_language_choices_arr" ) )&
( -1 == find( p_string, "g_db_table_prefix" ) )&
( -1 == find( p_string, "_path" ) )):
return a
return ""
# --- ------
# ===========================
# MAIN
# ===========================
config_file = "/home/www/mantis/config_inc.php"
py_release_file = "/home/www/py_release.py"
config_list = []
py_release_list = []
config_strings = {}
py_release_strings = {}
# open config file
file = open( config_file )
config_list = file.readlines()
file.close()
# populate dictionary
for i in config_list:
string_key = process_string( i )
if ( len( string_key ) > 0 ):
config_strings[string_key] = 1
# open config doc file
file = open( py_release_file )
py_release_list = file.readlines()
file.close()
# populate dictionary
for i in py_release_list:
string_key = process_string( i )
if ( len( string_key ) > 0 ):
py_release_strings[string_key] = 1
# check for missing
config_keys = config_strings.keys()
config_keys.sort()
for i in config_keys:
if ( not py_release_strings.has_key( i ) ):
print "Missing: "+i
print "----------------------------------"
# check for unused
py_release_keys = py_release_strings.keys()
py_release_keys.sort()
for i in py_release_keys:
if ( not config_strings.has_key( i ) ):
print "Unused: "+i
print "----------------------------------"