Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
formatter.DumbWriter Class Reference
Inheritance diagram for formatter.DumbWriter:
Inheritance graph
[legend]
Collaboration diagram for formatter.DumbWriter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def reset
def send_paragraph
def send_line_break
def send_hor_rule
def send_literal_data
def send_flowing_data
def flush
def new_alignment
def new_font
def new_margin
def new_spacing
def new_styles
def send_label_data

Public Attributes

 file
 maxcol
 col
 atbreak

Detailed Description

Simple writer class which writes output on the file object passed in
as the file parameter or, if file is omitted, on standard output.  The
output is simply word-wrapped to the number of columns specified by
the maxcol parameter.  This class is suitable for reflowing a sequence
of paragraphs.

Definition at line 360 of file formatter.py.


Constructor & Destructor Documentation

def formatter.DumbWriter.__init__ (   self,
  file = None,
  maxcol = 72 
)

Definition at line 369 of file formatter.py.

00369 
00370     def __init__(self, file=None, maxcol=72):
00371         self.file = file or sys.stdout
00372         self.maxcol = maxcol
00373         NullWriter.__init__(self)
00374         self.reset()

Here is the caller graph for this function:


Member Function Documentation

def formatter.NullWriter.flush (   self) [inherited]

Definition at line 304 of file formatter.py.

00304 
    def flush(self): pass

Here is the caller graph for this function:

def formatter.NullWriter.new_alignment (   self,
  align 
) [inherited]

Reimplemented in formatter.AbstractWriter.

Definition at line 305 of file formatter.py.

00305 
    def new_alignment(self, align): pass
def formatter.NullWriter.new_font (   self,
  font 
) [inherited]

Reimplemented in formatter.AbstractWriter.

Definition at line 306 of file formatter.py.

00306 
    def new_font(self, font): pass
def formatter.NullWriter.new_margin (   self,
  margin,
  level 
) [inherited]

Reimplemented in formatter.AbstractWriter.

Definition at line 307 of file formatter.py.

00307 
    def new_margin(self, margin, level): pass
def formatter.NullWriter.new_spacing (   self,
  spacing 
) [inherited]

Reimplemented in formatter.AbstractWriter.

Definition at line 308 of file formatter.py.

00308 
    def new_spacing(self, spacing): pass
def formatter.NullWriter.new_styles (   self,
  styles 
) [inherited]

Reimplemented in formatter.AbstractWriter.

Definition at line 309 of file formatter.py.

00309 
    def new_styles(self, styles): pass

Definition at line 375 of file formatter.py.

00375 
00376     def reset(self):
00377         self.col = 0
00378         self.atbreak = 0

Here is the caller graph for this function:

def formatter.DumbWriter.send_flowing_data (   self,
  data 
)

Reimplemented from formatter.NullWriter.

Definition at line 406 of file formatter.py.

00406 
00407     def send_flowing_data(self, data):
00408         if not data: return
00409         atbreak = self.atbreak or data[0].isspace()
00410         col = self.col
00411         maxcol = self.maxcol
00412         write = self.file.write
00413         for word in data.split():
00414             if atbreak:
00415                 if col + len(word) >= maxcol:
00416                     write('\n')
00417                     col = 0
00418                 else:
00419                     write(' ')
00420                     col = col + 1
00421             write(word)
00422             col = col + len(word)
00423             atbreak = 1
00424         self.col = col
00425         self.atbreak = data[-1].isspace()
00426 

Here is the call graph for this function:

def formatter.DumbWriter.send_hor_rule (   self,
  args,
  kw 
)

Reimplemented from formatter.NullWriter.

Definition at line 389 of file formatter.py.

00389 
00390     def send_hor_rule(self, *args, **kw):
00391         self.file.write('\n')
00392         self.file.write('-'*self.maxcol)
00393         self.file.write('\n')
00394         self.col = 0
00395         self.atbreak = 0

def formatter.NullWriter.send_label_data (   self,
  data 
) [inherited]

Reimplemented in formatter.AbstractWriter.

Definition at line 313 of file formatter.py.

00313 
    def send_label_data(self, data): pass

Reimplemented from formatter.NullWriter.

Definition at line 384 of file formatter.py.

00384 
00385     def send_line_break(self):
00386         self.file.write('\n')
00387         self.col = 0
00388         self.atbreak = 0

def formatter.DumbWriter.send_literal_data (   self,
  data 
)

Reimplemented from formatter.NullWriter.

Definition at line 396 of file formatter.py.

00396 
00397     def send_literal_data(self, data):
00398         self.file.write(data)
00399         i = data.rfind('\n')
00400         if i >= 0:
00401             self.col = 0
00402             data = data[i+1:]
00403         data = data.expandtabs()
00404         self.col = self.col + len(data)
00405         self.atbreak = 0

def formatter.DumbWriter.send_paragraph (   self,
  blankline 
)

Reimplemented from formatter.NullWriter.

Definition at line 379 of file formatter.py.

00379 
00380     def send_paragraph(self, blankline):
00381         self.file.write('\n'*blankline)
00382         self.col = 0
00383         self.atbreak = 0


Member Data Documentation

Definition at line 377 of file formatter.py.

Definition at line 376 of file formatter.py.

Definition at line 370 of file formatter.py.

Definition at line 371 of file formatter.py.


The documentation for this class was generated from the following file: