Pep8
This commit is contained in:
		
							parent
							
								
									07cde3ca7b
								
							
						
					
					
						commit
						cce409a729
					
				@ -18,7 +18,13 @@ from plone.app.discussion.interfaces import IConversation, IReplies, IComment
 | 
			
		||||
def DT2dt(DT):
 | 
			
		||||
    """Convert a Zope DateTime (with timezone) into a Python datetime (GMT)."""
 | 
			
		||||
    DT = DT.toZone('GMT')
 | 
			
		||||
    return datetime(DT.year(), DT.month(), DT.day(), DT.hour(), DT.minute(), int(DT.second()))
 | 
			
		||||
    return datetime(
 | 
			
		||||
        DT.year(),
 | 
			
		||||
        DT.month(),
 | 
			
		||||
        DT.day(),
 | 
			
		||||
        DT.hour(),
 | 
			
		||||
        DT.minute(),
 | 
			
		||||
        int(DT.second()))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class View(BrowserView):
 | 
			
		||||
@ -32,11 +38,11 @@ class View(BrowserView):
 | 
			
		||||
        self.total_comments_migrated = 0
 | 
			
		||||
        self.total_comments_deleted = 0
 | 
			
		||||
 | 
			
		||||
        dry_run = self.request.has_key("dry_run")
 | 
			
		||||
        dry_run = "dry_run" in self.request
 | 
			
		||||
 | 
			
		||||
        # This is for testing only.
 | 
			
		||||
        # Do not use transactions during a test.
 | 
			
		||||
        test = self.request.has_key("test")
 | 
			
		||||
        test = "test" in self.request
 | 
			
		||||
 | 
			
		||||
        if not test:
 | 
			
		||||
            transaction.begin()  # pragma: no cover
 | 
			
		||||
@ -50,7 +56,8 @@ class View(BrowserView):
 | 
			
		||||
            context.plone_log(msg)
 | 
			
		||||
            out.append(msg)
 | 
			
		||||
 | 
			
		||||
        def migrate_replies(context, in_reply_to, replies, depth=0, just_delete=0):
 | 
			
		||||
        def migrate_replies(context, in_reply_to, replies,
 | 
			
		||||
                            depth=0, just_delete=0):
 | 
			
		||||
            # Recursive function to migrate all direct replies
 | 
			
		||||
            # of a comment. Returns True if there are no replies to
 | 
			
		||||
            # this comment left, and therefore the comment can be removed.
 | 
			
		||||
@ -101,11 +108,12 @@ class View(BrowserView):
 | 
			
		||||
                self.total_comments_migrated += 1
 | 
			
		||||
 | 
			
		||||
                # migrate all talkbacks of the reply
 | 
			
		||||
                talkback = getattr( reply, 'talkback', None )
 | 
			
		||||
                no_replies_left = migrate_replies(context,
 | 
			
		||||
                talkback = getattr(reply, 'talkback', None)
 | 
			
		||||
                no_replies_left = migrate_replies(
 | 
			
		||||
                    context,
 | 
			
		||||
                    new_in_reply_to,
 | 
			
		||||
                    talkback.getReplies(),
 | 
			
		||||
                                                  depth=depth+1,
 | 
			
		||||
                    depth=depth + 1,
 | 
			
		||||
                    just_delete=not should_migrate)
 | 
			
		||||
 | 
			
		||||
                if no_replies_left:
 | 
			
		||||
@ -151,7 +159,7 @@ class View(BrowserView):
 | 
			
		||||
        # Recursively run through the comment tree and migrate all comments.
 | 
			
		||||
        for brain in new_brains:
 | 
			
		||||
            obj = brain.getObject()
 | 
			
		||||
            talkback = getattr( obj, 'talkback', None )
 | 
			
		||||
            talkback = getattr(obj, 'talkback', None)
 | 
			
		||||
            if talkback:
 | 
			
		||||
                replies = talkback.getReplies()
 | 
			
		||||
                if replies:
 | 
			
		||||
@ -180,9 +188,11 @@ class View(BrowserView):
 | 
			
		||||
            % (self.total_comments_migrated, count_comments_old))
 | 
			
		||||
 | 
			
		||||
        if self.total_comments_migrated != count_comments_old:
 | 
			
		||||
            log("%s comments could not be migrated."
 | 
			
		||||
                % (count_comments_old - self.total_comments_migrated)) # pragma: no cover
 | 
			
		||||
            log("Please make sure your portal catalog is up-to-date.") # pragma: no cover
 | 
			
		||||
            log("%s comments could not be migrated." %
 | 
			
		||||
                (count_comments_old - \
 | 
			
		||||
                self.total_comments_migrated))  # pragma: no cover
 | 
			
		||||
            log("Please make sure your " +
 | 
			
		||||
                "portal catalog is up-to-date.")  # pragma: no cover
 | 
			
		||||
 | 
			
		||||
        if dry_run and not test:
 | 
			
		||||
            transaction.abort()  # pragma: no cover
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user