Open jyn514 opened 6 years ago
Can you elaborate a little bit on what you are looking to do? Are you referring To the argparse arguments?
Can you show an example of the error?
Currently:
joshua@debian-thinkpad:/usr/local/src/bitshuffle$ ./bitshuffle.py -e some message here
usage: bitshuffle.py [-h] [--input INPUT] [--output OUTPUT]
[--filename FILENAME] [--encode] [--decode] [--version]
[--chunksize CHUNKSIZE] [--compresslevel COMPRESSLEVEL]
[--editor EDITOR] [--compresstype COMPRESSTYPE]
bitshuffle.py: error: unrecognized arguments: some message here
After this has been added:
joshua@debian-thinkpad:/usr/local/src/bitshuffle$ ./bitshuffle.py -e some message here
((<<This is encoded with BitShuffle, which you can download from https://github.com/charlesdaniels/bitshuffle|1|base64|bz2|0|0|stdin|9477a94f13fef4343e1fca75a1a814f870160dc6|QlpoNTFBWSZTWdy1BSkAAAhRgAAQQAAiwpgAIAAxADAp6A9JP28BA1onHC7kinChIblqClI=>>))
Argparse does have the functionality you’re after. There is a way to make it accept arbitrary positional arguments to a parameter.
I actually implemented a similar feature for a tiny script I wrote for another project recently. link]
For this to work, we need to move away from having everything run on file handles. I propose we add a wrapper class which can contain any of:
file
)IOBase
) The wrapper class should be set up with __iter__
(?) so that we can do for line in thing
and have it work right. We can also use this wrapper to abstract out the Python 2.x and 3.x differences.
The class's constructor should take either a file-like or a list-of-strings and handle setting up it's internal state appropriately.
Currently, adding extra arguments gives a usage error. It would be nice to take additional arguments to encode.