1 #! /usr/local/bin/python -O
2 """This file is a part of XSetBg.
3 Author: Oleg BroytMann <phd@phd.pp.ru>
4 Copyright (C) 2004-2006 PhiloSoft Design
7 __version__ = "$Revision$"[11:-2]
8 __author__ = "Oleg BroytMann <phd@phd.pp.ru>"
9 __copyright__ = "Copyright (C) 2004-2006 PhiloSoft Design"
10 __date__ = "$Date$"[7:-2]
11 __revision__ = "$Id$"[5:-2]
14 import sys, os, shelve
18 sys.stderr.write("Usage: %s [-0|--null] [-o|--old] [-s|--spaces] [-w|--width] [width]\n" % sys.argv[0])
23 from getopt import getopt, GetoptError
26 options, arguments = getopt(sys.argv[1:], "0osw:",
27 ["null", "old", "spaces", "width="])
36 for option, value in options:
37 if option in ("-h", "--help"):
39 elif option in ("-0", "--null"):
41 elif option in ("-o", "--old"):
43 elif option in ("-s", "--spaces"):
45 elif option in ("-w", "--width"):
53 elif len(arguments) > 1:
56 width = int(arguments[0])
58 return print0, old, spaces, width
60 print0, old, spaces, width = get_args()
63 xsetbg_dir = os.path.join(os.environ["HOME"], "lib", "xsetbg")
66 global_db_name = "xsetbg.db"
67 filename_key = "filename"
68 old_filename_key = "old_filename"
71 global_db = shelve.open(global_db_name, flag='r')
73 key = old_filename_key
76 filename = global_db[key]
83 lines.append("%s%s%s" % (spaces, filename[:width], spaces))
84 filename = filename[width:]
85 filename = "\n".join(lines)
87 filename = "%s%s%s" % (spaces, filename, spaces)
90 sys.stdout.write(filename)
93 sys.stdout.write('\0')