File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -109,11 +109,26 @@ init python:
109109 )
110110
111111 # Parse rules
112+ line_no = 0
112113 for line in open (rules_path, ' r' ).readlines():
113- if line.startswith(' #' ):
114+ line_no += 1
115+
116+ if line.startswith(' #' ) or line.strip() == ' ' :
114117 continue
115- (f_rule, f_type, f_pattern) = line.rstrip(" \r \n " ).split(' ' , 3 - 1 )
116- f_rule = {' +' : True , ' -' : False }.get(f_rule)
118+
119+ try :
120+ (f_rule, f_type, f_pattern) = line.rstrip(" \r \n " ).split(' ' , 3 - 1 )
121+ except ValueError :
122+ raise RuntimeError (" Missing element at progressive_download.txt:%d" % line_no)
123+
124+ try :
125+ f_rule = {' +' : True , ' -' : False }[f_rule]
126+ except KeyError :
127+ raise RuntimeError (" Invalid rule '%s' at progressive_download.txt:%d" % (f_rule, line_no))
128+
129+ if f_type not in (' image' , ' music' , ' voice' ):
130+ raise RuntimeError (" Invalid type '%s' at progressive_download.txt:%d" % (f_type, line_no))
131+
117132 path_filters.append((f_rule, f_type, f_pattern))
118133
119134 def filters_match (path_filters , path , path_type ):
You can’t perform that action at this time.
0 commit comments