@@ -47,10 +47,32 @@ def review_patches(patches):
47
47
48
48
added_files .sort ()
49
49
for f in added_files :
50
- dir_id = f .rfind ("/" ) + 1
50
+ dir_id = f .rfind ("/" ) + 1 # f[dir_id:] is name.type[.source.txt]
51
+ if dir_id == 0 :
52
+ out += "\t Malformed patch: " + f + " should be of the form 'b/db/type/name.type[.source.txt]'\n "
53
+ ret = 1
54
+ local_error = True
55
+ continue
56
+ if not "/db/" in f :
57
+ continue # file is not in db subdir
58
+
51
59
ext_id = dir_id + f [dir_id :].find ("." )
52
- if ext_id != - 1 :
53
- ext = f [ext_id + 1 :]
60
+ if ext_id == dir_id - 1 : # check if f is .../db/type/type or .../db/misc/type
61
+ dir_id2 = f .rfind ("/" , 0 , dir_id - 1 )+ 1 # f[dir_id2:dir_id] is subdir within db/
62
+ if f [dir_id2 :dir_id - 1 ] == f [dir_id :]:
63
+ pass # ok, is .../db/type/type
64
+ if f [dir_id2 ] in ('.' , '_' ):
65
+ out += "\t " + f + ": Subdir names may not start with . or _\n "
66
+ ret = 1
67
+ local_error = True
68
+ elif f [dir_id2 :dir_id - 1 ] == 'misc' :
69
+ pass # ok, is .../db/msic/type
70
+ else :
71
+ out += "\t " + f + ": File is not in proper directory according to extension\n "
72
+ ret = 1
73
+ local_error = True
74
+ else :
75
+ ext = f [ext_id + 1 :] # ext is type[.source.txt]
54
76
if ext .endswith ("source.txt" ):
55
77
real_db_file = f [:- len (".source.txt" )]
56
78
try :
@@ -87,6 +109,12 @@ def review_patches(patches):
87
109
- Every file with extension '.X' has to be in directory 'db/X' according to
88
110
its extension. Note that case sensitivity is important and must be
89
111
respected.
112
+ - If a file has no (typical) extension (e.g. AppleDouble), then it has to go
113
+ to folder db/misc or must be given a descriptive short name and no extension
114
+ and appear in a directory of the same name (e.g. db/AppleDouble/AppleDouble).
115
+ The corresponding .source.txt needs to explain this in a line starting with
116
+ 'NOTE: ' (see e.g. db/AppleDouble/AppleDouble.source.txt). No leading . or _
117
+ (e.g. .DS_Store --> DS_Store)
90
118
"""
91
119
print "Usage: " + sys .argv [0 ] + " [[patch1], [patch2], ...]"
92
120
print "Usage: " + sys .argv [0 ] + " *.patch"
0 commit comments