{ "info": { "author": "Nic Roland", "author_email": "nicroland9@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.7", "Topic :: Software Development", "Topic :: Text Processing :: Filters", "Topic :: Utilities" ], "description": "GrepTools\n=========\n\nInstallation\n------------\n\nFrom pip (recommended):\n\n::\n\n $ sudo pip install greptools\n\nFrom source (for developers):\n\n::\n\n $ git clone https://github.com/nicr9/greptools.git\n $ cd greptools\n $ sudo python2.7 setup.py develop\n\nAbout\n-----\n\n``greptools`` is a collection of CLI search tools similar to ``grep`` or\n``ack``. These tools were designed with programmers in mind and each\ntool is targetted at a different programming language or structured file\nformat.\n\nEach language specific tool recursively searches files relating to that\nlanguage in the current directory and sorts results into a context tree\n(refered to as a grep tree). The exact format of the grep tree depends\non the language in question but it takes the form of nested datstructure\nwith each level representing a file, class or function.\n\nEach tool uses ``grep`` to perform the actual searching, and for each\nresult it opens the file and reads it to decide which class/function it\nbelongs to.\n\nUsage\n-----\n\nIt's simple to use. Here's an example using the tool for python code:\n``pygt``.\n\nTo look for usages of the word \"traceback\" inside a subdirectory of the\ncore Python source code:\n\n::\n\n $ cd Python-2.7.3/Lib/multiprocessing\n $ pygt traceback\n ./reduction.py\n def _serve\n 132:^ import traceback$\n 135:^ '-'*79 + '\\n' + traceback.format_exc() + '-'*79$\n\n ./queues.py\n class Queue\n def _feed\n 280:^ import traceback$\n 281:^ traceback.print_exc()$\n\n ./managers.py\n 49:^from traceback import format_exc$\n\n class Server\n def shutdown\n 368:^ import traceback$\n 369:^ traceback.print_exc()$\n\n ./util.py\n def _run_finalizers\n 263:^ import traceback$\n 264:^ traceback.print_exc()$\n\n ./process.py\n class Process\n def _bootstrap\n 273:^ import traceback$\n 276:^ traceback.print_exc()$\n\nCommand-line options\n--------------------\n\nThese options should apply to all the available greptools so just use\nthe name of the tool you're using in place of ```` below:\n\nCase-insensitive search\n~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n $ -i \n\nDebug information\n~~~~~~~~~~~~~~~~~\n\nTurning this on prints out lots of additional information (e.g. raw grep\nresults) that can be used to diagnose bugs in the logic at various\nstages. Useful if you're trying to develop your own greptool or add\nfeatures to the base classes.\n\n::\n\n $ -d \n\nSet operations\n~~~~~~~~~~~~~~\n\nOne of the really useful features these greptools is that they support\ntreating the results like sets and quickly filtering results by applying\nset operations.\n\nLet's look at a simple example.\n\nLet's say you need to quickly look through all the ``import``\\ s in your\npython project. That's simple: ``pygt import``.\n\nNow lets say you want to narrow down those results to those that mention\n``os.path``. This can be done by piping the results from our earlier\nsearch into a new search for the new term like so:\n\n::\n\n $ pygt import | pygt os.path\n\nThis will effectively perform an intersection on both sets of results\nand so only provide matches that contain both ``import`` and\n``os.path``.\n\nYou can perform other set operations too! Let's say you don't want any\nresults containing ``os.path``. You can get the relative complement by\npiping like we did before and setting the ``-F`` (filter) flag on the\nlast search command like so:\n\n::\n\n $ pygt import | pygt -F os.path\n\nYou can add both sets of results together with ``-U`` (union) and only\nreturn results that contain one and not the other by using ``-X`` (XOR,\na.k.a symetric difference).\n\nCaveats with using set operations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nBoth the default (intersection) set op and the filter set op shown above\naren't actually true set operations.\n\nIt turns out treating search results like sets and performing these\noperations isn't that fast as we hoped so we made a compromise. These\ntwo work by iterating through that first set of results and checking for\nthe second search term using python's built in regex engine.\n\nYou may experience issues from the use of two different engines. For\nexample, if you are using complicated regular expressions you may find\nthat they behave differently when using intersection or filter set\noperations.\n\nYou can choose to use the slow intersection (``-N``) and the slow filter\n(``-E``) instead which work by building both sets of results and\ncomparing.\n\nIn order to use the pipe to pass one set of results to an other pygt\nprocess we had to serialise them first. This means that if you try\npiping the results to any other process (like ``less`` for example)\nthey'll show up in json format. This will happen even if you use other\noutput formats like the histogram format.\n\nIf this causes problems for you, use ``-p``. This will force it to pipe\nout results in what ever format you've choosen (except the default\n'colour' format. It will be changed to clean because it looks really\nugly when it's piped out).\n\nWriting a new greptool\n----------------------\n\nSo you've decided you need a greptool for your favourite language X.\n\nHere are a basic set of instructions to create a new greptool:\n\n1) Implement a new Reader class.\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAre code blocks in X based on indentation or deliniated by braces?\n\nThere are some classes you can inherit from (``IndentReader`` and\n``BraceReader``) that are generalised for these cases. The docstrings\nshould have details that tell you what needs to be implemented by\nsubclasses. ``PythonReader`` and ``JavaReader`` are good examples of\n``IndentReader`` and ``BraceReader`` subclasses respectively.\n\nIf neither of these suit your purposes, you may need to inherit from\n``BaseReader``. The logic you need to implement in this case is a little\nmore abstract, I'm not sure the docstrings are detailed enough. If you\ncan't figure out what to do from a reading of the code feel free to drop\nme an email with an outline of what you're working on, I'd be glad to\nhelp!\n\n2) Add details to ``greptools/reader/__init__.py``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTwo things you'll need to do: include a relative import of your new\nreader class and add the name of that class to ``__all__``.\n\n3) Add new script to ``bin/``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nMy advice is to copy a preexisting script. The convention is to base the\nscript name on the language file extention (e.g. Python files have a\n``.py`` extention so the Python greptool is called ``pygt``).\n\nDon't forget to change the name of the Reader class used in the script.\n\n::\n\n $ cp bin/pygt bin/xgt\n $ sed -i \"s/PythonReader/XReader/g\" bin/xgt\n\n4) Mention script in setup.py.\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere's a ``scripts`` list in setup.py. Add your new script here so that\nit's installed with all the others.\n\n5) Reinstall.\n~~~~~~~~~~~~~\n\n::\n\n $ sudo python2.7 setup.py develop\n\nAuthor\n------\n\n::\n\n Name: Nic Roland\n Twitter: @nicr9_\n Email: nicroland9@gmail.com", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/nicr9/greptools/tarball/0.9b1", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nicr9/greptools", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "greptools", "package_url": "https://pypi.org/project/greptools/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/greptools/", "project_urls": { "Download": "https://github.com/nicr9/greptools/tarball/0.9b1", "Homepage": "https://github.com/nicr9/greptools" }, "release_url": "https://pypi.org/project/greptools/0.9b1/", "requires_dist": null, "requires_python": null, "summary": "A collection of grep wrappers and tools for various filetypes.", "version": "0.9b1" }, "last_serial": 1879004, "releases": { "0.9b0": [ { "comment_text": "", "digests": { "md5": "b0c3811a82ab16446fd5b9bae458a444", "sha256": "278e41f0ef0eea17df2ae8f9ee63afd89350de338ca16a2a898fdae64ac2a15c" }, "downloads": -1, "filename": "greptools-0.9b0.tar.gz", "has_sig": false, "md5_digest": "b0c3811a82ab16446fd5b9bae458a444", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14349, "upload_time": "2015-12-27T18:11:35", "url": "https://files.pythonhosted.org/packages/63/9b/1a67c35aab930f9cf36ec25e5a776262c072ed4f2a51c34860cd2cbaba53/greptools-0.9b0.tar.gz" } ], "0.9b1": [ { "comment_text": "", "digests": { "md5": "7be4f4c124e8955c29dda86294fbc4e9", "sha256": "3a8408f6d6f772a06a86622b04a09f91b3ec94219d5e2128562a33adcef6f1b1" }, "downloads": -1, "filename": "greptools-0.9b1.tar.gz", "has_sig": false, "md5_digest": "7be4f4c124e8955c29dda86294fbc4e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14380, "upload_time": "2015-12-27T18:18:52", "url": "https://files.pythonhosted.org/packages/e0/be/cc79046e917d280c992f32caed5e43936022d0efd39f605237fbcbf60336/greptools-0.9b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7be4f4c124e8955c29dda86294fbc4e9", "sha256": "3a8408f6d6f772a06a86622b04a09f91b3ec94219d5e2128562a33adcef6f1b1" }, "downloads": -1, "filename": "greptools-0.9b1.tar.gz", "has_sig": false, "md5_digest": "7be4f4c124e8955c29dda86294fbc4e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14380, "upload_time": "2015-12-27T18:18:52", "url": "https://files.pythonhosted.org/packages/e0/be/cc79046e917d280c992f32caed5e43936022d0efd39f605237fbcbf60336/greptools-0.9b1.tar.gz" } ] }