commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r5973 - trunk/gnue-common/src/printing/barcodes


From: jcater
Subject: r5973 - trunk/gnue-common/src/printing/barcodes
Date: Mon, 12 Jul 2004 14:18:19 -0500 (CDT)

Author: jcater
Date: 2004-07-12 14:18:18 -0500 (Mon, 12 Jul 2004)
New Revision: 5973

Modified:
   trunk/gnue-common/src/printing/barcodes/Base.py
   trunk/gnue-common/src/printing/barcodes/README
Log:
added support for either filename strings or file objects to be passed in; 
updated README examples

Modified: trunk/gnue-common/src/printing/barcodes/Base.py
===================================================================
--- trunk/gnue-common/src/printing/barcodes/Base.py     2004-07-12 19:11:06 UTC 
(rev 5972)
+++ trunk/gnue-common/src/printing/barcodes/Base.py     2004-07-12 19:18:18 UTC 
(rev 5973)
@@ -92,6 +92,13 @@
   def generate(self, value, stream=sys.stdout,
                format='eps', includeText=None, textSize=7, dpi=300):
 
+    # If they passed a text name
+    if not hasattr(stream, 'write'):
+      closeFile = True
+      stream = open(stream,'w')
+    else:
+      closeFile = False
+
     if includeText is None:
       includeText = self.defaultIncludeText
     code = self._buildBinary(value)
@@ -200,6 +207,8 @@
 #
 #       image.save(stream, format)
 
+    if closeFile:
+      close(stream)
 
   # Line height is .15 * barcode width, but at least .25"
   # This is used by Code39, Interleaved 2 of 5, etc

Modified: trunk/gnue-common/src/printing/barcodes/README
===================================================================
--- trunk/gnue-common/src/printing/barcodes/README      2004-07-12 19:11:06 UTC 
(rev 5972)
+++ trunk/gnue-common/src/printing/barcodes/README      2004-07-12 19:18:18 UTC 
(rev 5973)
@@ -1,15 +1,22 @@
 Usage:
 
   from gnue.common.printing.barcodes import Code39
+
+  # You can pass either a file object, or a string containing a file name:
+
+  # File Object:
   myfile = open('foo.eps','w')
   Code39().generate('123443',myfile,'eps')
   myfile.close
 
-It has strong support for "postscript" and "eps". It also supports
+  # or string...
+  Code39().generate('123456','foo2.eps','eps')
+
+It has strong support for "eps". It somewhat supports
 "png", "tiff", and "xbm" via Python Imaging Library. 
 
 Test the outputs with your scanners before using in mass-production. 
-We try to stay within specs in our code, but printers vary. 
+We try to stay within specs in our code, but printers and readers vary. 
 
 Specs:
  * http://www.adams1.com/pub/russadam/info.html#Specs





reply via email to

[Prev in Thread] Current Thread [Next in Thread]