Пример #1
0
 def clear_caches(self):  # pylint: disable=import-outside-toplevel
     from Orange.misc import environ
     log.info("Clearing caches")
     self._rm_tree(environ.cache_dir())
     log.info("Clearing data")
     self._rm_tree(environ.data_dir(versioned=True))
     self._rm_tree(environ.data_dir(versioned=False))
Пример #2
0
def data_dir():
    """Return the application data directory. If the directory path
    does not yet exists then create it.

    """
    from Orange.misc import environ
    path = os.path.join(environ.data_dir(), "canvas")

    if not os.path.isdir(path):
        os.makedirs(path, exist_ok=True)
    return path
Пример #3
0
def data_dir():
    """
    Return the Orange application data directory. If the directory path
    does not yet exists then create it.
    """
    path = os.path.join(environ.data_dir(), "canvas")
    try:
        os.makedirs(path, exist_ok=True)
    except OSError:
        pass
    return path
Пример #4
0
    def __init__(self, parent=None):
        QObject.__init__(self, parent)
        assert QThread.currentThread() is QApplication.instance().thread()

        netmanager = self._NETMANAGER_REF and self._NETMANAGER_REF()
        if netmanager is None:
            netmanager = QNetworkAccessManager()
            cache = QNetworkDiskCache()
            cache.setCacheDirectory(
                os.path.join(data_dir(), "geo", __name__ + ".GeoMap.Cache"))
            netmanager.setCache(cache)
            ImageLoader._NETMANAGER_REF = weakref.ref(netmanager)
        self._netmanager = netmanager
Пример #5
0
def tag_list():
    """List of available tags and their pretty-print with indices"""
    server_url = "http://butler.fri.uni-lj.si/datasets/"
    PATH = os.path.join(data_dir(), "datasets")
    local_files = LocalFiles(PATH, serverfiles=ServerFiles(server=server_url))
    local_info = local_files.serverfiles.allinfo()

    nested_tags = [i["tags"] for i in local_info.values() if i["tags"]]
    all_tags = sorted(list(set(itertools.chain(*nested_tags))))
    w = max(len(t) for t in all_tags)
    n = int(75 / (w + 5))

    s = ["{:>3}-{:<{width}}".format(i, t, width=w) for i, t in enumerate(all_tags)]
    c = "\n".join(["".join(s[x:x + n]) for x in range(0, len(s), n)])

    return all_tags, c
def tag_list():
    """List of available tags and their pretty-print with indices"""
    server_url = "http://butler.fri.uni-lj.si/datasets/"
    PATH = os.path.join(data_dir(), "datasets")
    local_files = LocalFiles(PATH, serverfiles=ServerFiles(server=server_url))
    local_info = local_files.serverfiles.allinfo()

    nested_tags = [i["tags"] for i in local_info.values() if i["tags"]]
    all_tags = sorted(list(set(itertools.chain(*nested_tags))))
    w = max(len(t) for t in all_tags)
    n = int(75 / (w + 5))

    s = [
        "{:>3}-{:<{width}}".format(i, t, width=w)
        for i, t in enumerate(all_tags)
    ]
    c = "\n".join(["".join(s[x:x + n]) for x in range(0, len(s), n)])

    return all_tags, c
Пример #7
0
 def __init__(self):
     self.local_data = os.path.join(data_dir(versioned=False), 'udpipe/')
     self.serverfiles = serverfiles.ServerFiles(self.server_url)
     self.localfiles = serverfiles.LocalFiles(self.local_data,
                                              serverfiles=self.serverfiles)
     self._supported_languages = []
Пример #8
0
    def __init__(self):
        super().__init__()
        self.allinfo_local = {}
        self.allinfo_remote = {}

        self.local_cache_path = os.path.join(data_dir(), self.DATASET_DIR)
        # current_output does not equal selected_id when, for instance, the
        # data is still downloading
        self.current_output = None

        self._header_labels = [
            header['label'] for _, header in self.HEADER_SCHEMA]
        self._header_index = namedtuple(
            '_header_index', [info_tag for info_tag, _ in self.HEADER_SCHEMA])
        self.Header = self._header_index(
            *[index for index, _ in enumerate(self._header_labels)])

        self.__awaiting_state = None  # type: Optional[_FetchState]

        self.filterLineEdit = QLineEdit(
            textChanged=self.filter, placeholderText="Search for data set ..."
        )
        self.mainArea.layout().addWidget(self.filterLineEdit)

        self.splitter = QSplitter(orientation=Qt.Vertical)

        self.view = TreeViewWithReturn(
            sortingEnabled=True,
            selectionMode=QTreeView.SingleSelection,
            alternatingRowColors=True,
            rootIsDecorated=False,
            editTriggers=QTreeView.NoEditTriggers,
            uniformRowHeights=True,
            toolTip="Press Return or double-click to send"
        )
        # the method doesn't exists yet, pylint: disable=unnecessary-lambda
        self.view.doubleClicked.connect(self.commit)
        self.view.returnPressed.connect(self.commit)
        box = gui.widgetBox(self.splitter, "说明", addToLayout=False)
        self.descriptionlabel = QLabel(
            wordWrap=True,
            textFormat=Qt.RichText,
        )
        self.descriptionlabel = QTextBrowser(
            openExternalLinks=True,
            textInteractionFlags=(Qt.TextSelectableByMouse |
                                  Qt.LinksAccessibleByMouse)
        )
        self.descriptionlabel.setFrameStyle(QTextBrowser.NoFrame)
        # no (white) text background
        self.descriptionlabel.viewport().setAutoFillBackground(False)

        box.layout().addWidget(self.descriptionlabel)
        self.splitter.addWidget(self.view)
        self.splitter.addWidget(box)

        self.splitter.setSizes([300, 200])
        self.splitter.splitterMoved.connect(
            lambda:
            setattr(self, "splitter_state", bytes(self.splitter.saveState()))
        )
        self.mainArea.layout().addWidget(self.splitter)

        proxy = QSortFilterProxyModel()
        proxy.setFilterKeyColumn(-1)
        proxy.setFilterCaseSensitivity(False)
        self.view.setModel(proxy)

        if self.splitter_state:
            self.splitter.restoreState(self.splitter_state)

        self.assign_delegates()

        self.setBlocking(True)
        self.setStatusMessage("Initializing")

        self._executor = ThreadPoolExecutor(max_workers=1)
        f = self._executor.submit(self.list_remote)
        w = FutureWatcher(f, parent=self)
        w.done.connect(self.__set_index)
Пример #9
0
 def __init__(self):
     self.local_data = os.path.join(data_dir(versioned=False), 'sentiment/')
     self.serverfiles = serverfiles.ServerFiles(self.server_url)
     self.localfiles = serverfiles.LocalFiles(self.local_data,
                                              serverfiles=self.serverfiles)
     self._supported_languages = []
Пример #10
0
 def __init__(self):
     self.local_data = os.path.join(data_dir(versioned=False), 'udpipe/')
     self.serverfiles = serverfiles.ServerFiles(self.server_url)
     self.localfiles = serverfiles.LocalFiles(self.local_data,
                                              serverfiles=self.serverfiles)
Пример #11
0
def local_cache_path():
    return os.path.join(data_dir(), "datasets")
Пример #12
0
import os

import serverfiles
from Orange.misc.environ import data_dir

import orangecontrib.infrared  # loads file readers


server = serverfiles.ServerFiles("http://193.2.72.57/infrared-data/")
localfiles = serverfiles.LocalFiles(
    os.path.join(data_dir(), "orange-infrared"), serverfiles=server)


def spectra20nea():
    return localfiles.localpath_download("spectra20.nea")

def dust():
    localfiles.localpath_download("20160831_06_Paris_25x_highmag.dat")
    return localfiles.localpath_download("20160831_06_Paris_25x_highmag.hdr")
Пример #13
0
import os

import serverfiles
from Orange.misc.environ import data_dir

import orangecontrib.spectroscopy  # loads file readers

server = serverfiles.ServerFiles("http://193.2.72.57/infrared-data/")
localfiles = serverfiles.LocalFiles(os.path.join(data_dir(),
                                                 "orange-infrared"),
                                    serverfiles=server)


def spectra20nea():
    return localfiles.localpath_download("spectra20.nea")


def dust():
    localfiles.localpath_download("20160831_06_Paris_25x_highmag.dat")
    return localfiles.localpath_download("20160831_06_Paris_25x_highmag.hdr")
Пример #14
0
import os

from Orange.misc.environ import data_dir


def progress_bar_milestones(count, iterations=100):
    return set([int(i * count / float(iterations)) for i in range(iterations)])


local_cache = os.path.join(data_dir(), 'bioinformatics/')


def ensure_type(value, types):
    if isinstance(value, types):
        return value
    else:
        raise TypeError(
            'Wrong variable type. {value} is {value_type}, but should be {types}'
            .format(value=value, value_type=type(value), types=types))
Пример #15
0
    def __init__(self):
        super().__init__()
        self.local_cache_path = os.path.join(data_dir(), self.DATASET_DIR)

        self.__awaiting_state = None  # type: Optional[_FetchState]

        box = gui.widgetBox(self.controlArea, "Info")

        self.infolabel = QLabel(text="Initializing...\n\n")
        box.layout().addWidget(self.infolabel)

        gui.widgetLabel(self.mainArea, "Filter")
        self.filterLineEdit = QLineEdit(
            textChanged=self.filter
        )
        self.mainArea.layout().addWidget(self.filterLineEdit)

        self.splitter = QSplitter(orientation=Qt.Vertical)

        self.view = QTreeView(
            sortingEnabled=True,
            selectionMode=QTreeView.SingleSelection,
            alternatingRowColors=True,
            rootIsDecorated=False,
            editTriggers=QTreeView.NoEditTriggers,
        )

        box = gui.widgetBox(self.splitter, "Description", addToLayout=False)
        self.descriptionlabel = QLabel(
            wordWrap=True,
            textFormat=Qt.RichText,
        )
        self.descriptionlabel = QTextBrowser(
            openExternalLinks=True,
            textInteractionFlags=(Qt.TextSelectableByMouse |
                                  Qt.LinksAccessibleByMouse)
        )
        self.descriptionlabel.setFrameStyle(QTextBrowser.NoFrame)
        # no (white) text background
        self.descriptionlabel.viewport().setAutoFillBackground(False)

        box.layout().addWidget(self.descriptionlabel)
        self.splitter.addWidget(self.view)
        self.splitter.addWidget(box)

        self.splitter.setSizes([300, 200])
        self.splitter.splitterMoved.connect(
            lambda:
            setattr(self, "splitter_state", bytes(self.splitter.saveState()))
        )
        self.mainArea.layout().addWidget(self.splitter)
        self.controlArea.layout().addStretch(10)
        gui.auto_commit(self.controlArea, self, "auto_commit", "Send Data")

        model = QStandardItemModel(self)
        model.setHorizontalHeaderLabels(HEADER)
        proxy = QSortFilterProxyModel()
        proxy.setSourceModel(model)
        proxy.setFilterKeyColumn(-1)
        proxy.setFilterCaseSensitivity(False)
        self.view.setModel(proxy)

        if self.splitter_state:
            self.splitter.restoreState(self.splitter_state)

        self.view.setItemDelegateForColumn(
            Header.Size, SizeDelegate(self))
        self.view.setItemDelegateForColumn(
            Header.Local, gui.IndicatorItemDelegate(self, role=Qt.DisplayRole))
        self.view.setItemDelegateForColumn(
            Header.Instances, NumericalDelegate(self))
        self.view.setItemDelegateForColumn(
            Header.Variables, NumericalDelegate(self))

        self.view.resizeColumnToContents(Header.Local)

        if self.header_state:
            self.view.header().restoreState(self.header_state)

        self.setBlocking(True)
        self.setStatusMessage("Initializing")

        self._executor = ThreadPoolExecutor(max_workers=1)
        f = self._executor.submit(self.list_remote)
        w = FutureWatcher(f, parent=self)
        w.done.connect(self.__set_index)
Пример #16
0
def local_cache_path(path):
    return os.path.join(data_dir(), path)
Пример #17
0
import os

import serverfiles
from Orange.misc.environ import data_dir

import orangecontrib.spectroscopy  # loads file readers


server = serverfiles.ServerFiles("http://193.2.72.57/infrared-data/")
localfiles = serverfiles.LocalFiles(
    os.path.join(data_dir(), "orange-infrared"), serverfiles=server)


def spectra20nea():
    return localfiles.localpath_download("spectra20.nea")

def dust():
    localfiles.localpath_download("20160831_06_Paris_25x_highmag.dat")
    return localfiles.localpath_download("20160831_06_Paris_25x_highmag.hdr")
Пример #18
0
"""
import os
import json

import numpy as np
from serverfiles import LocalFiles, ServerFiles

from Orange.data import Table, Domain, StringVariable, DiscreteVariable
from Orange.data import filter as table_filter
from Orange.misc.environ import data_dir

from orangecontrib.bioinformatics.widgets.utils.data import TableAnnotation

domain = 'geo'
_local_cache_path = os.path.join(data_dir(), domain)
_all_info_file = os.path.join(_local_cache_path, '__INFO__')
_server_url = 'http://download.biolab.si/datasets/geo/'
pubmed_url = 'http://www.ncbi.nlm.nih.gov/pubmed/{}'

server_files = ServerFiles(server=_server_url)
local_files = LocalFiles(_local_cache_path, serverfiles=server_files)


def is_cached(gds_id):
    return os.path.exists(os.path.join(_local_cache_path, gds_id + '.tab'))


def info_cache(f):
    """Store content of __INFO__ file locally."""
Пример #19
0
    def __init__(self):
        super().__init__()
        self.local_cache_path = os.path.join(data_dir(), self.DATASET_DIR)

        self._header_labels = [header['label'] for _, header in self.HEADER_SCHEMA]
        self._header_index = namedtuple('_header_index', [info_tag for info_tag, _ in self.HEADER_SCHEMA])
        self.Header = self._header_index(*[index for index, _ in enumerate(self._header_labels)])

        self.__awaiting_state = None  # type: Optional[_FetchState]

        box = gui.widgetBox(self.controlArea, "Info")

        self.infolabel = QLabel(text="Initializing...\n\n")
        box.layout().addWidget(self.infolabel)

        gui.widgetLabel(self.mainArea, "Filter")
        self.filterLineEdit = QLineEdit(
            textChanged=self.filter
        )
        self.mainArea.layout().addWidget(self.filterLineEdit)

        self.splitter = QSplitter(orientation=Qt.Vertical)

        self.view = QTreeView(
            sortingEnabled=True,
            selectionMode=QTreeView.SingleSelection,
            alternatingRowColors=True,
            rootIsDecorated=False,
            editTriggers=QTreeView.NoEditTriggers,
            uniformRowHeights=True,
        )
        box = gui.widgetBox(self.splitter, "Description", addToLayout=False)
        self.descriptionlabel = QLabel(
            wordWrap=True,
            textFormat=Qt.RichText,
        )
        self.descriptionlabel = QTextBrowser(
            openExternalLinks=True,
            textInteractionFlags=(Qt.TextSelectableByMouse |
                                  Qt.LinksAccessibleByMouse)
        )
        self.descriptionlabel.setFrameStyle(QTextBrowser.NoFrame)
        # no (white) text background
        self.descriptionlabel.viewport().setAutoFillBackground(False)

        box.layout().addWidget(self.descriptionlabel)
        self.splitter.addWidget(self.view)
        self.splitter.addWidget(box)

        self.splitter.setSizes([300, 200])
        self.splitter.splitterMoved.connect(
            lambda:
            setattr(self, "splitter_state", bytes(self.splitter.saveState()))
        )
        self.mainArea.layout().addWidget(self.splitter)
        self.controlArea.layout().addStretch(10)
        gui.auto_commit(self.controlArea, self, "auto_commit", "Send Data")

        proxy = QSortFilterProxyModel()
        proxy.setFilterKeyColumn(-1)
        proxy.setFilterCaseSensitivity(False)
        self.view.setModel(proxy)

        if self.splitter_state:
            self.splitter.restoreState(self.splitter_state)

        self.assign_delegates()

        self.setBlocking(True)
        self.setStatusMessage("Initializing")

        self._executor = ThreadPoolExecutor(max_workers=1)
        f = self._executor.submit(self.list_remote)
        w = FutureWatcher(f, parent=self)
        w.done.connect(self.__set_index)