[Python-checkins] CVS: distutils/distutils text_file.py,1.10,1.11

Greg Ward python-dev@python.org
Sat, 16 Sep 2000 11:06:35 -0700


Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17123

Modified Files:
	text_file.py 
Log Message:
[change from 2000/08/11, propagating now to distutils copy]
Factored the guts of 'warn()' out to 'gen_error()', and added the
'error()' method (trivial thanks to the refactoring).


Index: text_file.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/text_file.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** text_file.py	2000/09/16 18:04:55	1.10
--- text_file.py	2000/09/16 18:06:31	1.11
***************
*** 135,138 ****
--- 135,154 ----
  
  
+     def gen_error (self, msg, line=None):
+         outmsg = []
+         if line is None:
+             line = self.current_line
+         outmsg.append(self.filename + ", ")
+         if type (line) in (ListType, TupleType):
+             outmsg.append("lines %d-%d: " % tuple (line))
+         else:
+             outmsg.append("line %d: " % line)
+         outmsg.append(str(msg))
+         return string.join(outmsg, "")
+ 
+ 
+     def error (self, msg, line=None):
+         raise ValueError, "error: " + self.gen_error(msg, line)
+ 
      def warn (self, msg, line=None):
          """Print (to stderr) a warning message tied to the current logical
***************
*** 143,155 ****
             range of physical lines, or an integer for a single physical
             line."""
! 
!         if line is None:
!             line = self.current_line
!         sys.stderr.write (self.filename + ", ")
!         if type (line) in (ListType, TupleType):
!             sys.stderr.write ("lines %d-%d: " % tuple (line))
!         else:
!             sys.stderr.write ("line %d: " % line)
!         sys.stderr.write (str (msg) + "\n")
  
  
--- 159,163 ----
             range of physical lines, or an integer for a single physical
             line."""
!         sys.stderr.write("warning: " + self.gen_error(msg, line) + "\n")