zodb warnings removed

--HG--
branch : sandbox
This commit is contained in:
baloan
2014-12-09 21:43:29 +01:00
parent 2359d9251d
commit a6010663ac
2 changed files with 36 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ import re
import logging import logging
logging.basicConfig(level=logging.DEBUG, logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
datefmt='%H:%M:%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.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 # 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 argv = sys.argv
LOG.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"])
@@ -38,11 +39,11 @@ def main(argv = None):
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")
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 = r"c:\Dokumente\Eigene Videos\Shaun the Sheep"
tng = "." tng = "."
# os.chdir(tng) # os.chdir(tng)
for (dirpath, dirnames, filenames) in os.walk(tng): for (_, _, 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:
@@ -51,8 +52,8 @@ def main(argv = None):
title1 = title0.replace('.', ' ') title1 = title0.replace('.', ' ')
nf = r"%s - DVDRip [tvu.org.ru].avi" % (title1,) 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:
LOG.error(err.message) LOG.error(err.message)
return 1 return 1

View File

@@ -1,9 +1,14 @@
#! /usr/bin/env python2 #!/usr/bin/env python
# -*- coding: cp1252 -*- # -*- 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 # imports
@@ -14,6 +19,7 @@ import transaction
# Persistent objects # Persistent objects
class Account(Persistent): class Account(Persistent):
def __init__(self): def __init__(self):
self.balance = 0.0 self.balance = 0.0
@@ -27,29 +33,35 @@ class Account(Persistent):
# Configuration # Configuration
storage = FileStorage(r"e:\workspaces\zodb3\data.zodb") storage = FileStorage(r"e:\workspaces\zodb3\tutorial.zodb")
db = DB(storage) db = DB(storage)
connection = db.open() ctx = db.open()
root = connection.root() root = ctx.root()
print root.keys() print(root.keys())
# Storing objects # 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 # Transactions
root['account-2'].deposit(5) root['account-2'].deposit(5)
transaction.commit() transaction.commit()
print root.keys() print(root.keys())
del root['account-1'] del root['account-1']
print root.keys() print(root.keys())
# ['account-2'] # ['account-2']
transaction.abort() transaction.abort()
print root.keys() print(root.keys())
# ['account-1', 'account-2'] # ['account-1', 'account-2']
print root['account-2'].balance print(root['account-2'].balance)
a = root['account-1']
b = root['account-2']
print("id(a): {}, id(b): {}".format(id(a), id(b)))