Ejemplo n.º 1
0
 def OnSelectLocation(self, evt):
     filename = widgets.AttachmentSelector()
     if filename:
         if self.basePath:
             filename = attachment.getRelativePath(filename, self.basePath)
         self._subjectEntry.SetValue(os.path.split(filename)[-1])
         self._locationEntry.SetValue(filename)
Ejemplo n.º 2
0
 def onDropFiles(self, item, filenames, **kwargs):
     """ This method is called by the widget when one or more files
         are dropped on an item. """
     attachmentBase = self.settings.get("file", "attachmentbase")
     if attachmentBase:
         filenames = [attachment.getRelativePath(filename, attachmentBase) for filename in filenames]
     attachments = [attachment.FileAttachment(filename) for filename in filenames]
     self._addAttachments(attachments, item, **kwargs)
Ejemplo n.º 3
0
 def onDropFiles(self, item, filenames, **kwargs):
     ''' This method is called by the widget when one or more files
         are dropped on an item. '''
     attachmentBase = self.settings.get('file', 'attachmentbase')
     if attachmentBase:
         filenames = [attachment.getRelativePath(filename, attachmentBase) \
                      for filename in filenames]
     attachments = [attachment.FileAttachment(filename) for filename in filenames]
     self._addAttachments(attachments, item, **kwargs)
Ejemplo n.º 4
0
    def onFileDrop(self, x, y, filenames):
        base = self.settings.get("file", "attachmentbase")
        for filename in filenames:
            if base:
                path = attachment.getRelativePath(filename, base)
            else:
                path = filename

            self.addAttachmentToListCtrl(attachment.FileAttachment(path))
Ejemplo n.º 5
0
 def onDropFiles(self, index, filenames):
     ''' This method is called by the widget when one or more files
         are dropped on an item. '''
     base = self.settings.get('file', 'attachmentbase')
     if base:
         func = lambda x: attachment.getRelativePath(x, base)
     else:
         func = lambda x: x
     attachments = [attachment.FileAttachment(func(name)) for name in filenames]
     self._addAttachments(attachments, index)
Ejemplo n.º 6
0
    def onBrowse(self, *args, **kwargs):
        filename = widgets.AttachmentSelector()
        if filename:
            base = self.settings.get("file", "attachmentbase")
            if base:
                path = attachment.getRelativePath(filename, base)
            else:
                path = filename

            self.addAttachmentToListCtrl(attachment.FileAttachment(path))
Ejemplo n.º 7
0
    def onSelectLocation(self, event):  # pylint: disable-msg=W0613
        if self.items[0].type_ == "file":
            basePath = os.path.split(self.items[0].normalizedLocation())[0]
        else:
            basePath = os.getcwd()

        filename = widgets.AttachmentSelector(default_path=basePath)

        if filename:
            if self.basePath:
                filename = attachment.getRelativePath(filename, self.basePath)
            self._subjectEntry.SetValue(os.path.split(filename)[-1])
            self._locationEntry.SetValue(filename)
            self._subjectSync.onAttributeEdited(event)
            self._locationSync.onAttributeEdited(event)
Ejemplo n.º 8
0
 def testBaseAndPathAreDifferent(self):
     self.assertEqual(os.path.join("..", "bar"), attachment.getRelativePath("/bar", "/foo"))
Ejemplo n.º 9
0
 def testBaseIsSubDirOfPath(self):
     self.assertEqual("..", attachment.getRelativePath("/test", "/test/subdir"))
Ejemplo n.º 10
0
 def testPathIsSubDirOfBase(self):
     self.assertEqual("subdir", attachment.getRelativePath("/test/subdir", "/test"))
Ejemplo n.º 11
0
 def testBaseAndPathEqual(self):
     self.assertEqual("", attachment.getRelativePath("/test", "/test"))
Ejemplo n.º 12
0
 def testBaseIsSubDirOfPath(self):
     self.assertEqual('..', attachment.getRelativePath('/test', '/test/subdir'))
Ejemplo n.º 13
0
 def testPathIsSubDirOfBase(self):
     self.assertEqual('subdir',
                      attachment.getRelativePath('/test/subdir', '/test'))
Ejemplo n.º 14
0
 def testBaseAndPathEqual(self):
     self.assertEqual('', attachment.getRelativePath('/test', '/test'))
Ejemplo n.º 15
0
 def testBaseAndPathEqual(self):
     self.assertEqual('', attachment.getRelativePath('/test', '/test'))
Ejemplo n.º 16
0
 def testPathIsSubDirOfBase(self):
     self.assertEqual('subdir', attachment.getRelativePath('/test/subdir', '/test'))
Ejemplo n.º 17
0
 def testBaseIsSubDirOfPath(self):
     self.assertEqual('..',
                      attachment.getRelativePath('/test', '/test/subdir'))
Ejemplo n.º 18
0
 def testBaseAndPathAreDifferent(self):
     self.assertEqual(os.path.join('..', 'bar'),
                      attachment.getRelativePath('/bar', '/foo'))
Ejemplo n.º 19
0
 def testBaseAndPathAreDifferent(self):
     self.assertEqual(os.path.join('..', 'bar'),
                      attachment.getRelativePath('/bar', '/foo'))