12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #!/usr/bin/python
- # coding=utf-8
- """Convert bank statement CSV to GnuCash-importable CSV
-
- usage: gcconv [options] <format> <file>
- gcconv --list
-
- Options:
- -e, --encoding ENCODING input file encoding as understood by Python [default: utf-8]
- -l, --list list known formats
- --help show this screen
- --version show version
- """
-
- __VERSION__ = "gcconv 0.0.1"
-
- import sys
-
- import docopt
-
- import gcconv
-
- class App(object):
- """
- Main application
- """
-
- class UsageError(ValueError):
- """Usage error"""
- pass
-
- def __init__(self, args):
- self.args = args
-
- @classmethod
- def main(cls, args):
- """
- Main entry point
- """
- app = cls(args)
- app.run()
-
- def run(self):
- """
- Run the app (main entry point)
- """
- if self.args['--list']:
- print "\n".join(gcconv.valid_formats())
- sys.exit(0)
- print gcconv.convert_file(
- self.args['<file>'],
- self.args['<format>'],
- encoding=self.args['--encoding']
- )
-
-
- if __name__ == "__main__":
- App.main(docopt.docopt(__doc__, version=__VERSION__))
|