(args)
return 0
Looks for Lua code lines that match a pattern in one or more carts.

    Args:
      args: The argparser parsed args object.

    Returns:
      0 on success, 1 on failure.
Looks for Lua code lines that match a pattern in one or more carts.
Looks for Lua code lines that match a pattern in one or more carts .
def luafind(args):
    """Looks for Lua code lines that match a pattern in one or more carts.

    Args:
      args: The argparser parsed args object.

    Returns:
      0 on success, 1 on failure.
    """
    # (The first argument is the pattern, but it's stored in args.filename.)
    filenames = list(args.filename)
    if len(filenames) < 2:
        util.error(
            'Usage: p8tool luafind <pattern> <filename> [<filename>...]\n')
        return 1
    pattern = re.compile(filenames.pop(0))

    # TODO: Tell the Lua class not to bother parsing, since we only need the
    # token stream to get the lines of code.
    for fname, g in _games_for_filenames(filenames):
        line_count = 0
        for line in g.lua.to_lines():
            line_count += 1
            if pattern.search(line) is None:
                continue
            if args.listfiles:
                util.write(fname + '\n')
                break
            util.write('{}:{}:{}'.format(
                fname, line_count, _as_friendly_string(line)))

    return 0
def luafind ( args ) : # (The first argument is the pattern, but it's stored in args.filename.) filenames = list ( args . filename ) if len ( filenames ) < 2 : util . error ( 'Usage: p8tool luafind <pattern> <filename> [<filename>...]\n' ) return 1 pattern = re . compile ( filenames . pop ( 0 ) ) # TODO: Tell the Lua class not to bother parsing, since we only need the # token stream to get the lines of code. for fname , g in _games_for_filenames ( filenames ) : line_count = 0 for line in g . lua . to_lines ( ) : line_count += 1 if pattern . search ( line ) is None : continue if args . listfiles : util . write ( fname + '\n' ) break util . write ( '{}:{}:{}' . format ( fname , line_count , _as_friendly_string ( line ) ) ) return 0