diff --git a/src/misc/batch_rename.py b/src/misc/batch_rename.py index 790abd7..cdc5c0b 100644 --- a/src/misc/batch_rename.py +++ b/src/misc/batch_rename.py @@ -7,7 +7,7 @@ import re import logging -logging.basicConfig(level=logging.DEBUG, +logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', datefmt='%H:%M:%S') @@ -26,10 +26,11 @@ class Error(Exception): # Star.Trek.The.Next.Generation.1x01-02.Encounter.At.Farpoint.DVDRip-AMC.[tvu.org.ru].avi # Star Trek TNG - 1x01-2 - Encounter At Farpoint - DVDRip-AMC.divx.avi -def main(argv = None): - if argv == None: + +def main(argv=None): + if argv is None: argv = sys.argv - LOG.info("starting [%s]" % (argv[0],)) + LOG.info("starting [%s]" % (argv[0],)) try: try: opts, args = getopt.getopt(argv[1:], "h", ["help"]) @@ -38,11 +39,11 @@ def main(argv = None): raise Usage(msg) # more code, unchanged # p = re.compile("Star\.Trek\.The\.Next\.Generation.(.*?)\.(.*)\.(DVDRip-.*)\.\[tvu.org.ru\]\.avi") - p = re.compile("Shaun\.The\.Sheep\..*\.(.*)\.DVDRip\.XviD-WPi\.\[tvu\.org\.ru\]\.avi") + p = re.compile("Shaun\.The\.Sheep\..*\.(.*)\.DVDRip\.XviD-WPi\.\[tvu\.org\.ru\]\.avi") # tng = r"c:\Dokumente\Eigene Videos\Shaun the Sheep" tng = "." # os.chdir(tng) - for (dirpath, dirnames, filenames) in os.walk(tng): + for (_, _, filenames) in os.walk(tng): for f in filenames: mot = re.match(p, f) if mot is not None: @@ -51,8 +52,8 @@ def main(argv = None): title1 = title0.replace('.', ' ') nf = r"%s - DVDRip [tvu.org.ru].avi" % (title1,) # os.rename(f, nf) - print 'ren "%s" "%s"' % (f, nf) - + print 'ren "%s" "%s"' % (f, nf) + except Error, err: LOG.error(err.message) return 1 diff --git a/src/zodb/tutorial.py b/src/zodb/tutorial.py index fbeb21f..2f36646 100644 --- a/src/zodb/tutorial.py +++ b/src/zodb/tutorial.py @@ -1,9 +1,14 @@ -#! /usr/bin/env python2 +#!/usr/bin/env python # -*- coding: cp1252 -*- +# Copyright (c) 2014 Andreas +# See LICENSE for details. -# ZODB Tutorial +""" tutorial """ -""" zodb.tutorial """ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals # imports @@ -14,6 +19,7 @@ import transaction # Persistent objects + class Account(Persistent): def __init__(self): self.balance = 0.0 @@ -27,29 +33,35 @@ class Account(Persistent): # Configuration -storage = FileStorage(r"e:\workspaces\zodb3\data.zodb") +storage = FileStorage(r"e:\workspaces\zodb3\tutorial.zodb") db = DB(storage) -connection = db.open() -root = connection.root() +ctx = db.open() +root = ctx.root() -print root.keys() +print(root.keys()) # Storing objects - -root['account-1'] = Account() -if "account-2" not in root: - root['account-2'] = Account() +a = b = Account() + +root['account-1'] = a +if "account-2" not in root: + root['account-2'] = b + +print("id(a): {}, id(b): {}".format(id(a), id(b))) # Transactions root['account-2'].deposit(5) transaction.commit() -print root.keys() +print(root.keys()) del root['account-1'] -print root.keys() +print(root.keys()) # ['account-2'] transaction.abort() -print root.keys() +print(root.keys()) # ['account-1', 'account-2'] -print root['account-2'].balance \ No newline at end of file +print(root['account-2'].balance) +a = root['account-1'] +b = root['account-2'] +print("id(a): {}, id(b): {}".format(id(a), id(b)))