A semantic search engine for source code https://bitshift.benkurtovic.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

68 lines
2.8 KiB

  1. __all__ = ["Codelet"]
  2. class Codelet(object):
  3. """
  4. A source-code object with code metadata and composition analysis.
  5. :ivar name: (str) A suitable name for the codelet.
  6. :ivar code: (str) A containing the raw source code.
  7. :ivar filename: (str, or None) The filename of the snippet.
  8. :ivar language: (int, or None) The inferred language of `code`.
  9. :ivar authors: (array of tuples (str, str or None)) An array of tuples
  10. containing an author's name and profile URL (on the service the code
  11. was pulled from).
  12. :ivar code_url: (str) The url of the (page containing the) source code.
  13. :ivar date_created: (:class:`datetime.datetime`, or None) The date the code
  14. was published.
  15. :ivar date_modified: (:class:`datetime.datetime`, or None) The date the
  16. code was last modified.
  17. :ivar rank: (float) A quanitification of the source code's quality, as
  18. per available ratings (stars, forks, upvotes, etc.).
  19. :ivar symbols: (dict) Dictionary containing dictionaries of functions,
  20. classes, variable definitions, etc.
  21. :ivar origin: (tuple) 3-tuple of (site_name, site_url, image_blob), as
  22. added by the database.
  23. """
  24. def __init__(self, name, code, filename, language, authors, code_url,
  25. date_created, date_modified, rank, symbols=None, origin=None):
  26. """
  27. Create a Codelet instance.
  28. :param name: see :attr:`self.name`
  29. :param code: see :attr:`self.code`
  30. :param filename: see :attr:`self.filename`
  31. :param language: see :attr:`self.language`
  32. :param authors: see :attr:`self.authors`
  33. :param code_url: see :attr:`self.code_url`
  34. :param date_created: see :attr:`self.date_created`
  35. :param date_modified: see :attr:`self.date_modified`
  36. :param rank: see :attr:`self.rank`
  37. :param symbols: see :attr:`self.symbols`
  38. :param origin: see :attr:`self.origin`
  39. :type name: see :attr:`self.name`
  40. :type code: see :attr:`self.code`
  41. :type filename: see :attr:`self.filename`
  42. :type language: see :attr:`self.language`
  43. :type authors: see :attr:`self.authors`
  44. :type code_url: see :attr:`self.code_url`
  45. :type date_created: see :attr:`self.date_created`
  46. :type date_modified: see :attr:`self.date_modified`
  47. :type rank: see :attr:`self.rank`
  48. :type symbols: see :attr:`self.symbols`
  49. :type origin: see :attr:`self.origin`
  50. """
  51. self.name = name
  52. self.code = code
  53. self.filename = filename
  54. self.language = language
  55. self.authors = authors
  56. self.code_url = code_url
  57. self.date_created = date_created
  58. self.date_modified = date_modified
  59. self.rank = rank
  60. self.symbols = symbols or {}
  61. self.origin = origin or (None, None, None)