codeseeker package

Submodules

codeseeker.codeseeker module

codeseeker.seeker module

class codeseeker.seeker.Query

Bases: object

Representation of a query.

github

GitHub url.

Type

str

base

The base url.

Type

str

repo

The name of the repository.

Type

str

lang

Target Programming language of the keyword.

Type

str

query

Query that performs the search.

Type

str

url

The url to be used by requests.

Type

str

Github link to the file.

Type

str

tag

The tag used in the response.

Type

str

class codeseeker.seeker.Seeker

Bases: object

Seeker that searchs for code on GitHub.

q

Query object.

Type

Query

search(keyword, repo=None, lang=None, tag='items')

Search for a keyword in a GitHub repository.

Parameters
  • keyword (str) – Keyword to search.

  • repo (str, optional) – Repository to search.

  • lang (str, optional) – Programming language target.

  • tag (str, optional) – Tag to be used to search. Defaults to “items”.

Raises
  • SearchException – If the response is not 200.

  • ValidationException – If the keyword is not valid.

Returns

The data.

Return type

Union[List[Dict[str, str]], None]

codeseeker.seeker.get_file(seeker, data)

Downloads the query in ‘results/filname’.

Parameters
  • seeker (Seeker) – Seeker object.

  • (List[Dict[str (data) – Data received from the search.

  • str]] – Data received from the search.

  • data (List[Dict[str, str]]) –

Raises

ValidationException – If the data is empty.

Return type

None

codeseeker.seeker.open_url(seeker, data)

Open the results in a web browser.

Parameters
  • seeker (Seeker) – Seeker object.

  • (List[Dict[str (data) – Data received from the search.

  • str]] – Data received from the search.

  • tag (str, optional) – Tag that will be used to open the URL.

  • data (List[Dict[str, str]]) –

Raises

ValidationException – If the data is empty.

Return type

None

Prints the results in the terminal.

Parameters
  • seeker (Seeker) – Seeker object.

  • (List[Dict[str (data) – Data received from the search.

  • str]] – Data received from the search.

  • data (List[Dict[str, str]]) –

Raises

ValidationException – If the data is empty.

Return type

None

codeseeker.seeker.to_txt(seeker, data)

Saves the results in a text file.

Parameters
  • seeker (Seeker) – Seeker object.

  • (List[Dict[str (data) – Data received from the search.

  • str]] – Data received from the search.

  • data (List[Dict[str, str]]) –

Raises

ValidationException – If the data is empty.

Return type

None

codeseeker.utils module

codeseeker.utils.show(data, tag='path')

Display the data.

Parameters
  • data (Dict[str, str]) – The data to be displayed.

  • tag (str) –

Return type

None

codeseeker.validators module

exception codeseeker.validators.CodeSeekerException

Bases: Exception

Base class for exceptions.

exception codeseeker.validators.NoLinkFoundException

Bases: codeseeker.validators.CodeSeekerException

Exception raised when no link is found.

exception codeseeker.validators.ValidationException

Bases: codeseeker.validators.CodeSeekerException

Exception raised when a validation function is called and the value is not valid.

Validate the data links.

Parameters

data (List[str]) – The data to be validated.

Raises

NoLinkFoundException – If no link is found.

Return type

None

codeseeker.validators.validate_keyword(keyword)

Validate the keyword.

Parameters

keyword (str) – The keyword to be validated.

Raises

ValidationException – If the keyword is not valid.

Return type

None

codeseeker.validators.validate_response(response)

Validate the response.

Parameters

response (requests.Response) – The response to be validated.

Raises

ValidationException – If the response status code is not 200.

Return type

None

Module contents

class codeseeker.Seeker

Bases: object

Seeker that searchs for code on GitHub.

q

Query object.

Type

Query

search(keyword, repo=None, lang=None, tag='items')

Search for a keyword in a GitHub repository.

Parameters
  • keyword (str) – Keyword to search.

  • repo (str, optional) – Repository to search.

  • lang (str, optional) – Programming language target.

  • tag (str, optional) – Tag to be used to search. Defaults to “items”.

Raises
  • SearchException – If the response is not 200.

  • ValidationException – If the keyword is not valid.

Returns

The data.

Return type

Union[List[Dict[str, str]], None]

codeseeker.get_file(seeker, data)

Downloads the query in ‘results/filname’.

Parameters
  • seeker (Seeker) – Seeker object.

  • (List[Dict[str (data) – Data received from the search.

  • str]] – Data received from the search.

  • data (List[Dict[str, str]]) –

Raises

ValidationException – If the data is empty.

Return type

None

codeseeker.open_url(seeker, data)

Open the results in a web browser.

Parameters
  • seeker (Seeker) – Seeker object.

  • (List[Dict[str (data) – Data received from the search.

  • str]] – Data received from the search.

  • tag (str, optional) – Tag that will be used to open the URL.

  • data (List[Dict[str, str]]) –

Raises

ValidationException – If the data is empty.

Return type

None

codeseeker.parse_args()

Function to parse arguments.

codeseeker.show(data, tag='path')

Display the data.

Parameters
  • data (Dict[str, str]) – The data to be displayed.

  • tag (str) –

Return type

None

codeseeker.to_txt(seeker, data)

Saves the results in a text file.

Parameters
  • seeker (Seeker) – Seeker object.

  • (List[Dict[str (data) – Data received from the search.

  • str]] – Data received from the search.

  • data (List[Dict[str, str]]) –

Raises

ValidationException – If the data is empty.

Return type

None