Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 9 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<p align="center"><img src="https://searchcode.com/static/searchcode_logo.png" width=300 height=60><br>Python SDK and CLI utility for <a href="https://searchcode.com">Searchcode</a>.<br><i>Simple, comprehensive code search.</i></p>
<p align="center">
<img src="https://searchcode.com/static/searchcode_logo.png" width=300><br><strong>Searchcode SDK</strong>: Python library and CLI utility for <a href="https://searchcode.com">Searchcode</a>.<br><i>Simple, comprehensive code search.</i></p>
<p align="center"></p>

---

```commandline
searchcode search "import module"
```
Expand All @@ -15,7 +14,7 @@ sc search "import module"

```python
from pprint import pprint
from src.searchcode import Searchcode
from searchcode import Searchcode

sc = Searchcode(user_agent="My-Searchcode-script")
search = sc.search(query="import module")
Expand Down Expand Up @@ -44,7 +43,7 @@ searchcode "import module"

```python
from pprint import pprint
from src.searchcode import Searchcode
from searchcode import Searchcode

sc = Searchcode(user_agent="My-Searchcode-script")
search = sc.search(query="import module")
Expand All @@ -66,7 +65,7 @@ searchcode "import module" --languages java,javascript

```python
from pprint import pprint
from src.searchcode import Searchcode
from searchcode import Searchcode

sc = Searchcode(user_agent="My-Searchcode-script")
search = sc.search(query="import module", languages=["Java", "JavaScript"])
Expand All @@ -89,7 +88,7 @@ searchcode "import module" --sources bitbucket,codeplex

```python
from pprint import pprint
from src.searchcode import Searchcode
from searchcode import Searchcode

sc = Searchcode(user_agent="My-Searchcode-script")
search = sc.search(query="import module", sources=["BitBucket", "CodePlex"])
Expand All @@ -112,7 +111,7 @@ searchcode "import module" --lines-of-code-gt 500 --lines-of-code-lt 1000

```python
from pprint import pprint
from src.searchcode import Searchcode
from searchcode import Searchcode

sc = Searchcode(user_agent="My-Searchcode-script")
search = sc.search(query="import module", lines_of_code_gt=500, lines_of_code_lt=1000)
Expand All @@ -135,7 +134,7 @@ searchcode "import module" --callback myCallback

```python
from pprint import pprint
from src.searchcode import Searchcode
from searchcode import Searchcode

sc = Searchcode(user_agent="My-Searchcode-script")
search = sc.search(query="import module", callback="myCallback")
Expand Down Expand Up @@ -163,39 +162,6 @@ pprint(search)

> To fetch all results for a given query, keep incrementing `page` parameter until you get a page with an empty results
> list.
---

### Response Attribute Definitions

| Attribute | Description |
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **searchterm** | Search term supplied to the API through the use of the `q` parameter. |
| **query** | Identical to `searchterm` and included for historical reasons to maintain backward compatibility. |
| **matchterm** | Identical to `searchterm` and included for historical reasons to maintain backward compatibility. |
| **page** | ID of the current page that the query has returned. This is a zero-based index. |
| **nextpage** | ID of the offset of the next page. Always set to the current page + 1, even if you have reached the end of the results. This is a zero-based index. |
| **previouspage** | ID of the offset of the previous page. If no previous page is available, it will be set to `null`. This is a zero-based index. |
| **total** | The total number of results that match the `searchterm` in the index. Note that this value is approximate. It becomes more accurate as you go deeper into the results or use more filters. |
| **language_filters** | Returns an array containing languages that exist in the result set. |
| **id** | Unique ID for this language used by searchcode, which can be used in other API calls. |
| **count** | Total number of results that are written in this language. |
| **language** | The name of this language. |
| **source_filters** | Returns an array containing sources that exist in the result set. |
| **id** | Unique ID for this source used by searchcode, which can be used in other API calls. |
| **count** | Total number of results that belong to this source. |
| **source** | The name of this source. |
| **results** | Returns an array containing the matching code results. |
| **id** | Unique ID for this code result used by searchcode, which can be used in other API calls. |
| **filename** | The filename for this file. |
| **repo** | HTML link to the location of the repository where this code was found. |
| **linescount** | Total number of lines in the matching file. |
| **location** | Location inside the repository where this file exists. |
| **name** | Name of the repository that this file belongs to. |
| **language** | The identified language of this result. |
| **url** | URL to searchcode's location of the file. |
| **md5hash** | Calculated MD5 hash of the file's contents. |
| **lines** | Contains line numbers and lines which match the `searchterm`. Lines immediately before and after the match are included. If only the filename matches, up to the first 15 lines of the file are returned. |

___

### Code Result
Expand All @@ -216,7 +182,7 @@ searchode code 4061576

```python

from src.searchcode import Searchcode
from searchcode import Searchcode

sc = Searchcode(user_agent="My-Searchcode-script")
data = sc.code(4061576)
Expand Down
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "searchcode"
version = "0.5.1"
version = "0.6.0"
description = "Simple, comprehensive code search."
authors = ["Ritchie Mwewa <rly0nheart@duck.com>"]
license = "GPLv3+"
Expand All @@ -16,6 +16,10 @@ classifiers = [
"Natural Language :: English"
]


packages = [
{ include = "searchcode", from = "src" }
]
[tool.poetry.dependencies]
python = "^3.10"
requests = "^2.32.2"
Expand All @@ -30,5 +34,5 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
sc = "searchcode.__app:cli"
searchcode = "searchcode.__app:cli"
sc = "searchcode._cli.app:cli"
searchcode = "searchcode._cli.app:cli"
184 changes: 0 additions & 184 deletions src/searchcode/__app.py

This file was deleted.

4 changes: 3 additions & 1 deletion src/searchcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
from .api import Searchcode

__pkg__ = "searchcode"
__version__ = "0.5.1"
__version__ = "0.6.0"
__author__ = "Ritchie Mwewa"

__all__ = ["Searchcode"]


class License:
terms_and_conditions: str = """
Expand Down
Loading