id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
45,100
spyder-ide/conda-manager
setup.py
get_data_files
def get_data_files(): """Return data_files in a platform dependent manner""" if sys.platform.startswith('linux'): if PY3: data_files = [('share/applications', ['scripts/condamanager3.desktop']), ('share/pixmaps', ...
python
def get_data_files(): """Return data_files in a platform dependent manner""" if sys.platform.startswith('linux'): if PY3: data_files = [('share/applications', ['scripts/condamanager3.desktop']), ('share/pixmaps', ...
[ "def", "get_data_files", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", ":", "if", "PY3", ":", "data_files", "=", "[", "(", "'share/applications'", ",", "[", "'scripts/condamanager3.desktop'", "]", ")", ",", "(", "'sha...
Return data_files in a platform dependent manner
[ "Return", "data_files", "in", "a", "platform", "dependent", "manner" ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/setup.py#L32-L49
45,101
spyder-ide/conda-manager
conda_manager/utils/encoding.py
encode
def encode(text, orig_coding): """ Function to encode a text. @param text text to encode (string) @param orig_coding type of the original coding (string) @return encoded text and encoding """ if orig_coding == 'utf-8-bom': return BOM_UTF8 + text.encode("utf-8"), 'utf-8-bom' ...
python
def encode(text, orig_coding): """ Function to encode a text. @param text text to encode (string) @param orig_coding type of the original coding (string) @return encoded text and encoding """ if orig_coding == 'utf-8-bom': return BOM_UTF8 + text.encode("utf-8"), 'utf-8-bom' ...
[ "def", "encode", "(", "text", ",", "orig_coding", ")", ":", "if", "orig_coding", "==", "'utf-8-bom'", ":", "return", "BOM_UTF8", "+", "text", ".", "encode", "(", "\"utf-8\"", ")", ",", "'utf-8-bom'", "# Try declared coding spec\r", "coding", "=", "get_coding", ...
Function to encode a text. @param text text to encode (string) @param orig_coding type of the original coding (string) @return encoded text and encoding
[ "Function", "to", "encode", "a", "text", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/utils/encoding.py#L151-L184
45,102
spyder-ide/conda-manager
conda_manager/utils/qthelpers.py
qapplication
def qapplication(translate=True, test_time=3): """Return QApplication instance Creates it if it doesn't already exist""" app = QApplication.instance() if app is None: app = QApplication(['Conda-Manager']) app.setApplicationName('Conda-Manager') if translate: install_t...
python
def qapplication(translate=True, test_time=3): """Return QApplication instance Creates it if it doesn't already exist""" app = QApplication.instance() if app is None: app = QApplication(['Conda-Manager']) app.setApplicationName('Conda-Manager') if translate: install_t...
[ "def", "qapplication", "(", "translate", "=", "True", ",", "test_time", "=", "3", ")", ":", "app", "=", "QApplication", ".", "instance", "(", ")", "if", "app", "is", "None", ":", "app", "=", "QApplication", "(", "[", "'Conda-Manager'", "]", ")", "app",...
Return QApplication instance Creates it if it doesn't already exist
[ "Return", "QApplication", "instance", "Creates", "it", "if", "it", "doesn", "t", "already", "exist" ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/utils/qthelpers.py#L20-L35
45,103
berlincode/sjcl
sjcl/sjcl.py
get_aes_mode
def get_aes_mode(mode): """Return pycrypto's AES mode, raise exception if not supported""" aes_mode_attr = "MODE_{}".format(mode.upper()) try: aes_mode = getattr(AES, aes_mode_attr) except AttributeError: raise Exception( "Pycrypto/pycryptodome does not seem to support {}. "....
python
def get_aes_mode(mode): """Return pycrypto's AES mode, raise exception if not supported""" aes_mode_attr = "MODE_{}".format(mode.upper()) try: aes_mode = getattr(AES, aes_mode_attr) except AttributeError: raise Exception( "Pycrypto/pycryptodome does not seem to support {}. "....
[ "def", "get_aes_mode", "(", "mode", ")", ":", "aes_mode_attr", "=", "\"MODE_{}\"", ".", "format", "(", "mode", ".", "upper", "(", ")", ")", "try", ":", "aes_mode", "=", "getattr", "(", "AES", ",", "aes_mode_attr", ")", "except", "AttributeError", ":", "r...
Return pycrypto's AES mode, raise exception if not supported
[ "Return", "pycrypto", "s", "AES", "mode", "raise", "exception", "if", "not", "supported" ]
e8bdad312fa99c89c74f8651a1240afba8a9f3bd
https://github.com/berlincode/sjcl/blob/e8bdad312fa99c89c74f8651a1240afba8a9f3bd/sjcl/sjcl.py#L68-L78
45,104
spyder-ide/conda-manager
conda_manager/api/download_api.py
process_proxy_servers
def process_proxy_servers(proxy_settings): """Split the proxy conda configuration to be used by the proxy factory.""" proxy_settings_dic = {} for key in proxy_settings: proxy = proxy_settings[key] proxy_config = [m.groupdict() for m in PROXY_RE.finditer(proxy)] if proxy_config: ...
python
def process_proxy_servers(proxy_settings): """Split the proxy conda configuration to be used by the proxy factory.""" proxy_settings_dic = {} for key in proxy_settings: proxy = proxy_settings[key] proxy_config = [m.groupdict() for m in PROXY_RE.finditer(proxy)] if proxy_config: ...
[ "def", "process_proxy_servers", "(", "proxy_settings", ")", ":", "proxy_settings_dic", "=", "{", "}", "for", "key", "in", "proxy_settings", ":", "proxy", "=", "proxy_settings", "[", "key", "]", "proxy_config", "=", "[", "m", ".", "groupdict", "(", ")", "for"...
Split the proxy conda configuration to be used by the proxy factory.
[ "Split", "the", "proxy", "conda", "configuration", "to", "be", "used", "by", "the", "proxy", "factory", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L41-L60
45,105
spyder-ide/conda-manager
conda_manager/api/download_api.py
NetworkProxyFactory.proxy_servers
def proxy_servers(self): """ Return the proxy servers available. First env variables will be searched and updated with values from condarc config file. """ proxy_servers = {} if self._load_rc_func is None: return proxy_servers else: ...
python
def proxy_servers(self): """ Return the proxy servers available. First env variables will be searched and updated with values from condarc config file. """ proxy_servers = {} if self._load_rc_func is None: return proxy_servers else: ...
[ "def", "proxy_servers", "(", "self", ")", ":", "proxy_servers", "=", "{", "}", "if", "self", ".", "_load_rc_func", "is", "None", ":", "return", "proxy_servers", "else", ":", "HTTP_PROXY", "=", "os", ".", "environ", ".", "get", "(", "'HTTP_PROXY'", ")", "...
Return the proxy servers available. First env variables will be searched and updated with values from condarc config file.
[ "Return", "the", "proxy", "servers", "available", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L72-L95
45,106
spyder-ide/conda-manager
conda_manager/api/download_api.py
NetworkProxyFactory._create_proxy
def _create_proxy(proxy_setting): """Create a Network proxy for the given proxy settings.""" proxy = QNetworkProxy() proxy_scheme = proxy_setting['scheme'] proxy_host = proxy_setting['host'] proxy_port = proxy_setting['port'] proxy_username = proxy_setting['username'] ...
python
def _create_proxy(proxy_setting): """Create a Network proxy for the given proxy settings.""" proxy = QNetworkProxy() proxy_scheme = proxy_setting['scheme'] proxy_host = proxy_setting['host'] proxy_port = proxy_setting['port'] proxy_username = proxy_setting['username'] ...
[ "def", "_create_proxy", "(", "proxy_setting", ")", ":", "proxy", "=", "QNetworkProxy", "(", ")", "proxy_scheme", "=", "proxy_setting", "[", "'scheme'", "]", "proxy_host", "=", "proxy_setting", "[", "'host'", "]", "proxy_port", "=", "proxy_setting", "[", "'port'"...
Create a Network proxy for the given proxy settings.
[ "Create", "a", "Network", "proxy", "for", "the", "given", "proxy", "settings", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L98-L122
45,107
spyder-ide/conda-manager
conda_manager/api/download_api.py
_DownloadAPI._request_finished
def _request_finished(self, reply): """Callback for download once the request has finished.""" url = to_text_string(reply.url().toEncoded(), encoding='utf-8') if url in self._paths: path = self._paths[url] if url in self._workers: worker = self._workers[url] ...
python
def _request_finished(self, reply): """Callback for download once the request has finished.""" url = to_text_string(reply.url().toEncoded(), encoding='utf-8') if url in self._paths: path = self._paths[url] if url in self._workers: worker = self._workers[url] ...
[ "def", "_request_finished", "(", "self", ",", "reply", ")", ":", "url", "=", "to_text_string", "(", "reply", ".", "url", "(", ")", ".", "toEncoded", "(", ")", ",", "encoding", "=", "'utf-8'", ")", "if", "url", "in", "self", ".", "_paths", ":", "path"...
Callback for download once the request has finished.
[ "Callback", "for", "download", "once", "the", "request", "has", "finished", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L243-L298
45,108
spyder-ide/conda-manager
conda_manager/api/download_api.py
_DownloadAPI._save
def _save(self, url, path, data): """Save `data` of downloaded `url` in `path`.""" worker = self._workers[url] path = self._paths[url] if len(data): try: with open(path, 'wb') as f: f.write(data) except Exception: ...
python
def _save(self, url, path, data): """Save `data` of downloaded `url` in `path`.""" worker = self._workers[url] path = self._paths[url] if len(data): try: with open(path, 'wb') as f: f.write(data) except Exception: ...
[ "def", "_save", "(", "self", ",", "url", ",", "path", ",", "data", ")", ":", "worker", "=", "self", ".", "_workers", "[", "url", "]", "path", "=", "self", ".", "_paths", "[", "url", "]", "if", "len", "(", "data", ")", ":", "try", ":", "with", ...
Save `data` of downloaded `url` in `path`.
[ "Save", "data", "of", "downloaded", "url", "in", "path", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L300-L318
45,109
spyder-ide/conda-manager
conda_manager/api/download_api.py
_DownloadAPI._progress
def _progress(bytes_received, bytes_total, worker): """Return download progress.""" worker.sig_download_progress.emit( worker.url, worker.path, bytes_received, bytes_total)
python
def _progress(bytes_received, bytes_total, worker): """Return download progress.""" worker.sig_download_progress.emit( worker.url, worker.path, bytes_received, bytes_total)
[ "def", "_progress", "(", "bytes_received", ",", "bytes_total", ",", "worker", ")", ":", "worker", ".", "sig_download_progress", ".", "emit", "(", "worker", ".", "url", ",", "worker", ".", "path", ",", "bytes_received", ",", "bytes_total", ")" ]
Return download progress.
[ "Return", "download", "progress", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L321-L324
45,110
spyder-ide/conda-manager
conda_manager/api/download_api.py
_DownloadAPI.download
def download(self, url, path): """Download url and save data to path.""" # original_url = url # print(url) qurl = QUrl(url) url = to_text_string(qurl.toEncoded(), encoding='utf-8') logger.debug(str((url, path))) if url in self._workers: while not self....
python
def download(self, url, path): """Download url and save data to path.""" # original_url = url # print(url) qurl = QUrl(url) url = to_text_string(qurl.toEncoded(), encoding='utf-8') logger.debug(str((url, path))) if url in self._workers: while not self....
[ "def", "download", "(", "self", ",", "url", ",", "path", ")", ":", "# original_url = url", "# print(url)", "qurl", "=", "QUrl", "(", "url", ")", "url", "=", "to_text_string", "(", "qurl", ".", "toEncoded", "(", ")", ",", "encoding", "=", "'utf-8'", ...
Download url and save data to path.
[ "Download", "url", "and", "save", "data", "to", "path", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L326-L352
45,111
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI._start
def _start(self): """Start the next threaded worker in the queue.""" if len(self._queue) == 1: thread = self._queue.popleft() thread.start() self._timer.start()
python
def _start(self): """Start the next threaded worker in the queue.""" if len(self._queue) == 1: thread = self._queue.popleft() thread.start() self._timer.start()
[ "def", "_start", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_queue", ")", "==", "1", ":", "thread", "=", "self", ".", "_queue", ".", "popleft", "(", ")", "thread", ".", "start", "(", ")", "self", ".", "_timer", ".", "start", "(", ")...
Start the next threaded worker in the queue.
[ "Start", "the", "next", "threaded", "worker", "in", "the", "queue", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L437-L442
45,112
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI._create_worker
def _create_worker(self, method, *args, **kwargs): """Create a new worker instance.""" thread = QThread() worker = RequestsDownloadWorker(method, args, kwargs) worker.moveToThread(thread) worker.sig_finished.connect(self._start) self._sig_download_finished.connect(worker....
python
def _create_worker(self, method, *args, **kwargs): """Create a new worker instance.""" thread = QThread() worker = RequestsDownloadWorker(method, args, kwargs) worker.moveToThread(thread) worker.sig_finished.connect(self._start) self._sig_download_finished.connect(worker....
[ "def", "_create_worker", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "thread", "=", "QThread", "(", ")", "worker", "=", "RequestsDownloadWorker", "(", "method", ",", "args", ",", "kwargs", ")", "worker", ".", "moveT...
Create a new worker instance.
[ "Create", "a", "new", "worker", "instance", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L444-L458
45,113
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI._download
def _download(self, url, path=None, force=False): """Callback for download.""" if path is None: path = url.split('/')[-1] # Make dir if non existent folder = os.path.dirname(os.path.abspath(path)) if not os.path.isdir(folder): os.makedirs(folder) ...
python
def _download(self, url, path=None, force=False): """Callback for download.""" if path is None: path = url.split('/')[-1] # Make dir if non existent folder = os.path.dirname(os.path.abspath(path)) if not os.path.isdir(folder): os.makedirs(folder) ...
[ "def", "_download", "(", "self", ",", "url", ",", "path", "=", "None", ",", "force", "=", "False", ")", ":", "if", "path", "is", "None", ":", "path", "=", "url", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "# Make dir if non existent", "fold...
Callback for download.
[ "Callback", "for", "download", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L460-L504
45,114
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI._is_valid_url
def _is_valid_url(self, url): """Callback for is_valid_url.""" try: r = requests.head(url, proxies=self.proxy_servers) value = r.status_code in [200] except Exception as error: logger.error(str(error)) value = False return value
python
def _is_valid_url(self, url): """Callback for is_valid_url.""" try: r = requests.head(url, proxies=self.proxy_servers) value = r.status_code in [200] except Exception as error: logger.error(str(error)) value = False return value
[ "def", "_is_valid_url", "(", "self", ",", "url", ")", ":", "try", ":", "r", "=", "requests", ".", "head", "(", "url", ",", "proxies", "=", "self", ".", "proxy_servers", ")", "value", "=", "r", ".", "status_code", "in", "[", "200", "]", "except", "E...
Callback for is_valid_url.
[ "Callback", "for", "is_valid_url", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L506-L515
45,115
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI._is_valid_channel
def _is_valid_channel(self, channel, conda_url='https://conda.anaconda.org'): """Callback for is_valid_channel.""" if channel.startswith('https://') or channel.startswith('http://'): url = channel else: url = "{0}/{1}".format(conda_url, channel) ...
python
def _is_valid_channel(self, channel, conda_url='https://conda.anaconda.org'): """Callback for is_valid_channel.""" if channel.startswith('https://') or channel.startswith('http://'): url = channel else: url = "{0}/{1}".format(conda_url, channel) ...
[ "def", "_is_valid_channel", "(", "self", ",", "channel", ",", "conda_url", "=", "'https://conda.anaconda.org'", ")", ":", "if", "channel", ".", "startswith", "(", "'https://'", ")", "or", "channel", ".", "startswith", "(", "'http://'", ")", ":", "url", "=", ...
Callback for is_valid_channel.
[ "Callback", "for", "is_valid_channel", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L517-L538
45,116
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI._is_valid_api_url
def _is_valid_api_url(self, url): """Callback for is_valid_api_url.""" # Check response is a JSON with ok: 1 data = {} try: r = requests.get(url, proxies=self.proxy_servers) content = to_text_string(r.content, encoding='utf-8') data = json.loads(conten...
python
def _is_valid_api_url(self, url): """Callback for is_valid_api_url.""" # Check response is a JSON with ok: 1 data = {} try: r = requests.get(url, proxies=self.proxy_servers) content = to_text_string(r.content, encoding='utf-8') data = json.loads(conten...
[ "def", "_is_valid_api_url", "(", "self", ",", "url", ")", ":", "# Check response is a JSON with ok: 1", "data", "=", "{", "}", "try", ":", "r", "=", "requests", ".", "get", "(", "url", ",", "proxies", "=", "self", ".", "proxy_servers", ")", "content", "=",...
Callback for is_valid_api_url.
[ "Callback", "for", "is_valid_api_url", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L540-L551
45,117
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI.download
def download(self, url, path=None, force=False): """Download file given by url and save it to path.""" logger.debug(str((url, path, force))) method = self._download return self._create_worker(method, url, path=path, force=force)
python
def download(self, url, path=None, force=False): """Download file given by url and save it to path.""" logger.debug(str((url, path, force))) method = self._download return self._create_worker(method, url, path=path, force=force)
[ "def", "download", "(", "self", ",", "url", ",", "path", "=", "None", ",", "force", "=", "False", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "url", ",", "path", ",", "force", ")", ")", ")", "method", "=", "self", ".", "_download", ...
Download file given by url and save it to path.
[ "Download", "file", "given", "by", "url", "and", "save", "it", "to", "path", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L555-L559
45,118
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI.terminate
def terminate(self): """Terminate all workers and threads.""" for t in self._threads: t.quit() self._thread = [] self._workers = []
python
def terminate(self): """Terminate all workers and threads.""" for t in self._threads: t.quit() self._thread = [] self._workers = []
[ "def", "terminate", "(", "self", ")", ":", "for", "t", "in", "self", ".", "_threads", ":", "t", ".", "quit", "(", ")", "self", ".", "_thread", "=", "[", "]", "self", ".", "_workers", "=", "[", "]" ]
Terminate all workers and threads.
[ "Terminate", "all", "workers", "and", "threads", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L561-L566
45,119
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI.is_valid_url
def is_valid_url(self, url, non_blocking=True): """Check if url is valid.""" logger.debug(str((url))) if non_blocking: method = self._is_valid_url return self._create_worker(method, url) else: return self._is_valid_url(url)
python
def is_valid_url(self, url, non_blocking=True): """Check if url is valid.""" logger.debug(str((url))) if non_blocking: method = self._is_valid_url return self._create_worker(method, url) else: return self._is_valid_url(url)
[ "def", "is_valid_url", "(", "self", ",", "url", ",", "non_blocking", "=", "True", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "url", ")", ")", ")", "if", "non_blocking", ":", "method", "=", "self", ".", "_is_valid_url", "return", "self", ...
Check if url is valid.
[ "Check", "if", "url", "is", "valid", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L568-L575
45,120
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI.is_valid_api_url
def is_valid_api_url(self, url, non_blocking=True): """Check if anaconda api url is valid.""" logger.debug(str((url))) if non_blocking: method = self._is_valid_api_url return self._create_worker(method, url) else: return self._is_valid_api_url(url=url)
python
def is_valid_api_url(self, url, non_blocking=True): """Check if anaconda api url is valid.""" logger.debug(str((url))) if non_blocking: method = self._is_valid_api_url return self._create_worker(method, url) else: return self._is_valid_api_url(url=url)
[ "def", "is_valid_api_url", "(", "self", ",", "url", ",", "non_blocking", "=", "True", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "url", ")", ")", ")", "if", "non_blocking", ":", "method", "=", "self", ".", "_is_valid_api_url", "return", "s...
Check if anaconda api url is valid.
[ "Check", "if", "anaconda", "api", "url", "is", "valid", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L577-L584
45,121
spyder-ide/conda-manager
conda_manager/api/download_api.py
_RequestsDownloadAPI.is_valid_channel
def is_valid_channel(self, channel, conda_url='https://conda.anaconda.org', non_blocking=True): """Check if a conda channel is valid.""" logger.debug(str((channel, conda_url))) if non_blocking: method = self._...
python
def is_valid_channel(self, channel, conda_url='https://conda.anaconda.org', non_blocking=True): """Check if a conda channel is valid.""" logger.debug(str((channel, conda_url))) if non_blocking: method = self._...
[ "def", "is_valid_channel", "(", "self", ",", "channel", ",", "conda_url", "=", "'https://conda.anaconda.org'", ",", "non_blocking", "=", "True", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "channel", ",", "conda_url", ")", ")", ")", "if", "non_...
Check if a conda channel is valid.
[ "Check", "if", "a", "conda", "channel", "is", "valid", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/download_api.py#L586-L596
45,122
spyder-ide/conda-manager
conda_manager/utils/misc.py
human_bytes
def human_bytes(n): """ Return the number of bytes n in more human readable form. """ if n < 1024: return '%d B' % n k = n/1024 if k < 1024: return '%d KB' % round(k) m = k/1024 if m < 1024: return '%.1f MB' % m g = m/1024 return '%.2f GB' % g
python
def human_bytes(n): """ Return the number of bytes n in more human readable form. """ if n < 1024: return '%d B' % n k = n/1024 if k < 1024: return '%d KB' % round(k) m = k/1024 if m < 1024: return '%.1f MB' % m g = m/1024 return '%.2f GB' % g
[ "def", "human_bytes", "(", "n", ")", ":", "if", "n", "<", "1024", ":", "return", "'%d B'", "%", "n", "k", "=", "n", "/", "1024", "if", "k", "<", "1024", ":", "return", "'%d KB'", "%", "round", "(", "k", ")", "m", "=", "k", "/", "1024", "if", ...
Return the number of bytes n in more human readable form.
[ "Return", "the", "number", "of", "bytes", "n", "in", "more", "human", "readable", "form", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/utils/misc.py#L3-L16
45,123
spyder-ide/conda-manager
conda_manager/api/conda_api.py
ready_print
def ready_print(worker, output, error): # pragma : no cover """Local test helper.""" global COUNTER COUNTER += 1 print(COUNTER, output, error)
python
def ready_print(worker, output, error): # pragma : no cover """Local test helper.""" global COUNTER COUNTER += 1 print(COUNTER, output, error)
[ "def", "ready_print", "(", "worker", ",", "output", ",", "error", ")", ":", "# pragma : no cover", "global", "COUNTER", "COUNTER", "+=", "1", "print", "(", "COUNTER", ",", "output", ",", "error", ")" ]
Local test helper.
[ "Local", "test", "helper", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L1128-L1132
45,124
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._clean
def _clean(self): """Remove references of inactive workers periodically.""" if self._workers: for w in self._workers: if w.is_finished(): self._workers.remove(w) else: self._current_worker = None self._timer.stop()
python
def _clean(self): """Remove references of inactive workers periodically.""" if self._workers: for w in self._workers: if w.is_finished(): self._workers.remove(w) else: self._current_worker = None self._timer.stop()
[ "def", "_clean", "(", "self", ")", ":", "if", "self", ".", "_workers", ":", "for", "w", "in", "self", ".", "_workers", ":", "if", "w", ".", "is_finished", "(", ")", ":", "self", ".", "_workers", ".", "remove", "(", "w", ")", "else", ":", "self", ...
Remove references of inactive workers periodically.
[ "Remove", "references", "of", "inactive", "workers", "periodically", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L268-L276
45,125
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._call_conda
def _call_conda(self, extra_args, abspath=True, parse=False, callback=None): """ Call conda with the list of extra arguments, and return the worker. The result can be force by calling worker.communicate(), which returns the tuple (stdout, stderr). """ ...
python
def _call_conda(self, extra_args, abspath=True, parse=False, callback=None): """ Call conda with the list of extra arguments, and return the worker. The result can be force by calling worker.communicate(), which returns the tuple (stdout, stderr). """ ...
[ "def", "_call_conda", "(", "self", ",", "extra_args", ",", "abspath", "=", "True", ",", "parse", "=", "False", ",", "callback", "=", "None", ")", ":", "if", "abspath", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "python", "=", "join", "(...
Call conda with the list of extra arguments, and return the worker. The result can be force by calling worker.communicate(), which returns the tuple (stdout, stderr).
[ "Call", "conda", "with", "the", "list", "of", "extra", "arguments", "and", "return", "the", "worker", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L296-L325
45,126
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._setup_install_commands_from_kwargs
def _setup_install_commands_from_kwargs(kwargs, keys=tuple()): """Setup install commands for conda.""" cmd_list = [] if kwargs.get('override_channels', False) and 'channel' not in kwargs: raise TypeError('conda search: override_channels requires channel') if 'env' in kwargs:...
python
def _setup_install_commands_from_kwargs(kwargs, keys=tuple()): """Setup install commands for conda.""" cmd_list = [] if kwargs.get('override_channels', False) and 'channel' not in kwargs: raise TypeError('conda search: override_channels requires channel') if 'env' in kwargs:...
[ "def", "_setup_install_commands_from_kwargs", "(", "kwargs", ",", "keys", "=", "tuple", "(", ")", ")", ":", "cmd_list", "=", "[", "]", "if", "kwargs", ".", "get", "(", "'override_channels'", ",", "False", ")", "and", "'channel'", "not", "in", "kwargs", ":"...
Setup install commands for conda.
[ "Setup", "install", "commands", "for", "conda", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L332-L354
45,127
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._get_conda_version
def _get_conda_version(stdout, stderr): """Callback for get_conda_version.""" # argparse outputs version to stderr in Python < 3.4. # http://bugs.python.org/issue18920 pat = re.compile(r'conda:?\s+(\d+\.\d\S+|unknown)') m = pat.match(stderr.decode().strip()) if m is None:...
python
def _get_conda_version(stdout, stderr): """Callback for get_conda_version.""" # argparse outputs version to stderr in Python < 3.4. # http://bugs.python.org/issue18920 pat = re.compile(r'conda:?\s+(\d+\.\d\S+|unknown)') m = pat.match(stderr.decode().strip()) if m is None:...
[ "def", "_get_conda_version", "(", "stdout", ",", "stderr", ")", ":", "# argparse outputs version to stderr in Python < 3.4.", "# http://bugs.python.org/issue18920", "pat", "=", "re", ".", "compile", "(", "r'conda:?\\s+(\\d+\\.\\d\\S+|unknown)'", ")", "m", "=", "pat", ".", ...
Callback for get_conda_version.
[ "Callback", "for", "get_conda_version", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L377-L389
45,128
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.get_envs
def get_envs(self, log=True): """Return environment list of absolute path to their prefixes.""" if log: logger.debug('') # return self._call_and_parse(['info', '--json'], # callback=lambda o, e: o['envs']) envs = os.listdir(os.sep.join([self....
python
def get_envs(self, log=True): """Return environment list of absolute path to their prefixes.""" if log: logger.debug('') # return self._call_and_parse(['info', '--json'], # callback=lambda o, e: o['envs']) envs = os.listdir(os.sep.join([self....
[ "def", "get_envs", "(", "self", ",", "log", "=", "True", ")", ":", "if", "log", ":", "logger", ".", "debug", "(", "''", ")", "# return self._call_and_parse(['info', '--json'],", "# callback=lambda o, e: o['envs'])", "envs", "=", ...
Return environment list of absolute path to their prefixes.
[ "Return", "environment", "list", "of", "absolute", "path", "to", "their", "prefixes", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L391-L403
45,129
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.get_prefix_envname
def get_prefix_envname(self, name, log=False): """Return full prefix path of environment defined by `name`.""" prefix = None if name == 'root': prefix = self.ROOT_PREFIX # envs, error = self.get_envs().communicate() envs = self.get_envs() for p in envs: ...
python
def get_prefix_envname(self, name, log=False): """Return full prefix path of environment defined by `name`.""" prefix = None if name == 'root': prefix = self.ROOT_PREFIX # envs, error = self.get_envs().communicate() envs = self.get_envs() for p in envs: ...
[ "def", "get_prefix_envname", "(", "self", ",", "name", ",", "log", "=", "False", ")", ":", "prefix", "=", "None", "if", "name", "==", "'root'", ":", "prefix", "=", "self", ".", "ROOT_PREFIX", "# envs, error = self.get_envs().communicate()", "envs", "=", ...
Return full prefix path of environment defined by `name`.
[ "Return", "full", "prefix", "path", "of", "environment", "defined", "by", "name", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L405-L417
45,130
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.linked
def linked(prefix): """Return set of canonical names of linked packages in `prefix`.""" logger.debug(str(prefix)) if not isdir(prefix): return set() meta_dir = join(prefix, 'conda-meta') if not isdir(meta_dir): # We might have nothing in linked (and no c...
python
def linked(prefix): """Return set of canonical names of linked packages in `prefix`.""" logger.debug(str(prefix)) if not isdir(prefix): return set() meta_dir = join(prefix, 'conda-meta') if not isdir(meta_dir): # We might have nothing in linked (and no c...
[ "def", "linked", "(", "prefix", ")", ":", "logger", ".", "debug", "(", "str", "(", "prefix", ")", ")", "if", "not", "isdir", "(", "prefix", ")", ":", "return", "set", "(", ")", "meta_dir", "=", "join", "(", "prefix", ",", "'conda-meta'", ")", "if",...
Return set of canonical names of linked packages in `prefix`.
[ "Return", "set", "of", "canonical", "names", "of", "linked", "packages", "in", "prefix", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L420-L433
45,131
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.info
def info(self, abspath=True): """ Return a dictionary with configuration information. No guarantee is made about which keys exist. Therefore this function should only be used for testing and debugging. """ logger.debug(str('')) return self._call_and_parse(['info...
python
def info(self, abspath=True): """ Return a dictionary with configuration information. No guarantee is made about which keys exist. Therefore this function should only be used for testing and debugging. """ logger.debug(str('')) return self._call_and_parse(['info...
[ "def", "info", "(", "self", ",", "abspath", "=", "True", ")", ":", "logger", ".", "debug", "(", "str", "(", "''", ")", ")", "return", "self", ".", "_call_and_parse", "(", "[", "'info'", ",", "'--json'", "]", ",", "abspath", "=", "abspath", ")" ]
Return a dictionary with configuration information. No guarantee is made about which keys exist. Therefore this function should only be used for testing and debugging.
[ "Return", "a", "dictionary", "with", "configuration", "information", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L440-L448
45,132
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.package_info
def package_info(self, package, abspath=True): """Return a dictionary with package information.""" return self._call_and_parse(['info', package, '--json'], abspath=abspath)
python
def package_info(self, package, abspath=True): """Return a dictionary with package information.""" return self._call_and_parse(['info', package, '--json'], abspath=abspath)
[ "def", "package_info", "(", "self", ",", "package", ",", "abspath", "=", "True", ")", ":", "return", "self", ".", "_call_and_parse", "(", "[", "'info'", ",", "package", ",", "'--json'", "]", ",", "abspath", "=", "abspath", ")" ]
Return a dictionary with package information.
[ "Return", "a", "dictionary", "with", "package", "information", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L450-L453
45,133
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.search
def search(self, regex=None, spec=None, **kwargs): """Search for packages.""" cmd_list = ['search', '--json'] if regex and spec: raise TypeError('conda search: only one of regex or spec allowed') if regex: cmd_list.append(regex) if spec: cmd...
python
def search(self, regex=None, spec=None, **kwargs): """Search for packages.""" cmd_list = ['search', '--json'] if regex and spec: raise TypeError('conda search: only one of regex or spec allowed') if regex: cmd_list.append(regex) if spec: cmd...
[ "def", "search", "(", "self", ",", "regex", "=", "None", ",", "spec", "=", "None", ",", "*", "*", "kwargs", ")", ":", "cmd_list", "=", "[", "'search'", ",", "'--json'", "]", "if", "regex", "and", "spec", ":", "raise", "TypeError", "(", "'conda search...
Search for packages.
[ "Search", "for", "packages", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L455-L478
45,134
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.create_from_yaml
def create_from_yaml(self, name, yamlfile): """ Create new environment using conda-env via a yaml specification file. Unlike other methods, this calls conda-env, and requires a named environment and uses channels as defined in rcfiles. Parameters ---------- name...
python
def create_from_yaml(self, name, yamlfile): """ Create new environment using conda-env via a yaml specification file. Unlike other methods, this calls conda-env, and requires a named environment and uses channels as defined in rcfiles. Parameters ---------- name...
[ "def", "create_from_yaml", "(", "self", ",", "name", ",", "yamlfile", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "name", ",", "yamlfile", ")", ")", ")", "cmd_list", "=", "[", "'env'", ",", "'create'", ",", "'-n'", ",", "name", ",", "'-...
Create new environment using conda-env via a yaml specification file. Unlike other methods, this calls conda-env, and requires a named environment and uses channels as defined in rcfiles. Parameters ---------- name : string Environment name yamlfile : string...
[ "Create", "new", "environment", "using", "conda", "-", "env", "via", "a", "yaml", "specification", "file", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L480-L496
45,135
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.create
def create(self, name=None, prefix=None, pkgs=None, channels=None): """Create an environment with a specified set of packages.""" logger.debug(str((prefix, pkgs, channels))) # TODO: Fix temporal hack if (not pkgs or (not isinstance(pkgs, (list, tuple)) and not i...
python
def create(self, name=None, prefix=None, pkgs=None, channels=None): """Create an environment with a specified set of packages.""" logger.debug(str((prefix, pkgs, channels))) # TODO: Fix temporal hack if (not pkgs or (not isinstance(pkgs, (list, tuple)) and not i...
[ "def", "create", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "pkgs", "=", "None", ",", "channels", "=", "None", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "prefix", ",", "pkgs", ",", "channels", ")", ")", ...
Create an environment with a specified set of packages.
[ "Create", "an", "environment", "with", "a", "specified", "set", "of", "packages", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L498-L540
45,136
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.parse_token_channel
def parse_token_channel(self, channel, token): """ Adapt a channel to include token of the logged user. Ignore default channels. """ if (token and channel not in self.DEFAULT_CHANNELS and channel != 'defaults'): url_parts = channel.split('/') ...
python
def parse_token_channel(self, channel, token): """ Adapt a channel to include token of the logged user. Ignore default channels. """ if (token and channel not in self.DEFAULT_CHANNELS and channel != 'defaults'): url_parts = channel.split('/') ...
[ "def", "parse_token_channel", "(", "self", ",", "channel", ",", "token", ")", ":", "if", "(", "token", "and", "channel", "not", "in", "self", ".", "DEFAULT_CHANNELS", "and", "channel", "!=", "'defaults'", ")", ":", "url_parts", "=", "channel", ".", "split"...
Adapt a channel to include token of the logged user. Ignore default channels.
[ "Adapt", "a", "channel", "to", "include", "token", "of", "the", "logged", "user", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L542-L557
45,137
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.install
def install(self, name=None, prefix=None, pkgs=None, dep=True, channels=None, token=None): """ Install a set of packages into an environment by name or path. If token is specified, the channels different from the defaults will get the token appended. """ ...
python
def install(self, name=None, prefix=None, pkgs=None, dep=True, channels=None, token=None): """ Install a set of packages into an environment by name or path. If token is specified, the channels different from the defaults will get the token appended. """ ...
[ "def", "install", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "pkgs", "=", "None", ",", "dep", "=", "True", ",", "channels", "=", "None", ",", "token", "=", "None", ")", ":", "logger", ".", "debug", "(", "str", "(", ...
Install a set of packages into an environment by name or path. If token is specified, the channels different from the defaults will get the token appended.
[ "Install", "a", "set", "of", "packages", "into", "an", "environment", "by", "name", "or", "path", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L559-L601
45,138
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.remove_environment
def remove_environment(self, name=None, path=None, **kwargs): """ Remove an environment entirely. See ``remove``. """ return self.remove(name=name, path=path, all=True, **kwargs)
python
def remove_environment(self, name=None, path=None, **kwargs): """ Remove an environment entirely. See ``remove``. """ return self.remove(name=name, path=path, all=True, **kwargs)
[ "def", "remove_environment", "(", "self", ",", "name", "=", "None", ",", "path", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "remove", "(", "name", "=", "name", ",", "path", "=", "path", ",", "all", "=", "True", ",", "*...
Remove an environment entirely. See ``remove``.
[ "Remove", "an", "environment", "entirely", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L655-L661
45,139
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.clone_environment
def clone_environment(self, clone, name=None, prefix=None, **kwargs): """Clone the environment `clone` into `name` or `prefix`.""" cmd_list = ['create', '--json'] if (name and prefix) or not (name or prefix): raise TypeError("conda clone_environment: exactly one of `name` " ...
python
def clone_environment(self, clone, name=None, prefix=None, **kwargs): """Clone the environment `clone` into `name` or `prefix`.""" cmd_list = ['create', '--json'] if (name and prefix) or not (name or prefix): raise TypeError("conda clone_environment: exactly one of `name` " ...
[ "def", "clone_environment", "(", "self", ",", "clone", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "*", "*", "kwargs", ")", ":", "cmd_list", "=", "[", "'create'", ",", "'--json'", "]", "if", "(", "name", "and", "prefix", ")", "or", "...
Clone the environment `clone` into `name` or `prefix`.
[ "Clone", "the", "environment", "clone", "into", "name", "or", "prefix", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L663-L687
45,140
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._setup_config_from_kwargs
def _setup_config_from_kwargs(kwargs): """Setup config commands for conda.""" cmd_list = ['--json', '--force'] if 'file' in kwargs: cmd_list.extend(['--file', kwargs['file']]) if 'system' in kwargs: cmd_list.append('--system') return cmd_list
python
def _setup_config_from_kwargs(kwargs): """Setup config commands for conda.""" cmd_list = ['--json', '--force'] if 'file' in kwargs: cmd_list.extend(['--file', kwargs['file']]) if 'system' in kwargs: cmd_list.append('--system') return cmd_list
[ "def", "_setup_config_from_kwargs", "(", "kwargs", ")", ":", "cmd_list", "=", "[", "'--json'", ",", "'--force'", "]", "if", "'file'", "in", "kwargs", ":", "cmd_list", ".", "extend", "(", "[", "'--file'", ",", "kwargs", "[", "'file'", "]", "]", ")", "if",...
Setup config commands for conda.
[ "Setup", "config", "commands", "for", "conda", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L727-L737
45,141
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.config_add
def config_add(self, key, value, **kwargs): """ Add a value to a key. Returns a list of warnings Conda may have emitted. """ cmd_list = ['config', '--add', key, value] cmd_list.extend(self._setup_config_from_kwargs(kwargs)) return self._call_and_parse( ...
python
def config_add(self, key, value, **kwargs): """ Add a value to a key. Returns a list of warnings Conda may have emitted. """ cmd_list = ['config', '--add', key, value] cmd_list.extend(self._setup_config_from_kwargs(kwargs)) return self._call_and_parse( ...
[ "def", "config_add", "(", "self", ",", "key", ",", "value", ",", "*", "*", "kwargs", ")", ":", "cmd_list", "=", "[", "'config'", ",", "'--add'", ",", "key", ",", "value", "]", "cmd_list", ".", "extend", "(", "self", ".", "_setup_config_from_kwargs", "(...
Add a value to a key. Returns a list of warnings Conda may have emitted.
[ "Add", "a", "value", "to", "a", "key", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L777-L789
45,142
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.dependencies
def dependencies(self, name=None, prefix=None, pkgs=None, channels=None, dep=True): """Get dependenciy list for packages to be installed in an env.""" if not pkgs or not isinstance(pkgs, (list, tuple)): raise TypeError('must specify a list of one or more packages to ' ...
python
def dependencies(self, name=None, prefix=None, pkgs=None, channels=None, dep=True): """Get dependenciy list for packages to be installed in an env.""" if not pkgs or not isinstance(pkgs, (list, tuple)): raise TypeError('must specify a list of one or more packages to ' ...
[ "def", "dependencies", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "pkgs", "=", "None", ",", "channels", "=", "None", ",", "dep", "=", "True", ")", ":", "if", "not", "pkgs", "or", "not", "isinstance", "(", "pkgs", ",", ...
Get dependenciy list for packages to be installed in an env.
[ "Get", "dependenciy", "list", "for", "packages", "to", "be", "installed", "in", "an", "env", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L832-L861
45,143
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.environment_exists
def environment_exists(self, name=None, prefix=None, abspath=True, log=True): """Check if an environment exists by 'name' or by 'prefix'. If query is by 'name' only the default conda environments directory is searched. """ if log: logger.de...
python
def environment_exists(self, name=None, prefix=None, abspath=True, log=True): """Check if an environment exists by 'name' or by 'prefix'. If query is by 'name' only the default conda environments directory is searched. """ if log: logger.de...
[ "def", "environment_exists", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "abspath", "=", "True", ",", "log", "=", "True", ")", ":", "if", "log", ":", "logger", ".", "debug", "(", "str", "(", "(", "name", ",", "prefix", ...
Check if an environment exists by 'name' or by 'prefix'. If query is by 'name' only the default conda environments directory is searched.
[ "Check", "if", "an", "environment", "exists", "by", "name", "or", "by", "prefix", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L863-L882
45,144
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.clear_lock
def clear_lock(self, abspath=True): """Clean any conda lock in the system.""" cmd_list = ['clean', '--lock', '--json'] return self._call_and_parse(cmd_list, abspath=abspath)
python
def clear_lock(self, abspath=True): """Clean any conda lock in the system.""" cmd_list = ['clean', '--lock', '--json'] return self._call_and_parse(cmd_list, abspath=abspath)
[ "def", "clear_lock", "(", "self", ",", "abspath", "=", "True", ")", ":", "cmd_list", "=", "[", "'clean'", ",", "'--lock'", ",", "'--json'", "]", "return", "self", ".", "_call_and_parse", "(", "cmd_list", ",", "abspath", "=", "abspath", ")" ]
Clean any conda lock in the system.
[ "Clean", "any", "conda", "lock", "in", "the", "system", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L884-L887
45,145
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.package_version
def package_version(self, prefix=None, name=None, pkg=None, build=False): """Get installed package version in a given env.""" package_versions = {} if name and prefix: raise TypeError("Exactly one of 'name' or 'prefix' is required.") if name: prefix = self.get_p...
python
def package_version(self, prefix=None, name=None, pkg=None, build=False): """Get installed package version in a given env.""" package_versions = {} if name and prefix: raise TypeError("Exactly one of 'name' or 'prefix' is required.") if name: prefix = self.get_p...
[ "def", "package_version", "(", "self", ",", "prefix", "=", "None", ",", "name", "=", "None", ",", "pkg", "=", "None", ",", "build", "=", "False", ")", ":", "package_versions", "=", "{", "}", "if", "name", "and", "prefix", ":", "raise", "TypeError", "...
Get installed package version in a given env.
[ "Get", "installed", "package", "version", "in", "a", "given", "env", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L889-L909
45,146
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.load_rc
def load_rc(self, path=None, system=False): """ Load the conda configuration file. If both user and system configuration exists, user will be used. """ if os.path.isfile(self.user_rc_path) and not system: path = self.user_rc_path elif os.path.isfile(self.sys_...
python
def load_rc(self, path=None, system=False): """ Load the conda configuration file. If both user and system configuration exists, user will be used. """ if os.path.isfile(self.user_rc_path) and not system: path = self.user_rc_path elif os.path.isfile(self.sys_...
[ "def", "load_rc", "(", "self", ",", "path", "=", "None", ",", "system", "=", "False", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "user_rc_path", ")", "and", "not", "system", ":", "path", "=", "self", ".", "user_rc_path", "e...
Load the conda configuration file. If both user and system configuration exists, user will be used.
[ "Load", "the", "conda", "configuration", "file", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L931-L946
45,147
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.get_condarc_channels
def get_condarc_channels(self, normalize=False, conda_url='https://conda.anaconda.org', channels=None): """Return all the channel urls defined in .condarc. If no condarc file is found, use the default channels. ...
python
def get_condarc_channels(self, normalize=False, conda_url='https://conda.anaconda.org', channels=None): """Return all the channel urls defined in .condarc. If no condarc file is found, use the default channels. ...
[ "def", "get_condarc_channels", "(", "self", ",", "normalize", "=", "False", ",", "conda_url", "=", "'https://conda.anaconda.org'", ",", "channels", "=", "None", ")", ":", "# https://docs.continuum.io/anaconda-repository/configuration", "# They can only exist on a system condarc...
Return all the channel urls defined in .condarc. If no condarc file is found, use the default channels. the `default_channel_alias` key is ignored and only the anaconda client `url` key is used.
[ "Return", "all", "the", "channel", "urls", "defined", "in", ".", "condarc", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L948-L985
45,148
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._call_pip
def _call_pip(self, name=None, prefix=None, extra_args=None, callback=None): """Call pip in QProcess worker.""" cmd_list = self._pip_cmd(name=name, prefix=prefix) cmd_list.extend(extra_args) process_worker = ProcessWorker(cmd_list, pip=True, callback=callback) ...
python
def _call_pip(self, name=None, prefix=None, extra_args=None, callback=None): """Call pip in QProcess worker.""" cmd_list = self._pip_cmd(name=name, prefix=prefix) cmd_list.extend(extra_args) process_worker = ProcessWorker(cmd_list, pip=True, callback=callback) ...
[ "def", "_call_pip", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "extra_args", "=", "None", ",", "callback", "=", "None", ")", ":", "cmd_list", "=", "self", ".", "_pip_cmd", "(", "name", "=", "name", ",", "prefix", "=", "...
Call pip in QProcess worker.
[ "Call", "pip", "in", "QProcess", "worker", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L989-L1000
45,149
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._pip_cmd
def _pip_cmd(self, name=None, prefix=None): """Get pip location based on environment `name` or `prefix`.""" if (name and prefix) or not (name or prefix): raise TypeError("conda pip: exactly one of 'name' ""or 'prefix' " "required.") if name and self.envir...
python
def _pip_cmd(self, name=None, prefix=None): """Get pip location based on environment `name` or `prefix`.""" if (name and prefix) or not (name or prefix): raise TypeError("conda pip: exactly one of 'name' ""or 'prefix' " "required.") if name and self.envir...
[ "def", "_pip_cmd", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ")", ":", "if", "(", "name", "and", "prefix", ")", "or", "not", "(", "name", "or", "prefix", ")", ":", "raise", "TypeError", "(", "\"conda pip: exactly one of 'name' \"...
Get pip location based on environment `name` or `prefix`.
[ "Get", "pip", "location", "based", "on", "environment", "name", "or", "prefix", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L1002-L1020
45,150
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.pip_list
def pip_list(self, name=None, prefix=None, abspath=True): """Get list of pip installed packages.""" if (name and prefix) or not (name or prefix): raise TypeError("conda pip: exactly one of 'name' ""or 'prefix' " "required.") if name: prefix = ...
python
def pip_list(self, name=None, prefix=None, abspath=True): """Get list of pip installed packages.""" if (name and prefix) or not (name or prefix): raise TypeError("conda pip: exactly one of 'name' ""or 'prefix' " "required.") if name: prefix = ...
[ "def", "pip_list", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "abspath", "=", "True", ")", ":", "if", "(", "name", "and", "prefix", ")", "or", "not", "(", "name", "or", "prefix", ")", ":", "raise", "TypeError", "(", "...
Get list of pip installed packages.
[ "Get", "list", "of", "pip", "installed", "packages", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L1022-L1040
45,151
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._pip_list
def _pip_list(self, stdout, stderr, prefix=None): """Callback for `pip_list`.""" result = stdout # A dict linked = self.linked(prefix) pip_only = [] linked_names = [self.split_canonical_name(l)[0] for l in linked] for pkg in result: name = self.split_canon...
python
def _pip_list(self, stdout, stderr, prefix=None): """Callback for `pip_list`.""" result = stdout # A dict linked = self.linked(prefix) pip_only = [] linked_names = [self.split_canonical_name(l)[0] for l in linked] for pkg in result: name = self.split_canon...
[ "def", "_pip_list", "(", "self", ",", "stdout", ",", "stderr", ",", "prefix", "=", "None", ")", ":", "result", "=", "stdout", "# A dict", "linked", "=", "self", ".", "linked", "(", "prefix", ")", "pip_only", "=", "[", "]", "linked_names", "=", "[", "...
Callback for `pip_list`.
[ "Callback", "for", "pip_list", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L1042-L1066
45,152
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.pip_remove
def pip_remove(self, name=None, prefix=None, pkgs=None): """Remove a pip package in given environment by `name` or `prefix`.""" logger.debug(str((prefix, pkgs))) if isinstance(pkgs, (list, tuple)): pkg = ' '.join(pkgs) else: pkg = pkgs extra_args = ['uni...
python
def pip_remove(self, name=None, prefix=None, pkgs=None): """Remove a pip package in given environment by `name` or `prefix`.""" logger.debug(str((prefix, pkgs))) if isinstance(pkgs, (list, tuple)): pkg = ' '.join(pkgs) else: pkg = pkgs extra_args = ['uni...
[ "def", "pip_remove", "(", "self", ",", "name", "=", "None", ",", "prefix", "=", "None", ",", "pkgs", "=", "None", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "prefix", ",", "pkgs", ")", ")", ")", "if", "isinstance", "(", "pkgs", ",", ...
Remove a pip package in given environment by `name` or `prefix`.
[ "Remove", "a", "pip", "package", "in", "given", "environment", "by", "name", "or", "prefix", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L1068-L1079
45,153
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI.pip_search
def pip_search(self, search_string=None): """Search for pip packages in PyPI matching `search_string`.""" extra_args = ['search', search_string] return self._call_pip(name='root', extra_args=extra_args, callback=self._pip_search)
python
def pip_search(self, search_string=None): """Search for pip packages in PyPI matching `search_string`.""" extra_args = ['search', search_string] return self._call_pip(name='root', extra_args=extra_args, callback=self._pip_search)
[ "def", "pip_search", "(", "self", ",", "search_string", "=", "None", ")", ":", "extra_args", "=", "[", "'search'", ",", "search_string", "]", "return", "self", ".", "_call_pip", "(", "name", "=", "'root'", ",", "extra_args", "=", "extra_args", ",", "callba...
Search for pip packages in PyPI matching `search_string`.
[ "Search", "for", "pip", "packages", "in", "PyPI", "matching", "search_string", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L1081-L1085
45,154
spyder-ide/conda-manager
conda_manager/api/conda_api.py
_CondaAPI._pip_search
def _pip_search(stdout, stderr): """Callback for pip search.""" result = {} lines = to_text_string(stdout).split('\n') while '' in lines: lines.remove('') for line in lines: if ' - ' in line: parts = line.split(' - ') name ...
python
def _pip_search(stdout, stderr): """Callback for pip search.""" result = {} lines = to_text_string(stdout).split('\n') while '' in lines: lines.remove('') for line in lines: if ' - ' in line: parts = line.split(' - ') name ...
[ "def", "_pip_search", "(", "stdout", ",", "stderr", ")", ":", "result", "=", "{", "}", "lines", "=", "to_text_string", "(", "stdout", ")", ".", "split", "(", "'\\n'", ")", "while", "''", "in", "lines", ":", "lines", ".", "remove", "(", "''", ")", "...
Callback for pip search.
[ "Callback", "for", "pip", "search", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L1094-L1108
45,155
spyder-ide/conda-manager
conda_manager/models/dependencies.py
CondaDependenciesModel._timer_update
def _timer_update(self): """Add some moving points to the dependency resolution text.""" self._timer_counter += 1 dot = self._timer_dots.pop(0) self._timer_dots = self._timer_dots + [dot] self._rows = [[_(u'Resolving dependencies') + dot, u'', u'', u'']] index = self.crea...
python
def _timer_update(self): """Add some moving points to the dependency resolution text.""" self._timer_counter += 1 dot = self._timer_dots.pop(0) self._timer_dots = self._timer_dots + [dot] self._rows = [[_(u'Resolving dependencies') + dot, u'', u'', u'']] index = self.crea...
[ "def", "_timer_update", "(", "self", ")", ":", "self", ".", "_timer_counter", "+=", "1", "dot", "=", "self", ".", "_timer_dots", ".", "pop", "(", "0", ")", "self", ".", "_timer_dots", "=", "self", ".", "_timer_dots", "+", "[", "dot", "]", "self", "."...
Add some moving points to the dependency resolution text.
[ "Add", "some", "moving", "points", "to", "the", "dependency", "resolution", "text", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/models/dependencies.py#L72-L83
45,156
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI._create_worker
def _create_worker(self, method, *args, **kwargs): """Create a worker for this client to be run in a separate thread.""" # FIXME: this might be heavy... thread = QThread() worker = ClientWorker(method, args, kwargs) worker.moveToThread(thread) worker.sig_finished.connect(...
python
def _create_worker(self, method, *args, **kwargs): """Create a worker for this client to be run in a separate thread.""" # FIXME: this might be heavy... thread = QThread() worker = ClientWorker(method, args, kwargs) worker.moveToThread(thread) worker.sig_finished.connect(...
[ "def", "_create_worker", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# FIXME: this might be heavy...", "thread", "=", "QThread", "(", ")", "worker", "=", "ClientWorker", "(", "method", ",", "args", ",", "kwargs", ")", ...
Create a worker for this client to be run in a separate thread.
[ "Create", "a", "worker", "for", "this", "client", "to", "be", "run", "in", "a", "separate", "thread", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L110-L123
45,157
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI._load_repodata
def _load_repodata(filepaths, extra_data=None, metadata=None): """Load all the available pacakges information. For downloaded repodata files (repo.continuum.io), additional data provided (anaconda cloud), and additional metadata and merge into a single set of packages and apps. ...
python
def _load_repodata(filepaths, extra_data=None, metadata=None): """Load all the available pacakges information. For downloaded repodata files (repo.continuum.io), additional data provided (anaconda cloud), and additional metadata and merge into a single set of packages and apps. ...
[ "def", "_load_repodata", "(", "filepaths", ",", "extra_data", "=", "None", ",", "metadata", "=", "None", ")", ":", "extra_data", "=", "extra_data", "if", "extra_data", "else", "{", "}", "metadata", "=", "metadata", "if", "metadata", "else", "{", "}", "repo...
Load all the available pacakges information. For downloaded repodata files (repo.continuum.io), additional data provided (anaconda cloud), and additional metadata and merge into a single set of packages and apps.
[ "Load", "all", "the", "available", "pacakges", "information", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L126-L207
45,158
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI.login
def login(self, username, password, application, application_url): """Login to anaconda cloud.""" logger.debug(str((username, application, application_url))) method = self._anaconda_client_api.authenticate return self._create_worker(method, username, password, application, ...
python
def login(self, username, password, application, application_url): """Login to anaconda cloud.""" logger.debug(str((username, application, application_url))) method = self._anaconda_client_api.authenticate return self._create_worker(method, username, password, application, ...
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "application", ",", "application_url", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "username", ",", "application", ",", "application_url", ")", ")", ")", "method", "=", "self...
Login to anaconda cloud.
[ "Login", "to", "anaconda", "cloud", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L309-L314
45,159
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI.logout
def logout(self): """Logout from anaconda cloud.""" logger.debug('Logout') method = self._anaconda_client_api.remove_authentication return self._create_worker(method)
python
def logout(self): """Logout from anaconda cloud.""" logger.debug('Logout') method = self._anaconda_client_api.remove_authentication return self._create_worker(method)
[ "def", "logout", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Logout'", ")", "method", "=", "self", ".", "_anaconda_client_api", ".", "remove_authentication", "return", "self", ".", "_create_worker", "(", "method", ")" ]
Logout from anaconda cloud.
[ "Logout", "from", "anaconda", "cloud", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L316-L320
45,160
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI.load_repodata
def load_repodata(self, filepaths, extra_data=None, metadata=None): """ Load all the available pacakges information for downloaded repodata. Files include repo.continuum.io, additional data provided (anaconda cloud), and additional metadata and merge into a single set of packages ...
python
def load_repodata(self, filepaths, extra_data=None, metadata=None): """ Load all the available pacakges information for downloaded repodata. Files include repo.continuum.io, additional data provided (anaconda cloud), and additional metadata and merge into a single set of packages ...
[ "def", "load_repodata", "(", "self", ",", "filepaths", ",", "extra_data", "=", "None", ",", "metadata", "=", "None", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "filepaths", ")", ")", ")", "method", "=", "self", ".", "_load_repodata", "retu...
Load all the available pacakges information for downloaded repodata. Files include repo.continuum.io, additional data provided (anaconda cloud), and additional metadata and merge into a single set of packages and apps.
[ "Load", "all", "the", "available", "pacakges", "information", "for", "downloaded", "repodata", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L322-L333
45,161
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI.prepare_model_data
def prepare_model_data(self, packages, linked, pip=None, private_packages=None): """Prepare downloaded package info along with pip pacakges info.""" logger.debug('') return self._prepare_model_data(packages, linked, pip=pip, priv...
python
def prepare_model_data(self, packages, linked, pip=None, private_packages=None): """Prepare downloaded package info along with pip pacakges info.""" logger.debug('') return self._prepare_model_data(packages, linked, pip=pip, priv...
[ "def", "prepare_model_data", "(", "self", ",", "packages", ",", "linked", ",", "pip", "=", "None", ",", "private_packages", "=", "None", ")", ":", "logger", ".", "debug", "(", "''", ")", "return", "self", ".", "_prepare_model_data", "(", "packages", ",", ...
Prepare downloaded package info along with pip pacakges info.
[ "Prepare", "downloaded", "package", "info", "along", "with", "pip", "pacakges", "info", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L335-L340
45,162
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI.set_domain
def set_domain(self, domain='https://api.anaconda.org'): """Reset current api domain.""" logger.debug(str((domain))) config = binstar_client.utils.get_config() config['url'] = domain binstar_client.utils.set_config(config) self._anaconda_client_api = binstar_client.utils...
python
def set_domain(self, domain='https://api.anaconda.org'): """Reset current api domain.""" logger.debug(str((domain))) config = binstar_client.utils.get_config() config['url'] = domain binstar_client.utils.set_config(config) self._anaconda_client_api = binstar_client.utils...
[ "def", "set_domain", "(", "self", ",", "domain", "=", "'https://api.anaconda.org'", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "domain", ")", ")", ")", "config", "=", "binstar_client", ".", "utils", ".", "get_config", "(", ")", "config", "["...
Reset current api domain.
[ "Reset", "current", "api", "domain", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L342-L352
45,163
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI.packages
def packages(self, login=None, platform=None, package_type=None, type_=None, access=None): """Return all the available packages for a given user. Parameters ---------- type_: Optional[str] Only find packages that have this conda `type`, (i.e. 'app'). ...
python
def packages(self, login=None, platform=None, package_type=None, type_=None, access=None): """Return all the available packages for a given user. Parameters ---------- type_: Optional[str] Only find packages that have this conda `type`, (i.e. 'app'). ...
[ "def", "packages", "(", "self", ",", "login", "=", "None", ",", "platform", "=", "None", ",", "package_type", "=", "None", ",", "type_", "=", "None", ",", "access", "=", "None", ")", ":", "logger", ".", "debug", "(", "''", ")", "method", "=", "self...
Return all the available packages for a given user. Parameters ---------- type_: Optional[str] Only find packages that have this conda `type`, (i.e. 'app'). access : Optional[str] Only find packages that have this access level (e.g. 'private', 'authen...
[ "Return", "all", "the", "available", "packages", "for", "a", "given", "user", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L386-L402
45,164
yaph/geonamescache
geonamescache/mappers.py
country
def country(from_key='name', to_key='iso'): """Creates and returns a mapper function to access country data. The mapper function that is returned must be called with one argument. In the default case you call it with a name and it returns a 3-letter ISO_3166-1 code, e. g. called with ``Spain`` it would...
python
def country(from_key='name', to_key='iso'): """Creates and returns a mapper function to access country data. The mapper function that is returned must be called with one argument. In the default case you call it with a name and it returns a 3-letter ISO_3166-1 code, e. g. called with ``Spain`` it would...
[ "def", "country", "(", "from_key", "=", "'name'", ",", "to_key", "=", "'iso'", ")", ":", "gc", "=", "GeonamesCache", "(", ")", "dataset", "=", "gc", ".", "get_dataset_by_key", "(", "gc", ".", "get_countries", "(", ")", ",", "from_key", ")", "def", "map...
Creates and returns a mapper function to access country data. The mapper function that is returned must be called with one argument. In the default case you call it with a name and it returns a 3-letter ISO_3166-1 code, e. g. called with ``Spain`` it would return ``ESP``. :param from_key: (optional) t...
[ "Creates", "and", "returns", "a", "mapper", "function", "to", "access", "country", "data", "." ]
5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b
https://github.com/yaph/geonamescache/blob/5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b/geonamescache/mappers.py#L6-L33
45,165
yaph/geonamescache
geonamescache/__init__.py
GeonamesCache.get_cities
def get_cities(self): """Get a dictionary of cities keyed by geonameid.""" if self.cities is None: self.cities = self._load_data(self.cities, 'cities.json') return self.cities
python
def get_cities(self): """Get a dictionary of cities keyed by geonameid.""" if self.cities is None: self.cities = self._load_data(self.cities, 'cities.json') return self.cities
[ "def", "get_cities", "(", "self", ")", ":", "if", "self", ".", "cities", "is", "None", ":", "self", ".", "cities", "=", "self", ".", "_load_data", "(", "self", ".", "cities", ",", "'cities.json'", ")", "return", "self", ".", "cities" ]
Get a dictionary of cities keyed by geonameid.
[ "Get", "a", "dictionary", "of", "cities", "keyed", "by", "geonameid", "." ]
5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b
https://github.com/yaph/geonamescache/blob/5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b/geonamescache/__init__.py#L56-L61
45,166
yaph/geonamescache
geonamescache/__init__.py
GeonamesCache.get_cities_by_name
def get_cities_by_name(self, name): """Get a list of city dictionaries with the given name. City names cannot be used as keys, as they are not unique. """ if name not in self.cities_by_names: if self.cities_items is None: self.cities_items = list(self.get_ci...
python
def get_cities_by_name(self, name): """Get a list of city dictionaries with the given name. City names cannot be used as keys, as they are not unique. """ if name not in self.cities_by_names: if self.cities_items is None: self.cities_items = list(self.get_ci...
[ "def", "get_cities_by_name", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "cities_by_names", ":", "if", "self", ".", "cities_items", "is", "None", ":", "self", ".", "cities_items", "=", "list", "(", "self", ".", "get_cities...
Get a list of city dictionaries with the given name. City names cannot be used as keys, as they are not unique.
[ "Get", "a", "list", "of", "city", "dictionaries", "with", "the", "given", "name", "." ]
5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b
https://github.com/yaph/geonamescache/blob/5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b/geonamescache/__init__.py#L63-L74
45,167
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._set_repo_urls_from_channels
def _set_repo_urls_from_channels(self, channels): """ Convert a channel into a normalized repo name including. Channels are assumed in normalized url form. """ repos = [] sys_platform = self._conda_api.get_platform() for channel in channels: url = '{...
python
def _set_repo_urls_from_channels(self, channels): """ Convert a channel into a normalized repo name including. Channels are assumed in normalized url form. """ repos = [] sys_platform = self._conda_api.get_platform() for channel in channels: url = '{...
[ "def", "_set_repo_urls_from_channels", "(", "self", ",", "channels", ")", ":", "repos", "=", "[", "]", "sys_platform", "=", "self", ".", "_conda_api", ".", "get_platform", "(", ")", "for", "channel", "in", "channels", ":", "url", "=", "'{0}/{1}/repodata.json.b...
Convert a channel into a normalized repo name including. Channels are assumed in normalized url form.
[ "Convert", "a", "channel", "into", "a", "normalized", "repo", "name", "including", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L106-L119
45,168
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._check_repos
def _check_repos(self, repos): """Check if repodata urls are valid.""" self._checking_repos = [] self._valid_repos = [] for repo in repos: worker = self.download_is_valid_url(repo) worker.sig_finished.connect(self._repos_checked) worker.repo = repo ...
python
def _check_repos(self, repos): """Check if repodata urls are valid.""" self._checking_repos = [] self._valid_repos = [] for repo in repos: worker = self.download_is_valid_url(repo) worker.sig_finished.connect(self._repos_checked) worker.repo = repo ...
[ "def", "_check_repos", "(", "self", ",", "repos", ")", ":", "self", ".", "_checking_repos", "=", "[", "]", "self", ".", "_valid_repos", "=", "[", "]", "for", "repo", "in", "repos", ":", "worker", "=", "self", ".", "download_is_valid_url", "(", "repo", ...
Check if repodata urls are valid.
[ "Check", "if", "repodata", "urls", "are", "valid", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L121-L130
45,169
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._repos_checked
def _repos_checked(self, worker, output, error): """Callback for _check_repos.""" if worker.repo in self._checking_repos: self._checking_repos.remove(worker.repo) if output: self._valid_repos.append(worker.repo) if len(self._checking_repos) == 0: sel...
python
def _repos_checked(self, worker, output, error): """Callback for _check_repos.""" if worker.repo in self._checking_repos: self._checking_repos.remove(worker.repo) if output: self._valid_repos.append(worker.repo) if len(self._checking_repos) == 0: sel...
[ "def", "_repos_checked", "(", "self", ",", "worker", ",", "output", ",", "error", ")", ":", "if", "worker", ".", "repo", "in", "self", ".", "_checking_repos", ":", "self", ".", "_checking_repos", ".", "remove", "(", "worker", ".", "repo", ")", "if", "o...
Callback for _check_repos.
[ "Callback", "for", "_check_repos", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L132-L141
45,170
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._repo_url_to_path
def _repo_url_to_path(self, repo): """Convert a `repo` url to a file path for local storage.""" repo = repo.replace('http://', '') repo = repo.replace('https://', '') repo = repo.replace('/', '_') return os.sep.join([self._data_directory, repo])
python
def _repo_url_to_path(self, repo): """Convert a `repo` url to a file path for local storage.""" repo = repo.replace('http://', '') repo = repo.replace('https://', '') repo = repo.replace('/', '_') return os.sep.join([self._data_directory, repo])
[ "def", "_repo_url_to_path", "(", "self", ",", "repo", ")", ":", "repo", "=", "repo", ".", "replace", "(", "'http://'", ",", "''", ")", "repo", "=", "repo", ".", "replace", "(", "'https://'", ",", "''", ")", "repo", "=", "repo", ".", "replace", "(", ...
Convert a `repo` url to a file path for local storage.
[ "Convert", "a", "repo", "url", "to", "a", "file", "path", "for", "local", "storage", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L143-L149
45,171
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._download_repodata
def _download_repodata(self, checked_repos): """Dowload repodata.""" self._files_downloaded = [] self._repodata_files = [] self.__counter = -1 if checked_repos: for repo in checked_repos: path = self._repo_url_to_path(repo) self._files...
python
def _download_repodata(self, checked_repos): """Dowload repodata.""" self._files_downloaded = [] self._repodata_files = [] self.__counter = -1 if checked_repos: for repo in checked_repos: path = self._repo_url_to_path(repo) self._files...
[ "def", "_download_repodata", "(", "self", ",", "checked_repos", ")", ":", "self", ".", "_files_downloaded", "=", "[", "]", "self", ".", "_repodata_files", "=", "[", "]", "self", ".", "__counter", "=", "-", "1", "if", "checked_repos", ":", "for", "repo", ...
Dowload repodata.
[ "Dowload", "repodata", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L151-L171
45,172
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._get_repodata_from_meta
def _get_repodata_from_meta(self): """Generate repodata from local meta files.""" path = os.sep.join([self.ROOT_PREFIX, 'conda-meta']) packages = os.listdir(path) meta_repodata = {} for pkg in packages: if pkg.endswith('.json'): filepath = os.sep.join(...
python
def _get_repodata_from_meta(self): """Generate repodata from local meta files.""" path = os.sep.join([self.ROOT_PREFIX, 'conda-meta']) packages = os.listdir(path) meta_repodata = {} for pkg in packages: if pkg.endswith('.json'): filepath = os.sep.join(...
[ "def", "_get_repodata_from_meta", "(", "self", ")", ":", "path", "=", "os", ".", "sep", ".", "join", "(", "[", "self", ".", "ROOT_PREFIX", ",", "'conda-meta'", "]", ")", "packages", "=", "os", ".", "listdir", "(", "path", ")", "meta_repodata", "=", "{"...
Generate repodata from local meta files.
[ "Generate", "repodata", "from", "local", "meta", "files", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L173-L201
45,173
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._repodata_downloaded
def _repodata_downloaded(self, worker=None, output=None, error=None): """Callback for _download_repodata.""" if worker: self._files_downloaded.remove(worker.path) if worker.path in self._files_downloaded: self._files_downloaded.remove(worker.path) if len...
python
def _repodata_downloaded(self, worker=None, output=None, error=None): """Callback for _download_repodata.""" if worker: self._files_downloaded.remove(worker.path) if worker.path in self._files_downloaded: self._files_downloaded.remove(worker.path) if len...
[ "def", "_repodata_downloaded", "(", "self", ",", "worker", "=", "None", ",", "output", "=", "None", ",", "error", "=", "None", ")", ":", "if", "worker", ":", "self", ".", "_files_downloaded", ".", "remove", "(", "worker", ".", "path", ")", "if", "worke...
Callback for _download_repodata.
[ "Callback", "for", "_download_repodata", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L203-L212
45,174
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.repodata_files
def repodata_files(self, channels=None): """ Return the repodata paths based on `channels` and the `data_directory`. There is no check for validity here. """ if channels is None: channels = self.conda_get_condarc_channels() repodata_urls = self._set_repo_url...
python
def repodata_files(self, channels=None): """ Return the repodata paths based on `channels` and the `data_directory`. There is no check for validity here. """ if channels is None: channels = self.conda_get_condarc_channels() repodata_urls = self._set_repo_url...
[ "def", "repodata_files", "(", "self", ",", "channels", "=", "None", ")", ":", "if", "channels", "is", "None", ":", "channels", "=", "self", ".", "conda_get_condarc_channels", "(", ")", "repodata_urls", "=", "self", ".", "_set_repo_urls_from_channels", "(", "ch...
Return the repodata paths based on `channels` and the `data_directory`. There is no check for validity here.
[ "Return", "the", "repodata", "paths", "based", "on", "channels", "and", "the", "data_directory", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L216-L233
45,175
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.update_repodata
def update_repodata(self, channels=None): """Update repodata from channels or use condarc channels if None.""" norm_channels = self.conda_get_condarc_channels(channels=channels, normalize=True) repodata_urls = self._set_repo_urls_from_chann...
python
def update_repodata(self, channels=None): """Update repodata from channels or use condarc channels if None.""" norm_channels = self.conda_get_condarc_channels(channels=channels, normalize=True) repodata_urls = self._set_repo_urls_from_chann...
[ "def", "update_repodata", "(", "self", ",", "channels", "=", "None", ")", ":", "norm_channels", "=", "self", ".", "conda_get_condarc_channels", "(", "channels", "=", "channels", ",", "normalize", "=", "True", ")", "repodata_urls", "=", "self", ".", "_set_repo_...
Update repodata from channels or use condarc channels if None.
[ "Update", "repodata", "from", "channels", "or", "use", "condarc", "channels", "if", "None", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L239-L244
45,176
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.update_metadata
def update_metadata(self): """ Update the metadata available for packages in repo.continuum.io. Returns a download worker. """ if self._data_directory is None: raise Exception('Need to call `api.set_data_directory` first.') metadata_url = 'https://repo.conti...
python
def update_metadata(self): """ Update the metadata available for packages in repo.continuum.io. Returns a download worker. """ if self._data_directory is None: raise Exception('Need to call `api.set_data_directory` first.') metadata_url = 'https://repo.conti...
[ "def", "update_metadata", "(", "self", ")", ":", "if", "self", ".", "_data_directory", "is", "None", ":", "raise", "Exception", "(", "'Need to call `api.set_data_directory` first.'", ")", "metadata_url", "=", "'https://repo.continuum.io/pkgs/metadata.json'", "filepath", "...
Update the metadata available for packages in repo.continuum.io. Returns a download worker.
[ "Update", "the", "metadata", "available", "for", "packages", "in", "repo", ".", "continuum", ".", "io", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L246-L258
45,177
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.check_valid_channel
def check_valid_channel(self, channel, conda_url='https://conda.anaconda.org'): """Check if channel is valid.""" if channel.startswith('https://') or channel.startswith('http://'): url = channel else: url = "{0}/{1}"...
python
def check_valid_channel(self, channel, conda_url='https://conda.anaconda.org'): """Check if channel is valid.""" if channel.startswith('https://') or channel.startswith('http://'): url = channel else: url = "{0}/{1}"...
[ "def", "check_valid_channel", "(", "self", ",", "channel", ",", "conda_url", "=", "'https://conda.anaconda.org'", ")", ":", "if", "channel", ".", "startswith", "(", "'https://'", ")", "or", "channel", ".", "startswith", "(", "'http://'", ")", ":", "url", "=", ...
Check if channel is valid.
[ "Check", "if", "channel", "is", "valid", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L260-L275
45,178
google/python-cloud-utils
cloud_utils/list_instances.py
_aws_get_instance_by_tag
def _aws_get_instance_by_tag(region, name, tag, raw): """Get all instances matching a tag.""" client = boto3.session.Session().client('ec2', region) matching_reservations = client.describe_instances(Filters=[{'Name': tag, 'Values': [name]}]).get('Reservations', []) instances = [] [[instances.append(...
python
def _aws_get_instance_by_tag(region, name, tag, raw): """Get all instances matching a tag.""" client = boto3.session.Session().client('ec2', region) matching_reservations = client.describe_instances(Filters=[{'Name': tag, 'Values': [name]}]).get('Reservations', []) instances = [] [[instances.append(...
[ "def", "_aws_get_instance_by_tag", "(", "region", ",", "name", ",", "tag", ",", "raw", ")", ":", "client", "=", "boto3", ".", "session", ".", "Session", "(", ")", ".", "client", "(", "'ec2'", ",", "region", ")", "matching_reservations", "=", "client", "....
Get all instances matching a tag.
[ "Get", "all", "instances", "matching", "a", "tag", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L101-L108
45,179
google/python-cloud-utils
cloud_utils/list_instances.py
aws_get_instances_by_id
def aws_get_instances_by_id(region, instance_id, raw=True): """Returns instances mathing an id.""" client = boto3.session.Session().client('ec2', region) try: matching_reservations = client.describe_instances(InstanceIds=[instance_id]).get('Reservations', []) except ClientError as exc: i...
python
def aws_get_instances_by_id(region, instance_id, raw=True): """Returns instances mathing an id.""" client = boto3.session.Session().client('ec2', region) try: matching_reservations = client.describe_instances(InstanceIds=[instance_id]).get('Reservations', []) except ClientError as exc: i...
[ "def", "aws_get_instances_by_id", "(", "region", ",", "instance_id", ",", "raw", "=", "True", ")", ":", "client", "=", "boto3", ".", "session", ".", "Session", "(", ")", ".", "client", "(", "'ec2'", ",", "region", ")", "try", ":", "matching_reservations", ...
Returns instances mathing an id.
[ "Returns", "instances", "mathing", "an", "id", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L231-L243
45,180
google/python-cloud-utils
cloud_utils/list_instances.py
get_instances_by_name
def get_instances_by_name(name, sort_by_order=('cloud', 'name'), projects=None, raw=True, regions=None, gcp_credentials=None, clouds=SUPPORTED_CLOUDS): """Get intsances from GCP and AWS by name.""" matching_instances = all_clouds_get_instances_by_name( name, projects, raw, credentials=gcp_credentials, c...
python
def get_instances_by_name(name, sort_by_order=('cloud', 'name'), projects=None, raw=True, regions=None, gcp_credentials=None, clouds=SUPPORTED_CLOUDS): """Get intsances from GCP and AWS by name.""" matching_instances = all_clouds_get_instances_by_name( name, projects, raw, credentials=gcp_credentials, c...
[ "def", "get_instances_by_name", "(", "name", ",", "sort_by_order", "=", "(", "'cloud'", ",", "'name'", ")", ",", "projects", "=", "None", ",", "raw", "=", "True", ",", "regions", "=", "None", ",", "gcp_credentials", "=", "None", ",", "clouds", "=", "SUPP...
Get intsances from GCP and AWS by name.
[ "Get", "intsances", "from", "GCP", "and", "AWS", "by", "name", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L297-L304
45,181
google/python-cloud-utils
cloud_utils/list_instances.py
get_os_version
def get_os_version(instance): """Get OS Version for instances.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) image_id = client.describe_instances(InstanceIds=[instance.id])['Reservations'][0]['Instances'][0]['ImageId'] return '16.04' if '16.04' in client.de...
python
def get_os_version(instance): """Get OS Version for instances.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) image_id = client.describe_instances(InstanceIds=[instance.id])['Reservations'][0]['Instances'][0]['ImageId'] return '16.04' if '16.04' in client.de...
[ "def", "get_os_version", "(", "instance", ")", ":", "if", "instance", ".", "cloud", "==", "'aws'", ":", "client", "=", "boto3", ".", "client", "(", "'ec2'", ",", "instance", ".", "region", ")", "image_id", "=", "client", ".", "describe_instances", "(", "...
Get OS Version for instances.
[ "Get", "OS", "Version", "for", "instances", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L367-L387
45,182
google/python-cloud-utils
cloud_utils/list_instances.py
get_volumes
def get_volumes(instance): """Returns all the volumes of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) devices = client.describe_instance_attribute( InstanceId=instance.id, Attribute='blockDeviceMapping').get('BlockDeviceMappings', []) ...
python
def get_volumes(instance): """Returns all the volumes of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) devices = client.describe_instance_attribute( InstanceId=instance.id, Attribute='blockDeviceMapping').get('BlockDeviceMappings', []) ...
[ "def", "get_volumes", "(", "instance", ")", ":", "if", "instance", ".", "cloud", "==", "'aws'", ":", "client", "=", "boto3", ".", "client", "(", "'ec2'", ",", "instance", ".", "region", ")", "devices", "=", "client", ".", "describe_instance_attribute", "("...
Returns all the volumes of an instance.
[ "Returns", "all", "the", "volumes", "of", "an", "instance", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L390-L425
45,183
google/python-cloud-utils
cloud_utils/list_instances.py
get_persistent_address
def get_persistent_address(instance): """Returns the public ip address of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) try: client.describe_addresses(PublicIps=[instance.ip_address]) return instance.ip_address except bo...
python
def get_persistent_address(instance): """Returns the public ip address of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) try: client.describe_addresses(PublicIps=[instance.ip_address]) return instance.ip_address except bo...
[ "def", "get_persistent_address", "(", "instance", ")", ":", "if", "instance", ".", "cloud", "==", "'aws'", ":", "client", "=", "boto3", ".", "client", "(", "'ec2'", ",", "instance", ".", "region", ")", "try", ":", "client", ".", "describe_addresses", "(", ...
Returns the public ip address of an instance.
[ "Returns", "the", "public", "ip", "address", "of", "an", "instance", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L428-L449
45,184
spyder-ide/conda-manager
conda_manager/utils/findpip.py
main
def main(): """Use pip to find pip installed packages in a given prefix.""" pip_packages = {} for package in pip.get_installed_distributions(): name = package.project_name version = package.version full_name = "{0}-{1}-pip".format(name.lower(), version) pip_packages[full_name...
python
def main(): """Use pip to find pip installed packages in a given prefix.""" pip_packages = {} for package in pip.get_installed_distributions(): name = package.project_name version = package.version full_name = "{0}-{1}-pip".format(name.lower(), version) pip_packages[full_name...
[ "def", "main", "(", ")", ":", "pip_packages", "=", "{", "}", "for", "package", "in", "pip", ".", "get_installed_distributions", "(", ")", ":", "name", "=", "package", ".", "project_name", "version", "=", "package", ".", "version", "full_name", "=", "\"{0}-...
Use pip to find pip installed packages in a given prefix.
[ "Use", "pip", "to", "find", "pip", "installed", "packages", "in", "a", "given", "prefix", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/utils/findpip.py#L21-L30
45,185
xgvargas/js-css-min-django
jscssmin.py
_save
def _save(file, data, mode='w+'): """ Write all data to created file. Also overwrite previous file. """ with open(file, mode) as fh: fh.write(data)
python
def _save(file, data, mode='w+'): """ Write all data to created file. Also overwrite previous file. """ with open(file, mode) as fh: fh.write(data)
[ "def", "_save", "(", "file", ",", "data", ",", "mode", "=", "'w+'", ")", ":", "with", "open", "(", "file", ",", "mode", ")", "as", "fh", ":", "fh", ".", "write", "(", "data", ")" ]
Write all data to created file. Also overwrite previous file.
[ "Write", "all", "data", "to", "created", "file", ".", "Also", "overwrite", "previous", "file", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L32-L37
45,186
xgvargas/js-css-min-django
jscssmin.py
merge
def merge(obj): """ Merge contents. It does a simply merge of all files defined under 'static' key. If you have JS or CSS file with embeded django tags like {% url ... %} or {% static ... %} you should declare them under 'template' key. This function will render them and append to the merged o...
python
def merge(obj): """ Merge contents. It does a simply merge of all files defined under 'static' key. If you have JS or CSS file with embeded django tags like {% url ... %} or {% static ... %} you should declare them under 'template' key. This function will render them and append to the merged o...
[ "def", "merge", "(", "obj", ")", ":", "merge", "=", "''", "for", "f", "in", "obj", ".", "get", "(", "'static'", ",", "[", "]", ")", ":", "print", "'Merging: {}'", ".", "format", "(", "f", ")", "merge", "+=", "_read", "(", "f", ")", "def", "dole...
Merge contents. It does a simply merge of all files defined under 'static' key. If you have JS or CSS file with embeded django tags like {% url ... %} or {% static ... %} you should declare them under 'template' key. This function will render them and append to the merged output. To use the rende...
[ "Merge", "contents", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L40-L102
45,187
xgvargas/js-css-min-django
jscssmin.py
jsMin
def jsMin(data, file): """ Minify JS data and saves to file. Data should be a string will whole JS content, and file will be overwrited if exists. """ print 'Minifying JS... ', url = 'http://javascript-minifier.com/raw' #POST req = urllib2.Request(url, urllib.urlencode({'input': data}))...
python
def jsMin(data, file): """ Minify JS data and saves to file. Data should be a string will whole JS content, and file will be overwrited if exists. """ print 'Minifying JS... ', url = 'http://javascript-minifier.com/raw' #POST req = urllib2.Request(url, urllib.urlencode({'input': data}))...
[ "def", "jsMin", "(", "data", ",", "file", ")", ":", "print", "'Minifying JS... '", ",", "url", "=", "'http://javascript-minifier.com/raw'", "#POST", "req", "=", "urllib2", ".", "Request", "(", "url", ",", "urllib", ".", "urlencode", "(", "{", "'input'", ":",...
Minify JS data and saves to file. Data should be a string will whole JS content, and file will be overwrited if exists.
[ "Minify", "JS", "data", "and", "saves", "to", "file", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L105-L125
45,188
xgvargas/js-css-min-django
jscssmin.py
jpgMin
def jpgMin(file, force=False): """ Try to optimise a JPG file. The original will be saved at the same place with '.original' appended to its name. Once a .original exists the function will ignore this file unless force is True. """ if not os.path.isfile(file+'.original') or force: data...
python
def jpgMin(file, force=False): """ Try to optimise a JPG file. The original will be saved at the same place with '.original' appended to its name. Once a .original exists the function will ignore this file unless force is True. """ if not os.path.isfile(file+'.original') or force: data...
[ "def", "jpgMin", "(", "file", ",", "force", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "file", "+", "'.original'", ")", "or", "force", ":", "data", "=", "_read", "(", "file", ",", "'rb'", ")", "_save", "(", "file"...
Try to optimise a JPG file. The original will be saved at the same place with '.original' appended to its name. Once a .original exists the function will ignore this file unless force is True.
[ "Try", "to", "optimise", "a", "JPG", "file", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L151-L177
45,189
xgvargas/js-css-min-django
jscssmin.py
process
def process(obj): """ Process each block of the merger object. """ #merge all static and templates and less files merged = merge(obj) #save the full file if name defined if obj.get('full'): print 'Saving: {} ({:.2f}kB)'.format(obj['full'], len(merged)/1024.0) _save(obj['full...
python
def process(obj): """ Process each block of the merger object. """ #merge all static and templates and less files merged = merge(obj) #save the full file if name defined if obj.get('full'): print 'Saving: {} ({:.2f}kB)'.format(obj['full'], len(merged)/1024.0) _save(obj['full...
[ "def", "process", "(", "obj", ")", ":", "#merge all static and templates and less files", "merged", "=", "merge", "(", "obj", ")", "#save the full file if name defined", "if", "obj", ".", "get", "(", "'full'", ")", ":", "print", "'Saving: {} ({:.2f}kB)'", ".", "form...
Process each block of the merger object.
[ "Process", "each", "block", "of", "the", "merger", "object", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L284-L304
45,190
aisthesis/pynance
pynance/pf.py
optimize
def optimize(exp_rets, covs): """ Return parameters for portfolio optimization. Parameters ---------- exp_rets : ndarray Vector of expected returns for each investment.. covs : ndarray Covariance matrix for the given investments. Returns --------- a : ndarray ...
python
def optimize(exp_rets, covs): """ Return parameters for portfolio optimization. Parameters ---------- exp_rets : ndarray Vector of expected returns for each investment.. covs : ndarray Covariance matrix for the given investments. Returns --------- a : ndarray ...
[ "def", "optimize", "(", "exp_rets", ",", "covs", ")", ":", "_cov_inv", "=", "np", ".", "linalg", ".", "inv", "(", "covs", ")", "# unit vector", "_u", "=", "np", ".", "ones", "(", "(", "len", "(", "exp_rets", ")", ")", ")", "# compute some dot products ...
Return parameters for portfolio optimization. Parameters ---------- exp_rets : ndarray Vector of expected returns for each investment.. covs : ndarray Covariance matrix for the given investments. Returns --------- a : ndarray The first vector (to be combined with ta...
[ "Return", "parameters", "for", "portfolio", "optimization", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/pf.py#L13-L69
45,191
aisthesis/pynance
pynance/interest.py
growthfromrange
def growthfromrange(rangegrowth, startdate, enddate): """ Annual growth given growth from start date to end date. """ _yrs = (pd.Timestamp(enddate) - pd.Timestamp(startdate)).total_seconds() /\ dt.timedelta(365.25).total_seconds() return yrlygrowth(rangegrowth, _yrs)
python
def growthfromrange(rangegrowth, startdate, enddate): """ Annual growth given growth from start date to end date. """ _yrs = (pd.Timestamp(enddate) - pd.Timestamp(startdate)).total_seconds() /\ dt.timedelta(365.25).total_seconds() return yrlygrowth(rangegrowth, _yrs)
[ "def", "growthfromrange", "(", "rangegrowth", ",", "startdate", ",", "enddate", ")", ":", "_yrs", "=", "(", "pd", ".", "Timestamp", "(", "enddate", ")", "-", "pd", ".", "Timestamp", "(", "startdate", ")", ")", ".", "total_seconds", "(", ")", "/", "dt",...
Annual growth given growth from start date to end date.
[ "Annual", "growth", "given", "growth", "from", "start", "date", "to", "end", "date", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/interest.py#L30-L36
45,192
aisthesis/pynance
pynance/data/retrieve.py
equities
def equities(country='US'): """ Return a DataFrame of current US equities. .. versionadded:: 0.4.0 .. versionchanged:: 0.5.0 Return a DataFrame Parameters ---------- country : str, optional Country code for equities to return, defaults to 'US'. Returns ------- ...
python
def equities(country='US'): """ Return a DataFrame of current US equities. .. versionadded:: 0.4.0 .. versionchanged:: 0.5.0 Return a DataFrame Parameters ---------- country : str, optional Country code for equities to return, defaults to 'US'. Returns ------- ...
[ "def", "equities", "(", "country", "=", "'US'", ")", ":", "nasdaqblob", ",", "otherblob", "=", "_getrawdata", "(", ")", "eq_triples", "=", "[", "]", "eq_triples", ".", "extend", "(", "_get_nas_triples", "(", "nasdaqblob", ")", ")", "eq_triples", ".", "exte...
Return a DataFrame of current US equities. .. versionadded:: 0.4.0 .. versionchanged:: 0.5.0 Return a DataFrame Parameters ---------- country : str, optional Country code for equities to return, defaults to 'US'. Returns ------- eqs : :class:`pandas.DataFrame` ...
[ "Return", "a", "DataFrame", "of", "current", "US", "equities", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/retrieve.py#L36-L72
45,193
aisthesis/pynance
pynance/opt/spread/vert.py
Vert.straddle
def straddle(self, strike, expiry): """ Metrics for evaluating a straddle. Parameters ------------ strike : numeric Strike price. expiry : date or date str (e.g. '2015-01-01') Expiration date. Returns ------------ metrics ...
python
def straddle(self, strike, expiry): """ Metrics for evaluating a straddle. Parameters ------------ strike : numeric Strike price. expiry : date or date str (e.g. '2015-01-01') Expiration date. Returns ------------ metrics ...
[ "def", "straddle", "(", "self", ",", "strike", ",", "expiry", ")", ":", "_rows", "=", "{", "}", "_prices", "=", "{", "}", "for", "_opttype", "in", "_constants", ".", "OPTTYPES", ":", "_rows", "[", "_opttype", "]", "=", "_relevant_rows", "(", "self", ...
Metrics for evaluating a straddle. Parameters ------------ strike : numeric Strike price. expiry : date or date str (e.g. '2015-01-01') Expiration date. Returns ------------ metrics : DataFrame Metrics for evaluating straddle.
[ "Metrics", "for", "evaluating", "a", "straddle", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/spread/vert.py#L166-L192
45,194
aisthesis/pynance
pynance/opt/retrieve.py
get
def get(equity): """ Retrieve all current options chains for given equity. .. versionchanged:: 0.5.0 Eliminate special exception handling. Parameters ------------- equity : str Equity for which to retrieve options data. Returns ------------- optdata : :class:`~pynan...
python
def get(equity): """ Retrieve all current options chains for given equity. .. versionchanged:: 0.5.0 Eliminate special exception handling. Parameters ------------- equity : str Equity for which to retrieve options data. Returns ------------- optdata : :class:`~pynan...
[ "def", "get", "(", "equity", ")", ":", "_optmeta", "=", "pdr", ".", "data", ".", "Options", "(", "equity", ",", "'yahoo'", ")", "_optdata", "=", "_optmeta", ".", "get_all_data", "(", ")", "return", "Options", "(", "_optdata", ")" ]
Retrieve all current options chains for given equity. .. versionchanged:: 0.5.0 Eliminate special exception handling. Parameters ------------- equity : str Equity for which to retrieve options data. Returns ------------- optdata : :class:`~pynance.opt.core.Options` ...
[ "Retrieve", "all", "current", "options", "chains", "for", "given", "equity", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/retrieve.py#L17-L53
45,195
aisthesis/pynance
pynance/data/prep.py
transform
def transform(data_frame, **kwargs): """ Return a transformed DataFrame. Transform data_frame along the given axis. By default, each row will be normalized (axis=0). Parameters ----------- data_frame : DataFrame Data to be normalized. axis : int, optional 0 (default) to nor...
python
def transform(data_frame, **kwargs): """ Return a transformed DataFrame. Transform data_frame along the given axis. By default, each row will be normalized (axis=0). Parameters ----------- data_frame : DataFrame Data to be normalized. axis : int, optional 0 (default) to nor...
[ "def", "transform", "(", "data_frame", ",", "*", "*", "kwargs", ")", ":", "norm", "=", "kwargs", ".", "get", "(", "'norm'", ",", "1.0", ")", "axis", "=", "kwargs", ".", "get", "(", "'axis'", ",", "0", ")", "if", "axis", "==", "0", ":", "norm_vect...
Return a transformed DataFrame. Transform data_frame along the given axis. By default, each row will be normalized (axis=0). Parameters ----------- data_frame : DataFrame Data to be normalized. axis : int, optional 0 (default) to normalize each row, 1 to normalize each column. ...
[ "Return", "a", "transformed", "DataFrame", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/prep.py#L119-L181
45,196
aisthesis/pynance
pynance/data/prep.py
_get_norms_of_rows
def _get_norms_of_rows(data_frame, method): """ return a column vector containing the norm of each row """ if method == 'vector': norm_vector = np.linalg.norm(data_frame.values, axis=1) elif method == 'last': norm_vector = data_frame.iloc[:, -1].values elif method == 'mean': norm...
python
def _get_norms_of_rows(data_frame, method): """ return a column vector containing the norm of each row """ if method == 'vector': norm_vector = np.linalg.norm(data_frame.values, axis=1) elif method == 'last': norm_vector = data_frame.iloc[:, -1].values elif method == 'mean': norm...
[ "def", "_get_norms_of_rows", "(", "data_frame", ",", "method", ")", ":", "if", "method", "==", "'vector'", ":", "norm_vector", "=", "np", ".", "linalg", ".", "norm", "(", "data_frame", ".", "values", ",", "axis", "=", "1", ")", "elif", "method", "==", ...
return a column vector containing the norm of each row
[ "return", "a", "column", "vector", "containing", "the", "norm", "of", "each", "row" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/prep.py#L183-L195
45,197
aisthesis/pynance
pynance/opt/price.py
Price.get
def get(self, opttype, strike, expiry): """ Price as midpoint between bid and ask. Parameters ---------- opttype : str 'call' or 'put'. strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetim...
python
def get(self, opttype, strike, expiry): """ Price as midpoint between bid and ask. Parameters ---------- opttype : str 'call' or 'put'. strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetim...
[ "def", "get", "(", "self", ",", "opttype", ",", "strike", ",", "expiry", ")", ":", "_optrow", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "strike", ",", "expiry", ",", "opttype", ",", ")", ",", "\"No key for {} strike {} {}\"", ".", "forma...
Price as midpoint between bid and ask. Parameters ---------- opttype : str 'call' or 'put'. strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or a string that :mod:`pandas` can i...
[ "Price", "as", "midpoint", "between", "bid", "and", "ask", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L52-L79
45,198
aisthesis/pynance
pynance/opt/price.py
Price.metrics
def metrics(self, opttype, strike, expiry): """ Basic metrics for a specific option. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetim...
python
def metrics(self, opttype, strike, expiry): """ Basic metrics for a specific option. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetim...
[ "def", "metrics", "(", "self", ",", "opttype", ",", "strike", ",", "expiry", ")", ":", "_optrow", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "strike", ",", "expiry", ",", "opttype", ",", ")", ",", "\"No key for {} strike {} {}\"", ".", "f...
Basic metrics for a specific option. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or a string that :mod:`pandas` can interpret as s...
[ "Basic", "metrics", "for", "a", "specific", "option", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L81-L111
45,199
aisthesis/pynance
pynance/opt/price.py
Price.strikes
def strikes(self, opttype, expiry): """ Retrieve option prices for all strikes of a given type with a given expiration. Parameters ---------- opttype : str ('call' or 'put') expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or ...
python
def strikes(self, opttype, expiry): """ Retrieve option prices for all strikes of a given type with a given expiration. Parameters ---------- opttype : str ('call' or 'put') expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or ...
[ "def", "strikes", "(", "self", ",", "opttype", ",", "expiry", ")", ":", "_relevant", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "slice", "(", "None", ")", ",", "expiry", ",", "opttype", ",", ")", ",", "\"No key for {} {}\"", ".", "forma...
Retrieve option prices for all strikes of a given type with a given expiration. Parameters ---------- opttype : str ('call' or 'put') expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or a string that :mod:`pandas` can interpret as such, e.g...
[ "Retrieve", "option", "prices", "for", "all", "strikes", "of", "a", "given", "type", "with", "a", "given", "expiration", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L113-L148