Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility to render the OFX file to HTML #15

Open
petri opened this issue Nov 4, 2013 · 12 comments
Open

Add utility to render the OFX file to HTML #15

petri opened this issue Nov 4, 2013 · 12 comments
Labels

Comments

@petri
Copy link

petri commented Nov 4, 2013

I could not find such a utility, so I put together a XSLT transformation for debugging the OFX generated by ofxstatement from the input from the plugins I'm converting.

See here: https://gist.github.com/petri/7300330

Feel free to include in the project if you like. I will very likely improve it further; just wanted to contribute now that it's somewhat useful already.

It might be nice to add a command-line option to ofxstatement that uses the transform to generate a HTML representation?

@mcepl
Copy link
Contributor

mcepl commented Nov 4, 2013

Wouldn't just contrib/ directory with files like this be a good solution?

@petri
Copy link
Author

petri commented Nov 4, 2013

Sounds good to me. Do you think you'd later accept a pull request providing the command-line option?

@mcepl
Copy link
Contributor

mcepl commented Nov 4, 2013

Don't ask me, I have nothing to do with this project (aside from maintaining one plugin for it).

@petri
Copy link
Author

petri commented Nov 4, 2013

Sorry- just automatically thought I was responding to Andrey.

A contrib is a good start; however I think a command-line option would be useful.

@kedder
Copy link
Owner

kedder commented Nov 4, 2013

I used ofxdump program from ofx ubuntu package to debug resulting ofx. It gives nice textual representation of the OFX file though prints lots of irrelevant warnings too.

Lets start with contrib. @petri, what is your use case for command line option? Is it just for debugging?

@petri
Copy link
Author

petri commented Nov 4, 2013

Ah thanks I will take a look at ofxdump. Too bad there's no OSX version.

Initial use case is debug yes; however I plan to add a bit nicer HTML UI for end users for a quick review of their statement history, perhaps indexed in various ways, etc. Personal itch as well (I know - duplicating what GnuCash does to some extent).

@kedder
Copy link
Owner

kedder commented Nov 4, 2013

@petri, can you post a script that will actually apply xslt template on ofx file?

@petri
Copy link
Author

petri commented Nov 4, 2013

The bash script I posted in issue #16 does that using xsltproc, invoked thus:

xsltproc transformer.xslt infile.ofx > outfile.html

Or do you mean a Python script?

@petri
Copy link
Author

petri commented Nov 5, 2013

Here's how to invoke the transform from Python, using lxml:

from contextlib import contextmanager
from lxml import etree

@contextmanager
def xml(filename):
   with open(filename) as xmlfile:
      yield etree.XML(xmlfile.read())

with xml("transform.xslt") as transformer:
   transform = etree.XSLT(transformer)

with xml("out.ofx") as ofx:
   print(transform(ofx))

@kedder
Copy link
Owner

kedder commented Nov 5, 2013

Thanks. I just wanted to look at the html it produces.

Looks good. I think I'll accept a patch that adds --preview flag to convert action that would save resulting html to some temporary file and open it up in a default browser after conversion is complete. But then we have to put all information we have to that HTML, including summary data from o.s.Statement.

Would it make sense to you? Or you want to store HTMLs somewhere for later access?

@petri
Copy link
Author

petri commented Nov 7, 2013

I think for storing HTML I will run the parser(s) directly, as my use case requires access to the original transaction types, before they are mapped to types accepted by OFX. So a preview flag would make sense, yes.

Installation of the lxml package has historically been problematic, but perhaps those issues are a thing of the past by now. We can of course choose to not require lxml in setup.py, opting to just checking for it when user gives the --preview flag. So users not needing preview are not automatically forced to install lxml.

@kedder
Copy link
Owner

kedder commented Nov 10, 2013

Yeah, lxml requires compiling C module, something that I'd like to avoid for such a non-essential feature. So I agree, let's put lxml to "extras_require" and check presence when user asks to --preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants