@@ -18,6 +18,8 @@ class Codelet(object): | |||||
code was last modified. | code was last modified. | ||||
:ivar rank: (float) A quanitification of the source code's quality, as | :ivar rank: (float) A quanitification of the source code's quality, as | ||||
per available ratings (stars, forks, upvotes, etc.). | per available ratings (stars, forks, upvotes, etc.). | ||||
:ivar symbols: Dictionary containing dictionaries of functions, classes, | |||||
variable definitions, etc. | |||||
""" | """ | ||||
def __init__(self, name, code, filename, language, authors, code_url, | def __init__(self, name, code, filename, language, authors, code_url, | ||||
@@ -7,13 +7,26 @@ _all__ = ["parse"] | |||||
# TODO: modify to incorporate tags from stackoverflow | # TODO: modify to incorporate tags from stackoverflow | ||||
def _lang(codelet): | def _lang(codelet): | ||||
""" | |||||
Private function to identify the language of a codelet. | |||||
:param codelet: The codelet object to identified. | |||||
:type code: Codelet | |||||
""" | |||||
if codelet.filename is not None: | if codelet.filename is not None: | ||||
return pgl.guess_lexer_for_filename(codelet.filename).name | return pgl.guess_lexer_for_filename(codelet.filename).name | ||||
return pgl.guess_lexer(codelet.code) | return pgl.guess_lexer(codelet.code) | ||||
# dispatches the codelet to the correct parser | |||||
def parser(codelet): | def parser(codelet): | ||||
""" | |||||
Dispatch codelet to correct parser by language of code. | |||||
:param codelet: The codelet object to parsed. | |||||
:type code: Codelet | |||||
""" | |||||
lang = _lang(codelet) | lang = _lang(codelet) | ||||
if lang == "Python": | if lang == "Python": | ||||