open both plain text and gzipped gnucash files
This commit is contained in:
1 parent
022337f980
commit
c66f46da9a
2 files changed
+15
-2
No files matched your search
+5
-1
@@ -9,7 +9,11 @@ module Gnucash
|
||||
attr_accessor :end_date
|
||||
|
||||
def initialize(fname)
|
||||
@ng = Nokogiri.XML(Zlib::GzipReader.open(fname).read)
|
||||
begin
|
||||
@ng = Nokogiri.XML(Zlib::GzipReader.open(fname).read)
|
||||
rescue Zlib::GzipFile::Error
|
||||
@ng = Nokogiri.XML(File.read(fname))
|
||||
end
|
||||
book_nodes = @ng.xpath('/gnc-v2/gnc:book')
|
||||
if book_nodes.count != 1
|
||||
raise "Error: Expected to find one gnc:book entry"
|
||||
|
||||
Reference in new issue
Block a user