From d0ab0d6fcedb3d5d8c446cf7802e37bcee8fc48c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Feb 2012 14:48:57 +0530 Subject: [PATCH] Add a function to return the current library name --- src/calibre/library/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/calibre/library/__init__.py b/src/calibre/library/__init__.py index 84a7acbc73..605d062de3 100644 --- a/src/calibre/library/__init__.py +++ b/src/calibre/library/__init__.py @@ -61,4 +61,13 @@ def generate_test_db(library_path, # {{{ print 'Time per record:', t/float(num_of_records) # }}} +def current_library_name(): + from calibre.utils.config import prefs + import posixpath + path = prefs['library_path'] + if path: + path = path.replace('\\', '/') + while path.endswith('/'): + path = path[:-1] + return posixpath.basename(path)