@@ -1128,6 +1128,21 @@ def parse_udiff(diff, patterns=None, parent='.'):
11281128 if rows and filename_match (path , patterns )])
11291129
11301130
1131+ def normalize_paths (value , parent = os .curdir ):
1132+ """Parse a comma-separated list of paths.
1133+
1134+ Return a list of absolute paths.
1135+ """
1136+ if not value or isinstance (value , list ):
1137+ return value
1138+ paths = []
1139+ for path in value .split (',' ):
1140+ if path .startswith ('./' ):
1141+ path = os .path .abspath (os .path .join (parent , path ))
1142+ paths .append (path .rstrip ('/' ))
1143+ return paths
1144+
1145+
11311146def filename_match (filename , patterns , default = True ):
11321147 """
11331148 Check if patterns contains a pattern that matches filename.
@@ -1594,8 +1609,6 @@ def __init__(self, *args, **kwargs):
15941609 if not options .reporter :
15951610 options .reporter = BaseReport if options .quiet else StandardReport
15961611
1597- for index , value in enumerate (options .exclude ):
1598- options .exclude [index ] = value .rstrip ('/' )
15991612 options .select = tuple (options .select or ())
16001613 if not (options .select or options .ignore or
16011614 options .testsuite or options .doctest ) and DEFAULT_IGNORE :
@@ -1675,6 +1688,7 @@ def excluded(self, filename, parent=None):
16751688 return True
16761689 if parent :
16771690 filename = os .path .join (parent , filename )
1691+ filename = os .path .abspath (filename )
16781692 return filename_match (filename , self .options .exclude )
16791693
16801694 def ignore_code (self , code ):
@@ -1774,9 +1788,11 @@ def read_config(options, args, arglist, parser):
17741788 print ('user configuration: %s' % user_conf )
17751789 config .read (user_conf )
17761790
1791+ local_dir = os .curdir
17771792 parent = tail = args and os .path .abspath (os .path .commonprefix (args ))
17781793 while tail :
17791794 if config .read ([os .path .join (parent , fn ) for fn in PROJECT_CONFIG ]):
1795+ local_dir = parent
17801796 if options .verbose :
17811797 print ('local configuration: in %s' % parent )
17821798 break
@@ -1804,6 +1820,8 @@ def read_config(options, args, arglist, parser):
18041820 value = config .getint (pep8_section , opt )
18051821 elif opt_type == 'string' :
18061822 value = config .get (pep8_section , opt )
1823+ if normalized_opt == 'exclude' :
1824+ value = normalize_paths (value , local_dir )
18071825 else :
18081826 assert opt_type in ('store_true' , 'store_false' )
18091827 value = config .getboolean (pep8_section , opt )
@@ -1851,7 +1869,7 @@ def process_options(arglist=None, parse_argv=False, config_file=None,
18511869 options .reporter = parse_argv and options .quiet == 1 and FileReport
18521870
18531871 options .filename = options .filename and options .filename .split (',' )
1854- options .exclude = options .exclude . split ( ',' )
1872+ options .exclude = normalize_paths ( options .exclude )
18551873 options .select = options .select and options .select .split (',' )
18561874 options .ignore = options .ignore and options .ignore .split (',' )
18571875
0 commit comments