Add username field to CollectionWrapper
This commit is contained in:
		
							parent
							
								
									5051144124
								
							
						
					
					
						commit
						4fe378adce
					
				@ -16,6 +16,7 @@ class CollectionWrapper:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def __init__(self, path, setup_new_collection=None):
 | 
					    def __init__(self, path, setup_new_collection=None):
 | 
				
			||||||
        self.path = os.path.realpath(path)
 | 
					        self.path = os.path.realpath(path)
 | 
				
			||||||
 | 
					        self.username = os.path.basename(os.path.dirname(self.path))
 | 
				
			||||||
        self.setup_new_collection = setup_new_collection
 | 
					        self.setup_new_collection = setup_new_collection
 | 
				
			||||||
        self.__col = None
 | 
					        self.__col = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@ from ankisyncd.collection import CollectionWrapper, CollectionManager
 | 
				
			|||||||
from threading import Thread
 | 
					from threading import Thread
 | 
				
			||||||
from queue import Queue
 | 
					from queue import Queue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import time, logging, os.path
 | 
					import time, logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ThreadingCollectionWrapper:
 | 
					class ThreadingCollectionWrapper:
 | 
				
			||||||
    """Provides the same interface as CollectionWrapper, but it creates a new Thread to 
 | 
					    """Provides the same interface as CollectionWrapper, but it creates a new Thread to 
 | 
				
			||||||
@ -12,8 +12,6 @@ class ThreadingCollectionWrapper:
 | 
				
			|||||||
    def __init__(self, path, setup_new_collection=None):
 | 
					    def __init__(self, path, setup_new_collection=None):
 | 
				
			||||||
        self.path = path
 | 
					        self.path = path
 | 
				
			||||||
        self.wrapper = CollectionWrapper(path, setup_new_collection)
 | 
					        self.wrapper = CollectionWrapper(path, setup_new_collection)
 | 
				
			||||||
        # FIXME: this might not work for other collection wrappers, introduce self.wrapper.name?
 | 
					 | 
				
			||||||
        self._name = os.path.basename(os.path.dirname(self.wrapper.path))
 | 
					 | 
				
			||||||
        self.logger = logging.getLogger("ankisyncd." + str(self))
 | 
					        self.logger = logging.getLogger("ankisyncd." + str(self))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self._queue = Queue()
 | 
					        self._queue = Queue()
 | 
				
			||||||
@ -24,7 +22,7 @@ class ThreadingCollectionWrapper:
 | 
				
			|||||||
        self.start()
 | 
					        self.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return "CollectionThread[{}]".format(self._name) # TODO: self.wrapper.name?
 | 
					        return "CollectionThread[{}]".format(self.wrapper.username)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def running(self):
 | 
					    def running(self):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user