Ejemplo n.º 1
0
	def OnAdd(self, evt):

		path = self._dbb.GetValue()
		dName = os.path.basename(path) if not path.startswith('http') else filter(lambda a: a!='', path.split('/'))[-1]

		# si la lib n'est pas deja importee
		if not self.parent.tree.IsChildRoot(dName):
			if not self._d.has_key(dName) or (self._d.has_key(dName) and self._d[dName] != path):
				### si importation a partir du local
				if os.path.isdir(path):
					self.DoAdd(path, dName)
				### si importation à partir du web
				elif checkURL(path):
					self.DoAdd(path, dName)
				### gestion de l'erreur
				else:
					if path.startswith('http'):
						msg = _('%s is an invalid url')%path
					else:
						msg = _('%s directory does not exist')%dName
					dial = wx.MessageDialog(self, msg, _('New librarie manager'), wx.OK | wx.ICON_ERROR)
					dial.ShowModal()
					self._dbb.SetValue('')
			else:
				dial = wx.MessageDialog(self, _('%s is already imported!')%dName, _('New librarie manager'), wx.OK|wx.ICON_INFORMATION)
				dial.ShowModal()
				self._dbb.SetValue('')
		else:
			dial = wx.MessageDialog(self, _('%s is already imported!')%dName, _('New librarie manager'), wx.OK|wx.ICON_INFORMATION)
			dial.ShowModal()
			self._dbb.SetValue('')

		# on reactive le bouton pour un eventuel autre ajout
		self._btn_Add.Enable(True)
Ejemplo n.º 2
0
	def OnAdd(self, evt):

		path = self._dbb.GetValue()
		dName = os.path.basename(path) if not path.startswith('http') else filter(lambda a: a!='', path.split('/'))[-1]

		# si la lib n'est pas deja importee
		if not self.parent.tree.IsChildRoot(dName):
			if not self._d.has_key(dName) or (self._d.has_key(dName) and self._d[dName] != path):
				### si importation a partir du local
				if os.path.isdir(path):
					self.DoAdd(path, dName)
				### si importation à partir du web
				elif checkURL(path):
					self.DoAdd(path, dName)
				### gestion de l'erreur
				else:
					if path.startswith('http'):
						msg = _('%s is an invalid url')%path
					else:
						msg = _('%s directory does not exist')%dName
					dial = wx.MessageDialog(self, msg, _('New librarie manager'), wx.OK | wx.ICON_ERROR)
					dial.ShowModal()
					self._dbb.SetValue('')
			else:
				dial = wx.MessageDialog(self, _('%s is already imported!')%dName, _('New librarie manager'), wx.OK|wx.ICON_INFORMATION)
				dial.ShowModal()
				self._dbb.SetValue('')
		else:
			dial = wx.MessageDialog(self, _('%s is already imported!')%dName, _('New librarie manager'), wx.OK|wx.ICON_INFORMATION)
			dial.ShowModal()
			self._dbb.SetValue('')

		# on reactive le bouton pour un eventuel autre ajout
		self._btn_Add.Enable(True)
Ejemplo n.º 3
0
    def OnAdd(self, evt):
        """
		"""

        ### Get path to add
        dialog = wx.DirDialog(self,
                              "Choose a directory:",
                              style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
        else:
            path = None
        dialog.Destroy()

        if path:
            dName = os.path.basename(path) if not path.startswith(
                'http') else [a for a in path.split('/') if a != ''][-1]

            # si la lib n'est pas deja importee
            if not self.parent.tree.IsChildRoot(dName):
                if dName not in self._d or (dName in self._d
                                            and self._d[dName] != path):
                    ### si importation a partir du local
                    if os.path.isdir(path):
                        self.DoAdd(path, dName)
                    ### si importation à partir du web
                    elif checkURL(path):
                        self.DoAdd(path, dName)
                    ### gestion de l'erreur
                    else:
                        if path.startswith('http'):
                            msg = _('%s is an invalid url') % path
                        else:
                            msg = _('%s directory does not exist') % dName
                        dial = wx.MessageDialog(self, msg,
                                                _('New librarie manager'),
                                                wx.OK | wx.ICON_ERROR)
                        dial.ShowModal()
                else:
                    dial = wx.MessageDialog(
                        self,
                        _('%s is already imported!') % dName,
                        _('New librarie manager'), wx.OK | wx.ICON_INFORMATION)
                    dial.ShowModal()
            else:
                dial = wx.MessageDialog(self,
                                        _('%s is already imported!') % dName,
                                        _('New librarie manager'),
                                        wx.OK | wx.ICON_INFORMATION)
                dial.ShowModal()
Ejemplo n.º 4
0
	def OnAdd(self, evt):
		"""
		"""

		### Get path to add
		dialog = wx.DirDialog(self, "Choose a directory:",style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
		if dialog.ShowModal() == wx.ID_OK:
			path = dialog.GetPath()
		else:
			path = None
		dialog.Destroy()
		
		if path:
			dName = os.path.basename(path) if not path.startswith('http') else filter(lambda a: a!='', path.split('/'))[-1]

			# si la lib n'est pas deja importee
			if not self.parent.tree.IsChildRoot(dName):
				if not self._d.has_key(dName) or (self._d.has_key(dName) and self._d[dName] != path):
					### si importation a partir du local
					if os.path.isdir(path):
						self.DoAdd(path, dName)
					### si importation à partir du web
					elif checkURL(path):
						self.DoAdd(path, dName)
					### gestion de l'erreur
					else:
						if path.startswith('http'):
							msg = _('%s is an invalid url')%path
						else:
							msg = _('%s directory does not exist')%dName
						dial = wx.MessageDialog(self, msg, _('New librarie manager'), wx.OK | wx.ICON_ERROR)
						dial.ShowModal()
				else:
					dial = wx.MessageDialog(self, _('%s is already imported!')%dName, _('New librarie manager'), wx.OK|wx.ICON_INFORMATION)
					dial.ShowModal()
			else:
				dial = wx.MessageDialog(self, _('%s is already imported!')%dName, _('New librarie manager'), wx.OK|wx.ICON_INFORMATION)
				dial.ShowModal()