PopLines (version 2.1.1)
index

#    Copyright (c) 2016, 2017 Timothy Savannah All Rights Reserved
#  under terms of the GPL version 2. You should have recieved a copy of this with distribution,
#  as LICENSE. You may also find the full text at https://github.com/kata198/popLines/LICENSE
#

 
Package Contents
       

 
Functions
       
popHead(numLines, filename, saveChanges=True)
popHead - Pops a given number of lines from the head of a file.
 
@see popLines
 
Shortcut for popLines('head', numLines, filename)
popLines(popType, numLines, filename, saveChanges=True)
        popLines - Remove lines from a given file, and return them.
 
            @param popType <str> - The mode of selection to use when picking which lines to pop.
 
              Types are:
 
                head     - Remove from the top, numLines items
 
                tail     - Remove from the bottom, numLines items
 
                random   - Remove and sort randomly. "numLines" supports two formats, either old format (number of lines),
                            or new format: tuple(numLines, keepOrdered) where keepOrdered is a bool on whether the resulting lines
                            should be ordered (i.e. if random numbers are [5, 1, 2] and keepOrdered is True, you will get lines [1, 2, 5],
                            otherwise you will get [5, 1, 2].
 
                range    - Remove an inclusive 1-origin range. numLines is a tuple of (start, finish) or (start, finish, step). Use of negatives is allowed 
                            [e.x. (3, -1) returns the third line and all further, up to and including the final line]
 
                these     - Remove specific lines, 1-origin. numLines is an array of 1-origin line numbers to remove.
                            [e.x. [3, 5, 6, 8] removes the third, fifth, sixth, and eigth lines.]
 
 
            @param numLines <int/tuple(see below)> - Generally, number of lines to remove from filename. If there are not this many lines, every line in the file will be removed. Some values of #popType overload this value, see above.
 
 
            @param filename <str> - Path to the filename to pop lines
 
            @param saveChanges <bool> - Default True, if False op will be a "peek" not a "pop" (i.e. will return the lines, but will not modify the source file)
 
            @raises ValueError - Raised if invalid argument passes
            @raises IOError - If any error during reading/writing to file
 
        @return list<str> - A list of the lines removed from the file. If converting to a string, join with "
", and if length > 0 then add a final newline.
popRandom(numLines, filename, keepOrdered=False, saveChanges=True)
popRandom - Pops a given number of lines from random positions within a given file.
 
@see popLines
 
Shortcut for popLines('head', numLines, filename)
popRange(start, stop, step, filename, saveChanges=True)
popRange - Pops a given range (1-origin, inclusive) from a file.
 
@see popLines
 
Shortcut for popLines('range', (start, stop, step), filename)
popTail(numLines, filename, saveChanges=True)
popTail - Pops a given number of lines from the tail of a file.
 
@see popLines
 
Shortcut for popLines('head', numLines, filename)
popThese(lineNumbers, filename, saveChanges=True)
popThese - Pops specific lines (1-origin) from a file
 
@see popLines
 
Shortcut for popLines('these', lineNumbers, filename)

 
Data
        POP_TYPES = ('head', 'tail', 'random', 'range', 'these')
__all__ = ('POP_TYPES', 'popLines', 'popHead', 'popTail', 'popRandom', 'popRange', 'popThese')
__version_tuple__ = (2, 1, 1)