# HG changeset patch # User Emmanuel Gil Peyrot # Date 1354472117 -3600 # Node ID 2c81cc41de2d578eed14d259075ee2000e2dfddc # Parent a422e75bf464dff515c6992220491702a1a68f71 Allow only a base directory for the tags, which will be recursively walked to find the actual tags files. diff --git a/danboorufs.py b/danboorufs.py --- a/danboorufs.py +++ b/danboorufs.py @@ -59,11 +59,13 @@ class Danbooru(LoggingMixIn, Operations) self.paths[basename] = filename tags = [] self.files[basename] = tags - with open(name, 'r') as tagfile: + with open(name, 'rb') as tagfile: for line in tagfile: for tag in line.split(): try: tag = tag.decode('UTF-8') + except UnicodeDecodeError: + continue except AttributeError: pass tag = tag.replace('/', '�') #XXX @@ -189,10 +191,17 @@ def main(args): if args[1] == '-n' or args[1] == '--no-symlinks': use_symlinks = False - filelist = args[1:] + directory = args[2] else: use_symlinks = True - filelist = args[2:] + directory = args[1] + + filelist = [] + start = time() + for (path, _, files) in os.walk(directory): + filelist.extend(os.path.join(path, filename) for filename in files + if filename.endswith('.tags')) + print('[%d] Walk done.' % (time() - start)) FUSE(Danbooru(filelist, os.path.dirname(mountpoint), use_symlinks), mountpoint, foreground=True) @@ -201,7 +210,7 @@ def main(args): if __name__ == '__main__': if len(argv) < 3: print('USAGE: %s' % argv[0], '[-n|--no-symlinks]', - ' [...]', '') + '', '') exit(1) main(argv)