Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_file(fp, path, callback):
if not os.path.exists(path):
print('%s: %s: No such file or directory' % (sys.argv[0], path), file=sys.stderr)
return 1
try:
is_plat = is_platform_file(path)
except IOError as msg:
print('%s: %s: %s' % (sys.argv[0], path, msg), file=sys.stderr)
return 1
else:
if is_plat:
callback(fp, path)
return 0
def check_file(fp, path, callback):
if not os.path.exists(path):
print >>sys.stderr, '%s: %s: No such file or directory' % (sys.argv[0], path)
return 1
try:
is_plat = is_platform_file(path)
except IOError, msg:
print >>sys.stderr, '%s: %s: %s' % (sys.argv[0], path, msg)
return 1
else:
if is_plat:
callback(fp, path)
return 0
def check_file(fp, path, callback):
if not os.path.exists(path):
print('%s: %s: No such file or directory' % (sys.argv[0], path), file=sys.stderr)
return 1
try:
is_plat = is_platform_file(path)
except IOError as msg:
print('%s: %s: %s' % (sys.argv[0], path, msg), file=sys.stderr)
return 1
else:
if is_plat:
callback(fp, path)
return 0
def check_file(fp, path, callback):
if not os.path.exists(path):
print('%s: %s: No such file or directory' % (gCommand, path),
file=sys.stderr)
return 1
try:
is_plat = is_platform_file(path)
except IOError as msg:
print('%s: %s: %s' % (gCommand, path, msg), file=sys.stderr)
return 1
else:
if is_plat:
callback(fp, path)
return 0
def iter_platform_files(path, is_platform_file=macholib.util.is_platform_file):
"""
Iterate over all of the platform files in a directory
"""
for root, dirs, files in os.walk(path):
for fn in files:
fn = os.path.join(root, fn)
if is_platform_file(fn):
yield fn