← Back to team overview

zim-wiki team mailing list archive

Files with 1st line like "abc: def" cause stacktrace

 


First off, I depend on the ability to import large numbers of regular *.txt files into zim-wiki. In general there are few if any issues. I'm not aware of any import/conversion process, and simply copy files into a subdirectory of ~/Notebooks.

So a key question is what if any guidelines do we have on importing general text files to zim. A distinctive suffix (e.g. .data) might be a reasonable approach. As it is, I think files in the zim notebook hierarchy that aren't directories and don't end in .txt are ignored.

The one issue I discovered long ago is that any *.txt file with a first line like "abc: def" causes export to crash. lines like:
	"abc: def hij"
don't seem to cause a crash. It you just try to open such a file, a stack trace and warning appear, but zim does not crash.

Notes I made while tracking down the origin of the crash
In zim/formats/__init__.py parse_header_lines(), line 1769 is where the exception occurs. The two words (abc: def.) seem to be treated 'header' and 'value'. It may be due to uneasy coexistence of files created in the notebook and regular files imported into it.

This is the typical stack trace from a crash in export.


  File "/opt/zim-0.68/zim/main/__init__.py", line 850, in main
    ZIM_APPLICATION.run(*argv[1:])
  File "/opt/zim-0.68/zim/main/__init__.py", line 631, in run
    self._run_cmd(cmd, args) # test seam
  File "/opt/zim-0.68/zim/main/__init__.py", line 663, in _run_cmd
    cmd.run()
  File "/opt/zim-0.68/zim/main/__init__.py", line 455, in run
    exporter.export(selection)
File "/opt/zim-0.68/zim/export/exporters/__init__.py", line 24, in export
    for p in self.export_iter(pages):
File "/opt/zim-0.68/zim/export/exporters/files.py", line 103, in export_iter self.export_page(pages.notebook, page, pages, prevpage=prev, nextpage=next) File "/opt/zim-0.68/zim/export/exporters/files.py", line 139, in export_page
    title=page.get_title(),
  File "/opt/zim-0.68/zim/notebook/page.py", line 712, in get_title
    tree = self.get_parsetree()
  File "/opt/zim-0.68/zim/notebook/page.py", line 562, in get_parsetree
    self._parsetree = parser.parse(text)
  File "/opt/zim-0.68/zim/formats/wiki.py", line 464, in parse
    wikiparser(builder, input)
  File "/opt/zim-0.68/zim/formats/wiki.py", line 88, in __call__
    self.block_parser(builder, text)
  File "/opt/zim-0.68/zim/parser.py", line 399, in __call__
    assert text, 'BUG: processing empty string'
AssertionError: BUG: processing empty string




References