def showNewProjectDialog(self, default_name=None, text=None, parent=None): my_path = path(settings.get_project_dir()) if default_name: my_path = my_path / default_name if not text: text = 'Select name to create project' fname = QtGui.QFileDialog.getSaveFileName(parent, text, my_path) return fname
def create_project_shortcut(): """ Create a shortcut/symlink inside project directory to oalab.share directory. Permit to access to oalab examples simpler. """ project_dir = get_project_dir() project_link_name = path(project_dir)/"oalab_examples" if not project_link_name.exists(): oalab_dir = shared_data(oalab) symlink(oalab_dir,project_link_name)
def create_project_shortcut(): """ Create a shortcut/symlink inside project directory to oalab.share directory. Permit to access to oalab examples simpler. """ project_dir = get_project_dir() project_link_name = path(project_dir) / "oalab_examples" if not project_link_name.exists(): oalab_dir = shared_data(oalab) symlink(oalab_dir, project_link_name)
def showOpenFileDialog(extension=None, where=None, parent=None): if extension is None: extension = "" if where is not None: my_path = path(str(where)).abspath().splitpath()[0] else: my_path = path(settings.get_project_dir()) logger.debug("Search to open file with extension " + extension + " from " + my_path) fname = QtGui.QFileDialog.getOpenFileName(parent, 'Select File to open', my_path, "All (*);;Scripts Files (%s)" % extension) return fname
def showOpenFileDialog(extension=None, where=None, parent=None): if extension is None: extension = "" if where is not None: my_path = path(str(where)).abspath().splitpath()[0] else: my_path = path(settings.get_project_dir()) logger.debug("Search to open file with extension " + extension + " from " + my_path) fname = QtGui.QFileDialog.getOpenFileName( parent, 'Select File to open', my_path, "All (*);;Scripts Files (%s)" % extension) return fname
def __init__(self, proj=None, parent=None): super(CreateProjectWidget, self).__init__(parent) self.widget_metadata = QtGui.QWidget() self.widget_path = QtGui.QWidget() layout_path = QtGui.QFormLayout(self.widget_path) # Name and path if proj is None: date = strftime("%Y%m%d_%H-%M-%S", gmtime()) name = 'project_%s' % date if not proj else proj.name projectdir = path(settings.get_project_dir()) else: name = proj.name projectdir = proj.path.parent self.editor_name = widget('IStr', name) self.editor_projectdir = widget('IDirStr', projectdir) layout_path.addRow(QtGui.QLabel('Name'), self.editor_name) layout_path.addRow(QtGui.QLabel('Project Directory'), self.editor_projectdir) layout_path.setLabelAlignment(QtCore.Qt.AlignLeft) # Metadata self._metadata = {} layout_metadata = QtGui.QFormLayout(self.widget_metadata) layout_metadata.setLabelAlignment(QtCore.Qt.AlignLeft) for cat, metadata in Project.DEFAULT_METADATA.iteritems(): label = QtGui.QLabel(metadata.name.capitalize().replace('_', ' ')) editor = widget(metadata.interface, metadata.value) editor.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Preferred) self._metadata[cat] = editor layout_metadata.addRow(label, editor) if proj: for key in proj.DEFAULT_METADATA: self._metadata[key].setValue(proj.metadata[key]) title = "Edit '%s' metadata" % proj.name else: title = "New Project" layout = QtGui.QVBoxLayout(self) layout.addWidget(QtGui.QLabel(title)) layout.addWidget(self.widget_path) layout.addWidget(self.widget_metadata)
def search_path(): """ Return a list of all path containing projects """ repositories = set() # 1. Add default user project dir repositories.add(Path(settings.get_project_dir())) # 2. Add project repositories defined by packages for plugin in plugins( 'oalab.plugin', criteria=dict(implement="ProjectRepositoryList")): for repository in plugin(): repositories.add(repository) # 3. Read repositories defined by users and saved in config config = settings.Settings() lst = list(repositories) try: s = config.get("ProjectManager", "Path") lst = eval(s, {"path": Path}) except NoSectionError: config.add_section("ProjectManager") config.add_option("ProjectManager", "Path", str([str(path) for path in lst])) except NoOptionError: config.add_option("ProjectManager", "Path", str([str(path) for path in lst])) for repo in lst: repositories.add(repo) # Remove all paths to directories that don't exist final_list = set() for p in repositories: p = Path(p).abspath() if not p.isdir(): continue final_list.add(p) return list(final_list)
def search_path(): """ Return a list of all path containing projects """ repositories = set() # 1. Add default user project dir repositories.add(Path(settings.get_project_dir())) # 2. Add project repositories defined by packages for plugin in plugins('oalab.plugin', criteria=dict(implement="ProjectRepositoryList")): for repository in plugin(): repositories.add(repository) # 3. Read repositories defined by users and saved in config config = settings.Settings() lst = list(repositories) try: s = config.get("ProjectManager", "Path") lst = eval(s, {"path": Path}) except NoSectionError: config.add_section("ProjectManager") config.add_option("ProjectManager", "Path", str([str(path) for path in lst])) except NoOptionError: config.add_option("ProjectManager", "Path", str([str(path) for path in lst])) for repo in lst: repositories.add(repo) # Remove all paths to directories that don't exist final_list = set() for p in repositories: p = Path(p).abspath() if not p.isdir(): continue final_list.add(p) return list(final_list)
def showOpenProjectDialog(self, parent=None): my_path = path(settings.get_project_dir()) fname = QtGui.QFileDialog.getExistingDirectory(parent, 'Select Project Directory', my_path) return fname
def showOpenProjectDialog(self, parent=None): my_path = path(settings.get_project_dir()) fname = QtGui.QFileDialog.getExistingDirectory( parent, 'Select Project Directory', my_path) return fname
def defaultdir(self): return Path(settings.get_project_dir())