fourstate.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #
  2. # Copyright (c) 2000 Tyler C. Sarna <tsarna@sarna.org>
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. # 1. Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in the
  12. # documentation and/or other materials provided with the distribution.
  13. # 3. All advertising materials mentioning features or use of this software
  14. # must display the following acknowledgement:
  15. # This product includes software developed by Tyler C. Sarna.
  16. # 4. Neither the name of the author nor the names of contributors
  17. # may be used to endorse or promote products derived from this software
  18. # without specific prior written permission.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
  24. # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. # POSSIBILITY OF SUCH DAMAGE.
  31. #
  32. from reportlab.lib.units import inch
  33. from reportlab.graphics.barcode.common import Barcode
  34. import string
  35. # . 3 T Tracker
  36. # , 2 D Descender
  37. # ' 1 A Ascender
  38. # | 0 H Ascender/Descender
  39. _rm_patterns = {
  40. "0" : "--||", "1" : "-',|", "2" : "-'|,", "3" : "'-,|",
  41. "4" : "'-|,", "5" : "'',,", "6" : "-,'|", "7" : "-|-|",
  42. "8" : "-|',", "9" : "',-|", "A" : "',',", "B" : "'|-,",
  43. "C" : "-,|'", "D" : "-|,'", "E" : "-||-", "F" : "',,'",
  44. "G" : "',|-", "H" : "'|,-", "I" : ",-'|", "J" : ",'-|",
  45. "K" : ",'',", "L" : "|--|", "M" : "|-',", "N" : "|'-,",
  46. "O" : ",-|'", "P" : ",','", "Q" : ",'|-", "R" : "|-,'",
  47. "S" : "|-|-", "T" : "|',-", "U" : ",,''", "V" : ",|-'",
  48. "W" : ",|'-", "X" : "|,-'", "Y" : "|,'-", "Z" : "||--",
  49. # start, stop
  50. "(" : "'-,'", ")" : "'|,|"
  51. }
  52. _ozN_patterns = {
  53. "0" : "||", "1" : "|'", "2" : "|,", "3" : "'|", "4" : "''",
  54. "5" : "',", "6" : ",|", "7" : ",'", "8" : ",,", "9" : ".|"
  55. }
  56. _ozC_patterns = {
  57. "A" : "|||", "B" : "||'", "C" : "||,", "D" : "|'|",
  58. "E" : "|''", "F" : "|',", "G" : "|,|", "H" : "|,'",
  59. "I" : "|,,", "J" : "'||", "K" : "'|'", "L" : "'|,",
  60. "M" : "''|", "N" : "'''", "O" : "'',", "P" : "',|",
  61. "Q" : "','", "R" : "',,", "S" : ",||", "T" : ",|'",
  62. "U" : ",|,", "V" : ",'|", "W" : ",''", "X" : ",',",
  63. "Y" : ",,|", "Z" : ",,'", "a" : "|,.", "b" : "|.|",
  64. "c" : "|.'", "d" : "|.,", "e" : "|..", "f" : "'|.",
  65. "g" : "''.", "h" : "',.", "i" : "'.|", "j" : "'.'",
  66. "k" : "'.,", "l" : "'..", "m" : ",|.", "n" : ",'.",
  67. "o" : ",,.", "p" : ",.|", "q" : ",.'", "r" : ",.,",
  68. "s" : ",..", "t" : ".|.", "u" : ".'.", "v" : ".,.",
  69. "w" : "..|", "x" : "..'", "y" : "..,", "z" : "...",
  70. "0" : ",,,", "1" : ".||", "2" : ".|'", "3" : ".|,",
  71. "4" : ".'|", "5" : ".''", "6" : ".',", "7" : ".,|",
  72. "8" : ".,'", "9" : ".,,", " " : "||.", "#" : "|'.",
  73. }
  74. #http://www.auspost.com.au/futurepost/