| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
shudaoge
9年前发布

一个使用像jquery选择器的命令行工具来搜索python代码

来自: https://github.com/caioariede/pyq

pyq

A command-line tool to search for Python code using jQuery-like selectors

Installation

pip install pyqtool

Usage

pyq2 [OPTIONS] SELECTOR [PATH]  # Python 2.x  pyq3 [OPTIONS] SELECTOR [PATH]  # Python 3.x

Available selectors

Type

class , def and import

Name

#classname or #methodname

Attributes

[name=value] , [name!=value] , [name*=value] , [name^=value] and [name$=value]

Pseudo-selectors

:extends(classname) and :not(selector)

Combinators

parent > child , parent descendant

Examples

Search for classes that extends the IntegerField class:

❯ pyq3 'class:extends(IntegerField)' django/forms  django/forms/fields.py:278 class FloatField(IntegerField):  django/forms/fields.py:315 class DecimalField(IntegerField):

Search for classes with the name FloatField :

❯ pyq3 'class[name=FloatField]' django/forms  django/forms/fields.py:278 class FloatField(IntegerField):

Search for methods under the FloatField class:

❯ pyq3 'class[name=FloatField] > def' django/forms  django/forms/fields.py:283     def to_python(self, value):  django/forms/fields.py:299     def validate(self, value):  django/forms/fields.py:308     def widget_attrs(self, widget):

Search for methods whose name starts with to under the FloatField class:

❯ pyq3 'class[name=FloatField] > def[name^=to]' django/forms  django/forms/fields.py:283     def to_python(self, value):

Search for import statements importing Counter :

❯ pyq3 'import[from=collections][name=Counter]' django/  django/apps/registry.py:5 from collections import Counter, OrderedDict, defaultdict  django/template/utils.py:3 from collections import Counter, OrderedDict  django/test/testcases.py:14 from collections import Counter

 本文由用户 shudaoge 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1454980407917.html
Django jQuery Python开发