def factory(fs, db, parent): fileobj = fs if fs is not None else db name = fileobj.relpath or fileobj.fullpath if fileobj else '<path not found in filesystem or database>' if parent is None: progress = ProgressTree(name=name) maxlen = lambda s: util.trim_to_maxlen(50, s) progress.reporter = ProgressReporter(lvl=1, namefmt=maxlen) else: progress = parent.progress.spawnchild(name) return Item(fs, db, parent, progress)
def test_maxlen_trim(): assert util.trim_to_maxlen(7, 'abcdefghi') == 'a ... i'
def test_maxlen_trim(): assert util.trim_to_maxlen(7, "abcdefghi") == "a ... i"