3 # Copyright (C) 2004, 2005, 2006 James Troup <james@nocrew.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ################################################################################
21 import glob, os, stat, time
24 ################################################################################
27 Cnf = daklib.utils.get_conf()
29 os.chdir(Cnf["Dir::Queue::Done"])
30 files = glob.glob("%s/*" % (Cnf["Dir::Queue::Done"]))
31 for filename in files:
32 if os.path.isfile(filename):
33 mtime = time.gmtime(os.stat(filename)[stat.ST_MTIME])
34 dirname = time.strftime("%Y/%m/%d", mtime)
35 if not os.path.exists(dirname):
36 print "Creating: %s" % (dirname)
38 dest = dirname + '/' + os.path.basename(filename)
39 if os.path.exists(dest):
40 daklib.utils.fubar("%s already exists." % (dest))
41 print "Move: %s -> %s" % (filename, dest)
42 os.rename(filename, dest)
44 print "Moved %d files." % (count)
46 ############################################################
48 if __name__ == '__main__':