diff --git a/ChangeLog b/ChangeLog index 639fe24..427850e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +* 2.0.0 - Feb 28 2017 +- Add the "--peek" option to all of the pop* commands and the module (as "saveChanges" argument, default True). + This can be used to just pull the lines without modifying the source file (i.e. instead of a queue, you can use it for simple extraction) +- Add the "--ordered" option (and keepOrdered in module) to the "popRandom" command. When this is present, the output lines will still be picked at random, but they will be output in the order they appear in the file. By default, the old behaviour is retained, and random lines will be output in random order. + * 1.1.1 - Feb 28 2017 - Add missing scripts to setup.py diff --git a/PopLines/__init__.py b/PopLines/__init__.py index 3bd31e6..eed27f2 100755 --- a/PopLines/__init__.py +++ b/PopLines/__init__.py @@ -26,8 +26,8 @@ # these - Remove specific lines, 0-origin. numLines is an array of 0-origin line numbers to remove. POP_TYPES = ('head', 'tail', 'random', 'range', 'these') -__version__ = '1.1.1' -__version_tuple__ = (1, 1, 1) +__version__ = '2.0.0' +__version_tuple__ = (2, 0, 0) __all__ = ('POP_TYPES', 'popLines', 'popHead', 'popTail', 'popRandom', 'popRange', 'popThese') diff --git a/README.md b/README.md index cc1c39b..9a74174 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,23 @@ The followings modes and their associated command name are given: **Random** - popRandom \[numLines\] \[filename\] - Removes "numLines" from random positions within provided "filename", and prints to stdout in a random order. + +You can pass the --ordered flag, and the randomly-selected lines will be output in the same order they appear in the file. By default, the random lines will be output in random order. + + **Range** - popRange \[start\] \[stop\] (optional: \[step\]) \[filename\] - Removes lines using inclusive 1-origin start, stop, and optional step, and prints to stdout. Negative numbers are supported to mean "from the end", -1 is last line, -2 is second-to-last line. **These** - popThese \[line1\] \[...lineN\] \[filename\] - Removes specific lines given 1-origin numbers. If numbers are out of range, that number will be ommited. Lines are returned in provided order, and duplicates are allowed. Negative numbers are supported to mean "from the end". + +Peeking +------- + +By default, the pop\* commands are designed to implement queues, and thus they perform real "pops" and remove the elements extracted from the source file. + +If you'd just like to "peek" (extract lines but keep them in the source), add "--peek" when invoking any of the pop\* commands. + + Module ------ diff --git a/README.rst b/README.rst index 91e89cd..1a4bcfc 100644 --- a/README.rst +++ b/README.rst @@ -57,12 +57,22 @@ The followings modes and their associated command name are given: **Random** - popRandom [numLines] [filename] - Removes "numLines" from random positions within provided "filename", and prints to stdout in a random order. +You can pass the --ordered flag, and the randomly-selected lines will be output in the same order they appear in the file. By default, the random lines will be output in random order. + + **Range** - popRange [start] [stop] (optional: [step]) [filename] - Removes lines using inclusive 1-origin start, stop, and optional step, and prints to stdout. Negative numbers are supported to mean "from the end", -1 is last line, -2 is second-to-last line. **These** - popThese [line1] [...lineN] [filename] - Removes specific lines given 1-origin numbers. If numbers are out of range, that number will be ommited. Lines are returned in provided order, and duplicates are allowed. Negative numbers are supported to mean "from the end". +Peeking +------- + +By default, the pop\* commands are designed to implement queues, and thus they perform real "pops" and remove the elements extracted from the source file. + +If you'd just like to "peek" (extract lines but keep them in the source), add "--peek" when invoking any of the pop\* commands. + Module ------ diff --git a/setup.py b/setup.py index 59613c6..5c8ec3e 100755 --- a/setup.py +++ b/setup.py @@ -21,12 +21,12 @@ long_description = summary setup(name='popLines', - version='1.1.1', + version='2.0.0', scripts=['popHead', 'popTail', 'popRandom', 'popRange', 'popThese'], modules=['PopLines'], packages=['PopLines'], provides=['PopLines'], - keywords=['popLines', 'file', 'head', 'tail', 'random', 'queue', 'pop', 'lines', 'text', 'popHead', 'popTail', 'popRandom' ], + keywords=['popLines', 'file', 'head', 'tail', 'random', 'queue', 'pop', 'lines', 'peek', 'extract', 'text', 'popHead', 'popTail', 'popRandom' ], url='https://github.com/kata198/popLines', long_description=long_description, author='Tim Savannah',