并行快速的程序员搜索工具

lk的Python项目详细描述


注释

  • 用python编写
  • 灵感来自ack
  • 并行:使用python的 多处理库
  • 通过“import lk”可以方便地从python程序进行搜索

示例

在当前工作目录中搜索“class”一词

$ lk class
/home/elijah/Development/lk/lk.py:
10: class NullDevice():
54: class SearchManager(object):
85: class ColorWriter:
122: class DirectoryResult(object):
145: class LineResult(object):

在/home/elijah/development/lk/

$ lk "line_.*" /home/elijah/Development/lk/
/home/elijah/Development/lk/lk.py:
129:         self._line_results = {}
134:         line_number = file_contents.count('\n', 0, match_start) + 1
139:         line_result = LineResult(line_number, left_offset,
142:         if not file_name in self._line_results:
143:             self._line_results[file_name] = []
144:         self._line_results[file_name].append(line_result)
146:     def get_line_results(self):
147:         return self._line_results.items()
150:     def __init__(self, line_number, left_offset, left_of_group,
152:         self.line_number = line_number
160:     for file_name, line_results in directory_result.get_line_results():
164:         for line_result in line_results:
165:             writer.write('%s: ' % (line_result.line_number))
166:             writer.write(line_result.left_of_group)
167:             writer.write_blue(line_result.group)
168:             writer.write(line_result.right_of_group+'\n')

安装

$ sudo easy_install lk

$ sudo pip install lk

放气边缘安装

如果您想使用最新和最好的LK版本:

$ git clone git://github.com/elijahr/lk.git
$ cd lk
$ sudo chmod +x lk.py
$ sudo ln -s `pwd`/lk.py /usr/local/bin/lk

然后,每当您想更新到最新版本时,请执行以下操作:

$ cd lk && git pull

用法

usage: lk [-h] [--ignore-case] [--no-unicode] [--no-multiline] [--dot-all]
          [--follow-links] [--hidden] [--binary] [--no-colors] [--stats]
          [--num-processes NUMBER_PROCESSES] [--exclude PATH_PATTERN]
          [--open-with COMMAND]
          PATTERN [DIRECTORY]

A programmer's search tool, parallel and fast

positional arguments:
  PATTERN               a python re regular expression
  DIRECTORY             a directory to search in (default cwd)

optional arguments:
  -h, --help            show this help message and exit
  --ignore-case, -i     ignore case when searching
  --no-unicode, -u      unicode-unfriendly searching
  --no-multiline, -l    don't search over multiple lines
  --dot-all, -a         dot in pattern matches newline
  --follow-links, -s    follow symlinks
  --hidden, -n          search hidden files and directories
  --binary, -b          search binary files
  --no-colors, -c       don't print ANSI colors
  --stats, -t           print statistics
  --num-processes NUMBER_PROCESSES, -p NUMBER_PROCESSES
                        number of child processes to concurrently search with
  --exclude PATH_PATTERN, -x PATH_PATTERN
                        exclude paths matching PATH_PATTERN
  --open-with COMMAND, -o COMMAND
                        run each COMMAND where COMMAND is a string with a
                        placeholder, %s, for the absolute path of the matched
                        file

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
添加文件发送者后,Java聊天socket不显示消息   java显示存储在MySQL中的BLOB图像,无需写入磁盘   连接到SQLite数据库时发生java GAE受限类错误   如何在Java中自动从外部源(如文件)读取对象属性?   java使用google应用程序引擎发送电子邮件   java找不到应用程序。属性文件从War文件的外面   关于GridLayout和paintComponent方法的用户界面Java Swing问题   java6项目中的JavaOneLogin javasaml 2.0   数组Java GUI将文本文件数据导入JTable   游戏引擎从另一个类或文件中设置java数组的元素   构建如何将java类修补/复制到本地WebSphere服务器?   添加拦截器并使用Dagger2注入拦截器后,java翻新服务始终为空   java Guava LoadingCache如何处理备份存储中不存在的密钥   组织。openqa。硒。NoSuchSessionException:会话ID为空。在自动化中获取此错误(使用testng、selenium、java)   java是从4GB文件创建trie(JSON)的最快方法,只需1GB的ram?