KLL Compiler
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

channel.py 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env python3
  2. '''
  3. KLL Channel Containers
  4. '''
  5. # Copyright (C) 2016 by Jacob Alexander
  6. #
  7. # This file is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This file is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this file. If not, see <http://www.gnu.org/licenses/>.
  19. ### Imports ###
  20. ### Decorators ###
  21. ## Print Decorator Variables
  22. ERROR = '\033[5;1;31mERROR\033[0m:'
  23. WARNING = '\033[5;1;33mWARNING\033[0m:'
  24. ### Classes ###
  25. class Channel:
  26. '''
  27. Pixel Channel Container
  28. '''
  29. def __init__( self, uid, width ):
  30. self.uid = uid
  31. self.width = width
  32. def __repr__( self ):
  33. return "{0}:{1}".format( self.uid, self.width )
  34. class ChannelList:
  35. '''
  36. Pixel Channel List Container
  37. '''
  38. def __init__( self ):
  39. self.channels = []
  40. def setChannels( self, channel_list ):
  41. '''
  42. Apply channels to Pixel
  43. '''
  44. for channel in channel_list:
  45. self.channels.append( Channel( channel[0], channel[1] ) )
  46. def strChannels( self ):
  47. '''
  48. __repr__ of Channel when multiple inheritance is used
  49. '''
  50. output = ""
  51. for index, channel in enumerate( self.channels ):
  52. if index > 0:
  53. output += ","
  54. output += "{0}".format( channel )
  55. return output
  56. def __repr__( self ):
  57. return self.strChannels()