Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Differ Class Reference

Public Member Functions

def __init__
 
def compare
 

Data Fields

 linejunk
 
 charjunk
 

Detailed Description

Definition at line 638 of file difflib.py.

Constructor & Destructor Documentation

def __init__ (   self,
  linejunk = None,
  charjunk = None 
)
Construct a text differencer, with optional filters.

The two optional keyword parameters are for filter functions:

- `linejunk`: A function that should accept a single string argument,
  and return true iff the string is junk. The module-level function
  `IS_LINE_JUNK` may be used to filter out lines without visible
  characters, except for at most one splat ('#').

- `charjunk`: A function that should accept a string of length 1. The
  module-level function `IS_CHARACTER_JUNK` may be used to filter out
  whitespace characters (a blank or tab; **note**: bad idea to include
  newline in this!).

Definition at line 732 of file difflib.py.

733  def __init__(self, linejunk=None, charjunk=None):
734  """
735  Construct a text differencer, with optional filters.
736 
737  The two optional keyword parameters are for filter functions:
738 
739  - `linejunk`: A function that should accept a single string argument,
740  and return true iff the string is junk. The module-level function
741  `IS_LINE_JUNK` may be used to filter out lines without visible
742  characters, except for at most one splat ('#').
743 
744  - `charjunk`: A function that should accept a string of length 1. The
745  module-level function `IS_CHARACTER_JUNK` may be used to filter out
746  whitespace characters (a blank or tab; **note**: bad idea to include
747  newline in this!).
748  """
750  self.linejunk = linejunk
751  self.charjunk = charjunk

Member Function Documentation

def compare (   self,
  a,
  b 
)

Definition at line 752 of file difflib.py.

References Differ._dump(), Differ._fancy_helper(), Differ._fancy_replace(), Differ._plain_replace(), Differ._qformat(), Differ.charjunk, Differ.linejunk, sre_parse.min, and string.rstrip().

753  def compare(self, a, b):
754  r"""
755  Compare two sequences of lines; generate the resulting delta.
756 
757  Each sequence must contain individual single-line strings ending with
758  newlines. Such sequences can be obtained from the `readlines()` method
759  of file-like objects. The delta generated also consists of newline-
760  terminated strings, ready to be printed as-is via the writeline()
761  method of a file-like object.
762 
763  Example:
764 
765  >>> print ''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1),
766  ... 'ore\ntree\nemu\n'.splitlines(1))),
767  - one
768  ? ^
769  + ore
770  ? ^
771  - two
772  - three
773  ? -
774  + tree
775  + emu
776  """
777 
778  cruncher = SequenceMatcher(self.linejunk, a, b)
779  for tag, alo, ahi, blo, bhi in cruncher.get_opcodes():
780  if tag == 'replace':
781  g = self._fancy_replace(a, alo, ahi, b, blo, bhi)
782  elif tag == 'delete':
783  g = self._dump('-', a, alo, ahi)
784  elif tag == 'insert':
785  g = self._dump('+', b, blo, bhi)
786  elif tag == 'equal':
787  g = self._dump(' ', a, alo, ahi)
788  else:
789  raise ValueError, 'unknown tag ' + `tag`
790 
791  for line in g:
792  yield line

Field Documentation

charjunk

Definition at line 750 of file difflib.py.

linejunk

Definition at line 749 of file difflib.py.


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