repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
rongcloud/server-sdk-python | rongcloud/group.py | Group.refresh | def refresh(self, groupId, groupName):
"""
刷新群组信息方法 方法
@param groupId:群组 Id。(必传)
@param groupName:群名称。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。
"""
desc = {
"name": "CodeSuccessReslut",
"desc": " http 成功返回结果",
... | python | def refresh(self, groupId, groupName):
"""
刷新群组信息方法 方法
@param groupId:群组 Id。(必传)
@param groupName:群名称。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。
"""
desc = {
"name": "CodeSuccessReslut",
"desc": " http 成功返回结果",
... | [
"def",
"refresh",
"(",
"self",
",",
"groupId",
",",
"groupName",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"CodeSuccessReslut\"",
",",
"\"desc\"",
":",
"\" http 成功返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",
"\"type\"",
... | 刷新群组信息方法 方法
@param groupId:群组 Id。(必传)
@param groupName:群名称。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。 | [
"刷新群组信息方法",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/group.py#L74-L102 |
rongcloud/server-sdk-python | rongcloud/group.py | Group.join | def join(self, userId, groupId, groupName):
"""
将用户加入指定群组,用户将可以收到该群的消息,同一用户最多可加入 500 个群,每个群最大至 3000 人。 方法
@param userId:要加入群的用户 Id,可提交多个,最多不超过 1000 个。(必传)
@param groupId:要加入的群 Id。(必传)
@param groupName:要加入的群 Id 对应的名称。(必传)
@return code:返回码,200 为正常。
@return err... | python | def join(self, userId, groupId, groupName):
"""
将用户加入指定群组,用户将可以收到该群的消息,同一用户最多可加入 500 个群,每个群最大至 3000 人。 方法
@param userId:要加入群的用户 Id,可提交多个,最多不超过 1000 个。(必传)
@param groupId:要加入的群 Id。(必传)
@param groupName:要加入的群 Id 对应的名称。(必传)
@return code:返回码,200 为正常。
@return err... | [
"def",
"join",
"(",
"self",
",",
"userId",
",",
"groupId",
",",
"groupName",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"CodeSuccessReslut\"",
",",
"\"desc\"",
":",
"\" http 成功返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",... | 将用户加入指定群组,用户将可以收到该群的消息,同一用户最多可加入 500 个群,每个群最大至 3000 人。 方法
@param userId:要加入群的用户 Id,可提交多个,最多不超过 1000 个。(必传)
@param groupId:要加入的群 Id。(必传)
@param groupName:要加入的群 Id 对应的名称。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。 | [
"将用户加入指定群组,用户将可以收到该群的消息,同一用户最多可加入",
"500",
"个群,每个群最大至",
"3000",
"人。",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/group.py#L104-L136 |
rongcloud/server-sdk-python | rongcloud/group.py | Group.queryUser | def queryUser(self, groupId):
"""
查询群成员方法 方法
@param groupId:群组Id。(必传)
@return code:返回码,200 为正常。
@return id:群成员用户Id。
@return users:群成员列表。
"""
desc = {
"name": "GroupUserQueryReslut",
"desc": "groupUserQuery返回结果",
"field... | python | def queryUser(self, groupId):
"""
查询群成员方法 方法
@param groupId:群组Id。(必传)
@return code:返回码,200 为正常。
@return id:群成员用户Id。
@return users:群成员列表。
"""
desc = {
"name": "GroupUserQueryReslut",
"desc": "groupUserQuery返回结果",
"field... | [
"def",
"queryUser",
"(",
"self",
",",
"groupId",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"GroupUserQueryReslut\"",
",",
"\"desc\"",
":",
"\"groupUserQuery返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",
"\"type\"",
":",
"\"... | 查询群成员方法 方法
@param groupId:群组Id。(必传)
@return code:返回码,200 为正常。
@return id:群成员用户Id。
@return users:群成员列表。 | [
"查询群成员方法",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/group.py#L138-L169 |
rongcloud/server-sdk-python | rongcloud/group.py | Group.dismiss | def dismiss(self, userId, groupId):
"""
解散群组方法。(将该群解散,所有用户都无法再接收该群的消息。) 方法
@param userId:操作解散群的用户 Id。(必传)
@param groupId:要解散的群 Id。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。
"""
desc = {
"name": "CodeSuccessReslut",
... | python | def dismiss(self, userId, groupId):
"""
解散群组方法。(将该群解散,所有用户都无法再接收该群的消息。) 方法
@param userId:操作解散群的用户 Id。(必传)
@param groupId:要解散的群 Id。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。
"""
desc = {
"name": "CodeSuccessReslut",
... | [
"def",
"dismiss",
"(",
"self",
",",
"userId",
",",
"groupId",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"CodeSuccessReslut\"",
",",
"\"desc\"",
":",
"\" http 成功返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",
"\"type\"",
":... | 解散群组方法。(将该群解散,所有用户都无法再接收该群的消息。) 方法
@param userId:操作解散群的用户 Id。(必传)
@param groupId:要解散的群 Id。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。 | [
"解散群组方法。(将该群解散,所有用户都无法再接收该群的消息。)",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/group.py#L296-L324 |
kfdm/gntp | gntp/core.py | parse_gntp | def parse_gntp(data, password=None):
"""Attempt to parse a message as a GNTP message
:param string data: Message to be parsed
:param string password: Optional password to be used to verify the message
"""
data = gntp.shim.u(data)
match = GNTP_INFO_LINE_SHORT.match(data)
if not match:
raise errors.ParseError('... | python | def parse_gntp(data, password=None):
"""Attempt to parse a message as a GNTP message
:param string data: Message to be parsed
:param string password: Optional password to be used to verify the message
"""
data = gntp.shim.u(data)
match = GNTP_INFO_LINE_SHORT.match(data)
if not match:
raise errors.ParseError('... | [
"def",
"parse_gntp",
"(",
"data",
",",
"password",
"=",
"None",
")",
":",
"data",
"=",
"gntp",
".",
"shim",
".",
"u",
"(",
"data",
")",
"match",
"=",
"GNTP_INFO_LINE_SHORT",
".",
"match",
"(",
"data",
")",
"if",
"not",
"match",
":",
"raise",
"errors"... | Attempt to parse a message as a GNTP message
:param string data: Message to be parsed
:param string password: Optional password to be used to verify the message | [
"Attempt",
"to",
"parse",
"a",
"message",
"as",
"a",
"GNTP",
"message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L497-L518 |
kfdm/gntp | gntp/core.py | _GNTPBase._parse_info | def _parse_info(self, data):
"""Parse the first line of a GNTP message to get security and other info values
:param string data: GNTP Message
:return dict: Parsed GNTP Info line
"""
match = GNTP_INFO_LINE.match(data)
if not match:
raise errors.ParseError('ERROR_PARSING_INFO_LINE')
info = match.grou... | python | def _parse_info(self, data):
"""Parse the first line of a GNTP message to get security and other info values
:param string data: GNTP Message
:return dict: Parsed GNTP Info line
"""
match = GNTP_INFO_LINE.match(data)
if not match:
raise errors.ParseError('ERROR_PARSING_INFO_LINE')
info = match.grou... | [
"def",
"_parse_info",
"(",
"self",
",",
"data",
")",
":",
"match",
"=",
"GNTP_INFO_LINE",
".",
"match",
"(",
"data",
")",
"if",
"not",
"match",
":",
"raise",
"errors",
".",
"ParseError",
"(",
"'ERROR_PARSING_INFO_LINE'",
")",
"info",
"=",
"match",
".",
"... | Parse the first line of a GNTP message to get security and other info values
:param string data: GNTP Message
:return dict: Parsed GNTP Info line | [
"Parse",
"the",
"first",
"line",
"of",
"a",
"GNTP",
"message",
"to",
"get",
"security",
"and",
"other",
"info",
"values"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L87-L103 |
kfdm/gntp | gntp/core.py | _GNTPBase.set_password | def set_password(self, password, encryptAlgo='MD5'):
"""Set a password for a GNTP Message
:param string password: Null to clear password
:param string encryptAlgo: Supports MD5, SHA1, SHA256, SHA512
"""
if not password:
self.info['encryptionAlgorithmID'] = None
self.info['keyHashAlgorithm'] = None
r... | python | def set_password(self, password, encryptAlgo='MD5'):
"""Set a password for a GNTP Message
:param string password: Null to clear password
:param string encryptAlgo: Supports MD5, SHA1, SHA256, SHA512
"""
if not password:
self.info['encryptionAlgorithmID'] = None
self.info['keyHashAlgorithm'] = None
r... | [
"def",
"set_password",
"(",
"self",
",",
"password",
",",
"encryptAlgo",
"=",
"'MD5'",
")",
":",
"if",
"not",
"password",
":",
"self",
".",
"info",
"[",
"'encryptionAlgorithmID'",
"]",
"=",
"None",
"self",
".",
"info",
"[",
"'keyHashAlgorithm'",
"]",
"=",
... | Set a password for a GNTP Message
:param string password: Null to clear password
:param string encryptAlgo: Supports MD5, SHA1, SHA256, SHA512 | [
"Set",
"a",
"password",
"for",
"a",
"GNTP",
"Message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L105-L134 |
kfdm/gntp | gntp/core.py | _GNTPBase._decode_hex | def _decode_hex(self, value):
"""Helper function to decode hex string to `proper` hex string
:param string value: Human readable hex string
:return string: Hex string
"""
result = ''
for i in range(0, len(value), 2):
tmp = int(value[i:i + 2], 16)
result += chr(tmp)
return result | python | def _decode_hex(self, value):
"""Helper function to decode hex string to `proper` hex string
:param string value: Human readable hex string
:return string: Hex string
"""
result = ''
for i in range(0, len(value), 2):
tmp = int(value[i:i + 2], 16)
result += chr(tmp)
return result | [
"def",
"_decode_hex",
"(",
"self",
",",
"value",
")",
":",
"result",
"=",
"''",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"value",
")",
",",
"2",
")",
":",
"tmp",
"=",
"int",
"(",
"value",
"[",
"i",
":",
"i",
"+",
"2",
"]",
",",... | Helper function to decode hex string to `proper` hex string
:param string value: Human readable hex string
:return string: Hex string | [
"Helper",
"function",
"to",
"decode",
"hex",
"string",
"to",
"proper",
"hex",
"string"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L136-L146 |
kfdm/gntp | gntp/core.py | _GNTPBase._validate_password | def _validate_password(self, password):
"""Validate GNTP Message against stored password"""
self.password = password
if password is None:
raise errors.AuthError('Missing password')
keyHash = self.info.get('keyHash', None)
if keyHash is None and self.password is None:
return True
if keyHash is None:
... | python | def _validate_password(self, password):
"""Validate GNTP Message against stored password"""
self.password = password
if password is None:
raise errors.AuthError('Missing password')
keyHash = self.info.get('keyHash', None)
if keyHash is None and self.password is None:
return True
if keyHash is None:
... | [
"def",
"_validate_password",
"(",
"self",
",",
"password",
")",
":",
"self",
".",
"password",
"=",
"password",
"if",
"password",
"is",
"None",
":",
"raise",
"errors",
".",
"AuthError",
"(",
"'Missing password'",
")",
"keyHash",
"=",
"self",
".",
"info",
".... | Validate GNTP Message against stored password | [
"Validate",
"GNTP",
"Message",
"against",
"stored",
"password"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L158-L182 |
kfdm/gntp | gntp/core.py | _GNTPBase.validate | def validate(self):
"""Verify required headers"""
for header in self._requiredHeaders:
if not self.headers.get(header, False):
raise errors.ParseError('Missing Notification Header: ' + header) | python | def validate(self):
"""Verify required headers"""
for header in self._requiredHeaders:
if not self.headers.get(header, False):
raise errors.ParseError('Missing Notification Header: ' + header) | [
"def",
"validate",
"(",
"self",
")",
":",
"for",
"header",
"in",
"self",
".",
"_requiredHeaders",
":",
"if",
"not",
"self",
".",
"headers",
".",
"get",
"(",
"header",
",",
"False",
")",
":",
"raise",
"errors",
".",
"ParseError",
"(",
"'Missing Notificati... | Verify required headers | [
"Verify",
"required",
"headers"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L184-L188 |
kfdm/gntp | gntp/core.py | _GNTPBase._format_info | def _format_info(self):
"""Generate info line for GNTP Message
:return string:
"""
info = 'GNTP/%s %s' % (
self.info.get('version'),
self.info.get('messagetype'),
)
if self.info.get('encryptionAlgorithmID', None):
info += ' %s:%s' % (
self.info.get('encryptionAlgorithmID'),
self.info.get('... | python | def _format_info(self):
"""Generate info line for GNTP Message
:return string:
"""
info = 'GNTP/%s %s' % (
self.info.get('version'),
self.info.get('messagetype'),
)
if self.info.get('encryptionAlgorithmID', None):
info += ' %s:%s' % (
self.info.get('encryptionAlgorithmID'),
self.info.get('... | [
"def",
"_format_info",
"(",
"self",
")",
":",
"info",
"=",
"'GNTP/%s %s'",
"%",
"(",
"self",
".",
"info",
".",
"get",
"(",
"'version'",
")",
",",
"self",
".",
"info",
".",
"get",
"(",
"'messagetype'",
")",
",",
")",
"if",
"self",
".",
"info",
".",
... | Generate info line for GNTP Message
:return string: | [
"Generate",
"info",
"line",
"for",
"GNTP",
"Message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L190-L214 |
kfdm/gntp | gntp/core.py | _GNTPBase._parse_dict | def _parse_dict(self, data):
"""Helper function to parse blocks of GNTP headers into a dictionary
:param string data:
:return dict: Dictionary of parsed GNTP Headers
"""
d = {}
for line in data.split('\r\n'):
match = GNTP_HEADER.match(line)
if not match:
continue
key = match.group(1).strip()
... | python | def _parse_dict(self, data):
"""Helper function to parse blocks of GNTP headers into a dictionary
:param string data:
:return dict: Dictionary of parsed GNTP Headers
"""
d = {}
for line in data.split('\r\n'):
match = GNTP_HEADER.match(line)
if not match:
continue
key = match.group(1).strip()
... | [
"def",
"_parse_dict",
"(",
"self",
",",
"data",
")",
":",
"d",
"=",
"{",
"}",
"for",
"line",
"in",
"data",
".",
"split",
"(",
"'\\r\\n'",
")",
":",
"match",
"=",
"GNTP_HEADER",
".",
"match",
"(",
"line",
")",
"if",
"not",
"match",
":",
"continue",
... | Helper function to parse blocks of GNTP headers into a dictionary
:param string data:
:return dict: Dictionary of parsed GNTP Headers | [
"Helper",
"function",
"to",
"parse",
"blocks",
"of",
"GNTP",
"headers",
"into",
"a",
"dictionary"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L216-L231 |
kfdm/gntp | gntp/core.py | _GNTPBase.add_resource | def add_resource(self, data):
"""Add binary resource
:param string data: Binary Data
"""
data = gntp.shim.b(data)
identifier = hashlib.md5(data).hexdigest()
self.resources[identifier] = data
return 'x-growl-resource://%s' % identifier | python | def add_resource(self, data):
"""Add binary resource
:param string data: Binary Data
"""
data = gntp.shim.b(data)
identifier = hashlib.md5(data).hexdigest()
self.resources[identifier] = data
return 'x-growl-resource://%s' % identifier | [
"def",
"add_resource",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"gntp",
".",
"shim",
".",
"b",
"(",
"data",
")",
"identifier",
"=",
"hashlib",
".",
"md5",
"(",
"data",
")",
".",
"hexdigest",
"(",
")",
"self",
".",
"resources",
"[",
"identif... | Add binary resource
:param string data: Binary Data | [
"Add",
"binary",
"resource"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L236-L244 |
kfdm/gntp | gntp/core.py | _GNTPBase.decode | def decode(self, data, password=None):
"""Decode GNTP Message
:param string data:
"""
self.password = password
self.raw = gntp.shim.u(data)
parts = self.raw.split('\r\n\r\n')
self.info = self._parse_info(self.raw)
self.headers = self._parse_dict(parts[0]) | python | def decode(self, data, password=None):
"""Decode GNTP Message
:param string data:
"""
self.password = password
self.raw = gntp.shim.u(data)
parts = self.raw.split('\r\n\r\n')
self.info = self._parse_info(self.raw)
self.headers = self._parse_dict(parts[0]) | [
"def",
"decode",
"(",
"self",
",",
"data",
",",
"password",
"=",
"None",
")",
":",
"self",
".",
"password",
"=",
"password",
"self",
".",
"raw",
"=",
"gntp",
".",
"shim",
".",
"u",
"(",
"data",
")",
"parts",
"=",
"self",
".",
"raw",
".",
"split",... | Decode GNTP Message
:param string data: | [
"Decode",
"GNTP",
"Message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L246-L255 |
kfdm/gntp | gntp/core.py | GNTPRegister.validate | def validate(self):
'''Validate required headers and validate notification headers'''
for header in self._requiredHeaders:
if not self.headers.get(header, False):
raise errors.ParseError('Missing Registration Header: ' + header)
for notice in self.notifications:
for header in self._requiredNotificationH... | python | def validate(self):
'''Validate required headers and validate notification headers'''
for header in self._requiredHeaders:
if not self.headers.get(header, False):
raise errors.ParseError('Missing Registration Header: ' + header)
for notice in self.notifications:
for header in self._requiredNotificationH... | [
"def",
"validate",
"(",
"self",
")",
":",
"for",
"header",
"in",
"self",
".",
"_requiredHeaders",
":",
"if",
"not",
"self",
".",
"headers",
".",
"get",
"(",
"header",
",",
"False",
")",
":",
"raise",
"errors",
".",
"ParseError",
"(",
"'Missing Registrati... | Validate required headers and validate notification headers | [
"Validate",
"required",
"headers",
"and",
"validate",
"notification",
"headers"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L307-L315 |
kfdm/gntp | gntp/core.py | GNTPRegister.decode | def decode(self, data, password):
"""Decode existing GNTP Registration message
:param string data: Message to decode
"""
self.raw = gntp.shim.u(data)
parts = self.raw.split('\r\n\r\n')
self.info = self._parse_info(self.raw)
self._validate_password(password)
self.headers = self._parse_dict(parts[0])
... | python | def decode(self, data, password):
"""Decode existing GNTP Registration message
:param string data: Message to decode
"""
self.raw = gntp.shim.u(data)
parts = self.raw.split('\r\n\r\n')
self.info = self._parse_info(self.raw)
self._validate_password(password)
self.headers = self._parse_dict(parts[0])
... | [
"def",
"decode",
"(",
"self",
",",
"data",
",",
"password",
")",
":",
"self",
".",
"raw",
"=",
"gntp",
".",
"shim",
".",
"u",
"(",
"data",
")",
"parts",
"=",
"self",
".",
"raw",
".",
"split",
"(",
"'\\r\\n\\r\\n'",
")",
"self",
".",
"info",
"=",
... | Decode existing GNTP Registration message
:param string data: Message to decode | [
"Decode",
"existing",
"GNTP",
"Registration",
"message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L317-L339 |
kfdm/gntp | gntp/core.py | GNTPRegister.add_notification | def add_notification(self, name, enabled=True):
"""Add new Notification to Registration message
:param string name: Notification Name
:param boolean enabled: Enable this notification by default
"""
notice = {}
notice['Notification-Name'] = name
notice['Notification-Enabled'] = enabled
self.notificatio... | python | def add_notification(self, name, enabled=True):
"""Add new Notification to Registration message
:param string name: Notification Name
:param boolean enabled: Enable this notification by default
"""
notice = {}
notice['Notification-Name'] = name
notice['Notification-Enabled'] = enabled
self.notificatio... | [
"def",
"add_notification",
"(",
"self",
",",
"name",
",",
"enabled",
"=",
"True",
")",
":",
"notice",
"=",
"{",
"}",
"notice",
"[",
"'Notification-Name'",
"]",
"=",
"name",
"notice",
"[",
"'Notification-Enabled'",
"]",
"=",
"enabled",
"self",
".",
"notific... | Add new Notification to Registration message
:param string name: Notification Name
:param boolean enabled: Enable this notification by default | [
"Add",
"new",
"Notification",
"to",
"Registration",
"message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L341-L352 |
kfdm/gntp | gntp/core.py | GNTPRegister.encode | def encode(self):
"""Encode a GNTP Registration Message
:return string: Encoded GNTP Registration message. Returned as a byte string
"""
buff = _GNTPBuffer()
buff.writeln(self._format_info())
#Headers
for k, v in self.headers.items():
buff.writeheader(k, v)
buff.writeln()
#Notifications
if l... | python | def encode(self):
"""Encode a GNTP Registration Message
:return string: Encoded GNTP Registration message. Returned as a byte string
"""
buff = _GNTPBuffer()
buff.writeln(self._format_info())
#Headers
for k, v in self.headers.items():
buff.writeheader(k, v)
buff.writeln()
#Notifications
if l... | [
"def",
"encode",
"(",
"self",
")",
":",
"buff",
"=",
"_GNTPBuffer",
"(",
")",
"buff",
".",
"writeln",
"(",
"self",
".",
"_format_info",
"(",
")",
")",
"#Headers",
"for",
"k",
",",
"v",
"in",
"self",
".",
"headers",
".",
"items",
"(",
")",
":",
"b... | Encode a GNTP Registration Message
:return string: Encoded GNTP Registration message. Returned as a byte string | [
"Encode",
"a",
"GNTP",
"Registration",
"Message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L354-L385 |
rongcloud/server-sdk-python | rongcloud/sms.py | SMS.getImageCode | def getImageCode(self, appKey):
"""
获取图片验证码方法 方法
@param appKey:应用Id
@return code:返回码,200 为正常。
@return url:返回的图片验证码 URL 地址。
@return verifyId:返回图片验证标识 Id。
@return errorMessage:错误信息。
"""
desc = {
"name": "SMSImageCodeReslut",
... | python | def getImageCode(self, appKey):
"""
获取图片验证码方法 方法
@param appKey:应用Id
@return code:返回码,200 为正常。
@return url:返回的图片验证码 URL 地址。
@return verifyId:返回图片验证标识 Id。
@return errorMessage:错误信息。
"""
desc = {
"name": "SMSImageCodeReslut",
... | [
"def",
"getImageCode",
"(",
"self",
",",
"appKey",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"SMSImageCodeReslut\"",
",",
"\"desc\"",
":",
"\" getImageCode 成功返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",
"\"type\"",
":",
"... | 获取图片验证码方法 方法
@param appKey:应用Id
@return code:返回码,200 为正常。
@return url:返回的图片验证码 URL 地址。
@return verifyId:返回图片验证标识 Id。
@return errorMessage:错误信息。 | [
"获取图片验证码方法",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/sms.py#L9-L45 |
rongcloud/server-sdk-python | rongcloud/sms.py | SMS.sendCode | def sendCode(self,
mobile,
templateId,
region,
verifyId=None,
verifyCode=None):
"""
发送短信验证码方法。 方法
@param mobile:接收短信验证码的目标手机号,每分钟同一手机号只能发送一次短信验证码,同一手机号 1 小时内最多发送 3 次。(必传)
@param templateId:短信模板 Id,在开发者... | python | def sendCode(self,
mobile,
templateId,
region,
verifyId=None,
verifyCode=None):
"""
发送短信验证码方法。 方法
@param mobile:接收短信验证码的目标手机号,每分钟同一手机号只能发送一次短信验证码,同一手机号 1 小时内最多发送 3 次。(必传)
@param templateId:短信模板 Id,在开发者... | [
"def",
"sendCode",
"(",
"self",
",",
"mobile",
",",
"templateId",
",",
"region",
",",
"verifyId",
"=",
"None",
",",
"verifyCode",
"=",
"None",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"SMSSendCodeReslut\"",
",",
"\"desc\"",
":",
"\" SMSSendCodeReslut 成... | 发送短信验证码方法。 方法
@param mobile:接收短信验证码的目标手机号,每分钟同一手机号只能发送一次短信验证码,同一手机号 1 小时内最多发送 3 次。(必传)
@param templateId:短信模板 Id,在开发者后台->短信服务->服务设置->短信模版中获取。(必传)
@param region:手机号码所属国家区号,目前只支持中图区号 86)
@param verifyId:图片验证标识 Id ,开启图片验证功能后此参数必传,否则可以不传。在获取图片验证码方法返回值中获取。
@param verifyCode:图片验证码... | [
"发送短信验证码方法。",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/sms.py#L47-L93 |
rongcloud/server-sdk-python | rongcloud/sms.py | SMS.verifyCode | def verifyCode(self, sessionId, code):
"""
验证码验证方法 方法
@param sessionId:短信验证码唯一标识,在发送短信验证码方法,返回值中获取。(必传)
@param code:短信验证码内容。(必传)
@return code:返回码,200 为正常。
@return success:true 验证成功,false 验证失败。
@return errorMessage:错误信息。
"""
desc = {
... | python | def verifyCode(self, sessionId, code):
"""
验证码验证方法 方法
@param sessionId:短信验证码唯一标识,在发送短信验证码方法,返回值中获取。(必传)
@param code:短信验证码内容。(必传)
@return code:返回码,200 为正常。
@return success:true 验证成功,false 验证失败。
@return errorMessage:错误信息。
"""
desc = {
... | [
"def",
"verifyCode",
"(",
"self",
",",
"sessionId",
",",
"code",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"SMSVerifyCodeResult\"",
",",
"\"desc\"",
":",
"\" VerifyCode 返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",
"\"type... | 验证码验证方法 方法
@param sessionId:短信验证码唯一标识,在发送短信验证码方法,返回值中获取。(必传)
@param code:短信验证码内容。(必传)
@return code:返回码,200 为正常。
@return success:true 验证成功,false 验证失败。
@return errorMessage:错误信息。 | [
"验证码验证方法",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/sms.py#L95-L128 |
kfdm/gntp | gntp/notifier.py | mini | def mini(description, applicationName='PythonMini', noteType="Message",
title="Mini Message", applicationIcon=None, hostname='localhost',
password=None, port=23053, sticky=False, priority=None,
callback=None, notificationIcon=None, identifier=None,
notifierFactory=GrowlNotifier):
"""Single notification fun... | python | def mini(description, applicationName='PythonMini', noteType="Message",
title="Mini Message", applicationIcon=None, hostname='localhost',
password=None, port=23053, sticky=False, priority=None,
callback=None, notificationIcon=None, identifier=None,
notifierFactory=GrowlNotifier):
"""Single notification fun... | [
"def",
"mini",
"(",
"description",
",",
"applicationName",
"=",
"'PythonMini'",
",",
"noteType",
"=",
"\"Message\"",
",",
"title",
"=",
"\"Mini Message\"",
",",
"applicationIcon",
"=",
"None",
",",
"hostname",
"=",
"'localhost'",
",",
"password",
"=",
"None",
... | Single notification function
Simple notification function in one line. Has only one required parameter
and attempts to use reasonable defaults for everything else
:param string description: Notification message
.. warning::
For now, only URL callbacks are supported. In the future, the
callback argument will... | [
"Single",
"notification",
"function"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/notifier.py#L218-L260 |
kfdm/gntp | gntp/notifier.py | GrowlNotifier.register | def register(self):
"""Send GNTP Registration
.. warning::
Before sending notifications to Growl, you need to have
sent a registration message at least once
"""
logger.info('Sending registration to %s:%s', self.hostname, self.port)
register = gntp.core.GNTPRegister()
register.add_header('Application-... | python | def register(self):
"""Send GNTP Registration
.. warning::
Before sending notifications to Growl, you need to have
sent a registration message at least once
"""
logger.info('Sending registration to %s:%s', self.hostname, self.port)
register = gntp.core.GNTPRegister()
register.add_header('Application-... | [
"def",
"register",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Sending registration to %s:%s'",
",",
"self",
".",
"hostname",
",",
"self",
".",
"port",
")",
"register",
"=",
"gntp",
".",
"core",
".",
"GNTPRegister",
"(",
")",
"register",
".",
"a... | Send GNTP Registration
.. warning::
Before sending notifications to Growl, you need to have
sent a registration message at least once | [
"Send",
"GNTP",
"Registration"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/notifier.py#L75-L98 |
kfdm/gntp | gntp/notifier.py | GrowlNotifier.notify | def notify(self, noteType, title, description, icon=None, sticky=False,
priority=None, callback=None, identifier=None, custom={}):
"""Send a GNTP notifications
.. warning::
Must have registered with growl beforehand or messages will be ignored
:param string noteType: One of the notification names register... | python | def notify(self, noteType, title, description, icon=None, sticky=False,
priority=None, callback=None, identifier=None, custom={}):
"""Send a GNTP notifications
.. warning::
Must have registered with growl beforehand or messages will be ignored
:param string noteType: One of the notification names register... | [
"def",
"notify",
"(",
"self",
",",
"noteType",
",",
"title",
",",
"description",
",",
"icon",
"=",
"None",
",",
"sticky",
"=",
"False",
",",
"priority",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"identifier",
"=",
"None",
",",
"custom",
"=",
"{... | Send a GNTP notifications
.. warning::
Must have registered with growl beforehand or messages will be ignored
:param string noteType: One of the notification names registered earlier
:param string title: Notification title (usually displayed on the notification)
:param string description: The main content ... | [
"Send",
"a",
"GNTP",
"notifications"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/notifier.py#L100-L153 |
kfdm/gntp | gntp/notifier.py | GrowlNotifier.subscribe | def subscribe(self, id, name, port):
"""Send a Subscribe request to a remote machine"""
sub = gntp.core.GNTPSubscribe()
sub.add_header('Subscriber-ID', id)
sub.add_header('Subscriber-Name', name)
sub.add_header('Subscriber-Port', port)
if self.password:
sub.set_password(self.password, self.passwordHash)
... | python | def subscribe(self, id, name, port):
"""Send a Subscribe request to a remote machine"""
sub = gntp.core.GNTPSubscribe()
sub.add_header('Subscriber-ID', id)
sub.add_header('Subscriber-Name', name)
sub.add_header('Subscriber-Port', port)
if self.password:
sub.set_password(self.password, self.passwordHash)
... | [
"def",
"subscribe",
"(",
"self",
",",
"id",
",",
"name",
",",
"port",
")",
":",
"sub",
"=",
"gntp",
".",
"core",
".",
"GNTPSubscribe",
"(",
")",
"sub",
".",
"add_header",
"(",
"'Subscriber-ID'",
",",
"id",
")",
"sub",
".",
"add_header",
"(",
"'Subscr... | Send a Subscribe request to a remote machine | [
"Send",
"a",
"Subscribe",
"request",
"to",
"a",
"remote",
"machine"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/notifier.py#L155-L167 |
kfdm/gntp | gntp/notifier.py | GrowlNotifier.add_origin_info | def add_origin_info(self, packet):
"""Add optional Origin headers to message"""
packet.add_header('Origin-Machine-Name', platform.node())
packet.add_header('Origin-Software-Name', 'gntp.py')
packet.add_header('Origin-Software-Version', __version__)
packet.add_header('Origin-Platform-Name', platform.system())
... | python | def add_origin_info(self, packet):
"""Add optional Origin headers to message"""
packet.add_header('Origin-Machine-Name', platform.node())
packet.add_header('Origin-Software-Name', 'gntp.py')
packet.add_header('Origin-Software-Version', __version__)
packet.add_header('Origin-Platform-Name', platform.system())
... | [
"def",
"add_origin_info",
"(",
"self",
",",
"packet",
")",
":",
"packet",
".",
"add_header",
"(",
"'Origin-Machine-Name'",
",",
"platform",
".",
"node",
"(",
")",
")",
"packet",
".",
"add_header",
"(",
"'Origin-Software-Name'",
",",
"'gntp.py'",
")",
"packet",... | Add optional Origin headers to message | [
"Add",
"optional",
"Origin",
"headers",
"to",
"message"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/notifier.py#L169-L175 |
kfdm/gntp | gntp/notifier.py | GrowlNotifier._send | def _send(self, messagetype, packet):
"""Send the GNTP Packet"""
packet.validate()
data = packet.encode()
logger.debug('To : %s:%s <%s>\n%s', self.hostname, self.port, packet.__class__, data)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(self.socketTimeout)
try:
s.connect((self.... | python | def _send(self, messagetype, packet):
"""Send the GNTP Packet"""
packet.validate()
data = packet.encode()
logger.debug('To : %s:%s <%s>\n%s', self.hostname, self.port, packet.__class__, data)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(self.socketTimeout)
try:
s.connect((self.... | [
"def",
"_send",
"(",
"self",
",",
"messagetype",
",",
"packet",
")",
":",
"packet",
".",
"validate",
"(",
")",
"data",
"=",
"packet",
".",
"encode",
"(",
")",
"logger",
".",
"debug",
"(",
"'To : %s:%s <%s>\\n%s'",
",",
"self",
".",
"hostname",
",",
"se... | Send the GNTP Packet | [
"Send",
"the",
"GNTP",
"Packet"
] | train | https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/notifier.py#L186-L215 |
rongcloud/server-sdk-python | rongcloud/wordfilter.py | Wordfilter.add | def add(self, word):
"""
添加敏感词方法(设置敏感词后,App 中用户不会收到含有敏感词的消息内容,默认最多设置 50 个敏感词。) 方法
@param word:敏感词,最长不超过 32 个字符。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。
"""
desc = {
"name": "CodeSuccessReslut",
"desc": " http 成功返回结果",
... | python | def add(self, word):
"""
添加敏感词方法(设置敏感词后,App 中用户不会收到含有敏感词的消息内容,默认最多设置 50 个敏感词。) 方法
@param word:敏感词,最长不超过 32 个字符。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。
"""
desc = {
"name": "CodeSuccessReslut",
"desc": " http 成功返回结果",
... | [
"def",
"add",
"(",
"self",
",",
"word",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"CodeSuccessReslut\"",
",",
"\"desc\"",
":",
"\" http 成功返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",
"\"type\"",
":",
"\"Integer\"",
",",... | 添加敏感词方法(设置敏感词后,App 中用户不会收到含有敏感词的消息内容,默认最多设置 50 个敏感词。) 方法
@param word:敏感词,最长不超过 32 个字符。(必传)
@return code:返回码,200 为正常。
@return errorMessage:错误信息。 | [
"添加敏感词方法(设置敏感词后,App",
"中用户不会收到含有敏感词的消息内容,默认最多设置",
"50",
"个敏感词。)",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/wordfilter.py#L9-L35 |
rongcloud/server-sdk-python | rongcloud/wordfilter.py | Wordfilter.getList | def getList(self):
"""
查询敏感词列表方法 方法
@return code:返回码,200 为正常。
@return word:敏感词内容。
@return errorMessage:错误信息。
"""
desc = {
"name": "ListWordfilterReslut",
"desc": "listWordfilter返回结果",
"fields": [{
"name": "code"... | python | def getList(self):
"""
查询敏感词列表方法 方法
@return code:返回码,200 为正常。
@return word:敏感词内容。
@return errorMessage:错误信息。
"""
desc = {
"name": "ListWordfilterReslut",
"desc": "listWordfilter返回结果",
"fields": [{
"name": "code"... | [
"def",
"getList",
"(",
"self",
")",
":",
"desc",
"=",
"{",
"\"name\"",
":",
"\"ListWordfilterReslut\"",
",",
"\"desc\"",
":",
"\"listWordfilter返回结果\",",
"",
"\"fields\"",
":",
"[",
"{",
"\"name\"",
":",
"\"code\"",
",",
"\"type\"",
":",
"\"Integer\"",
",",
"... | 查询敏感词列表方法 方法
@return code:返回码,200 为正常。
@return word:敏感词内容。
@return errorMessage:错误信息。 | [
"查询敏感词列表方法",
"方法"
] | train | https://github.com/rongcloud/server-sdk-python/blob/3daadd8b67c84cc5d2a9419e8d45fd69c9baf976/rongcloud/wordfilter.py#L37-L67 |
openvax/pepdata | pepdata/iedb/alleles.py | local_path | def local_path(force_download=False):
"""Downloads allele database from IEDB, returns local path to XML file."""
return cache.fetch(
filename=ALLELE_XML_FILENAME,
url=ALLELE_XML_URL,
decompress=ALLELE_XML_DECOMPRESS,
force=force_download) | python | def local_path(force_download=False):
"""Downloads allele database from IEDB, returns local path to XML file."""
return cache.fetch(
filename=ALLELE_XML_FILENAME,
url=ALLELE_XML_URL,
decompress=ALLELE_XML_DECOMPRESS,
force=force_download) | [
"def",
"local_path",
"(",
"force_download",
"=",
"False",
")",
":",
"return",
"cache",
".",
"fetch",
"(",
"filename",
"=",
"ALLELE_XML_FILENAME",
",",
"url",
"=",
"ALLELE_XML_URL",
",",
"decompress",
"=",
"ALLELE_XML_DECOMPRESS",
",",
"force",
"=",
"force_downlo... | Downloads allele database from IEDB, returns local path to XML file. | [
"Downloads",
"allele",
"database",
"from",
"IEDB",
"returns",
"local",
"path",
"to",
"XML",
"file",
"."
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/iedb/alleles.py#L25-L31 |
openvax/pepdata | pepdata/iedb/alleles.py | delete | def delete():
"""Deletes local XML file"""
path = cache.local_path(
filename=ALLELE_XML_FILENAME,
url=ALLELE_XML_URL,
decompress=ALLELE_XML_DECOMPRESS)
os.remove(path) | python | def delete():
"""Deletes local XML file"""
path = cache.local_path(
filename=ALLELE_XML_FILENAME,
url=ALLELE_XML_URL,
decompress=ALLELE_XML_DECOMPRESS)
os.remove(path) | [
"def",
"delete",
"(",
")",
":",
"path",
"=",
"cache",
".",
"local_path",
"(",
"filename",
"=",
"ALLELE_XML_FILENAME",
",",
"url",
"=",
"ALLELE_XML_URL",
",",
"decompress",
"=",
"ALLELE_XML_DECOMPRESS",
")",
"os",
".",
"remove",
"(",
"path",
")"
] | Deletes local XML file | [
"Deletes",
"local",
"XML",
"file"
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/iedb/alleles.py#L33-L39 |
openvax/pepdata | pepdata/iedb/alleles.py | load_alleles | def load_alleles():
"""Parses the IEDB MhcAlleleName XML file and returns a list of Allele
namedtuple objects containing information about that each allele's HLA
class and source organism.
"""
result = []
path = local_path()
etree = xml.etree.ElementTree.parse(path)
for allele in etree.i... | python | def load_alleles():
"""Parses the IEDB MhcAlleleName XML file and returns a list of Allele
namedtuple objects containing information about that each allele's HLA
class and source organism.
"""
result = []
path = local_path()
etree = xml.etree.ElementTree.parse(path)
for allele in etree.i... | [
"def",
"load_alleles",
"(",
")",
":",
"result",
"=",
"[",
"]",
"path",
"=",
"local_path",
"(",
")",
"etree",
"=",
"xml",
".",
"etree",
".",
"ElementTree",
".",
"parse",
"(",
"path",
")",
"for",
"allele",
"in",
"etree",
".",
"iterfind",
"(",
"\"MhcAll... | Parses the IEDB MhcAlleleName XML file and returns a list of Allele
namedtuple objects containing information about that each allele's HLA
class and source organism. | [
"Parses",
"the",
"IEDB",
"MhcAlleleName",
"XML",
"file",
"and",
"returns",
"a",
"list",
"of",
"Allele",
"namedtuple",
"objects",
"containing",
"information",
"about",
"that",
"each",
"allele",
"s",
"HLA",
"class",
"and",
"source",
"organism",
"."
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/iedb/alleles.py#L50-L91 |
openvax/pepdata | pepdata/iedb/alleles.py | load_alleles_dict | def load_alleles_dict():
"""Create a dictionary mapping each unique allele name to a namedtuple
containing information about that alleles class, locus, species, &c.
"""
alleles = load_alleles()
result = {}
for allele in alleles:
for name in {allele.name}.union(allele.synonyms):
... | python | def load_alleles_dict():
"""Create a dictionary mapping each unique allele name to a namedtuple
containing information about that alleles class, locus, species, &c.
"""
alleles = load_alleles()
result = {}
for allele in alleles:
for name in {allele.name}.union(allele.synonyms):
... | [
"def",
"load_alleles_dict",
"(",
")",
":",
"alleles",
"=",
"load_alleles",
"(",
")",
"result",
"=",
"{",
"}",
"for",
"allele",
"in",
"alleles",
":",
"for",
"name",
"in",
"{",
"allele",
".",
"name",
"}",
".",
"union",
"(",
"allele",
".",
"synonyms",
"... | Create a dictionary mapping each unique allele name to a namedtuple
containing information about that alleles class, locus, species, &c. | [
"Create",
"a",
"dictionary",
"mapping",
"each",
"unique",
"allele",
"name",
"to",
"a",
"namedtuple",
"containing",
"information",
"about",
"that",
"alleles",
"class",
"locus",
"species",
"&c",
"."
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/iedb/alleles.py#L94-L103 |
openvax/pepdata | pepdata/pmbec.py | read_pmbec_coefficients | def read_pmbec_coefficients(
key_type='row',
verbose=True,
filename=join(MATRIX_DIR, 'pmbec.mat')):
"""
Parameters
------------
filename : str
Location of PMBEC coefficient matrix
key_type : str
'row' : every key is a single amino acid,
which maps... | python | def read_pmbec_coefficients(
key_type='row',
verbose=True,
filename=join(MATRIX_DIR, 'pmbec.mat')):
"""
Parameters
------------
filename : str
Location of PMBEC coefficient matrix
key_type : str
'row' : every key is a single amino acid,
which maps... | [
"def",
"read_pmbec_coefficients",
"(",
"key_type",
"=",
"'row'",
",",
"verbose",
"=",
"True",
",",
"filename",
"=",
"join",
"(",
"MATRIX_DIR",
",",
"'pmbec.mat'",
")",
")",
":",
"d",
"=",
"{",
"}",
"if",
"key_type",
"==",
"'row'",
":",
"def",
"add_pair",... | Parameters
------------
filename : str
Location of PMBEC coefficient matrix
key_type : str
'row' : every key is a single amino acid,
which maps to a dictionary for that row
'pair' : every key is a tuple of amino acids
'pair_string' : every key is a string of two ... | [
"Parameters",
"------------"
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/pmbec.py#L22-L84 |
kennedyshead/aioasuswrt | aioasuswrt/connection.py | SshConnection.async_run_command | async def async_run_command(self, command, retry=False):
"""Run commands through an SSH connection.
Connect to the SSH server if not currently connected, otherwise
use the existing connection.
"""
if not self.is_connected:
await self.async_connect()
try:
... | python | async def async_run_command(self, command, retry=False):
"""Run commands through an SSH connection.
Connect to the SSH server if not currently connected, otherwise
use the existing connection.
"""
if not self.is_connected:
await self.async_connect()
try:
... | [
"async",
"def",
"async_run_command",
"(",
"self",
",",
"command",
",",
"retry",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
":",
"await",
"self",
".",
"async_connect",
"(",
")",
"try",
":",
"result",
"=",
"await",
"asyncio",
".",
... | Run commands through an SSH connection.
Connect to the SSH server if not currently connected, otherwise
use the existing connection. | [
"Run",
"commands",
"through",
"an",
"SSH",
"connection",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/connection.py#L28-L54 |
kennedyshead/aioasuswrt | aioasuswrt/connection.py | SshConnection.async_connect | async def async_connect(self):
"""Fetches the client or creates a new one."""
kwargs = {
'username': self._username if self._username else None,
'client_keys': [self._ssh_key] if self._ssh_key else None,
'port': self._port,
'password': self._password if s... | python | async def async_connect(self):
"""Fetches the client or creates a new one."""
kwargs = {
'username': self._username if self._username else None,
'client_keys': [self._ssh_key] if self._ssh_key else None,
'port': self._port,
'password': self._password if s... | [
"async",
"def",
"async_connect",
"(",
"self",
")",
":",
"kwargs",
"=",
"{",
"'username'",
":",
"self",
".",
"_username",
"if",
"self",
".",
"_username",
"else",
"None",
",",
"'client_keys'",
":",
"[",
"self",
".",
"_ssh_key",
"]",
"if",
"self",
".",
"_... | Fetches the client or creates a new one. | [
"Fetches",
"the",
"client",
"or",
"creates",
"a",
"new",
"one",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/connection.py#L61-L73 |
kennedyshead/aioasuswrt | aioasuswrt/connection.py | TelnetConnection.async_run_command | async def async_run_command(self, command, first_try=True):
"""Run a command through a Telnet connection.
Connect to the Telnet server if not currently connected, otherwise
use the existing connection.
"""
await self.async_connect()
try:
with (await self._io_l... | python | async def async_run_command(self, command, first_try=True):
"""Run a command through a Telnet connection.
Connect to the Telnet server if not currently connected, otherwise
use the existing connection.
"""
await self.async_connect()
try:
with (await self._io_l... | [
"async",
"def",
"async_run_command",
"(",
"self",
",",
"command",
",",
"first_try",
"=",
"True",
")",
":",
"await",
"self",
".",
"async_connect",
"(",
")",
"try",
":",
"with",
"(",
"await",
"self",
".",
"_io_lock",
")",
":",
"self",
".",
"_writer",
"."... | Run a command through a Telnet connection.
Connect to the Telnet server if not currently connected, otherwise
use the existing connection. | [
"Run",
"a",
"command",
"through",
"a",
"Telnet",
"connection",
".",
"Connect",
"to",
"the",
"Telnet",
"server",
"if",
"not",
"currently",
"connected",
"otherwise",
"use",
"the",
"existing",
"connection",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/connection.py#L92-L118 |
kennedyshead/aioasuswrt | aioasuswrt/connection.py | TelnetConnection.async_connect | async def async_connect(self):
"""Connect to the ASUS-WRT Telnet server."""
self._reader, self._writer = await asyncio.open_connection(
self._host, self._port)
with (await self._io_lock):
try:
await asyncio.wait_for(self._reader.readuntil(b'login: '), 9)
... | python | async def async_connect(self):
"""Connect to the ASUS-WRT Telnet server."""
self._reader, self._writer = await asyncio.open_connection(
self._host, self._port)
with (await self._io_lock):
try:
await asyncio.wait_for(self._reader.readuntil(b'login: '), 9)
... | [
"async",
"def",
"async_connect",
"(",
"self",
")",
":",
"self",
".",
"_reader",
",",
"self",
".",
"_writer",
"=",
"await",
"asyncio",
".",
"open_connection",
"(",
"self",
".",
"_host",
",",
"self",
".",
"_port",
")",
"with",
"(",
"await",
"self",
".",
... | Connect to the ASUS-WRT Telnet server. | [
"Connect",
"to",
"the",
"ASUS",
"-",
"WRT",
"Telnet",
"server",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/connection.py#L120-L142 |
kennedyshead/aioasuswrt | aioasuswrt/asuswrt.py | _parse_lines | async def _parse_lines(lines, regex):
"""Parse the lines using the given regular expression.
If a line can't be parsed it is logged and skipped in the output.
"""
results = []
if inspect.iscoroutinefunction(lines):
lines = await lines
for line in lines:
if line:
matc... | python | async def _parse_lines(lines, regex):
"""Parse the lines using the given regular expression.
If a line can't be parsed it is logged and skipped in the output.
"""
results = []
if inspect.iscoroutinefunction(lines):
lines = await lines
for line in lines:
if line:
matc... | [
"async",
"def",
"_parse_lines",
"(",
"lines",
",",
"regex",
")",
":",
"results",
"=",
"[",
"]",
"if",
"inspect",
".",
"iscoroutinefunction",
"(",
"lines",
")",
":",
"lines",
"=",
"await",
"lines",
"for",
"line",
"in",
"lines",
":",
"if",
"line",
":",
... | Parse the lines using the given regular expression.
If a line can't be parsed it is logged and skipped in the output. | [
"Parse",
"the",
"lines",
"using",
"the",
"given",
"regular",
"expression",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/asuswrt.py#L59-L74 |
kennedyshead/aioasuswrt | aioasuswrt/asuswrt.py | AsusWrt.async_get_connected_devices | async def async_get_connected_devices(self):
"""Retrieve data from ASUSWRT.
Calls various commands on the router and returns the superset of all
responses. Some commands will not work on some routers.
"""
devices = {}
dev = await self.async_get_wl()
devices.updat... | python | async def async_get_connected_devices(self):
"""Retrieve data from ASUSWRT.
Calls various commands on the router and returns the superset of all
responses. Some commands will not work on some routers.
"""
devices = {}
dev = await self.async_get_wl()
devices.updat... | [
"async",
"def",
"async_get_connected_devices",
"(",
"self",
")",
":",
"devices",
"=",
"{",
"}",
"dev",
"=",
"await",
"self",
".",
"async_get_wl",
"(",
")",
"devices",
".",
"update",
"(",
"dev",
")",
"dev",
"=",
"await",
"self",
".",
"async_get_arp",
"(",... | Retrieve data from ASUSWRT.
Calls various commands on the router and returns the superset of all
responses. Some commands will not work on some routers. | [
"Retrieve",
"data",
"from",
"ASUSWRT",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/asuswrt.py#L159-L180 |
kennedyshead/aioasuswrt | aioasuswrt/asuswrt.py | AsusWrt.async_get_bytes_total | async def async_get_bytes_total(self, use_cache=True):
"""Retrieve total bytes (rx an tx) from ASUSWRT."""
now = datetime.utcnow()
if use_cache and self._trans_cache_timer and self._cache_time > \
(now - self._trans_cache_timer).total_seconds():
return self._transfer_... | python | async def async_get_bytes_total(self, use_cache=True):
"""Retrieve total bytes (rx an tx) from ASUSWRT."""
now = datetime.utcnow()
if use_cache and self._trans_cache_timer and self._cache_time > \
(now - self._trans_cache_timer).total_seconds():
return self._transfer_... | [
"async",
"def",
"async_get_bytes_total",
"(",
"self",
",",
"use_cache",
"=",
"True",
")",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"if",
"use_cache",
"and",
"self",
".",
"_trans_cache_timer",
"and",
"self",
".",
"_cache_time",
">",
"(",
"now",... | Retrieve total bytes (rx an tx) from ASUSWRT. | [
"Retrieve",
"total",
"bytes",
"(",
"rx",
"an",
"tx",
")",
"from",
"ASUSWRT",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/asuswrt.py#L182-L191 |
kennedyshead/aioasuswrt | aioasuswrt/asuswrt.py | AsusWrt.async_get_current_transfer_rates | async def async_get_current_transfer_rates(self, use_cache=True):
"""Gets current transfer rates calculated in per second in bytes."""
now = datetime.utcnow()
data = await self.async_get_bytes_total(use_cache)
if self._rx_latest is None or self._tx_latest is None:
self._lates... | python | async def async_get_current_transfer_rates(self, use_cache=True):
"""Gets current transfer rates calculated in per second in bytes."""
now = datetime.utcnow()
data = await self.async_get_bytes_total(use_cache)
if self._rx_latest is None or self._tx_latest is None:
self._lates... | [
"async",
"def",
"async_get_current_transfer_rates",
"(",
"self",
",",
"use_cache",
"=",
"True",
")",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"data",
"=",
"await",
"self",
".",
"async_get_bytes_total",
"(",
"use_cache",
")",
"if",
"self",
".",
... | Gets current transfer rates calculated in per second in bytes. | [
"Gets",
"current",
"transfer",
"rates",
"calculated",
"in",
"per",
"second",
"in",
"bytes",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/asuswrt.py#L203-L233 |
kennedyshead/aioasuswrt | aioasuswrt/asuswrt.py | AsusWrt.async_current_transfer_human_readable | async def async_current_transfer_human_readable(
self, use_cache=True):
"""Gets current transfer rates in a human readable format."""
rx, tx = await self.async_get_current_transfer_rates(use_cache)
return "%s/s" % convert_size(rx), "%s/s" % convert_size(tx) | python | async def async_current_transfer_human_readable(
self, use_cache=True):
"""Gets current transfer rates in a human readable format."""
rx, tx = await self.async_get_current_transfer_rates(use_cache)
return "%s/s" % convert_size(rx), "%s/s" % convert_size(tx) | [
"async",
"def",
"async_current_transfer_human_readable",
"(",
"self",
",",
"use_cache",
"=",
"True",
")",
":",
"rx",
",",
"tx",
"=",
"await",
"self",
".",
"async_get_current_transfer_rates",
"(",
"use_cache",
")",
"return",
"\"%s/s\"",
"%",
"convert_size",
"(",
... | Gets current transfer rates in a human readable format. | [
"Gets",
"current",
"transfer",
"rates",
"in",
"a",
"human",
"readable",
"format",
"."
] | train | https://github.com/kennedyshead/aioasuswrt/blob/0c4336433727abbb7b324ee29e4c5382be9aaa2b/aioasuswrt/asuswrt.py#L235-L240 |
openvax/pepdata | pepdata/iedb/tcell.py | load_dataframe | def load_dataframe(
mhc_class=None, # 1, 2, or None for neither
hla=None,
exclude_hla=None,
human_only=False,
peptide_length=None,
assay_method=None,
assay_group=None,
only_standard_amino_acids=True,
reduced_alphabet=None, # 20 letter AA strings ... | python | def load_dataframe(
mhc_class=None, # 1, 2, or None for neither
hla=None,
exclude_hla=None,
human_only=False,
peptide_length=None,
assay_method=None,
assay_group=None,
only_standard_amino_acids=True,
reduced_alphabet=None, # 20 letter AA strings ... | [
"def",
"load_dataframe",
"(",
"mhc_class",
"=",
"None",
",",
"# 1, 2, or None for neither",
"hla",
"=",
"None",
",",
"exclude_hla",
"=",
"None",
",",
"human_only",
"=",
"False",
",",
"peptide_length",
"=",
"None",
",",
"assay_method",
"=",
"None",
",",
"assay_... | Load IEDB T-cell data without aggregating multiple entries for same epitope
Parameters
----------
mhc_class: {None, 1, 2}
Restrict to MHC Class I or Class II (or None for neither)
hla: regex pattern, optional
Restrict results to specific HLA type used in assay
exclude_hla: regex p... | [
"Load",
"IEDB",
"T",
"-",
"cell",
"data",
"without",
"aggregating",
"multiple",
"entries",
"for",
"same",
"epitope"
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/iedb/tcell.py#L54-L192 |
openvax/pepdata | pepdata/blosum.py | parse_blosum_table | def parse_blosum_table(table, coeff_type=int, key_type='row'):
"""
Parse a table of pairwise amino acid coefficient (e.g. BLOSUM50)
"""
lines = table.split("\n")
# drop comments
lines = [line for line in lines if not line.startswith("#")]
# drop CR endline characters
lines = [line.repla... | python | def parse_blosum_table(table, coeff_type=int, key_type='row'):
"""
Parse a table of pairwise amino acid coefficient (e.g. BLOSUM50)
"""
lines = table.split("\n")
# drop comments
lines = [line for line in lines if not line.startswith("#")]
# drop CR endline characters
lines = [line.repla... | [
"def",
"parse_blosum_table",
"(",
"table",
",",
"coeff_type",
"=",
"int",
",",
"key_type",
"=",
"'row'",
")",
":",
"lines",
"=",
"table",
".",
"split",
"(",
"\"\\n\"",
")",
"# drop comments",
"lines",
"=",
"[",
"line",
"for",
"line",
"in",
"lines",
"if",... | Parse a table of pairwise amino acid coefficient (e.g. BLOSUM50) | [
"Parse",
"a",
"table",
"of",
"pairwise",
"amino",
"acid",
"coefficient",
"(",
"e",
".",
"g",
".",
"BLOSUM50",
")"
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/blosum.py#L21-L61 |
openvax/pepdata | pepdata/iedb/memoize.py | _prepare_memoization_key | def _prepare_memoization_key(args, kwargs):
"""
Make a tuple of arguments which can be used as a key
for a memoized function's lookup_table. If some object can't be hashed
then used its __repr__ instead.
"""
key_list = []
for arg in args:
try:
hash(arg)
key_li... | python | def _prepare_memoization_key(args, kwargs):
"""
Make a tuple of arguments which can be used as a key
for a memoized function's lookup_table. If some object can't be hashed
then used its __repr__ instead.
"""
key_list = []
for arg in args:
try:
hash(arg)
key_li... | [
"def",
"_prepare_memoization_key",
"(",
"args",
",",
"kwargs",
")",
":",
"key_list",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"try",
":",
"hash",
"(",
"arg",
")",
"key_list",
".",
"append",
"(",
"arg",
")",
"except",
":",
"key_list",
".",
"app... | Make a tuple of arguments which can be used as a key
for a memoized function's lookup_table. If some object can't be hashed
then used its __repr__ instead. | [
"Make",
"a",
"tuple",
"of",
"arguments",
"which",
"can",
"be",
"used",
"as",
"a",
"key",
"for",
"a",
"memoized",
"function",
"s",
"lookup_table",
".",
"If",
"some",
"object",
"can",
"t",
"be",
"hashed",
"then",
"used",
"its",
"__repr__",
"instead",
"."
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/iedb/memoize.py#L17-L37 |
openvax/pepdata | pepdata/iedb/mhc.py | load_dataframe | def load_dataframe(
mhc_class=None, # 1, 2, or None for neither
hla=None,
exclude_hla=None,
human_only=False,
peptide_length=None,
assay_method=None,
assay_group=None,
only_standard_amino_acids=True,
reduced_alphabet=None, # 20 letter AA strings ... | python | def load_dataframe(
mhc_class=None, # 1, 2, or None for neither
hla=None,
exclude_hla=None,
human_only=False,
peptide_length=None,
assay_method=None,
assay_group=None,
only_standard_amino_acids=True,
reduced_alphabet=None, # 20 letter AA strings ... | [
"def",
"load_dataframe",
"(",
"mhc_class",
"=",
"None",
",",
"# 1, 2, or None for neither",
"hla",
"=",
"None",
",",
"exclude_hla",
"=",
"None",
",",
"human_only",
"=",
"False",
",",
"peptide_length",
"=",
"None",
",",
"assay_method",
"=",
"None",
",",
"assay_... | Load IEDB MHC data without aggregating multiple entries for the same epitope
Parameters
----------
mhc_class : {None, 1, 2}
Restrict to MHC Class I or Class II (or None for neither)
hla : regex pattern, optional
Restrict results to specific HLA type used in assay
exclude_hla : reg... | [
"Load",
"IEDB",
"MHC",
"data",
"without",
"aggregating",
"multiple",
"entries",
"for",
"the",
"same",
"epitope"
] | train | https://github.com/openvax/pepdata/blob/2f1bad79f8084545227f4a7f895bbf08a6fb6fdc/pepdata/iedb/mhc.py#L51-L171 |
101Loop/drf-addons | drfaddons/admin.py | CreateUpdateAdmin.get_fieldsets | def get_fieldsets(self, request, obj=None):
"""
Add ownership info fields in fieldset with proper separation.
Author: Himanshu Shankar (https://himanshus.com)
"""
fieldsets = list(super(CreateUpdateAdmin, self).get_fieldsets(
request=request, obj=obj))
# Cre... | python | def get_fieldsets(self, request, obj=None):
"""
Add ownership info fields in fieldset with proper separation.
Author: Himanshu Shankar (https://himanshus.com)
"""
fieldsets = list(super(CreateUpdateAdmin, self).get_fieldsets(
request=request, obj=obj))
# Cre... | [
"def",
"get_fieldsets",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"fieldsets",
"=",
"list",
"(",
"super",
"(",
"CreateUpdateAdmin",
",",
"self",
")",
".",
"get_fieldsets",
"(",
"request",
"=",
"request",
",",
"obj",
"=",
"obj",
")... | Add ownership info fields in fieldset with proper separation.
Author: Himanshu Shankar (https://himanshus.com) | [
"Add",
"ownership",
"info",
"fields",
"in",
"fieldset",
"with",
"proper",
"separation",
"."
] | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/admin.py#L83-L121 |
101Loop/drf-addons | drfaddons/admin.py | CreateUpdateAdmin.get_readonly_fields | def get_readonly_fields(self, request, obj=None):
"""
Makes `created_by`, `create_date` & `update_date` readonly when
editing.
Author: Himanshu Shankar (https://himanshus.com)
"""
# Get read only fields from super
fields = list(super(CreateUpdateAdmin, self).get... | python | def get_readonly_fields(self, request, obj=None):
"""
Makes `created_by`, `create_date` & `update_date` readonly when
editing.
Author: Himanshu Shankar (https://himanshus.com)
"""
# Get read only fields from super
fields = list(super(CreateUpdateAdmin, self).get... | [
"def",
"get_readonly_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"# Get read only fields from super",
"fields",
"=",
"list",
"(",
"super",
"(",
"CreateUpdateAdmin",
",",
"self",
")",
".",
"get_readonly_fields",
"(",
"request",
"=",
... | Makes `created_by`, `create_date` & `update_date` readonly when
editing.
Author: Himanshu Shankar (https://himanshus.com) | [
"Makes",
"created_by",
"create_date",
"&",
"update_date",
"readonly",
"when",
"editing",
"."
] | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/admin.py#L123-L149 |
101Loop/drf-addons | drfaddons/auth.py | JSONWebTokenAuthenticationQS.get_authorization | def get_authorization(self, request):
"""
This function extracts the authorization JWT string. It first
looks for specified key in header and then looks
for the same in body part.
Parameters
----------
request: HttpRequest
This is the raw request that... | python | def get_authorization(self, request):
"""
This function extracts the authorization JWT string. It first
looks for specified key in header and then looks
for the same in body part.
Parameters
----------
request: HttpRequest
This is the raw request that... | [
"def",
"get_authorization",
"(",
"self",
",",
"request",
")",
":",
"from",
"django",
".",
"utils",
".",
"six",
"import",
"text_type",
"from",
"rest_framework",
"import",
"HTTP_HEADER_ENCODING",
"auth",
"=",
"request",
".",
"data",
".",
"get",
"(",
"self",
".... | This function extracts the authorization JWT string. It first
looks for specified key in header and then looks
for the same in body part.
Parameters
----------
request: HttpRequest
This is the raw request that user has sent.
Returns
-------
a... | [
"This",
"function",
"extracts",
"the",
"authorization",
"JWT",
"string",
".",
"It",
"first",
"looks",
"for",
"specified",
"key",
"in",
"header",
"and",
"then",
"looks",
"for",
"the",
"same",
"in",
"body",
"part",
"."
] | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/auth.py#L27-L55 |
101Loop/drf-addons | drfaddons/auth.py | JSONWebTokenAuthenticationQS.get_jwt_value | def get_jwt_value(self, request):
"""
This function has been overloaded and it returns the proper JWT
auth string.
Parameters
----------
request: HttpRequest
This is the request that is received by DJango in the view.
Returns
-------
st... | python | def get_jwt_value(self, request):
"""
This function has been overloaded and it returns the proper JWT
auth string.
Parameters
----------
request: HttpRequest
This is the request that is received by DJango in the view.
Returns
-------
st... | [
"def",
"get_jwt_value",
"(",
"self",
",",
"request",
")",
":",
"from",
"django",
".",
"utils",
".",
"encoding",
"import",
"smart_text",
"from",
"django",
".",
"utils",
".",
"translation",
"import",
"ugettext",
"as",
"_",
"from",
"rest_framework",
"import",
"... | This function has been overloaded and it returns the proper JWT
auth string.
Parameters
----------
request: HttpRequest
This is the request that is received by DJango in the view.
Returns
-------
str
This returns the extracted JWT auth toke... | [
"This",
"function",
"has",
"been",
"overloaded",
"and",
"it",
"returns",
"the",
"proper",
"JWT",
"auth",
"string",
".",
"Parameters",
"----------",
"request",
":",
"HttpRequest",
"This",
"is",
"the",
"request",
"that",
"is",
"received",
"by",
"DJango",
"in",
... | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/auth.py#L57-L99 |
frnmst/md-toc | md_toc/__main__.py | main | def main(args=None):
"""Call the CLI interface and wait for the result."""
retcode = 0
try:
ci = CliInterface()
args = ci.parser.parse_args()
result = args.func(args)
if result is not None:
print(result)
retcode = 0
except Exception:
retcode = ... | python | def main(args=None):
"""Call the CLI interface and wait for the result."""
retcode = 0
try:
ci = CliInterface()
args = ci.parser.parse_args()
result = args.func(args)
if result is not None:
print(result)
retcode = 0
except Exception:
retcode = ... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"retcode",
"=",
"0",
"try",
":",
"ci",
"=",
"CliInterface",
"(",
")",
"args",
"=",
"ci",
".",
"parser",
".",
"parse_args",
"(",
")",
"result",
"=",
"args",
".",
"func",
"(",
"args",
")",
"if",
... | Call the CLI interface and wait for the result. | [
"Call",
"the",
"CLI",
"interface",
"and",
"wait",
"for",
"the",
"result",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/__main__.py#L28-L41 |
frnmst/md-toc | md_toc/cli.py | CliToApi.write_toc | def write_toc(self, args):
"""Write the table of contents."""
# FIXME: Can this logic be moved into the create_parser function?
ordered = False
if args.ordered_list_marker is not None:
list_marker = args.ordered_list_marker
ordered = True
elif args.unorder... | python | def write_toc(self, args):
"""Write the table of contents."""
# FIXME: Can this logic be moved into the create_parser function?
ordered = False
if args.ordered_list_marker is not None:
list_marker = args.ordered_list_marker
ordered = True
elif args.unorder... | [
"def",
"write_toc",
"(",
"self",
",",
"args",
")",
":",
"# FIXME: Can this logic be moved into the create_parser function?",
"ordered",
"=",
"False",
"if",
"args",
".",
"ordered_list_marker",
"is",
"not",
"None",
":",
"list_marker",
"=",
"args",
".",
"ordered_list_mar... | Write the table of contents. | [
"Write",
"the",
"table",
"of",
"contents",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/cli.py#L46-L75 |
frnmst/md-toc | md_toc/cli.py | CliInterface.create_parser | def create_parser(self):
"""Create the CLI parser."""
parser = argparse.ArgumentParser(
description=PROGRAM_DESCRIPTION,
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=textwrap.dedent(PROGRAM_EPILOG))
parser.add_argument(
'filename',... | python | def create_parser(self):
"""Create the CLI parser."""
parser = argparse.ArgumentParser(
description=PROGRAM_DESCRIPTION,
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=textwrap.dedent(PROGRAM_EPILOG))
parser.add_argument(
'filename',... | [
"def",
"create_parser",
"(",
"self",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"PROGRAM_DESCRIPTION",
",",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatter",
",",
"epilog",
"=",
"textwrap",
".",
"dede... | Create the CLI parser. | [
"Create",
"the",
"CLI",
"parser",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/cli.py#L85-L229 |
theatlantic/python-monkey-business | monkeybiz/__init__.py | patch | def patch(func=None, obj=None, name=None, avoid_doublewrap=True):
"""
Decorator for monkeypatching functions on modules and classes.
Example::
# This replaces FooClass.bar with our method
@monkeybiz.patch(FooClass)
def bar(original_bar, *args, **kwargs):
print "Patched!... | python | def patch(func=None, obj=None, name=None, avoid_doublewrap=True):
"""
Decorator for monkeypatching functions on modules and classes.
Example::
# This replaces FooClass.bar with our method
@monkeybiz.patch(FooClass)
def bar(original_bar, *args, **kwargs):
print "Patched!... | [
"def",
"patch",
"(",
"func",
"=",
"None",
",",
"obj",
"=",
"None",
",",
"name",
"=",
"None",
",",
"avoid_doublewrap",
"=",
"True",
")",
":",
"if",
"obj",
"is",
"None",
":",
"if",
"isinstance",
"(",
"func",
",",
"(",
"type",
",",
"ModuleType",
")",
... | Decorator for monkeypatching functions on modules and classes.
Example::
# This replaces FooClass.bar with our method
@monkeybiz.patch(FooClass)
def bar(original_bar, *args, **kwargs):
print "Patched!"
return original_bar(*args, **kwargs)
# This replaces Fo... | [
"Decorator",
"for",
"monkeypatching",
"functions",
"on",
"modules",
"and",
"classes",
"."
] | train | https://github.com/theatlantic/python-monkey-business/blob/07e3bfbf0f7cd6add59a2a395bf750c6a48d0c1e/monkeybiz/__init__.py#L16-L105 |
theatlantic/python-monkey-business | monkeybiz/__init__.py | unpatch | def unpatch(obj, name):
"""
Undo the effects of patch(func, obj, name)
"""
setattr(obj, name, getattr(obj, name).original) | python | def unpatch(obj, name):
"""
Undo the effects of patch(func, obj, name)
"""
setattr(obj, name, getattr(obj, name).original) | [
"def",
"unpatch",
"(",
"obj",
",",
"name",
")",
":",
"setattr",
"(",
"obj",
",",
"name",
",",
"getattr",
"(",
"obj",
",",
"name",
")",
".",
"original",
")"
] | Undo the effects of patch(func, obj, name) | [
"Undo",
"the",
"effects",
"of",
"patch",
"(",
"func",
"obj",
"name",
")"
] | train | https://github.com/theatlantic/python-monkey-business/blob/07e3bfbf0f7cd6add59a2a395bf750c6a48d0c1e/monkeybiz/__init__.py#L108-L112 |
101Loop/drf-addons | drfaddons/utils.py | validate_email | def validate_email(email):
"""
Validates an email address
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
email: str
Returns
-------
bool
"""
from django.core.validators import validate_email
from django.core.exceptions import ValidationErr... | python | def validate_email(email):
"""
Validates an email address
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
email: str
Returns
-------
bool
"""
from django.core.validators import validate_email
from django.core.exceptions import ValidationErr... | [
"def",
"validate_email",
"(",
"email",
")",
":",
"from",
"django",
".",
"core",
".",
"validators",
"import",
"validate_email",
"from",
"django",
".",
"core",
".",
"exceptions",
"import",
"ValidationError",
"try",
":",
"validate_email",
"(",
"email",
")",
"retu... | Validates an email address
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
email: str
Returns
-------
bool | [
"Validates",
"an",
"email",
"address",
"Source",
":",
"Himanshu",
"Shankar",
"(",
"https",
":",
"//",
"github",
".",
"com",
"/",
"iamhssingh",
")",
"Parameters",
"----------",
"email",
":",
"str"
] | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/utils.py#L84-L102 |
101Loop/drf-addons | drfaddons/utils.py | get_mobile_number | def get_mobile_number(mobile):
"""
Returns a mobile number after removing blanks
Author: Himanshu Shankar (https://himanshus.com)
Parameters
----------
mobile: str
Returns
-------
str
"""
blanks = [' ', '.', ',', '(', ')', '-']
for b in blanks:
mobile = mobile.... | python | def get_mobile_number(mobile):
"""
Returns a mobile number after removing blanks
Author: Himanshu Shankar (https://himanshus.com)
Parameters
----------
mobile: str
Returns
-------
str
"""
blanks = [' ', '.', ',', '(', ')', '-']
for b in blanks:
mobile = mobile.... | [
"def",
"get_mobile_number",
"(",
"mobile",
")",
":",
"blanks",
"=",
"[",
"' '",
",",
"'.'",
",",
"','",
",",
"'('",
",",
"')'",
",",
"'-'",
"]",
"for",
"b",
"in",
"blanks",
":",
"mobile",
"=",
"mobile",
".",
"replace",
"(",
"b",
",",
"''",
")",
... | Returns a mobile number after removing blanks
Author: Himanshu Shankar (https://himanshus.com)
Parameters
----------
mobile: str
Returns
-------
str | [
"Returns",
"a",
"mobile",
"number",
"after",
"removing",
"blanks"
] | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/utils.py#L105-L123 |
101Loop/drf-addons | drfaddons/utils.py | paginate_data | def paginate_data(searched_data, request_data):
"""
Paginates the searched_data as per the request_data
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
searched_data: Serializer.data
It is the data received from queryset. It uses
... | python | def paginate_data(searched_data, request_data):
"""
Paginates the searched_data as per the request_data
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
searched_data: Serializer.data
It is the data received from queryset. It uses
... | [
"def",
"paginate_data",
"(",
"searched_data",
",",
"request_data",
")",
":",
"from",
"django",
".",
"core",
".",
"paginator",
"import",
"Paginator",
",",
"EmptyPage",
",",
"PageNotAnInteger",
"if",
"int",
"(",
"request_data",
".",
"data",
"[",
"'paginator'",
"... | Paginates the searched_data as per the request_data
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
searched_data: Serializer.data
It is the data received from queryset. It uses
show_serializer
request_data: Serializer.data
... | [
"Paginates",
"the",
"searched_data",
"as",
"per",
"the",
"request_data",
"Source",
":",
"Himanshu",
"Shankar",
"(",
"https",
":",
"//",
"github",
".",
"com",
"/",
"iamhssingh",
")",
"Parameters",
"----------",
"searched_data",
":",
"Serializer",
".",
"data",
"... | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/utils.py#L145-L189 |
101Loop/drf-addons | drfaddons/utils.py | send_message | def send_message(message: str, subject: str, recip: list, recip_email: list,
html_message: str = None):
"""
Sends message to specified value.
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
message: str
Message that is to be sent to user.
... | python | def send_message(message: str, subject: str, recip: list, recip_email: list,
html_message: str = None):
"""
Sends message to specified value.
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
message: str
Message that is to be sent to user.
... | [
"def",
"send_message",
"(",
"message",
":",
"str",
",",
"subject",
":",
"str",
",",
"recip",
":",
"list",
",",
"recip_email",
":",
"list",
",",
"html_message",
":",
"str",
"=",
"None",
")",
":",
"import",
"smtplib",
"from",
"django",
".",
"conf",
"impo... | Sends message to specified value.
Source: Himanshu Shankar (https://github.com/iamhssingh)
Parameters
----------
message: str
Message that is to be sent to user.
subject: str
Subject that is to be sent to user, in case prop is an email.
recip: list
Recipient to whom messa... | [
"Sends",
"message",
"to",
"specified",
"value",
".",
"Source",
":",
"Himanshu",
"Shankar",
"(",
"https",
":",
"//",
"github",
".",
"com",
"/",
"iamhssingh",
")",
"Parameters",
"----------",
"message",
":",
"str",
"Message",
"that",
"is",
"to",
"be",
"sent"... | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/utils.py#L192-L294 |
101Loop/drf-addons | drfaddons/permissions.py | IAWPOrSuperuser.has_object_permission | def has_object_permission(self, request, view, obj):
"""
Checks if user is superuser or it has permission over object
Parameters
----------
request
view
obj
Returns
-------
"""
return (
request.user.is_superuser or
... | python | def has_object_permission(self, request, view, obj):
"""
Checks if user is superuser or it has permission over object
Parameters
----------
request
view
obj
Returns
-------
"""
return (
request.user.is_superuser or
... | [
"def",
"has_object_permission",
"(",
"self",
",",
"request",
",",
"view",
",",
"obj",
")",
":",
"return",
"(",
"request",
".",
"user",
".",
"is_superuser",
"or",
"super",
"(",
"IAWPOrSuperuser",
",",
"self",
")",
".",
"has_object_permission",
"(",
"request",... | Checks if user is superuser or it has permission over object
Parameters
----------
request
view
obj
Returns
------- | [
"Checks",
"if",
"user",
"is",
"superuser",
"or",
"it",
"has",
"permission",
"over",
"object"
] | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/permissions.py#L63-L82 |
frnmst/md-toc | md_toc/api.py | write_string_on_file_between_markers | def write_string_on_file_between_markers(filename: str, string: str,
marker: str):
r"""Write the table of contents on a single file.
:parameter filename: the file that needs to be read or modified.
:parameter string: the string that will be written on the file.
... | python | def write_string_on_file_between_markers(filename: str, string: str,
marker: str):
r"""Write the table of contents on a single file.
:parameter filename: the file that needs to be read or modified.
:parameter string: the string that will be written on the file.
... | [
"def",
"write_string_on_file_between_markers",
"(",
"filename",
":",
"str",
",",
"string",
":",
"str",
",",
"marker",
":",
"str",
")",
":",
"if",
"filename",
"==",
"'-'",
":",
"raise",
"StdinIsNotAFileToBeWritten",
"final_string",
"=",
"marker",
"+",
"'\\n\\n'",... | r"""Write the table of contents on a single file.
:parameter filename: the file that needs to be read or modified.
:parameter string: the string that will be written on the file.
:parameter marker: a marker that will identify the start
and the end of the string.
:type filenames: str
:type ... | [
"r",
"Write",
"the",
"table",
"of",
"contents",
"on",
"a",
"single",
"file",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L35-L70 |
frnmst/md-toc | md_toc/api.py | write_strings_on_files_between_markers | def write_strings_on_files_between_markers(filenames: list, strings: list,
marker: str):
r"""Write the table of contents on multiple files.
:parameter filenames: the files that needs to be read or modified.
:parameter strings: the strings that will be written on t... | python | def write_strings_on_files_between_markers(filenames: list, strings: list,
marker: str):
r"""Write the table of contents on multiple files.
:parameter filenames: the files that needs to be read or modified.
:parameter strings: the strings that will be written on t... | [
"def",
"write_strings_on_files_between_markers",
"(",
"filenames",
":",
"list",
",",
"strings",
":",
"list",
",",
"marker",
":",
"str",
")",
":",
"assert",
"len",
"(",
"filenames",
")",
"==",
"len",
"(",
"strings",
")",
"if",
"len",
"(",
"filenames",
")",
... | r"""Write the table of contents on multiple files.
:parameter filenames: the files that needs to be read or modified.
:parameter strings: the strings that will be written on the file. Each
string is associated with one file.
:parameter marker: a marker that will identify the start
and the... | [
"r",
"Write",
"the",
"table",
"of",
"contents",
"on",
"multiple",
"files",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L73-L100 |
frnmst/md-toc | md_toc/api.py | build_toc | def build_toc(filename: str,
ordered: bool = False,
no_links: bool = False,
no_indentation: bool = False,
no_list_coherence: bool = False,
keep_header_levels: int = 3,
parser: str = 'github',
list_marker: str = '-') -> str... | python | def build_toc(filename: str,
ordered: bool = False,
no_links: bool = False,
no_indentation: bool = False,
no_list_coherence: bool = False,
keep_header_levels: int = 3,
parser: str = 'github',
list_marker: str = '-') -> str... | [
"def",
"build_toc",
"(",
"filename",
":",
"str",
",",
"ordered",
":",
"bool",
"=",
"False",
",",
"no_links",
":",
"bool",
"=",
"False",
",",
"no_indentation",
":",
"bool",
"=",
"False",
",",
"no_list_coherence",
":",
"bool",
"=",
"False",
",",
"keep_head... | r"""Build the table of contents of a single file.
:parameter filename: the file that needs to be read.
:parameter ordered: decides whether to build an ordered list or not.
Defaults to ``False``.
:parameter no_links: disables the use of links.
Defaults to ``False``.
:parameter no_inden... | [
"r",
"Build",
"the",
"table",
"of",
"contents",
"of",
"a",
"single",
"file",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L103-L240 |
frnmst/md-toc | md_toc/api.py | build_multiple_tocs | def build_multiple_tocs(filenames: list,
ordered: bool = False,
no_links: bool = False,
no_indentation: bool = False,
no_list_coherence: bool = False,
keep_header_levels: int = 3,
... | python | def build_multiple_tocs(filenames: list,
ordered: bool = False,
no_links: bool = False,
no_indentation: bool = False,
no_list_coherence: bool = False,
keep_header_levels: int = 3,
... | [
"def",
"build_multiple_tocs",
"(",
"filenames",
":",
"list",
",",
"ordered",
":",
"bool",
"=",
"False",
",",
"no_links",
":",
"bool",
"=",
"False",
",",
"no_indentation",
":",
"bool",
"=",
"False",
",",
"no_list_coherence",
":",
"bool",
"=",
"False",
",",
... | r"""Parse files by line and build the table of contents of each file.
:parameter filenames: the files that needs to be read.
:parameter ordered: decides whether to build an ordered list or not.
Defaults to ``False``.
:parameter no_links: disables the use of links.
Defaults to ``False``.
... | [
"r",
"Parse",
"files",
"by",
"line",
"and",
"build",
"the",
"table",
"of",
"contents",
"of",
"each",
"file",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L243-L291 |
frnmst/md-toc | md_toc/api.py | increase_index_ordered_list | def increase_index_ordered_list(header_type_count: dict,
header_type_prev: int,
header_type_curr: int,
parser: str = 'github'):
r"""Compute the current index for ordered list table of contents.
:parameter header_typ... | python | def increase_index_ordered_list(header_type_count: dict,
header_type_prev: int,
header_type_curr: int,
parser: str = 'github'):
r"""Compute the current index for ordered list table of contents.
:parameter header_typ... | [
"def",
"increase_index_ordered_list",
"(",
"header_type_count",
":",
"dict",
",",
"header_type_prev",
":",
"int",
",",
"header_type_curr",
":",
"int",
",",
"parser",
":",
"str",
"=",
"'github'",
")",
":",
"# header_type_prev might be 0 while header_type_curr can't.",
"a... | r"""Compute the current index for ordered list table of contents.
:parameter header_type_count: the count of each header type.
:parameter header_type_prev: the previous type of header (h[1-Inf]).
:parameter header_type_curr: the current type of header (h[1-Inf]).
:parameter parser: decides rules on how... | [
"r",
"Compute",
"the",
"current",
"index",
"for",
"ordered",
"list",
"table",
"of",
"contents",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L294-L330 |
frnmst/md-toc | md_toc/api.py | build_list_marker_log | def build_list_marker_log(parser: str = 'github',
list_marker: str = '.') -> list:
r"""Create a data structure that holds list marker information.
:parameter parser: decides rules on how compute indentations.
Defaults to ``github``.
:parameter list_marker: a string that c... | python | def build_list_marker_log(parser: str = 'github',
list_marker: str = '.') -> list:
r"""Create a data structure that holds list marker information.
:parameter parser: decides rules on how compute indentations.
Defaults to ``github``.
:parameter list_marker: a string that c... | [
"def",
"build_list_marker_log",
"(",
"parser",
":",
"str",
"=",
"'github'",
",",
"list_marker",
":",
"str",
"=",
"'.'",
")",
"->",
"list",
":",
"if",
"(",
"parser",
"==",
"'github'",
"or",
"parser",
"==",
"'cmark'",
"or",
"parser",
"==",
"'gitlab'",
"or"... | r"""Create a data structure that holds list marker information.
:parameter parser: decides rules on how compute indentations.
Defaults to ``github``.
:parameter list_marker: a string that contains some of the first
characters of the list element. Defaults to ``-``.
:type parser: str
:... | [
"r",
"Create",
"a",
"data",
"structure",
"that",
"holds",
"list",
"marker",
"information",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L333-L368 |
frnmst/md-toc | md_toc/api.py | compute_toc_line_indentation_spaces | def compute_toc_line_indentation_spaces(
header_type_curr: int = 1,
header_type_prev: int = 0,
no_of_indentation_spaces_prev: int = 0,
parser: str = 'github',
ordered: bool = False,
list_marker: str = '-',
list_marker_log: list = build_list_marker_log('github', '.... | python | def compute_toc_line_indentation_spaces(
header_type_curr: int = 1,
header_type_prev: int = 0,
no_of_indentation_spaces_prev: int = 0,
parser: str = 'github',
ordered: bool = False,
list_marker: str = '-',
list_marker_log: list = build_list_marker_log('github', '.... | [
"def",
"compute_toc_line_indentation_spaces",
"(",
"header_type_curr",
":",
"int",
"=",
"1",
",",
"header_type_prev",
":",
"int",
"=",
"0",
",",
"no_of_indentation_spaces_prev",
":",
"int",
"=",
"0",
",",
"parser",
":",
"str",
"=",
"'github'",
",",
"ordered",
... | r"""Compute the number of indentation spaces for the TOC list element.
:parameter header_type_curr: the current type of header (h[1-Inf]).
Defaults to ``1``.
:parameter header_type_prev: the previous type of header (h[1-Inf]).
Defaults to ``0``.
:parameter no_of_indentation_spaces_prev: t... | [
"r",
"Compute",
"the",
"number",
"of",
"indentation",
"spaces",
"for",
"the",
"TOC",
"list",
"element",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L371-L483 |
frnmst/md-toc | md_toc/api.py | build_toc_line_without_indentation | def build_toc_line_without_indentation(header: dict,
ordered: bool = False,
no_links: bool = False,
index: int = 1,
parser: str = 'github',
... | python | def build_toc_line_without_indentation(header: dict,
ordered: bool = False,
no_links: bool = False,
index: int = 1,
parser: str = 'github',
... | [
"def",
"build_toc_line_without_indentation",
"(",
"header",
":",
"dict",
",",
"ordered",
":",
"bool",
"=",
"False",
",",
"no_links",
":",
"bool",
"=",
"False",
",",
"index",
":",
"int",
"=",
"1",
",",
"parser",
":",
"str",
"=",
"'github'",
",",
"list_mar... | r"""Return a list element of the table of contents.
:parameter header: a data structure that contains the original
text, the trimmed text and the type of header.
:parameter ordered: if set to ``True``, numbers will be used
as list ids, otherwise a dash character. Defaults
to ``False`... | [
"r",
"Return",
"a",
"list",
"element",
"of",
"the",
"table",
"of",
"contents",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L486-L549 |
frnmst/md-toc | md_toc/api.py | build_toc_line | def build_toc_line(toc_line_no_indent: str,
no_of_indentation_spaces: int = 0) -> str:
r"""Build the TOC line.
:parameter toc_line_no_indent: the TOC line without indentation.
:parameter no_of_indentation_spaces: the number of indentation spaces.
Defaults to ``0``.
:type toc... | python | def build_toc_line(toc_line_no_indent: str,
no_of_indentation_spaces: int = 0) -> str:
r"""Build the TOC line.
:parameter toc_line_no_indent: the TOC line without indentation.
:parameter no_of_indentation_spaces: the number of indentation spaces.
Defaults to ``0``.
:type toc... | [
"def",
"build_toc_line",
"(",
"toc_line_no_indent",
":",
"str",
",",
"no_of_indentation_spaces",
":",
"int",
"=",
"0",
")",
"->",
"str",
":",
"assert",
"no_of_indentation_spaces",
">=",
"0",
"indentation",
"=",
"no_of_indentation_spaces",
"*",
"' '",
"toc_line",
"... | r"""Build the TOC line.
:parameter toc_line_no_indent: the TOC line without indentation.
:parameter no_of_indentation_spaces: the number of indentation spaces.
Defaults to ``0``.
:type toc_line_no_indent: str
:type no_of_indentation_spaces: int
:returns: toc_line, a single line of the tabl... | [
"r",
"Build",
"the",
"TOC",
"line",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L552-L570 |
frnmst/md-toc | md_toc/api.py | build_anchor_link | def build_anchor_link(header_text_trimmed: str,
header_duplicate_counter: str,
parser: str = 'github') -> str:
r"""Apply the specified slug rule to build the anchor link.
:parameter header_text_trimmed: the text that needs to be transformed
in a link.
:p... | python | def build_anchor_link(header_text_trimmed: str,
header_duplicate_counter: str,
parser: str = 'github') -> str:
r"""Apply the specified slug rule to build the anchor link.
:parameter header_text_trimmed: the text that needs to be transformed
in a link.
:p... | [
"def",
"build_anchor_link",
"(",
"header_text_trimmed",
":",
"str",
",",
"header_duplicate_counter",
":",
"str",
",",
"parser",
":",
"str",
"=",
"'github'",
")",
"->",
"str",
":",
"if",
"(",
"parser",
"==",
"'github'",
"or",
"parser",
"==",
"'cmark'",
"or",
... | r"""Apply the specified slug rule to build the anchor link.
:parameter header_text_trimmed: the text that needs to be transformed
in a link.
:parameter header_duplicate_counter: a data structure that keeps track of
possible duplicate header links in order to avoid them. This is
meani... | [
"r",
"Apply",
"the",
"specified",
"slug",
"rule",
"to",
"build",
"the",
"anchor",
"link",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L573-L665 |
frnmst/md-toc | md_toc/api.py | get_atx_heading | def get_atx_heading(line: str,
keep_header_levels: int = 3,
parser: str = 'github',
no_links: bool = False):
r"""Given a line extract the link label and its type.
:parameter line: the line to be examined.
:parameter keep_header_levels: the maximum... | python | def get_atx_heading(line: str,
keep_header_levels: int = 3,
parser: str = 'github',
no_links: bool = False):
r"""Given a line extract the link label and its type.
:parameter line: the line to be examined.
:parameter keep_header_levels: the maximum... | [
"def",
"get_atx_heading",
"(",
"line",
":",
"str",
",",
"keep_header_levels",
":",
"int",
"=",
"3",
",",
"parser",
":",
"str",
"=",
"'github'",
",",
"no_links",
":",
"bool",
"=",
"False",
")",
":",
"assert",
"keep_header_levels",
">=",
"1",
"if",
"len",
... | r"""Given a line extract the link label and its type.
:parameter line: the line to be examined.
:parameter keep_header_levels: the maximum level of headers to be
considered as such when building the table of contents.
Defaults to ``3``.
:parameter parser: decides rules on how to generate ... | [
"r",
"Given",
"a",
"line",
"extract",
"the",
"link",
"label",
"and",
"its",
"type",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L668-L840 |
frnmst/md-toc | md_toc/api.py | get_md_header | def get_md_header(header_text_line: str,
header_duplicate_counter: dict,
keep_header_levels: int = 3,
parser: str = 'github',
no_links: bool = False) -> dict:
r"""Build a data structure with the elements needed to create a TOC line.
:param... | python | def get_md_header(header_text_line: str,
header_duplicate_counter: dict,
keep_header_levels: int = 3,
parser: str = 'github',
no_links: bool = False) -> dict:
r"""Build a data structure with the elements needed to create a TOC line.
:param... | [
"def",
"get_md_header",
"(",
"header_text_line",
":",
"str",
",",
"header_duplicate_counter",
":",
"dict",
",",
"keep_header_levels",
":",
"int",
"=",
"3",
",",
"parser",
":",
"str",
"=",
"'github'",
",",
"no_links",
":",
"bool",
"=",
"False",
")",
"->",
"... | r"""Build a data structure with the elements needed to create a TOC line.
:parameter header_text_line: a single markdown line that needs to be
transformed into a TOC line.
:parameter header_duplicate_counter: a data structure that contains the
number of occurrencies of each header anchor link... | [
"r",
"Build",
"a",
"data",
"structure",
"with",
"the",
"elements",
"needed",
"to",
"create",
"a",
"TOC",
"line",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L843-L889 |
frnmst/md-toc | md_toc/api.py | is_valid_code_fence_indent | def is_valid_code_fence_indent(line: str, parser: str = 'github') -> bool:
r"""Determine if the given line has valid indentation for a code block fence.
:parameter line: a single markdown line to evaluate.
:parameter parser: decides rules on how to generate the anchor text.
Defaults to ``github``.... | python | def is_valid_code_fence_indent(line: str, parser: str = 'github') -> bool:
r"""Determine if the given line has valid indentation for a code block fence.
:parameter line: a single markdown line to evaluate.
:parameter parser: decides rules on how to generate the anchor text.
Defaults to ``github``.... | [
"def",
"is_valid_code_fence_indent",
"(",
"line",
":",
"str",
",",
"parser",
":",
"str",
"=",
"'github'",
")",
"->",
"bool",
":",
"if",
"(",
"parser",
"==",
"'github'",
"or",
"parser",
"==",
"'cmark'",
"or",
"parser",
"==",
"'gitlab'",
"or",
"parser",
"=... | r"""Determine if the given line has valid indentation for a code block fence.
:parameter line: a single markdown line to evaluate.
:parameter parser: decides rules on how to generate the anchor text.
Defaults to ``github``.
:type line: str
:type parser: str
:returns: True if the given line... | [
"r",
"Determine",
"if",
"the",
"given",
"line",
"has",
"valid",
"indentation",
"for",
"a",
"code",
"block",
"fence",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L892-L911 |
frnmst/md-toc | md_toc/api.py | is_opening_code_fence | def is_opening_code_fence(line: str, parser: str = 'github'):
r"""Determine if the given line is possibly the opening of a fenced code block.
:parameter line: a single markdown line to evaluate.
:parameter parser: decides rules on how to generate the anchor text.
Defaults to ``github``.
:type ... | python | def is_opening_code_fence(line: str, parser: str = 'github'):
r"""Determine if the given line is possibly the opening of a fenced code block.
:parameter line: a single markdown line to evaluate.
:parameter parser: decides rules on how to generate the anchor text.
Defaults to ``github``.
:type ... | [
"def",
"is_opening_code_fence",
"(",
"line",
":",
"str",
",",
"parser",
":",
"str",
"=",
"'github'",
")",
":",
"if",
"(",
"parser",
"==",
"'github'",
"or",
"parser",
"==",
"'cmark'",
"or",
"parser",
"==",
"'gitlab'",
"or",
"parser",
"==",
"'commonmarker'",... | r"""Determine if the given line is possibly the opening of a fenced code block.
:parameter line: a single markdown line to evaluate.
:parameter parser: decides rules on how to generate the anchor text.
Defaults to ``github``.
:type line: str
:type parser: str
:returns: None if the input li... | [
"r",
"Determine",
"if",
"the",
"given",
"line",
"is",
"possibly",
"the",
"opening",
"of",
"a",
"fenced",
"code",
"block",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L914-L957 |
frnmst/md-toc | md_toc/api.py | is_closing_code_fence | def is_closing_code_fence(line: str,
fence: str,
is_document_end: bool = False,
parser: str = 'github') -> bool:
r"""Determine if the given line is the end of a fenced code block.
:parameter line: a single markdown line to evaluate.
... | python | def is_closing_code_fence(line: str,
fence: str,
is_document_end: bool = False,
parser: str = 'github') -> bool:
r"""Determine if the given line is the end of a fenced code block.
:parameter line: a single markdown line to evaluate.
... | [
"def",
"is_closing_code_fence",
"(",
"line",
":",
"str",
",",
"fence",
":",
"str",
",",
"is_document_end",
":",
"bool",
"=",
"False",
",",
"parser",
":",
"str",
"=",
"'github'",
")",
"->",
"bool",
":",
"if",
"(",
"parser",
"==",
"'github'",
"or",
"pars... | r"""Determine if the given line is the end of a fenced code block.
:parameter line: a single markdown line to evaluate.
:paramter fence: a sequence of backticks or tildes marking the start of
the current code block. This is usually the return value of the
is_opening_code_fence function.
:... | [
"r",
"Determine",
"if",
"the",
"given",
"line",
"is",
"the",
"end",
"of",
"a",
"fenced",
"code",
"block",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L960-L1038 |
frnmst/md-toc | md_toc/api.py | build_indentation_list | def build_indentation_list(parser: str = 'github'):
r"""Create a data structure that holds the state of indentations.
:parameter parser: decides the length of the list.
Defaults to ``github``.
:type parser: str
:returns: indentation_list, a list that contains the state of
indentations... | python | def build_indentation_list(parser: str = 'github'):
r"""Create a data structure that holds the state of indentations.
:parameter parser: decides the length of the list.
Defaults to ``github``.
:type parser: str
:returns: indentation_list, a list that contains the state of
indentations... | [
"def",
"build_indentation_list",
"(",
"parser",
":",
"str",
"=",
"'github'",
")",
":",
"indentation_list",
"=",
"list",
"(",
")",
"if",
"(",
"parser",
"==",
"'github'",
"or",
"parser",
"==",
"'cmark'",
"or",
"parser",
"==",
"'gitlab'",
"or",
"parser",
"=="... | r"""Create a data structure that holds the state of indentations.
:parameter parser: decides the length of the list.
Defaults to ``github``.
:type parser: str
:returns: indentation_list, a list that contains the state of
indentations given a header type.
:rtype: list
:raises: a bu... | [
"r",
"Create",
"a",
"data",
"structure",
"that",
"holds",
"the",
"state",
"of",
"indentations",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L1041-L1059 |
frnmst/md-toc | md_toc/api.py | toc_renders_as_coherent_list | def toc_renders_as_coherent_list(
header_type_curr: int = 1,
indentation_list: list = build_indentation_list('github'),
parser: str = 'github') -> bool:
r"""Check if the TOC will render as a working list.
:parameter header_type_curr: the current type of header (h[1-Inf]).
:parameter... | python | def toc_renders_as_coherent_list(
header_type_curr: int = 1,
indentation_list: list = build_indentation_list('github'),
parser: str = 'github') -> bool:
r"""Check if the TOC will render as a working list.
:parameter header_type_curr: the current type of header (h[1-Inf]).
:parameter... | [
"def",
"toc_renders_as_coherent_list",
"(",
"header_type_curr",
":",
"int",
"=",
"1",
",",
"indentation_list",
":",
"list",
"=",
"build_indentation_list",
"(",
"'github'",
")",
",",
"parser",
":",
"str",
"=",
"'github'",
")",
"->",
"bool",
":",
"assert",
"head... | r"""Check if the TOC will render as a working list.
:parameter header_type_curr: the current type of header (h[1-Inf]).
:parameter parser: decides rules on how to generate ordered list markers
:type header_type_curr: int
:type indentation_list: list
:type parser: str
:returns: renders_as_list
... | [
"r",
"Check",
"if",
"the",
"TOC",
"will",
"render",
"as",
"a",
"working",
"list",
"."
] | train | https://github.com/frnmst/md-toc/blob/86d2002ecf52fa9e1e5316a31f7eb7d549cb0830/md_toc/api.py#L1062-L1105 |
101Loop/drf-addons | drfaddons/models.py | CreateUpdateModel.is_owner | def is_owner(self, user):
"""
Checks if user is the owner of object
Parameters
----------
user: get_user_model() instance
Returns
-------
bool
Author
------
Himanshu Shankar (https://himanshus.com)
"""
if user.is_... | python | def is_owner(self, user):
"""
Checks if user is the owner of object
Parameters
----------
user: get_user_model() instance
Returns
-------
bool
Author
------
Himanshu Shankar (https://himanshus.com)
"""
if user.is_... | [
"def",
"is_owner",
"(",
"self",
",",
"user",
")",
":",
"if",
"user",
".",
"is_authenticated",
":",
"return",
"self",
".",
"created_by",
".",
"id",
"==",
"user",
".",
"id",
"return",
"False"
] | Checks if user is the owner of object
Parameters
----------
user: get_user_model() instance
Returns
-------
bool
Author
------
Himanshu Shankar (https://himanshus.com) | [
"Checks",
"if",
"user",
"is",
"the",
"owner",
"of",
"object"
] | train | https://github.com/101Loop/drf-addons/blob/62392c72e8bce237f4140a2b7171e89984cb15c5/drfaddons/models.py#L30-L48 |
KarrLab/unitth | unitth/core.py | UnitTH.run | def run(xml_report_dir, xml_report_filter='TEST-', html_report_path='.',
generate_exec_time_graphs=True, html_report_dir='report.th',
initial_java_heap_size=None, maximum_java_heap_size=None):
""" Use UnitTH to generate a test history report
Args:
xml_report_dir (:obj:`str`... | python | def run(xml_report_dir, xml_report_filter='TEST-', html_report_path='.',
generate_exec_time_graphs=True, html_report_dir='report.th',
initial_java_heap_size=None, maximum_java_heap_size=None):
""" Use UnitTH to generate a test history report
Args:
xml_report_dir (:obj:`str`... | [
"def",
"run",
"(",
"xml_report_dir",
",",
"xml_report_filter",
"=",
"'TEST-'",
",",
"html_report_path",
"=",
"'.'",
",",
"generate_exec_time_graphs",
"=",
"True",
",",
"html_report_dir",
"=",
"'report.th'",
",",
"initial_java_heap_size",
"=",
"None",
",",
"maximum_j... | Use UnitTH to generate a test history report
Args:
xml_report_dir (:obj:`str`): Parent directory of XML reports of individual builds to generate a history report of
xml_report_filter (:obj:`str`, optional): Starts-with filter for individual reports with `xml_report_dir` that should
... | [
"Use",
"UnitTH",
"to",
"generate",
"a",
"test",
"history",
"report"
] | train | https://github.com/KarrLab/unitth/blob/f260cbc6047bb39cf6c06aa65a6d65dce0e3b8da/unitth/core.py#L17-L51 |
hadim/read-roi | read_roi/_read_roi.py | get_counter | def get_counter(data, base):
"""
See setCounters() / getCounters() methods in IJ source, ij/gui/PointRoi.java.
"""
b0 = data[base]
b1 = data[base + 1]
b2 = data[base + 2]
b3 = data[base + 3]
counter = b3
position = (b1 << 8) + b2
return counter, position | python | def get_counter(data, base):
"""
See setCounters() / getCounters() methods in IJ source, ij/gui/PointRoi.java.
"""
b0 = data[base]
b1 = data[base + 1]
b2 = data[base + 2]
b3 = data[base + 3]
counter = b3
position = (b1 << 8) + b2
return counter, position | [
"def",
"get_counter",
"(",
"data",
",",
"base",
")",
":",
"b0",
"=",
"data",
"[",
"base",
"]",
"b1",
"=",
"data",
"[",
"base",
"+",
"1",
"]",
"b2",
"=",
"data",
"[",
"base",
"+",
"2",
"]",
"b3",
"=",
"data",
"[",
"base",
"+",
"3",
"]",
"cou... | See setCounters() / getCounters() methods in IJ source, ij/gui/PointRoi.java. | [
"See",
"setCounters",
"()",
"/",
"getCounters",
"()",
"methods",
"in",
"IJ",
"source",
"ij",
"/",
"gui",
"/",
"PointRoi",
".",
"java",
"."
] | train | https://github.com/hadim/read-roi/blob/794d2fff02aabd39bbad9f3bc0bc22d963901824/read_roi/_read_roi.py#L113-L126 |
culqi/culqi-python | culqipy/resource.py | Operation.get_delete | def get_delete(url, id, method, key=None):
"""
Get or delete, just change the method: "GET" or "DELETE".
"""
return Util(
url=url + id + "/",
method=method,
key=key,
).json_result() | python | def get_delete(url, id, method, key=None):
"""
Get or delete, just change the method: "GET" or "DELETE".
"""
return Util(
url=url + id + "/",
method=method,
key=key,
).json_result() | [
"def",
"get_delete",
"(",
"url",
",",
"id",
",",
"method",
",",
"key",
"=",
"None",
")",
":",
"return",
"Util",
"(",
"url",
"=",
"url",
"+",
"id",
"+",
"\"/\"",
",",
"method",
"=",
"method",
",",
"key",
"=",
"key",
",",
")",
".",
"json_result",
... | Get or delete, just change the method: "GET" or "DELETE". | [
"Get",
"or",
"delete",
"just",
"change",
"the",
"method",
":",
"GET",
"or",
"DELETE",
"."
] | train | https://github.com/culqi/culqi-python/blob/ae263b05d287dc8067ccccd879874974f9d34061/culqipy/resource.py#L27-L35 |
devopshq/youtrack | youtrack/connection.py | Connection.get_user | def get_user(self, login):
""" http://confluence.jetbrains.net/display/YTD2/GET+user
"""
return youtrack.User(self._get("/admin/user/" + urlquote(login.encode('utf8'))), self) | python | def get_user(self, login):
""" http://confluence.jetbrains.net/display/YTD2/GET+user
"""
return youtrack.User(self._get("/admin/user/" + urlquote(login.encode('utf8'))), self) | [
"def",
"get_user",
"(",
"self",
",",
"login",
")",
":",
"return",
"youtrack",
".",
"User",
"(",
"self",
".",
"_get",
"(",
"\"/admin/user/\"",
"+",
"urlquote",
"(",
"login",
".",
"encode",
"(",
"'utf8'",
")",
")",
")",
",",
"self",
")"
] | http://confluence.jetbrains.net/display/YTD2/GET+user | [
"http",
":",
"//",
"confluence",
".",
"jetbrains",
".",
"net",
"/",
"display",
"/",
"YTD2",
"/",
"GET",
"+",
"user"
] | train | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L312-L315 |
devopshq/youtrack | youtrack/connection.py | Connection.import_users | def import_users(self, users):
""" Import users, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Users)
Example: importUsers([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'},
{'login':'maxim', 'fullName'... | python | def import_users(self, users):
""" Import users, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Users)
Example: importUsers([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'},
{'login':'maxim', 'fullName'... | [
"def",
"import_users",
"(",
"self",
",",
"users",
")",
":",
"if",
"len",
"(",
"users",
")",
"<=",
"0",
":",
"return",
"known_attrs",
"=",
"(",
"'login'",
",",
"'fullName'",
",",
"'email'",
",",
"'jabber'",
")",
"xml",
"=",
"'<list>\\n'",
"for",
"u",
... | Import users, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Users)
Example: importUsers([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'},
{'login':'maxim', 'fullName':'maxim', 'email':'aaa@ss.com', 'jabber':'w... | [
"Import",
"users",
"returns",
"import",
"result",
"(",
"http",
":",
"//",
"confluence",
".",
"jetbrains",
".",
"net",
"/",
"display",
"/",
"YTD2",
"/",
"Import",
"+",
"Users",
")",
"Example",
":",
"importUsers",
"(",
"[",
"{",
"login",
":",
"vadim",
"f... | train | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L332-L349 |
devopshq/youtrack | youtrack/connection.py | Connection.import_links | def import_links(self, links):
""" Import links, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Links)
Accepts result of getLinks()
Example: importLinks([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'},
... | python | def import_links(self, links):
""" Import links, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Links)
Accepts result of getLinks()
Example: importLinks([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'},
... | [
"def",
"import_links",
"(",
"self",
",",
"links",
")",
":",
"xml",
"=",
"'<list>\\n'",
"for",
"l",
"in",
"links",
":",
"# ignore typeOutward and typeInward returned by getLinks()",
"xml",
"+=",
"' <link '",
"+",
"\"\"",
".",
"join",
"(",
"attr",
"+",
"'='",
"... | Import links, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Links)
Accepts result of getLinks()
Example: importLinks([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'},
{'login':'maxim', 'fullName':'... | [
"Import",
"links",
"returns",
"import",
"result",
"(",
"http",
":",
"//",
"confluence",
".",
"jetbrains",
".",
"net",
"/",
"display",
"/",
"YTD2",
"/",
"Import",
"+",
"Links",
")",
"Accepts",
"result",
"of",
"getLinks",
"()",
"Example",
":",
"importLinks",... | train | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L356-L370 |
devopshq/youtrack | youtrack/connection.py | Connection.import_issues | def import_issues(self, project_id, assignee_group, issues):
""" Import issues, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Issues)
Accepts return of getIssues()
Example: importIssues([{'numberInProject':'1', 'summary':'some problem', 'description':'some de... | python | def import_issues(self, project_id, assignee_group, issues):
""" Import issues, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Issues)
Accepts return of getIssues()
Example: importIssues([{'numberInProject':'1', 'summary':'some problem', 'description':'some de... | [
"def",
"import_issues",
"(",
"self",
",",
"project_id",
",",
"assignee_group",
",",
"issues",
")",
":",
"if",
"len",
"(",
"issues",
")",
"<=",
"0",
":",
"return",
"bad_fields",
"=",
"[",
"'id'",
",",
"'projectShortName'",
",",
"'votes'",
",",
"'commentsCou... | Import issues, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Issues)
Accepts return of getIssues()
Example: importIssues([{'numberInProject':'1', 'summary':'some problem', 'description':'some description',
'priority':'1',
... | [
"Import",
"issues",
"returns",
"import",
"result",
"(",
"http",
":",
"//",
"confluence",
".",
"jetbrains",
".",
"net",
"/",
"display",
"/",
"YTD2",
"/",
"Import",
"+",
"Issues",
")",
"Accepts",
"return",
"of",
"getIssues",
"()",
"Example",
":",
"importIssu... | train | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L372-L490 |
devopshq/youtrack | youtrack/connection.py | Connection.get_project | def get_project(self, project_id):
""" http://confluence.jetbrains.net/display/YTD2/GET+project
"""
return youtrack.Project(self._get("/admin/project/" + urlquote(project_id)), self) | python | def get_project(self, project_id):
""" http://confluence.jetbrains.net/display/YTD2/GET+project
"""
return youtrack.Project(self._get("/admin/project/" + urlquote(project_id)), self) | [
"def",
"get_project",
"(",
"self",
",",
"project_id",
")",
":",
"return",
"youtrack",
".",
"Project",
"(",
"self",
".",
"_get",
"(",
"\"/admin/project/\"",
"+",
"urlquote",
"(",
"project_id",
")",
")",
",",
"self",
")"
] | http://confluence.jetbrains.net/display/YTD2/GET+project | [
"http",
":",
"//",
"confluence",
".",
"jetbrains",
".",
"net",
"/",
"display",
"/",
"YTD2",
"/",
"GET",
"+",
"project"
] | train | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L498-L501 |
devopshq/youtrack | youtrack/connection.py | Connection.create_subsystems | def create_subsystems(self, project_id, subsystems):
""" Accepts result of getSubsystems()
"""
for s in subsystems:
self.create_subsystem(project_id, s) | python | def create_subsystems(self, project_id, subsystems):
""" Accepts result of getSubsystems()
"""
for s in subsystems:
self.create_subsystem(project_id, s) | [
"def",
"create_subsystems",
"(",
"self",
",",
"project_id",
",",
"subsystems",
")",
":",
"for",
"s",
"in",
"subsystems",
":",
"self",
".",
"create_subsystem",
"(",
"project_id",
",",
"s",
")"
] | Accepts result of getSubsystems() | [
"Accepts",
"result",
"of",
"getSubsystems",
"()"
] | train | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L676-L681 |
devopshq/youtrack | youtrack/connection.py | Connection.create_versions | def create_versions(self, project_id, versions):
""" Accepts result of getVersions()
"""
for v in versions:
self.create_version(project_id, v) | python | def create_versions(self, project_id, versions):
""" Accepts result of getVersions()
"""
for v in versions:
self.create_version(project_id, v) | [
"def",
"create_versions",
"(",
"self",
",",
"project_id",
",",
"versions",
")",
":",
"for",
"v",
"in",
"versions",
":",
"self",
".",
"create_version",
"(",
"project_id",
",",
"v",
")"
] | Accepts result of getVersions() | [
"Accepts",
"result",
"of",
"getVersions",
"()"
] | train | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L702-L707 |
jupyterhub/chartpress | chartpress.py | run_cmd | def run_cmd(call, cmd, *, echo=True, **kwargs):
"""Run a command and echo it first"""
if echo:
print('$> ' + ' '.join(map(pipes.quote, cmd)))
return call(cmd, **kwargs) | python | def run_cmd(call, cmd, *, echo=True, **kwargs):
"""Run a command and echo it first"""
if echo:
print('$> ' + ' '.join(map(pipes.quote, cmd)))
return call(cmd, **kwargs) | [
"def",
"run_cmd",
"(",
"call",
",",
"cmd",
",",
"*",
",",
"echo",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"echo",
":",
"print",
"(",
"'$> '",
"+",
"' '",
".",
"join",
"(",
"map",
"(",
"pipes",
".",
"quote",
",",
"cmd",
")",
")",... | Run a command and echo it first | [
"Run",
"a",
"command",
"and",
"echo",
"it",
"first"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L34-L38 |
jupyterhub/chartpress | chartpress.py | git_remote | def git_remote(git_repo):
"""Return the URL for remote git repository.
Depending on the system setup it returns ssh or https remote.
"""
github_token = os.getenv(GITHUB_TOKEN_KEY)
if github_token:
return 'https://{0}@github.com/{1}'.format(
github_token, git_repo)
return 'gi... | python | def git_remote(git_repo):
"""Return the URL for remote git repository.
Depending on the system setup it returns ssh or https remote.
"""
github_token = os.getenv(GITHUB_TOKEN_KEY)
if github_token:
return 'https://{0}@github.com/{1}'.format(
github_token, git_repo)
return 'gi... | [
"def",
"git_remote",
"(",
"git_repo",
")",
":",
"github_token",
"=",
"os",
".",
"getenv",
"(",
"GITHUB_TOKEN_KEY",
")",
"if",
"github_token",
":",
"return",
"'https://{0}@github.com/{1}'",
".",
"format",
"(",
"github_token",
",",
"git_repo",
")",
"return",
"'git... | Return the URL for remote git repository.
Depending on the system setup it returns ssh or https remote. | [
"Return",
"the",
"URL",
"for",
"remote",
"git",
"repository",
"."
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L45-L54 |
jupyterhub/chartpress | chartpress.py | render_build_args | def render_build_args(options, ns):
"""Get docker build args dict, rendering any templated args.
Args:
options (dict):
The dictionary for a given image from chartpress.yaml.
Fields in `options['buildArgs']` will be rendered and returned,
if defined.
ns (dict): the namespace used... | python | def render_build_args(options, ns):
"""Get docker build args dict, rendering any templated args.
Args:
options (dict):
The dictionary for a given image from chartpress.yaml.
Fields in `options['buildArgs']` will be rendered and returned,
if defined.
ns (dict): the namespace used... | [
"def",
"render_build_args",
"(",
"options",
",",
"ns",
")",
":",
"build_args",
"=",
"options",
".",
"get",
"(",
"'buildArgs'",
",",
"{",
"}",
")",
"for",
"key",
",",
"value",
"in",
"build_args",
".",
"items",
"(",
")",
":",
"build_args",
"[",
"key",
... | Get docker build args dict, rendering any templated args.
Args:
options (dict):
The dictionary for a given image from chartpress.yaml.
Fields in `options['buildArgs']` will be rendered and returned,
if defined.
ns (dict): the namespace used when rendering templated arguments | [
"Get",
"docker",
"build",
"args",
"dict",
"rendering",
"any",
"templated",
"args",
"."
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L98-L111 |
jupyterhub/chartpress | chartpress.py | build_image | def build_image(image_path, image_name, build_args=None, dockerfile_path=None):
"""Build an image
Args:
image_path (str): the path to the image directory
image_name (str): image 'name:tag' to build
build_args (dict, optional): dict of docker build arguments
dockerfile_path (str, optional):
... | python | def build_image(image_path, image_name, build_args=None, dockerfile_path=None):
"""Build an image
Args:
image_path (str): the path to the image directory
image_name (str): image 'name:tag' to build
build_args (dict, optional): dict of docker build arguments
dockerfile_path (str, optional):
... | [
"def",
"build_image",
"(",
"image_path",
",",
"image_name",
",",
"build_args",
"=",
"None",
",",
"dockerfile_path",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'docker'",
",",
"'build'",
",",
"'-t'",
",",
"image_name",
",",
"image_path",
"]",
"if",
"dockerfil... | Build an image
Args:
image_path (str): the path to the image directory
image_name (str): image 'name:tag' to build
build_args (dict, optional): dict of docker build arguments
dockerfile_path (str, optional):
path to dockerfile relative to image_path
if not `image_path/Dockerfile`. | [
"Build",
"an",
"image"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L114-L131 |
jupyterhub/chartpress | chartpress.py | image_needs_pushing | def image_needs_pushing(image):
"""Return whether an image needs pushing
Args:
image (str): the `repository:tag` image to be build.
Returns:
True: if image needs to be pushed (not on registry)
False: if not (already present on registry)
"""
d = docker_client()
try:
d.imag... | python | def image_needs_pushing(image):
"""Return whether an image needs pushing
Args:
image (str): the `repository:tag` image to be build.
Returns:
True: if image needs to be pushed (not on registry)
False: if not (already present on registry)
"""
d = docker_client()
try:
d.imag... | [
"def",
"image_needs_pushing",
"(",
"image",
")",
":",
"d",
"=",
"docker_client",
"(",
")",
"try",
":",
"d",
".",
"images",
".",
"get_registry_data",
"(",
"image",
")",
"except",
"docker",
".",
"errors",
".",
"APIError",
":",
"# image not found on registry, nee... | Return whether an image needs pushing
Args:
image (str): the `repository:tag` image to be build.
Returns:
True: if image needs to be pushed (not on registry)
False: if not (already present on registry) | [
"Return",
"whether",
"an",
"image",
"needs",
"pushing"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L140-L159 |
jupyterhub/chartpress | chartpress.py | image_needs_building | def image_needs_building(image):
"""Return whether an image needs building
Checks if the image exists (ignores commit range),
either locally or on the registry.
Args:
image (str): the `repository:tag` image to be build.
Returns:
True: if image needs to be built
False: if not (image ... | python | def image_needs_building(image):
"""Return whether an image needs building
Checks if the image exists (ignores commit range),
either locally or on the registry.
Args:
image (str): the `repository:tag` image to be build.
Returns:
True: if image needs to be built
False: if not (image ... | [
"def",
"image_needs_building",
"(",
"image",
")",
":",
"d",
"=",
"docker_client",
"(",
")",
"# first, check for locally built image",
"try",
":",
"d",
".",
"images",
".",
"get",
"(",
"image",
")",
"except",
"docker",
".",
"errors",
".",
"ImageNotFound",
":",
... | Return whether an image needs building
Checks if the image exists (ignores commit range),
either locally or on the registry.
Args:
image (str): the `repository:tag` image to be build.
Returns:
True: if image needs to be built
False: if not (image already exists) | [
"Return",
"whether",
"an",
"image",
"needs",
"building"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L163-L191 |
jupyterhub/chartpress | chartpress.py | build_images | def build_images(prefix, images, tag=None, commit_range=None, push=False, chart_version=None):
"""Build a collection of docker images
Args:
prefix (str): the prefix to add to images
images (dict): dict of image-specs from chartpress.yml
tag (str):
Specific tag to use instead of the last mod... | python | def build_images(prefix, images, tag=None, commit_range=None, push=False, chart_version=None):
"""Build a collection of docker images
Args:
prefix (str): the prefix to add to images
images (dict): dict of image-specs from chartpress.yml
tag (str):
Specific tag to use instead of the last mod... | [
"def",
"build_images",
"(",
"prefix",
",",
"images",
",",
"tag",
"=",
"None",
",",
"commit_range",
"=",
"None",
",",
"push",
"=",
"False",
",",
"chart_version",
"=",
"None",
")",
":",
"value_modifications",
"=",
"{",
"}",
"for",
"name",
",",
"options",
... | Build a collection of docker images
Args:
prefix (str): the prefix to add to images
images (dict): dict of image-specs from chartpress.yml
tag (str):
Specific tag to use instead of the last modified commit.
If unspecified the tag for each image will be the hash of the last commit
... | [
"Build",
"a",
"collection",
"of",
"docker",
"images"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L194-L253 |
jupyterhub/chartpress | chartpress.py | build_values | def build_values(name, values_mods):
"""Update name/values.yaml with modifications"""
values_file = os.path.join(name, 'values.yaml')
with open(values_file) as f:
values = yaml.load(f)
for key, value in values_mods.items():
parts = key.split('.')
mod_obj = values
for p ... | python | def build_values(name, values_mods):
"""Update name/values.yaml with modifications"""
values_file = os.path.join(name, 'values.yaml')
with open(values_file) as f:
values = yaml.load(f)
for key, value in values_mods.items():
parts = key.split('.')
mod_obj = values
for p ... | [
"def",
"build_values",
"(",
"name",
",",
"values_mods",
")",
":",
"values_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"name",
",",
"'values.yaml'",
")",
"with",
"open",
"(",
"values_file",
")",
"as",
"f",
":",
"values",
"=",
"yaml",
".",
"load",
... | Update name/values.yaml with modifications | [
"Update",
"name",
"/",
"values",
".",
"yaml",
"with",
"modifications"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L256-L289 |
jupyterhub/chartpress | chartpress.py | build_chart | def build_chart(name, version=None, paths=None):
"""Update chart with specified version or last-modified commit in path(s)"""
chart_file = os.path.join(name, 'Chart.yaml')
with open(chart_file) as f:
chart = yaml.load(f)
if version is None:
if paths is None:
paths = ['.']
... | python | def build_chart(name, version=None, paths=None):
"""Update chart with specified version or last-modified commit in path(s)"""
chart_file = os.path.join(name, 'Chart.yaml')
with open(chart_file) as f:
chart = yaml.load(f)
if version is None:
if paths is None:
paths = ['.']
... | [
"def",
"build_chart",
"(",
"name",
",",
"version",
"=",
"None",
",",
"paths",
"=",
"None",
")",
":",
"chart_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"name",
",",
"'Chart.yaml'",
")",
"with",
"open",
"(",
"chart_file",
")",
"as",
"f",
":",
"... | Update chart with specified version or last-modified commit in path(s) | [
"Update",
"chart",
"with",
"specified",
"version",
"or",
"last",
"-",
"modified",
"commit",
"in",
"path",
"(",
"s",
")"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L292-L309 |
jupyterhub/chartpress | chartpress.py | publish_pages | def publish_pages(name, paths, git_repo, published_repo, extra_message=''):
"""Publish helm chart index to github pages"""
version = last_modified_commit(*paths)
checkout_dir = '{}-{}'.format(name, version)
check_call([
'git', 'clone', '--no-checkout',
git_remote(git_repo), checkout_dir]... | python | def publish_pages(name, paths, git_repo, published_repo, extra_message=''):
"""Publish helm chart index to github pages"""
version = last_modified_commit(*paths)
checkout_dir = '{}-{}'.format(name, version)
check_call([
'git', 'clone', '--no-checkout',
git_remote(git_repo), checkout_dir]... | [
"def",
"publish_pages",
"(",
"name",
",",
"paths",
",",
"git_repo",
",",
"published_repo",
",",
"extra_message",
"=",
"''",
")",
":",
"version",
"=",
"last_modified_commit",
"(",
"*",
"paths",
")",
"checkout_dir",
"=",
"'{}-{}'",
".",
"format",
"(",
"name",
... | Publish helm chart index to github pages | [
"Publish",
"helm",
"chart",
"index",
"to",
"github",
"pages"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L312-L358 |
jupyterhub/chartpress | chartpress.py | main | def main():
"""Run chartpress"""
argparser = argparse.ArgumentParser(description=__doc__)
argparser.add_argument('--commit-range',
help='Range of commits to consider when building images')
argparser.add_argument('--push', action='store_true',
help='push built images to docker hub')
... | python | def main():
"""Run chartpress"""
argparser = argparse.ArgumentParser(description=__doc__)
argparser.add_argument('--commit-range',
help='Range of commits to consider when building images')
argparser.add_argument('--push', action='store_true',
help='push built images to docker hub')
... | [
"def",
"main",
"(",
")",
":",
"argparser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
")",
"argparser",
".",
"add_argument",
"(",
"'--commit-range'",
",",
"help",
"=",
"'Range of commits to consider when building images'",
")",
"argp... | Run chartpress | [
"Run",
"chartpress"
] | train | https://github.com/jupyterhub/chartpress/blob/541f132f31c9f3a66750d7847fb28c7ce5a0ca6d/chartpress.py#L361-L412 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.