Developers > Code library for Python

Code library for Python

Download and installation

This library is released under the BSD license.

Requirements:

Download:

Installation: run python setup.py install.

Tutorial

There are many files in the test/ subdirectory, which can be used as a tutorial. They are very simple and well documented. We'll run through test/thing.py as an example.

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. """
  5. * likeorhate.com
  6. * Copyright (c) 2008-2010 likeorhate.com
  7. *
  8. * Released under BSD license.
  9. """
  10.  
  11. import likeorhate.likeorhate, likeorhate.thing
  12.  
  13. # get the base singleton. We can use it to set some basic data
  14. loh = likeorhate.likeorhate.LikeOrHate()
  15.  
  16. # Use the sandbox server. We can mess it as much as we want, so it's great for
  17. # debugging. Use "production" when your application is deployed.
  18. loh.setServer('sandbox')
  19.  
  20. # construct the thing
  21. thing = likeorhate.thing.Thing(0, 'likeorhate.com')
  22.  
  23. # get basic information
  24. base = thing.getBase()
  25. if base['status']:
  26. print 'Base: '
  27. print base
  28. else:
  29. print "Error getting base.\n"
  30.  
  31. # get extended information
  32. information = thing.getInformation()
  33. if information['status']:
  34. print 'information: '
  35. print information
  36. else:
  37. print "Error getting information.\n"
  38.  
  39. # get 5 comments, starting at 0,
  40. comments = thing.getComments(0, 5)
  41. if comments['status']:
  42. print 'comments: '
  43. print comments
  44. else:
  45. print "Error getting comments.\n"
  46.  
  47. # get trackback information
  48. trackback = thing.getTrackback(0, 5)
  49. if trackback['status']:
  50. print 'Trackback: '
  51. print trackback
  52. else:
  53. print "Error getting trackback.\n"
  54.  

Back to main developers page

 
All Content in this site is the sole responsibility of the person from whom such Content originated. See our Terms of service