From 20b518fccc730b0891229a02b43d0cf5cac4a683 Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Fri, 11 Apr 2014 13:03:03 -0400 Subject: [PATCH] Minor refactor of codelet. Add: bitshift/codelet.py -complete docstrings, add filename to Codelet constructor. --- bitshift/codelet.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bitshift/codelet.py b/bitshift/codelet.py index 5c8ec40..08b0d36 100644 --- a/bitshift/codelet.py +++ b/bitshift/codelet.py @@ -4,37 +4,39 @@ class Codelet(object): """ A source-code object with code metadata and composition analysis. - :ivar code: (string) A containing the raw source code. - :ivar language: (string) The inferred language of `code`. - :ivar author: (string) The - :ivar url: The url of the (page containing the) source code. - :ivar date_created: The date the code was published. - :ivar date_modified: The date the code was last modified. + :ivar code: (str) A containing the raw source code. + :ivar filename: (str, or None) The filename of the snippet. + :ivar language: (str, or None) The inferred language of `code`. + :ivar author: (str, or None) The name of the code's author. + :ivar url: (str) The url of the (page containing the) source code. + :ivar date_created: (str, or None) The date the code was published. + :ivar date_modified: (str, or None) The date the code was last modified. """ - def __init__(self, code, author, language, code_url, author_url, - date_created, date_modified): + def __init__(self, code, filename, author, language, code_url, author_url, + date_created, date_modified): """ Create a Codelet instance. :param code: The raw source code. + :param filename: The filename of the code, if any. :param author: The author of the code. :param language: The inferred language. :param code_url: The url of the (page containing the) source code. - :param author_url: The url of the code author's public profile on the - framework said code was retrieved from. :param date_created: The date the code was published. :param date_modified: The date the code was last modified. - :type code: string - :type language: string - :type author: string - :type url: string - :type date_created: string - :type date_modified: string + :type code: str + :type filename: str, or None + :type language: str, or None + :type author: str, or None + :type url: str + :type date_created: str, or None + :type date_modified: str, or None """ self.code = code + self.filename = filename self.author = author self.language = language self.code_url = code_url