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 listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mgedmin/imgdiff | imgdiff.py | best_diff | def best_diff(img1, img2, opts):
"""Find the best alignment of two images that minimizes the differences.
Returns (diff, alignments) where ``diff`` is a difference map, and
``alignments`` is a tuple ((x1, y2), (x2, y2)).
See ``diff()`` for the description of the alignment numbers.
"""
w1, h1 =... | python | def best_diff(img1, img2, opts):
"""Find the best alignment of two images that minimizes the differences.
Returns (diff, alignments) where ``diff`` is a difference map, and
``alignments`` is a tuple ((x1, y2), (x2, y2)).
See ``diff()`` for the description of the alignment numbers.
"""
w1, h1 =... | [
"def",
"best_diff",
"(",
"img1",
",",
"img2",
",",
"opts",
")",
":",
"w1",
",",
"h1",
"=",
"img1",
".",
"size",
"w2",
",",
"h2",
"=",
"img2",
".",
"size",
"w",
",",
"h",
"=",
"min",
"(",
"w1",
",",
"w2",
")",
",",
"min",
"(",
"h1",
",",
"... | Find the best alignment of two images that minimizes the differences.
Returns (diff, alignments) where ``diff`` is a difference map, and
``alignments`` is a tuple ((x1, y2), (x2, y2)).
See ``diff()`` for the description of the alignment numbers. | [
"Find",
"the",
"best",
"alignment",
"of",
"two",
"images",
"that",
"minimizes",
"the",
"differences",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L415-L450 | train | 62,000 |
mgedmin/imgdiff | imgdiff.py | simple_highlight | def simple_highlight(img1, img2, opts):
"""Try to align the two images to minimize pixel differences.
Produces two masks for img1 and img2.
The algorithm works by comparing every possible alignment of the images,
finding the aligment that minimzes the differences, and then smoothing
it a bit to re... | python | def simple_highlight(img1, img2, opts):
"""Try to align the two images to minimize pixel differences.
Produces two masks for img1 and img2.
The algorithm works by comparing every possible alignment of the images,
finding the aligment that minimzes the differences, and then smoothing
it a bit to re... | [
"def",
"simple_highlight",
"(",
"img1",
",",
"img2",
",",
"opts",
")",
":",
"try",
":",
"diff",
",",
"(",
"(",
"x1",
",",
"y1",
")",
",",
"(",
"x2",
",",
"y2",
")",
")",
"=",
"best_diff",
"(",
"img1",
",",
"img2",
",",
"opts",
")",
"except",
... | Try to align the two images to minimize pixel differences.
Produces two masks for img1 and img2.
The algorithm works by comparing every possible alignment of the images,
finding the aligment that minimzes the differences, and then smoothing
it a bit to reduce spurious matches in areas that are percept... | [
"Try",
"to",
"align",
"the",
"two",
"images",
"to",
"minimize",
"pixel",
"differences",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L453-L478 | train | 62,001 |
mgedmin/imgdiff | imgdiff.py | slow_highlight | def slow_highlight(img1, img2, opts):
"""Try to find similar areas between two images.
Produces two masks for img1 and img2.
The algorithm works by comparing every possible alignment of the images,
smoothing it a bit to reduce spurious matches in areas that are
perceptibly different (e.g. text), a... | python | def slow_highlight(img1, img2, opts):
"""Try to find similar areas between two images.
Produces two masks for img1 and img2.
The algorithm works by comparing every possible alignment of the images,
smoothing it a bit to reduce spurious matches in areas that are
perceptibly different (e.g. text), a... | [
"def",
"slow_highlight",
"(",
"img1",
",",
"img2",
",",
"opts",
")",
":",
"w1",
",",
"h1",
"=",
"img1",
".",
"size",
"w2",
",",
"h2",
"=",
"img2",
".",
"size",
"W",
",",
"H",
"=",
"max",
"(",
"w1",
",",
"w2",
")",
",",
"max",
"(",
"h1",
","... | Try to find similar areas between two images.
Produces two masks for img1 and img2.
The algorithm works by comparing every possible alignment of the images,
smoothing it a bit to reduce spurious matches in areas that are
perceptibly different (e.g. text), and then taking the point-wise minimum
of ... | [
"Try",
"to",
"find",
"similar",
"areas",
"between",
"two",
"images",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L481-L552 | train | 62,002 |
LinuxChristian/pyW215 | pyW215/pyW215.py | SmartPlug.SOAPAction | def SOAPAction(self, Action, responseElement, params = "", recursive = False):
"""Generate the SOAP action call.
:type Action: str
:type responseElement: str
:type params: str
:type recursive: bool
:param Action: The action to perform on the device
:param respons... | python | def SOAPAction(self, Action, responseElement, params = "", recursive = False):
"""Generate the SOAP action call.
:type Action: str
:type responseElement: str
:type params: str
:type recursive: bool
:param Action: The action to perform on the device
:param respons... | [
"def",
"SOAPAction",
"(",
"self",
",",
"Action",
",",
"responseElement",
",",
"params",
"=",
"\"\"",
",",
"recursive",
"=",
"False",
")",
":",
"# Authenticate client",
"if",
"self",
".",
"authenticated",
"is",
"None",
":",
"self",
".",
"authenticated",
"=",
... | Generate the SOAP action call.
:type Action: str
:type responseElement: str
:type params: str
:type recursive: bool
:param Action: The action to perform on the device
:param responseElement: The XML element that is returned upon success
:param params: Any additio... | [
"Generate",
"the",
"SOAP",
"action",
"call",
"."
] | 63e50b8ee11bc38ed66554f9b92429b552dda550 | https://github.com/LinuxChristian/pyW215/blob/63e50b8ee11bc38ed66554f9b92429b552dda550/pyW215/pyW215.py#L117-L184 | train | 62,003 |
LinuxChristian/pyW215 | pyW215/pyW215.py | SmartPlug.fetchMyCgi | def fetchMyCgi(self):
"""Fetches statistics from my_cgi.cgi"""
try:
response = urlopen(Request('http://{}/my_cgi.cgi'.format(self.ip), b'request=create_chklst'));
except (HTTPError, URLError):
_LOGGER.warning("Failed to open url to {}".format(self.ip))
self._e... | python | def fetchMyCgi(self):
"""Fetches statistics from my_cgi.cgi"""
try:
response = urlopen(Request('http://{}/my_cgi.cgi'.format(self.ip), b'request=create_chklst'));
except (HTTPError, URLError):
_LOGGER.warning("Failed to open url to {}".format(self.ip))
self._e... | [
"def",
"fetchMyCgi",
"(",
"self",
")",
":",
"try",
":",
"response",
"=",
"urlopen",
"(",
"Request",
"(",
"'http://{}/my_cgi.cgi'",
".",
"format",
"(",
"self",
".",
"ip",
")",
",",
"b'request=create_chklst'",
")",
")",
"except",
"(",
"HTTPError",
",",
"URLE... | Fetches statistics from my_cgi.cgi | [
"Fetches",
"statistics",
"from",
"my_cgi",
".",
"cgi"
] | 63e50b8ee11bc38ed66554f9b92429b552dda550 | https://github.com/LinuxChristian/pyW215/blob/63e50b8ee11bc38ed66554f9b92429b552dda550/pyW215/pyW215.py#L186-L196 | train | 62,004 |
LinuxChristian/pyW215 | pyW215/pyW215.py | SmartPlug.current_consumption | def current_consumption(self):
"""Get the current power consumption in Watt."""
res = 'N/A'
if self.use_legacy_protocol:
# Use /my_cgi.cgi to retrieve current consumption
try:
res = self.fetchMyCgi()['Meter Watt']
except:
return... | python | def current_consumption(self):
"""Get the current power consumption in Watt."""
res = 'N/A'
if self.use_legacy_protocol:
# Use /my_cgi.cgi to retrieve current consumption
try:
res = self.fetchMyCgi()['Meter Watt']
except:
return... | [
"def",
"current_consumption",
"(",
"self",
")",
":",
"res",
"=",
"'N/A'",
"if",
"self",
".",
"use_legacy_protocol",
":",
"# Use /my_cgi.cgi to retrieve current consumption",
"try",
":",
"res",
"=",
"self",
".",
"fetchMyCgi",
"(",
")",
"[",
"'Meter Watt'",
"]",
"... | Get the current power consumption in Watt. | [
"Get",
"the",
"current",
"power",
"consumption",
"in",
"Watt",
"."
] | 63e50b8ee11bc38ed66554f9b92429b552dda550 | https://github.com/LinuxChristian/pyW215/blob/63e50b8ee11bc38ed66554f9b92429b552dda550/pyW215/pyW215.py#L199-L222 | train | 62,005 |
LinuxChristian/pyW215 | pyW215/pyW215.py | SmartPlug.total_consumption | def total_consumption(self):
"""Get the total power consumpuntion in the device lifetime."""
if self.use_legacy_protocol:
# TotalConsumption currently fails on the legacy protocol and
# creates a mess in the logs. Just return 'N/A' for now.
return 'N/A'
res =... | python | def total_consumption(self):
"""Get the total power consumpuntion in the device lifetime."""
if self.use_legacy_protocol:
# TotalConsumption currently fails on the legacy protocol and
# creates a mess in the logs. Just return 'N/A' for now.
return 'N/A'
res =... | [
"def",
"total_consumption",
"(",
"self",
")",
":",
"if",
"self",
".",
"use_legacy_protocol",
":",
"# TotalConsumption currently fails on the legacy protocol and",
"# creates a mess in the logs. Just return 'N/A' for now.",
"return",
"'N/A'",
"res",
"=",
"'N/A'",
"try",
":",
"... | Get the total power consumpuntion in the device lifetime. | [
"Get",
"the",
"total",
"power",
"consumpuntion",
"in",
"the",
"device",
"lifetime",
"."
] | 63e50b8ee11bc38ed66554f9b92429b552dda550 | https://github.com/LinuxChristian/pyW215/blob/63e50b8ee11bc38ed66554f9b92429b552dda550/pyW215/pyW215.py#L229-L250 | train | 62,006 |
LinuxChristian/pyW215 | pyW215/pyW215.py | SmartPlug.state | def state(self, value):
"""Set device state.
:type value: str
:param value: Future state (either ON or OFF)
"""
if value.upper() == ON:
return self.SOAPAction('SetSocketSettings', 'SetSocketSettingsResult', self.controlParameters("1", "true"))
elif value.uppe... | python | def state(self, value):
"""Set device state.
:type value: str
:param value: Future state (either ON or OFF)
"""
if value.upper() == ON:
return self.SOAPAction('SetSocketSettings', 'SetSocketSettingsResult', self.controlParameters("1", "true"))
elif value.uppe... | [
"def",
"state",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
".",
"upper",
"(",
")",
"==",
"ON",
":",
"return",
"self",
".",
"SOAPAction",
"(",
"'SetSocketSettings'",
",",
"'SetSocketSettingsResult'",
",",
"self",
".",
"controlParameters",
"(",
"\"1... | Set device state.
:type value: str
:param value: Future state (either ON or OFF) | [
"Set",
"device",
"state",
"."
] | 63e50b8ee11bc38ed66554f9b92429b552dda550 | https://github.com/LinuxChristian/pyW215/blob/63e50b8ee11bc38ed66554f9b92429b552dda550/pyW215/pyW215.py#L285-L296 | train | 62,007 |
LinuxChristian/pyW215 | pyW215/pyW215.py | SmartPlug.auth | def auth(self):
"""Authenticate using the SOAP interface.
Authentication is a two-step process. First a initial payload
is sent to the device requesting additional login information in the form
of a publickey, a challenge string and a cookie.
These values are then hashed by a MD... | python | def auth(self):
"""Authenticate using the SOAP interface.
Authentication is a two-step process. First a initial payload
is sent to the device requesting additional login information in the form
of a publickey, a challenge string and a cookie.
These values are then hashed by a MD... | [
"def",
"auth",
"(",
"self",
")",
":",
"payload",
"=",
"self",
".",
"initial_auth_payload",
"(",
")",
"# Build initial header",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'\"text/xml; charset=utf-8\"'",
",",
"'SOAPAction'",
":",
"'\"http://purenetworks.com/HNAP1/Login\... | Authenticate using the SOAP interface.
Authentication is a two-step process. First a initial payload
is sent to the device requesting additional login information in the form
of a publickey, a challenge string and a cookie.
These values are then hashed by a MD5 algorithm producing a pri... | [
"Authenticate",
"using",
"the",
"SOAP",
"interface",
"."
] | 63e50b8ee11bc38ed66554f9b92429b552dda550 | https://github.com/LinuxChristian/pyW215/blob/63e50b8ee11bc38ed66554f9b92429b552dda550/pyW215/pyW215.py#L302-L374 | train | 62,008 |
TeamHG-Memex/json-lines | json_lines/_gzip.py | get_known_read_position | def get_known_read_position(fp, buffered=True):
"""
Return a position in a file which is known to be read & handled.
It assumes a buffered file and streaming processing.
"""
buffer_size = io.DEFAULT_BUFFER_SIZE if buffered else 0
return max(fp.tell() - buffer_size, 0) | python | def get_known_read_position(fp, buffered=True):
"""
Return a position in a file which is known to be read & handled.
It assumes a buffered file and streaming processing.
"""
buffer_size = io.DEFAULT_BUFFER_SIZE if buffered else 0
return max(fp.tell() - buffer_size, 0) | [
"def",
"get_known_read_position",
"(",
"fp",
",",
"buffered",
"=",
"True",
")",
":",
"buffer_size",
"=",
"io",
".",
"DEFAULT_BUFFER_SIZE",
"if",
"buffered",
"else",
"0",
"return",
"max",
"(",
"fp",
".",
"tell",
"(",
")",
"-",
"buffer_size",
",",
"0",
")"... | Return a position in a file which is known to be read & handled.
It assumes a buffered file and streaming processing. | [
"Return",
"a",
"position",
"in",
"a",
"file",
"which",
"is",
"known",
"to",
"be",
"read",
"&",
"handled",
".",
"It",
"assumes",
"a",
"buffered",
"file",
"and",
"streaming",
"processing",
"."
] | b0488ac746c90065f1599e51b710205d9c2392ad | https://github.com/TeamHG-Memex/json-lines/blob/b0488ac746c90065f1599e51b710205d9c2392ad/json_lines/_gzip.py#L10-L16 | train | 62,009 |
TeamHG-Memex/json-lines | json_lines/_gzip.py | recover | def recover(gzfile, last_good_position):
# type: (gzip.GzipFile, int) -> gzip.GzipFile
"""
Skip to the next possibly decompressable part of a gzip file.
Return a new GzipFile object if such part is found or None
if it is not found.
"""
pos = get_recover_position(gzfile, last_good_position=l... | python | def recover(gzfile, last_good_position):
# type: (gzip.GzipFile, int) -> gzip.GzipFile
"""
Skip to the next possibly decompressable part of a gzip file.
Return a new GzipFile object if such part is found or None
if it is not found.
"""
pos = get_recover_position(gzfile, last_good_position=l... | [
"def",
"recover",
"(",
"gzfile",
",",
"last_good_position",
")",
":",
"# type: (gzip.GzipFile, int) -> gzip.GzipFile",
"pos",
"=",
"get_recover_position",
"(",
"gzfile",
",",
"last_good_position",
"=",
"last_good_position",
")",
"if",
"pos",
"==",
"-",
"1",
":",
"re... | Skip to the next possibly decompressable part of a gzip file.
Return a new GzipFile object if such part is found or None
if it is not found. | [
"Skip",
"to",
"the",
"next",
"possibly",
"decompressable",
"part",
"of",
"a",
"gzip",
"file",
".",
"Return",
"a",
"new",
"GzipFile",
"object",
"if",
"such",
"part",
"is",
"found",
"or",
"None",
"if",
"it",
"is",
"not",
"found",
"."
] | b0488ac746c90065f1599e51b710205d9c2392ad | https://github.com/TeamHG-Memex/json-lines/blob/b0488ac746c90065f1599e51b710205d9c2392ad/json_lines/_gzip.py#L19-L32 | train | 62,010 |
TeamHG-Memex/json-lines | json_lines/utils.py | maybe_gzip_open | def maybe_gzip_open(path, *args, **kwargs):
"""
Open file with either open or gzip.open, depending on file extension.
This function doesn't handle json lines format, just opens a file
in a way it is decoded transparently if needed.
"""
path = path_to_str(path)
if path.endswith('.gz') or pat... | python | def maybe_gzip_open(path, *args, **kwargs):
"""
Open file with either open or gzip.open, depending on file extension.
This function doesn't handle json lines format, just opens a file
in a way it is decoded transparently if needed.
"""
path = path_to_str(path)
if path.endswith('.gz') or pat... | [
"def",
"maybe_gzip_open",
"(",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"path_to_str",
"(",
"path",
")",
"if",
"path",
".",
"endswith",
"(",
"'.gz'",
")",
"or",
"path",
".",
"endswith",
"(",
"'.gzip'",
")",
":",
"_o... | Open file with either open or gzip.open, depending on file extension.
This function doesn't handle json lines format, just opens a file
in a way it is decoded transparently if needed. | [
"Open",
"file",
"with",
"either",
"open",
"or",
"gzip",
".",
"open",
"depending",
"on",
"file",
"extension",
"."
] | b0488ac746c90065f1599e51b710205d9c2392ad | https://github.com/TeamHG-Memex/json-lines/blob/b0488ac746c90065f1599e51b710205d9c2392ad/json_lines/utils.py#L7-L19 | train | 62,011 |
TeamHG-Memex/json-lines | json_lines/utils.py | path_to_str | def path_to_str(path):
""" Convert pathlib.Path objects to str; return other objects as-is. """
try:
from pathlib import Path as _Path
except ImportError: # Python < 3.4
class _Path:
pass
if isinstance(path, _Path):
return str(path)
return path | python | def path_to_str(path):
""" Convert pathlib.Path objects to str; return other objects as-is. """
try:
from pathlib import Path as _Path
except ImportError: # Python < 3.4
class _Path:
pass
if isinstance(path, _Path):
return str(path)
return path | [
"def",
"path_to_str",
"(",
"path",
")",
":",
"try",
":",
"from",
"pathlib",
"import",
"Path",
"as",
"_Path",
"except",
"ImportError",
":",
"# Python < 3.4",
"class",
"_Path",
":",
"pass",
"if",
"isinstance",
"(",
"path",
",",
"_Path",
")",
":",
"return",
... | Convert pathlib.Path objects to str; return other objects as-is. | [
"Convert",
"pathlib",
".",
"Path",
"objects",
"to",
"str",
";",
"return",
"other",
"objects",
"as",
"-",
"is",
"."
] | b0488ac746c90065f1599e51b710205d9c2392ad | https://github.com/TeamHG-Memex/json-lines/blob/b0488ac746c90065f1599e51b710205d9c2392ad/json_lines/utils.py#L22-L31 | train | 62,012 |
croach/django-simple-rest | simple_rest/auth/signature.py | calculate_signature | def calculate_signature(key, data, timestamp=None):
"""
Calculates the signature for the given request data.
"""
# Create a timestamp if one was not given
if timestamp is None:
timestamp = int(time.time())
# Construct the message from the timestamp and the data in the request
messag... | python | def calculate_signature(key, data, timestamp=None):
"""
Calculates the signature for the given request data.
"""
# Create a timestamp if one was not given
if timestamp is None:
timestamp = int(time.time())
# Construct the message from the timestamp and the data in the request
messag... | [
"def",
"calculate_signature",
"(",
"key",
",",
"data",
",",
"timestamp",
"=",
"None",
")",
":",
"# Create a timestamp if one was not given",
"if",
"timestamp",
"is",
"None",
":",
"timestamp",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"# Construct th... | Calculates the signature for the given request data. | [
"Calculates",
"the",
"signature",
"for",
"the",
"given",
"request",
"data",
"."
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/auth/signature.py#L6-L20 | train | 62,013 |
rs/eve-auth-jwt | eve_auth_jwt/auth.py | JWTAuth.authenticate | def authenticate(self):
"""
Indicate to the client that it needs to authenticate via a 401.
"""
if request.headers.get('Authorization') or request.args.get('access_token'):
realm = 'Bearer realm="%s", error="invalid_token"' % __package__
else:
realm = 'Bea... | python | def authenticate(self):
"""
Indicate to the client that it needs to authenticate via a 401.
"""
if request.headers.get('Authorization') or request.args.get('access_token'):
realm = 'Bearer realm="%s", error="invalid_token"' % __package__
else:
realm = 'Bea... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"if",
"request",
".",
"headers",
".",
"get",
"(",
"'Authorization'",
")",
"or",
"request",
".",
"args",
".",
"get",
"(",
"'access_token'",
")",
":",
"realm",
"=",
"'Bearer realm=\"%s\", error=\"invalid_token\"'",
"... | Indicate to the client that it needs to authenticate via a 401. | [
"Indicate",
"to",
"the",
"client",
"that",
"it",
"needs",
"to",
"authenticate",
"via",
"a",
"401",
"."
] | 23c906433de80cf60cab93381a8996b17938651e | https://github.com/rs/eve-auth-jwt/blob/23c906433de80cf60cab93381a8996b17938651e/eve_auth_jwt/auth.py#L73-L82 | train | 62,014 |
rs/eve-auth-jwt | eve_auth_jwt/auth.py | JWTAuth.check_token | def check_token(self, token, allowed_roles, resource, method):
"""
This function is called when a token is sent throught the access_token
parameter or the Authorization header as specified in the oAuth 2 specification.
The provided token is validated with the JWT_SECRET defined in the E... | python | def check_token(self, token, allowed_roles, resource, method):
"""
This function is called when a token is sent throught the access_token
parameter or the Authorization header as specified in the oAuth 2 specification.
The provided token is validated with the JWT_SECRET defined in the E... | [
"def",
"check_token",
"(",
"self",
",",
"token",
",",
"allowed_roles",
",",
"resource",
",",
"method",
")",
":",
"resource_conf",
"=",
"config",
".",
"DOMAIN",
"[",
"resource",
"]",
"audiences",
"=",
"resource_conf",
".",
"get",
"(",
"'audiences'",
",",
"c... | This function is called when a token is sent throught the access_token
parameter or the Authorization header as specified in the oAuth 2 specification.
The provided token is validated with the JWT_SECRET defined in the Eve configuration.
The token issuer (iss claim) must be the one specified by... | [
"This",
"function",
"is",
"called",
"when",
"a",
"token",
"is",
"sent",
"throught",
"the",
"access_token",
"parameter",
"or",
"the",
"Authorization",
"header",
"as",
"specified",
"in",
"the",
"oAuth",
"2",
"specification",
"."
] | 23c906433de80cf60cab93381a8996b17938651e | https://github.com/rs/eve-auth-jwt/blob/23c906433de80cf60cab93381a8996b17938651e/eve_auth_jwt/auth.py#L84-L106 | train | 62,015 |
rs/eve-auth-jwt | eve_auth_jwt/auth.py | JWTAuth.requires_token | def requires_token(self, audiences=None, allowed_roles=None):
"""
Decorator for functions that will be protected with token authentication.
Token must be provvided either through access_token parameter or Authorization
header.
See check_token() method for further details.
... | python | def requires_token(self, audiences=None, allowed_roles=None):
"""
Decorator for functions that will be protected with token authentication.
Token must be provvided either through access_token parameter or Authorization
header.
See check_token() method for further details.
... | [
"def",
"requires_token",
"(",
"self",
",",
"audiences",
"=",
"None",
",",
"allowed_roles",
"=",
"None",
")",
":",
"def",
"requires_token_wrapper",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"... | Decorator for functions that will be protected with token authentication.
Token must be provvided either through access_token parameter or Authorization
header.
See check_token() method for further details. | [
"Decorator",
"for",
"functions",
"that",
"will",
"be",
"protected",
"with",
"token",
"authentication",
"."
] | 23c906433de80cf60cab93381a8996b17938651e | https://github.com/rs/eve-auth-jwt/blob/23c906433de80cf60cab93381a8996b17938651e/eve_auth_jwt/auth.py#L108-L130 | train | 62,016 |
mherrmann/pypxlib | pypxlib/pxlib_ctypes/py2.py | LibraryLoader.load_library | def load_library(self,libname):
"""Given the name of a library, load it."""
paths = self.getpaths(libname)
for path in paths:
if os.path.exists(path):
return self.load(path)
raise ImportError("%s not found." % libname) | python | def load_library(self,libname):
"""Given the name of a library, load it."""
paths = self.getpaths(libname)
for path in paths:
if os.path.exists(path):
return self.load(path)
raise ImportError("%s not found." % libname) | [
"def",
"load_library",
"(",
"self",
",",
"libname",
")",
":",
"paths",
"=",
"self",
".",
"getpaths",
"(",
"libname",
")",
"for",
"path",
"in",
"paths",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"self",
".",
"load... | Given the name of a library, load it. | [
"Given",
"the",
"name",
"of",
"a",
"library",
"load",
"it",
"."
] | b2235383fe27f46a1f2e4c283403cc39f1b58a19 | https://github.com/mherrmann/pypxlib/blob/b2235383fe27f46a1f2e4c283403cc39f1b58a19/pypxlib/pxlib_ctypes/py2.py#L360-L368 | train | 62,017 |
mherrmann/pypxlib | pypxlib/pxlib_ctypes/py2.py | LibraryLoader.getpaths | def getpaths(self,libname):
"""Return a list of paths where the library might be found."""
if os.path.isabs(libname):
yield libname
else:
# FIXME / TODO return '.' and os.path.dirname(__file__)
for path in self.getplatformpaths(libname):
yield ... | python | def getpaths(self,libname):
"""Return a list of paths where the library might be found."""
if os.path.isabs(libname):
yield libname
else:
# FIXME / TODO return '.' and os.path.dirname(__file__)
for path in self.getplatformpaths(libname):
yield ... | [
"def",
"getpaths",
"(",
"self",
",",
"libname",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"libname",
")",
":",
"yield",
"libname",
"else",
":",
"# FIXME / TODO return '.' and os.path.dirname(__file__)",
"for",
"path",
"in",
"self",
".",
"getplatfor... | Return a list of paths where the library might be found. | [
"Return",
"a",
"list",
"of",
"paths",
"where",
"the",
"library",
"might",
"be",
"found",
"."
] | b2235383fe27f46a1f2e4c283403cc39f1b58a19 | https://github.com/mherrmann/pypxlib/blob/b2235383fe27f46a1f2e4c283403cc39f1b58a19/pypxlib/pxlib_ctypes/py2.py#L384-L394 | train | 62,018 |
croach/django-simple-rest | simple_rest/utils/serializers.py | to_json | def to_json(content, indent=None):
"""
Serializes a python object as JSON
This method uses the DJangoJSONEncoder to to ensure that python objects
such as Decimal objects are properly serialized. It can also serialize
Django QuerySet objects.
"""
if isinstance(content, QuerySet):
jso... | python | def to_json(content, indent=None):
"""
Serializes a python object as JSON
This method uses the DJangoJSONEncoder to to ensure that python objects
such as Decimal objects are properly serialized. It can also serialize
Django QuerySet objects.
"""
if isinstance(content, QuerySet):
jso... | [
"def",
"to_json",
"(",
"content",
",",
"indent",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"content",
",",
"QuerySet",
")",
":",
"json_serializer",
"=",
"serializers",
".",
"get_serializer",
"(",
"'json'",
")",
"(",
")",
"serialized_content",
"=",
"j... | Serializes a python object as JSON
This method uses the DJangoJSONEncoder to to ensure that python objects
such as Decimal objects are properly serialized. It can also serialize
Django QuerySet objects. | [
"Serializes",
"a",
"python",
"object",
"as",
"JSON"
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/utils/serializers.py#L33-L50 | train | 62,019 |
croach/django-simple-rest | simple_rest/utils/serializers.py | to_html | def to_html(data):
"""
Serializes a python object as HTML
This method uses the to_json method to turn the given data object into
formatted JSON that is displayed in an HTML page. If pygments in installed,
syntax highlighting will also be applied to the JSON.
"""
base_html_template = Templat... | python | def to_html(data):
"""
Serializes a python object as HTML
This method uses the to_json method to turn the given data object into
formatted JSON that is displayed in an HTML page. If pygments in installed,
syntax highlighting will also be applied to the JSON.
"""
base_html_template = Templat... | [
"def",
"to_html",
"(",
"data",
")",
":",
"base_html_template",
"=",
"Template",
"(",
"'''\n <html>\n <head>\n {% if style %}\n <style type=\"text/css\">\n {{ style }}\n </style>\n {% endif %}\n ... | Serializes a python object as HTML
This method uses the to_json method to turn the given data object into
formatted JSON that is displayed in an HTML page. If pygments in installed,
syntax highlighting will also be applied to the JSON. | [
"Serializes",
"a",
"python",
"object",
"as",
"HTML"
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/utils/serializers.py#L53-L90 | train | 62,020 |
croach/django-simple-rest | simple_rest/utils/serializers.py | to_text | def to_text(data):
"""
Serializes a python object as plain text
If the data can be serialized as JSON, this method will use the to_json
method to format the data, otherwise the data is returned as is.
"""
try:
serialized_content = to_json(data, indent=4)
except Exception, e:
... | python | def to_text(data):
"""
Serializes a python object as plain text
If the data can be serialized as JSON, this method will use the to_json
method to format the data, otherwise the data is returned as is.
"""
try:
serialized_content = to_json(data, indent=4)
except Exception, e:
... | [
"def",
"to_text",
"(",
"data",
")",
":",
"try",
":",
"serialized_content",
"=",
"to_json",
"(",
"data",
",",
"indent",
"=",
"4",
")",
"except",
"Exception",
",",
"e",
":",
"serialized_content",
"=",
"data",
"return",
"serialized_content"
] | Serializes a python object as plain text
If the data can be serialized as JSON, this method will use the to_json
method to format the data, otherwise the data is returned as is. | [
"Serializes",
"a",
"python",
"object",
"as",
"plain",
"text"
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/utils/serializers.py#L92-L103 | train | 62,021 |
croach/django-simple-rest | simple_rest/auth/decorators.py | auth_required | def auth_required(secret_key_func):
"""
Requires that the user be authenticated either by a signature or by
being actively logged in.
"""
def actual_decorator(obj):
def test_func(request, *args, **kwargs):
secret_key = secret_key_func(request, *args, **kwargs)
return... | python | def auth_required(secret_key_func):
"""
Requires that the user be authenticated either by a signature or by
being actively logged in.
"""
def actual_decorator(obj):
def test_func(request, *args, **kwargs):
secret_key = secret_key_func(request, *args, **kwargs)
return... | [
"def",
"auth_required",
"(",
"secret_key_func",
")",
":",
"def",
"actual_decorator",
"(",
"obj",
")",
":",
"def",
"test_func",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"secret_key",
"=",
"secret_key_func",
"(",
"request",
",",
... | Requires that the user be authenticated either by a signature or by
being actively logged in. | [
"Requires",
"that",
"the",
"user",
"be",
"authenticated",
"either",
"by",
"a",
"signature",
"or",
"by",
"being",
"actively",
"logged",
"in",
"."
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/auth/decorators.py#L10-L24 | train | 62,022 |
croach/django-simple-rest | simple_rest/auth/decorators.py | login_required | def login_required(obj):
"""
Requires that the user be logged in order to gain access to the resource
at the specified the URI.
"""
decorator = request_passes_test(lambda r, *args, **kwargs: r.user.is_authenticated())
return wrap_object(obj, decorator) | python | def login_required(obj):
"""
Requires that the user be logged in order to gain access to the resource
at the specified the URI.
"""
decorator = request_passes_test(lambda r, *args, **kwargs: r.user.is_authenticated())
return wrap_object(obj, decorator) | [
"def",
"login_required",
"(",
"obj",
")",
":",
"decorator",
"=",
"request_passes_test",
"(",
"lambda",
"r",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
":",
"r",
".",
"user",
".",
"is_authenticated",
"(",
")",
")",
"return",
"wrap_object",
"(",
"obj",
"... | Requires that the user be logged in order to gain access to the resource
at the specified the URI. | [
"Requires",
"that",
"the",
"user",
"be",
"logged",
"in",
"order",
"to",
"gain",
"access",
"to",
"the",
"resource",
"at",
"the",
"specified",
"the",
"URI",
"."
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/auth/decorators.py#L27-L33 | train | 62,023 |
croach/django-simple-rest | simple_rest/auth/decorators.py | admin_required | def admin_required(obj):
"""
Requires that the user be logged AND be set as a superuser
"""
decorator = request_passes_test(lambda r, *args, **kwargs: r.user.is_superuser)
return wrap_object(obj, decorator) | python | def admin_required(obj):
"""
Requires that the user be logged AND be set as a superuser
"""
decorator = request_passes_test(lambda r, *args, **kwargs: r.user.is_superuser)
return wrap_object(obj, decorator) | [
"def",
"admin_required",
"(",
"obj",
")",
":",
"decorator",
"=",
"request_passes_test",
"(",
"lambda",
"r",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
":",
"r",
".",
"user",
".",
"is_superuser",
")",
"return",
"wrap_object",
"(",
"obj",
",",
"decorator",... | Requires that the user be logged AND be set as a superuser | [
"Requires",
"that",
"the",
"user",
"be",
"logged",
"AND",
"be",
"set",
"as",
"a",
"superuser"
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/auth/decorators.py#L36-L41 | train | 62,024 |
croach/django-simple-rest | simple_rest/auth/decorators.py | signature_required | def signature_required(secret_key_func):
"""
Requires that the request contain a valid signature to gain access
to a specified resource.
"""
def actual_decorator(obj):
def test_func(request, *args, **kwargs):
secret_key = secret_key_func(request, *args, **kwargs)
ret... | python | def signature_required(secret_key_func):
"""
Requires that the request contain a valid signature to gain access
to a specified resource.
"""
def actual_decorator(obj):
def test_func(request, *args, **kwargs):
secret_key = secret_key_func(request, *args, **kwargs)
ret... | [
"def",
"signature_required",
"(",
"secret_key_func",
")",
":",
"def",
"actual_decorator",
"(",
"obj",
")",
":",
"def",
"test_func",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"secret_key",
"=",
"secret_key_func",
"(",
"request",
"... | Requires that the request contain a valid signature to gain access
to a specified resource. | [
"Requires",
"that",
"the",
"request",
"contain",
"a",
"valid",
"signature",
"to",
"gain",
"access",
"to",
"a",
"specified",
"resource",
"."
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/auth/decorators.py#L44-L58 | train | 62,025 |
croach/django-simple-rest | simple_rest/auth/decorators.py | validate_signature | def validate_signature(request, secret_key):
"""
Validates the signature associated with the given request.
"""
# Extract the request parameters according to the HTTP method
data = request.GET.copy()
if request.method != 'GET':
message_body = getattr(request, request.method, {})
... | python | def validate_signature(request, secret_key):
"""
Validates the signature associated with the given request.
"""
# Extract the request parameters according to the HTTP method
data = request.GET.copy()
if request.method != 'GET':
message_body = getattr(request, request.method, {})
... | [
"def",
"validate_signature",
"(",
"request",
",",
"secret_key",
")",
":",
"# Extract the request parameters according to the HTTP method",
"data",
"=",
"request",
".",
"GET",
".",
"copy",
"(",
")",
"if",
"request",
".",
"method",
"!=",
"'GET'",
":",
"message_body",
... | Validates the signature associated with the given request. | [
"Validates",
"the",
"signature",
"associated",
"with",
"the",
"given",
"request",
"."
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/auth/decorators.py#L78-L119 | train | 62,026 |
gtaylor/django-dynamodb-sessions | dynamodb_sessions/backends/dynamodb.py | SessionStore.exists | def exists(self, session_key):
"""
Checks to see if a session currently exists in DynamoDB.
:rtype: bool
:returns: ``True`` if a session with the given key exists in the DB,
``False`` if not.
"""
response = self.table.get_item(
Key={'session_key'... | python | def exists(self, session_key):
"""
Checks to see if a session currently exists in DynamoDB.
:rtype: bool
:returns: ``True`` if a session with the given key exists in the DB,
``False`` if not.
"""
response = self.table.get_item(
Key={'session_key'... | [
"def",
"exists",
"(",
"self",
",",
"session_key",
")",
":",
"response",
"=",
"self",
".",
"table",
".",
"get_item",
"(",
"Key",
"=",
"{",
"'session_key'",
":",
"session_key",
"}",
",",
"ConsistentRead",
"=",
"ALWAYS_CONSISTENT",
")",
"if",
"'Item'",
"in",
... | Checks to see if a session currently exists in DynamoDB.
:rtype: bool
:returns: ``True`` if a session with the given key exists in the DB,
``False`` if not. | [
"Checks",
"to",
"see",
"if",
"a",
"session",
"currently",
"exists",
"in",
"DynamoDB",
"."
] | 434031aa483b26b0b7b5acbdf683bbe1575956f1 | https://github.com/gtaylor/django-dynamodb-sessions/blob/434031aa483b26b0b7b5acbdf683bbe1575956f1/dynamodb_sessions/backends/dynamodb.py#L102-L117 | train | 62,027 |
gtaylor/django-dynamodb-sessions | dynamodb_sessions/backends/dynamodb.py | SessionStore.save | def save(self, must_create=False):
"""
Saves the current session data to the database.
:keyword bool must_create: If ``True``, a ``CreateError`` exception
will be raised if the saving operation doesn't create a *new* entry
(as opposed to possibly updating an existing ent... | python | def save(self, must_create=False):
"""
Saves the current session data to the database.
:keyword bool must_create: If ``True``, a ``CreateError`` exception
will be raised if the saving operation doesn't create a *new* entry
(as opposed to possibly updating an existing ent... | [
"def",
"save",
"(",
"self",
",",
"must_create",
"=",
"False",
")",
":",
"# If the save method is called with must_create equal to True, I'm",
"# setting self._session_key equal to None and when",
"# self.get_or_create_session_key is called the new",
"# session_key will be created.",
"if"... | Saves the current session data to the database.
:keyword bool must_create: If ``True``, a ``CreateError`` exception
will be raised if the saving operation doesn't create a *new* entry
(as opposed to possibly updating an existing entry).
:raises: ``CreateError`` if ``must_create`... | [
"Saves",
"the",
"current",
"session",
"data",
"to",
"the",
"database",
"."
] | 434031aa483b26b0b7b5acbdf683bbe1575956f1 | https://github.com/gtaylor/django-dynamodb-sessions/blob/434031aa483b26b0b7b5acbdf683bbe1575956f1/dynamodb_sessions/backends/dynamodb.py#L136-L179 | train | 62,028 |
gtaylor/django-dynamodb-sessions | dynamodb_sessions/backends/dynamodb.py | SessionStore.delete | def delete(self, session_key=None):
"""
Deletes the current session, or the one specified in ``session_key``.
:keyword str session_key: Optionally, override the session key
to delete.
"""
if session_key is None:
if self.session_key is None:
... | python | def delete(self, session_key=None):
"""
Deletes the current session, or the one specified in ``session_key``.
:keyword str session_key: Optionally, override the session key
to delete.
"""
if session_key is None:
if self.session_key is None:
... | [
"def",
"delete",
"(",
"self",
",",
"session_key",
"=",
"None",
")",
":",
"if",
"session_key",
"is",
"None",
":",
"if",
"self",
".",
"session_key",
"is",
"None",
":",
"return",
"session_key",
"=",
"self",
".",
"session_key",
"self",
".",
"table",
".",
"... | Deletes the current session, or the one specified in ``session_key``.
:keyword str session_key: Optionally, override the session key
to delete. | [
"Deletes",
"the",
"current",
"session",
"or",
"the",
"one",
"specified",
"in",
"session_key",
"."
] | 434031aa483b26b0b7b5acbdf683bbe1575956f1 | https://github.com/gtaylor/django-dynamodb-sessions/blob/434031aa483b26b0b7b5acbdf683bbe1575956f1/dynamodb_sessions/backends/dynamodb.py#L181-L194 | train | 62,029 |
gtaylor/django-dynamodb-sessions | dynamodb_sessions/backends/cached_dynamodb.py | SessionStore.flush | def flush(self):
"""
Removes the current session data from the database and regenerates the
key.
"""
self.clear()
self.delete(self.session_key)
self.create() | python | def flush(self):
"""
Removes the current session data from the database and regenerates the
key.
"""
self.clear()
self.delete(self.session_key)
self.create() | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"clear",
"(",
")",
"self",
".",
"delete",
"(",
"self",
".",
"session_key",
")",
"self",
".",
"create",
"(",
")"
] | Removes the current session data from the database and regenerates the
key. | [
"Removes",
"the",
"current",
"session",
"data",
"from",
"the",
"database",
"and",
"regenerates",
"the",
"key",
"."
] | 434031aa483b26b0b7b5acbdf683bbe1575956f1 | https://github.com/gtaylor/django-dynamodb-sessions/blob/434031aa483b26b0b7b5acbdf683bbe1575956f1/dynamodb_sessions/backends/cached_dynamodb.py#L49-L57 | train | 62,030 |
croach/django-simple-rest | simple_rest/utils/decorators.py | wrap_object | def wrap_object(obj, decorator):
"""
Decorates the given object with the decorator function.
If obj is a method, the method is decorated with the decorator function
and returned. If obj is a class (i.e., a class based view), the methods
in the class corresponding to HTTP methods will be decorated a... | python | def wrap_object(obj, decorator):
"""
Decorates the given object with the decorator function.
If obj is a method, the method is decorated with the decorator function
and returned. If obj is a class (i.e., a class based view), the methods
in the class corresponding to HTTP methods will be decorated a... | [
"def",
"wrap_object",
"(",
"obj",
",",
"decorator",
")",
":",
"actual_decorator",
"=",
"method_decorator",
"(",
"decorator",
")",
"if",
"inspect",
".",
"isfunction",
"(",
"obj",
")",
":",
"wrapped_obj",
"=",
"actual_decorator",
"(",
"obj",
")",
"update_wrapper... | Decorates the given object with the decorator function.
If obj is a method, the method is decorated with the decorator function
and returned. If obj is a class (i.e., a class based view), the methods
in the class corresponding to HTTP methods will be decorated and the
resultant class object will be ret... | [
"Decorates",
"the",
"given",
"object",
"with",
"the",
"decorator",
"function",
"."
] | 5f5904969d170ef3803a9fb735f814ef76f79427 | https://github.com/croach/django-simple-rest/blob/5f5904969d170ef3803a9fb735f814ef76f79427/simple_rest/utils/decorators.py#L7-L32 | train | 62,031 |
spyder-ide/conda-manager | conda_manager/models/packages.py | CondaPackagesModel.get_package_versions | def get_package_versions(self, name):
"""
Gives all the compatible package canonical name
name : str
Name of the package
"""
package_data = self._packages.get(name)
versions = []
if package_data:
versions = sort_versions(list(package_data... | python | def get_package_versions(self, name):
"""
Gives all the compatible package canonical name
name : str
Name of the package
"""
package_data = self._packages.get(name)
versions = []
if package_data:
versions = sort_versions(list(package_data... | [
"def",
"get_package_versions",
"(",
"self",
",",
"name",
")",
":",
"package_data",
"=",
"self",
".",
"_packages",
".",
"get",
"(",
"name",
")",
"versions",
"=",
"[",
"]",
"if",
"package_data",
":",
"versions",
"=",
"sort_versions",
"(",
"list",
"(",
"pac... | Gives all the compatible package canonical name
name : str
Name of the package | [
"Gives",
"all",
"the",
"compatible",
"package",
"canonical",
"name"
] | 89a2126cbecefc92185cf979347ccac1c5ee5d9d | https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/models/packages.py#L416-L429 | train | 62,032 |
spyder-ide/conda-manager | conda_manager/utils/__init__.py | get_conf_path | def get_conf_path(filename=None):
"""Return absolute path for configuration file with specified filename."""
conf_dir = osp.join(get_home_dir(), '.condamanager')
if not osp.isdir(conf_dir):
os.mkdir(conf_dir)
if filename is None:
return conf_dir
else:
return osp.j... | python | def get_conf_path(filename=None):
"""Return absolute path for configuration file with specified filename."""
conf_dir = osp.join(get_home_dir(), '.condamanager')
if not osp.isdir(conf_dir):
os.mkdir(conf_dir)
if filename is None:
return conf_dir
else:
return osp.j... | [
"def",
"get_conf_path",
"(",
"filename",
"=",
"None",
")",
":",
"conf_dir",
"=",
"osp",
".",
"join",
"(",
"get_home_dir",
"(",
")",
",",
"'.condamanager'",
")",
"if",
"not",
"osp",
".",
"isdir",
"(",
"conf_dir",
")",
":",
"os",
".",
"mkdir",
"(",
"co... | Return absolute path for configuration file with specified filename. | [
"Return",
"absolute",
"path",
"for",
"configuration",
"file",
"with",
"specified",
"filename",
"."
] | 89a2126cbecefc92185cf979347ccac1c5ee5d9d | https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/utils/__init__.py#L68-L78 | train | 62,033 |
spyder-ide/conda-manager | conda_manager/utils/__init__.py | sort_versions | def sort_versions(versions=(), reverse=False, sep=u'.'):
"""Sort a list of version number strings.
This function ensures that the package sorting based on number name is
performed correctly when including alpha, dev rc1 etc...
"""
if versions == []:
return []
digits = u'012345... | python | def sort_versions(versions=(), reverse=False, sep=u'.'):
"""Sort a list of version number strings.
This function ensures that the package sorting based on number name is
performed correctly when including alpha, dev rc1 etc...
"""
if versions == []:
return []
digits = u'012345... | [
"def",
"sort_versions",
"(",
"versions",
"=",
"(",
")",
",",
"reverse",
"=",
"False",
",",
"sep",
"=",
"u'.'",
")",
":",
"if",
"versions",
"==",
"[",
"]",
":",
"return",
"[",
"]",
"digits",
"=",
"u'0123456789'",
"def",
"toint",
"(",
"x",
")",
":",
... | Sort a list of version number strings.
This function ensures that the package sorting based on number name is
performed correctly when including alpha, dev rc1 etc... | [
"Sort",
"a",
"list",
"of",
"version",
"number",
"strings",
".",
"This",
"function",
"ensures",
"that",
"the",
"package",
"sorting",
"based",
"on",
"number",
"name",
"is",
"performed",
"correctly",
"when",
"including",
"alpha",
"dev",
"rc1",
"etc",
"..."
] | 89a2126cbecefc92185cf979347ccac1c5ee5d9d | https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/utils/__init__.py#L86-L151 | train | 62,034 |
berlincode/sjcl | examples/backup_cryptedblog.py | write_file | def write_file(fname_parts, content):
""" write a file and create all needed directories """
fname_parts = [str(part) for part in fname_parts]
# try to create the directory
if len(fname_parts) > 1:
try:
os.makedirs(os.path.join(*fname_parts[:-1]))
except OSError:
... | python | def write_file(fname_parts, content):
""" write a file and create all needed directories """
fname_parts = [str(part) for part in fname_parts]
# try to create the directory
if len(fname_parts) > 1:
try:
os.makedirs(os.path.join(*fname_parts[:-1]))
except OSError:
... | [
"def",
"write_file",
"(",
"fname_parts",
",",
"content",
")",
":",
"fname_parts",
"=",
"[",
"str",
"(",
"part",
")",
"for",
"part",
"in",
"fname_parts",
"]",
"# try to create the directory",
"if",
"len",
"(",
"fname_parts",
")",
">",
"1",
":",
"try",
":",
... | write a file and create all needed directories | [
"write",
"a",
"file",
"and",
"create",
"all",
"needed",
"directories"
] | e8bdad312fa99c89c74f8651a1240afba8a9f3bd | https://github.com/berlincode/sjcl/blob/e8bdad312fa99c89c74f8651a1240afba8a9f3bd/examples/backup_cryptedblog.py#L27-L40 | train | 62,035 |
spyder-ide/conda-manager | conda_manager/models/filter.py | MultiColumnSortFilterProxy.remove_filter_function | def remove_filter_function(self, name):
"""Removes the filter function associated with name, if it exists.
name : hashable object
"""
if name in self._filter_functions.keys():
del self._filter_functions[name]
self.invalidateFilter() | python | def remove_filter_function(self, name):
"""Removes the filter function associated with name, if it exists.
name : hashable object
"""
if name in self._filter_functions.keys():
del self._filter_functions[name]
self.invalidateFilter() | [
"def",
"remove_filter_function",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_filter_functions",
".",
"keys",
"(",
")",
":",
"del",
"self",
".",
"_filter_functions",
"[",
"name",
"]",
"self",
".",
"invalidateFilter",
"(",
")"
] | Removes the filter function associated with name, if it exists.
name : hashable object | [
"Removes",
"the",
"filter",
"function",
"associated",
"with",
"name",
"if",
"it",
"exists",
"."
] | 89a2126cbecefc92185cf979347ccac1c5ee5d9d | https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/models/filter.py#L78-L85 | train | 62,036 |
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 | train | 62,037 |
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 | train | 62,038 |
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 | train | 62,039 |
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 | train | 62,040 |
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 | train | 62,041 |
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 | train | 62,042 |
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 | train | 62,043 |
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 | train | 62,044 |
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 | train | 62,045 |
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 | train | 62,046 |
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 | train | 62,047 |
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 | train | 62,048 |
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 | train | 62,049 |
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 | train | 62,050 |
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 | train | 62,051 |
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 | train | 62,052 |
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 | train | 62,053 |
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 | train | 62,054 |
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 | train | 62,055 |
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 | train | 62,056 |
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 | train | 62,057 |
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 | train | 62,058 |
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 | train | 62,059 |
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 | train | 62,060 |
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 | train | 62,061 |
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 | train | 62,062 |
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 | train | 62,063 |
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 | train | 62,064 |
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 | train | 62,065 |
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 | train | 62,066 |
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 | train | 62,067 |
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 | train | 62,068 |
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 | train | 62,069 |
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 | train | 62,070 |
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 | train | 62,071 |
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 | train | 62,072 |
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 | train | 62,073 |
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 | train | 62,074 |
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 | train | 62,075 |
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 | train | 62,076 |
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 | train | 62,077 |
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 | train | 62,078 |
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 | train | 62,079 |
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 | train | 62,080 |
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 | train | 62,081 |
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 | train | 62,082 |
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 | train | 62,083 |
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 | train | 62,084 |
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 | train | 62,085 |
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 | train | 62,086 |
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 | train | 62,087 |
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 | train | 62,088 |
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 | train | 62,089 |
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 | train | 62,090 |
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 | train | 62,091 |
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 | train | 62,092 |
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 | train | 62,093 |
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 | train | 62,094 |
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 | train | 62,095 |
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 | train | 62,096 |
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 | train | 62,097 |
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 | train | 62,098 |
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 | train | 62,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.