Exemplo n.º 1
0
def check(filename, opts):
    try:
        with io.open(filename, encoding='utf-8', errors='replace') as fh:
            return mapfilechk(fh, verbose=opts['verbose'], output=sys.stdout)
    except IOError as e:
        sys.stderr.write("failed to open '%s': %s\n" %
                         (e.filename, e.strerror))
        return 1
Exemplo n.º 2
0
	sys.stderr.write('''Usage: %s [-v] [-x exceptions] paths...
        -v		report on all files, not just those with errors.
        -x exceptions	load an exceptions file
''' % progname)
	sys.exit(2)


def check(filename, opts):
	try:
		fh = open(filename, 'r')
	except IOError, e:
		sys.stderr.write("failed to open '%s': %s\n" %
				 (e.filename, e.strerror))
		return 1
	else:
		return mapfilechk(fh, verbose=opts['verbose'],
			       output=sys.stdout)

def walker(opts, dirname, fnames):
	for f in fnames:
		path = os.path.join(dirname, f)

		if not os.path.isdir(path):
			if not path in opts['exclude']:
				opts['status'] |= check(path, opts)
		else:
			if path in opts['exclude']:
				fnames.remove(f)

def walkpath(path, opts):
	if os.path.isdir(path):
		os.path.walk(path, walker, opts)
Exemplo n.º 3
0
    sys.stderr.write('''Usage: %s [-v] [-x exceptions] paths...
        -v		report on all files, not just those with errors.
        -x exceptions	load an exceptions file
''' % progname)
    sys.exit(2)


def check(filename, opts):
    try:
        fh = open(filename, 'r')
    except IOError, e:
        sys.stderr.write("failed to open '%s': %s\n" %
                         (e.filename, e.strerror))
        return 1
    else:
        return mapfilechk(fh, verbose=opts['verbose'], output=sys.stdout)


def walker(opts, dirname, fnames):
    for f in fnames:
        path = os.path.join(dirname, f)

        if not os.path.isdir(path):
            if not path in opts['exclude']:
                opts['status'] |= check(path, opts)
        else:
            if path in opts['exclude']:
                fnames.remove(f)


def walkpath(path, opts):