readfiles

Contains various helper functions and classes that accept query strings and search and manipulate the file system.

The GorpSession class is intended as the main point of access to all things gorp, but anyone who wants to help me make this package better can peruse the source code.

CLASSES

class gorp.readfiles.GorpSession(print_output=True)

This is the normal high-level interface for gorp. A typical usage in a programmatic context (i.e., not from the command line) is something like this:

>>> with GorpSession(print_output = False) as session:
    # sessions are context managers like file handles from open()
    session.receive_query("help")
    session.receive_query("DEFAULTS")
    session.receive_query("cd directory/of/interest")
    session.receive_query("some query")
    blah = session.resultset
    # the resultset of the last query (other than cd/ls/help)
>>> session2 = GorpSession()
>>> session2.receive_query("another query")
>>> session2.close()
class gorp.readfiles.GorpHandler(parsedQuery: list, session: GorpSession, resultset=None, print_output=True)
Handles a single query, including generating the initial resultset,

piping to subqueries as needed, and any optional post-processing like the -k and -p options.

GorpHandlers should only be created by a GorpSession.

class gorp.readfiles.FileReader(options, regex, files, handler: GorpHandler)
Handles a single subquery, filtering a set of files based on filenames or text

matching a regex. These should only be created by a GorpHandler.

options: a tuple of options.

regex: a string (regex, gorp.jsonpath query, XPath, or CSS selector)

files: a list of files or filename.

handler: the GorpHandler that spawned it.