GithubHelp home page GithubHelp logo

chromium / codesearch-py Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 18.0 3.4 MB

Python library for accessing Chromium CodeSearch via https://cs.chromium.org

Home Page: https://chromium.org

License: BSD 3-Clause "New" or "Revised" License

Python 97.90% Shell 2.10%

codesearch-py's Introduction

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure.

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.

If you found a bug, please file it at https://crbug.com/new.

codesearch-py's People

Contributors

asankah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codesearch-py's Issues

Server requests return HTML due to redirect to new codesearch

API requests currently return HTML instead of JSON, resulting in an error. @asankah advised that this is due to requests to cs.chromium.org being redirected to the new codesearch at source.chromium.org, which now requires an API key.

For example, this test script:

g_cs = codesearch.CodeSearch(should_cache=True, source_root='.')
response = g_cs.SendRequestToServer(codesearch.CompoundRequest(
    search_request=[
    codesearch.SearchRequest(query='hello world',
                             return_line_matches=True,
                             lines_context=0,
                             max_num_results=10)
    ]))

Currently hits this error:

Traceback (most recent call last):
  File "C:\Users\jessemckenna\AppData\Roaming\Sublime Text 3\Packages\ChromiumXRefs\third_party\codesearch\messages.py", line 204, in FromJsonString
    d = json.loads(s)
  File "C:\src\depot_tools\bootstrap-3_8_0_chromium_8_bin\python3\bin\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\src\depot_tools\bootstrap-3_8_0_chromium_8_bin\python3\bin\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\src\depot_tools\bootstrap-3_8_0_chromium_8_bin\python3\bin\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Printing the server response, result, from SendRequestToServer before it is passed to FromJSONString shows an HTML response from source.chromium.org.

Deal with platform specific signatures

The backend can return platform specific signatures in response to xref_search. These signatures don't show up in an annotation_request for the same file. This breaks GetDisplayName().

AssertionError in test_file_cache.py

Running python -m unittest discover shows one test error.

======================================================================
FAIL: test_with_cache_dir (codesearch.test_file_cache.TestFileCache)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/ports/devel/py-codesearch/work/codesearch-py-7ed08c1/codesearch/test_file_cache.py", line 37, in test_with_cache_dir
    self.assertEqual('hello'.encode('utf-8'), g.get('foo'))
AssertionError: 'hello' != ''

----------------------------------------------------------------------
Ran 32 tests in 1.248s

FAILED (failures=1)
*** Error code 1

Duplicate results in Xref Search

Due to platform specific signatures, there could be multiple matches in a xref search. Need a way to squash those into a single xrefnode.

GetAnnotations options

When I call csfile.GetAnnotations(), it's missing some important annoations types, namely AnnotationTypeValue.LINK_TO_DEFINITION.

I can get them by calling GetAnnotationsForFile but that bypasses the CsFile cache. Can you add AnnotationTypeValue.LINK_TO_DEFINITION to the default types?

Following links to `out/win-Debug/gen` etc. paths don't work

The search index stores platform specific generated files in the following directories (as of this writing):

  • out/Debug: for Linux
  • out/win-Debug: for Windows
  • out/android-Debug: for Android
  • out/chromeos-Debug: for Chrome OS.

When references to these files show up, the library should "intelligently" map the path to whatever output directories exist on the local host.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.