#50: create invest-signal indicators and signal

(ACCEPTED)

--HG--
branch : sandbox
This commit is contained in:
Andreas
2010-02-27 21:46:15 +00:00
parent e985f59bb9
commit 4f9469e222

View File

@@ -6,7 +6,13 @@ import os
import re import re
import logging import logging
mylog = logging.getLogger('batch_rename')
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
datefmt='%H:%M:%S')
LOG = logging.getLogger()
class Usage(Exception): class Usage(Exception):
def __init__(self, message): def __init__(self, message):
@@ -23,7 +29,7 @@ class Error(Exception):
def main(argv = None): def main(argv = None):
if argv == None: if argv == None:
argv = sys.argv argv = sys.argv
mylog.info("starting [%s]" % (argv[0],)) LOG.info("starting [%s]" % (argv[0],))
try: try:
try: try:
opts, args = getopt.getopt(argv[1:], "h", ["help"]) opts, args = getopt.getopt(argv[1:], "h", ["help"])
@@ -31,32 +37,29 @@ def main(argv = None):
except getopt.error, msg: except getopt.error, msg:
raise Usage(msg) raise Usage(msg)
# more code, unchanged # more code, unchanged
p = re.compile("Star\.Trek\.The\.Next\.Generation.(.*?)\.(.*)\.(DVDRip-.*)\.\[tvu.org.ru\]\.avi") # p = re.compile("Star\.Trek\.The\.Next\.Generation.(.*?)\.(.*)\.(DVDRip-.*)\.\[tvu.org.ru\]\.avi")
tng = "e:\\share\\movies\\star trek tng" p = re.compile("Shaun\.The\.Sheep\..*\.(.*)\.DVDRip\.XviD-WPi\.\[tvu\.org\.ru\]\.avi")
os.chdir(tng) # tng = r"c:\Dokumente\Eigene Videos\Shaun the Sheep"
tng = "."
# os.chdir(tng)
for (dirpath, dirnames, filenames) in os.walk(tng): for (dirpath, dirnames, filenames) in os.walk(tng):
for f in filenames: for f in filenames:
mot = re.match(p, f) mot = re.match(p, f)
if mot is not None: if mot is not None:
# print mot.group() # print mot.groups()
print mot.groups() title0 = mot.group(1)
ver = mot.group(1)
title0 = mot.group(2)
title1 = title0.replace('.', ' ') title1 = title0.replace('.', ' ')
nf = "Star Trek TNG - %s - %s - %s.divx.avi" % (ver, title1, mot.group(3)) nf = r"%s - DVDRip [tvu.org.ru].avi" % (title1,)
# os.rename(f, nf) # os.rename(f, nf)
print 'ren "%s" "%s"' % (f, nf) print 'ren "%s" "%s"' % (f, nf)
except Error, err: except Error, err:
mylog.error(err.message) LOG.error(err.message)
return 1 return 1
except Usage, err: except Usage, err:
mylog.error(err.message) LOG.error(err.message)
mylog.error("for help use --help") LOG.error("for help use --help")
return 2 return 2
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
datefmt='%H:%M:%S')
sys.exit(main()) sys.exit(main())