id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2,300 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP.ehlo | async def ehlo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP EHLO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | python | async def ehlo(
self, hostname: str = None, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Send the SMTP EHLO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code
... | [
"async",
"def",
"ehlo",
"(",
"self",
",",
"hostname",
":",
"str",
"=",
"None",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"if",
"hostname",
"is",
"None",
":",
"hostname",
"=",
"self",
".",
"source_address",
"a... | Send the SMTP EHLO command.
Hostname to send for this command defaults to the FQDN of the local
host.
:raises SMTPHeloError: on unexpected server response code | [
"Send",
"the",
"SMTP",
"EHLO",
"command",
".",
"Hostname",
"to",
"send",
"for",
"this",
"command",
"defaults",
"to",
"the",
"FQDN",
"of",
"the",
"local",
"host",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L337-L359 |
2,301 | cole/aiosmtplib | src/aiosmtplib/esmtp.py | ESMTP._reset_server_state | def _reset_server_state(self) -> None:
"""
Clear stored information about the server.
"""
self.last_helo_response = None
self._last_ehlo_response = None
self.esmtp_extensions = {}
self.supports_esmtp = False
self.server_auth_methods = [] | python | def _reset_server_state(self) -> None:
"""
Clear stored information about the server.
"""
self.last_helo_response = None
self._last_ehlo_response = None
self.esmtp_extensions = {}
self.supports_esmtp = False
self.server_auth_methods = [] | [
"def",
"_reset_server_state",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"last_helo_response",
"=",
"None",
"self",
".",
"_last_ehlo_response",
"=",
"None",
"self",
".",
"esmtp_extensions",
"=",
"{",
"}",
"self",
".",
"supports_esmtp",
"=",
"False",
"... | Clear stored information about the server. | [
"Clear",
"stored",
"information",
"about",
"the",
"server",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/esmtp.py#L384-L392 |
2,302 | cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.supported_auth_methods | def supported_auth_methods(self) -> List[str]:
"""
Get all AUTH methods supported by the both server and by us.
"""
return [auth for auth in self.AUTH_METHODS if auth in self.server_auth_methods] | python | def supported_auth_methods(self) -> List[str]:
"""
Get all AUTH methods supported by the both server and by us.
"""
return [auth for auth in self.AUTH_METHODS if auth in self.server_auth_methods] | [
"def",
"supported_auth_methods",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"auth",
"for",
"auth",
"in",
"self",
".",
"AUTH_METHODS",
"if",
"auth",
"in",
"self",
".",
"server_auth_methods",
"]"
] | Get all AUTH methods supported by the both server and by us. | [
"Get",
"all",
"AUTH",
"methods",
"supported",
"by",
"the",
"both",
"server",
"and",
"by",
"us",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L40-L44 |
2,303 | cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.login | async def login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Tries to login with supported auth methods.
Some servers advertise authentication methods they don't really
support, so if authentication fails, we continue until w... | python | async def login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Tries to login with supported auth methods.
Some servers advertise authentication methods they don't really
support, so if authentication fails, we continue until w... | [
"async",
"def",
"login",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"await",
"self",
".",
"_ehlo_or_helo_if_needed",
"(",
")",
"if",
"not",
... | Tries to login with supported auth methods.
Some servers advertise authentication methods they don't really
support, so if authentication fails, we continue until we've tried
all methods. | [
"Tries",
"to",
"login",
"with",
"supported",
"auth",
"methods",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L46-L82 |
2,304 | cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.auth_crammd5 | async def auth_crammd5(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
response.
Example::
250 AUTH CRAM-MD5
auth cram-md5
... | python | async def auth_crammd5(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
response.
Example::
250 AUTH CRAM-MD5
auth cram-md5
... | [
"async",
"def",
"auth_crammd5",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"async",
"with",
"self",
".",
"_command_lock",
":",
"initial_respon... | CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
response.
Example::
250 AUTH CRAM-MD5
auth cram-md5
334 PDI0NjA5LjEwNDc5MTQwNDZAcG9wbWFpbC5TcGFjZS5OZXQ+
dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw | [
"CRAM",
"-",
"MD5",
"auth",
"uses",
"the",
"password",
"as",
"a",
"shared",
"secret",
"to",
"MD5",
"the",
"server",
"s",
"response",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L84-L122 |
2,305 | cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.auth_plain | async def auth_plain(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
PLAIN auth encodes the username and password in one Base64 encoded
string. No verification message is required.
Example::
220-esmtp.example.com
... | python | async def auth_plain(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
PLAIN auth encodes the username and password in one Base64 encoded
string. No verification message is required.
Example::
220-esmtp.example.com
... | [
"async",
"def",
"auth_plain",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"username_bytes",
"=",
"username",
".",
"encode",
"(",
"\"ascii\"",
... | PLAIN auth encodes the username and password in one Base64 encoded
string. No verification message is required.
Example::
220-esmtp.example.com
AUTH PLAIN dGVzdAB0ZXN0AHRlc3RwYXNz
235 ok, go ahead (#2.0.0) | [
"PLAIN",
"auth",
"encodes",
"the",
"username",
"and",
"password",
"in",
"one",
"Base64",
"encoded",
"string",
".",
"No",
"verification",
"message",
"is",
"required",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L124-L151 |
2,306 | cole/aiosmtplib | src/aiosmtplib/auth.py | SMTPAuth.auth_login | async def auth_login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
LOGIN auth sends the Base64 encoded username and password in sequence.
Example::
250 AUTH LOGIN PLAIN CRAM-MD5
auth login avlsdkfj
... | python | async def auth_login(
self, username: str, password: str, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
LOGIN auth sends the Base64 encoded username and password in sequence.
Example::
250 AUTH LOGIN PLAIN CRAM-MD5
auth login avlsdkfj
... | [
"async",
"def",
"auth_login",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"encoded_username",
"=",
"base64",
".",
"b64encode",
"(",
"username",... | LOGIN auth sends the Base64 encoded username and password in sequence.
Example::
250 AUTH LOGIN PLAIN CRAM-MD5
auth login avlsdkfj
334 UGFzc3dvcmQ6
avlsdkfj
Note that there is an alternate version sends the username
as a separate command::
... | [
"LOGIN",
"auth",
"sends",
"the",
"Base64",
"encoded",
"username",
"and",
"password",
"in",
"sequence",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/auth.py#L153-L197 |
2,307 | cole/aiosmtplib | src/aiosmtplib/email.py | parse_address | def parse_address(address: str) -> str:
"""
Parse an email address, falling back to the raw string given.
"""
display_name, parsed_address = email.utils.parseaddr(address)
return parsed_address or address | python | def parse_address(address: str) -> str:
"""
Parse an email address, falling back to the raw string given.
"""
display_name, parsed_address = email.utils.parseaddr(address)
return parsed_address or address | [
"def",
"parse_address",
"(",
"address",
":",
"str",
")",
"->",
"str",
":",
"display_name",
",",
"parsed_address",
"=",
"email",
".",
"utils",
".",
"parseaddr",
"(",
"address",
")",
"return",
"parsed_address",
"or",
"address"
] | Parse an email address, falling back to the raw string given. | [
"Parse",
"an",
"email",
"address",
"falling",
"back",
"to",
"the",
"raw",
"string",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L16-L22 |
2,308 | cole/aiosmtplib | src/aiosmtplib/email.py | quote_address | def quote_address(address: str) -> str:
"""
Quote a subset of the email addresses defined by RFC 821.
Should be able to handle anything email.utils.parseaddr can handle.
"""
display_name, parsed_address = email.utils.parseaddr(address)
if parsed_address:
quoted_address = "<{}>".format(p... | python | def quote_address(address: str) -> str:
"""
Quote a subset of the email addresses defined by RFC 821.
Should be able to handle anything email.utils.parseaddr can handle.
"""
display_name, parsed_address = email.utils.parseaddr(address)
if parsed_address:
quoted_address = "<{}>".format(p... | [
"def",
"quote_address",
"(",
"address",
":",
"str",
")",
"->",
"str",
":",
"display_name",
",",
"parsed_address",
"=",
"email",
".",
"utils",
".",
"parseaddr",
"(",
"address",
")",
"if",
"parsed_address",
":",
"quoted_address",
"=",
"\"<{}>\"",
".",
"format"... | Quote a subset of the email addresses defined by RFC 821.
Should be able to handle anything email.utils.parseaddr can handle. | [
"Quote",
"a",
"subset",
"of",
"the",
"email",
"addresses",
"defined",
"by",
"RFC",
"821",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L25-L38 |
2,309 | cole/aiosmtplib | src/aiosmtplib/email.py | _extract_sender | def _extract_sender(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> str:
"""
Extract the sender from the message object given.
"""
if resent_dates:
sender_header = "Resent-Sender"
from_header = "Resent-From"
else:
sender_header = "Sender"
fro... | python | def _extract_sender(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> str:
"""
Extract the sender from the message object given.
"""
if resent_dates:
sender_header = "Resent-Sender"
from_header = "Resent-From"
else:
sender_header = "Sender"
fro... | [
"def",
"_extract_sender",
"(",
"message",
":",
"Message",
",",
"resent_dates",
":",
"List",
"[",
"Union",
"[",
"str",
",",
"Header",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"resent_dates",
":",
"sender_header",
"=",
"\"Resent-Sender\"",
"from_h... | Extract the sender from the message object given. | [
"Extract",
"the",
"sender",
"from",
"the",
"message",
"object",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L62-L81 |
2,310 | cole/aiosmtplib | src/aiosmtplib/email.py | _extract_recipients | def _extract_recipients(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> List[str]:
"""
Extract the recipients from the message object given.
"""
recipients = [] # type: List[str]
if resent_dates:
recipient_headers = ("Resent-To", "Resent-Cc", "Resent-Bcc")
els... | python | def _extract_recipients(
message: Message, resent_dates: List[Union[str, Header]] = None
) -> List[str]:
"""
Extract the recipients from the message object given.
"""
recipients = [] # type: List[str]
if resent_dates:
recipient_headers = ("Resent-To", "Resent-Cc", "Resent-Bcc")
els... | [
"def",
"_extract_recipients",
"(",
"message",
":",
"Message",
",",
"resent_dates",
":",
"List",
"[",
"Union",
"[",
"str",
",",
"Header",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"str",
"]",
":",
"recipients",
"=",
"[",
"]",
"# type: List[str]",
"... | Extract the recipients from the message object given. | [
"Extract",
"the",
"recipients",
"from",
"the",
"message",
"object",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L84-L105 |
2,311 | cole/aiosmtplib | src/aiosmtplib/connection.py | SMTPConnection.execute_command | async def execute_command(
self, *args: bytes, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Check that we're connected, if we got a timeout value, and then
pass the command to the protocol.
:raises SMTPServerDisconnected: connection lost
"""
if t... | python | async def execute_command(
self, *args: bytes, timeout: DefaultNumType = _default
) -> SMTPResponse:
"""
Check that we're connected, if we got a timeout value, and then
pass the command to the protocol.
:raises SMTPServerDisconnected: connection lost
"""
if t... | [
"async",
"def",
"execute_command",
"(",
"self",
",",
"*",
"args",
":",
"bytes",
",",
"timeout",
":",
"DefaultNumType",
"=",
"_default",
")",
"->",
"SMTPResponse",
":",
"if",
"timeout",
"is",
"_default",
":",
"timeout",
"=",
"self",
".",
"timeout",
"# type:... | Check that we're connected, if we got a timeout value, and then
pass the command to the protocol.
:raises SMTPServerDisconnected: connection lost | [
"Check",
"that",
"we",
"re",
"connected",
"if",
"we",
"got",
"a",
"timeout",
"value",
"and",
"then",
"pass",
"the",
"command",
"to",
"the",
"protocol",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L274-L301 |
2,312 | cole/aiosmtplib | src/aiosmtplib/connection.py | SMTPConnection._get_tls_context | def _get_tls_context(self) -> ssl.SSLContext:
"""
Build an SSLContext object from the options we've been given.
"""
if self.tls_context is not None:
context = self.tls_context
else:
# SERVER_AUTH is what we want for a client side socket
context... | python | def _get_tls_context(self) -> ssl.SSLContext:
"""
Build an SSLContext object from the options we've been given.
"""
if self.tls_context is not None:
context = self.tls_context
else:
# SERVER_AUTH is what we want for a client side socket
context... | [
"def",
"_get_tls_context",
"(",
"self",
")",
"->",
"ssl",
".",
"SSLContext",
":",
"if",
"self",
".",
"tls_context",
"is",
"not",
"None",
":",
"context",
"=",
"self",
".",
"tls_context",
"else",
":",
"# SERVER_AUTH is what we want for a client side socket",
"contex... | Build an SSLContext object from the options we've been given. | [
"Build",
"an",
"SSLContext",
"object",
"from",
"the",
"options",
"we",
"ve",
"been",
"given",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L306-L327 |
2,313 | cole/aiosmtplib | src/aiosmtplib/connection.py | SMTPConnection._raise_error_if_disconnected | def _raise_error_if_disconnected(self) -> None:
"""
See if we're still connected, and if not, raise
``SMTPServerDisconnected``.
"""
if (
self.transport is None
or self.protocol is None
or self.transport.is_closing()
):
self.... | python | def _raise_error_if_disconnected(self) -> None:
"""
See if we're still connected, and if not, raise
``SMTPServerDisconnected``.
"""
if (
self.transport is None
or self.protocol is None
or self.transport.is_closing()
):
self.... | [
"def",
"_raise_error_if_disconnected",
"(",
"self",
")",
"->",
"None",
":",
"if",
"(",
"self",
".",
"transport",
"is",
"None",
"or",
"self",
".",
"protocol",
"is",
"None",
"or",
"self",
".",
"transport",
".",
"is_closing",
"(",
")",
")",
":",
"self",
"... | See if we're still connected, and if not, raise
``SMTPServerDisconnected``. | [
"See",
"if",
"we",
"re",
"still",
"connected",
"and",
"if",
"not",
"raise",
"SMTPServerDisconnected",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/connection.py#L329-L340 |
2,314 | cole/aiosmtplib | src/aiosmtplib/smtp.py | SMTP.sendmail | async def sendmail(
self,
sender: str,
recipients: RecipientsType,
message: Union[str, bytes],
mail_options: Iterable[str] = None,
rcpt_options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SendmailResponseType:
"""
This comma... | python | async def sendmail(
self,
sender: str,
recipients: RecipientsType,
message: Union[str, bytes],
mail_options: Iterable[str] = None,
rcpt_options: Iterable[str] = None,
timeout: DefaultNumType = _default,
) -> SendmailResponseType:
"""
This comma... | [
"async",
"def",
"sendmail",
"(",
"self",
",",
"sender",
":",
"str",
",",
"recipients",
":",
"RecipientsType",
",",
"message",
":",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"mail_options",
":",
"Iterable",
"[",
"str",
"]",
"=",
"None",
",",
"rcpt_op... | This command performs an entire mail transaction.
The arguments are:
- sender: The address sending this mail.
- recipients: A list of addresses to send this mail to. A bare
string will be treated as a list with 1 address.
- message: The message string to sen... | [
"This",
"command",
"performs",
"an",
"entire",
"mail",
"transaction",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L57-L166 |
2,315 | cole/aiosmtplib | src/aiosmtplib/smtp.py | SMTP._run_sync | def _run_sync(self, method: Callable, *args, **kwargs) -> Any:
"""
Utility method to run commands synchronously for testing.
"""
if self.loop.is_running():
raise RuntimeError("Event loop is already running.")
if not self.is_connected:
self.loop.run_until_... | python | def _run_sync(self, method: Callable, *args, **kwargs) -> Any:
"""
Utility method to run commands synchronously for testing.
"""
if self.loop.is_running():
raise RuntimeError("Event loop is already running.")
if not self.is_connected:
self.loop.run_until_... | [
"def",
"_run_sync",
"(",
"self",
",",
"method",
":",
"Callable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"Any",
":",
"if",
"self",
".",
"loop",
".",
"is_running",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Event loop is already running... | Utility method to run commands synchronously for testing. | [
"Utility",
"method",
"to",
"run",
"commands",
"synchronously",
"for",
"testing",
"."
] | 0cd00e5059005371cbdfca995feff9183a16a51f | https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/smtp.py#L237-L252 |
2,316 | cs50/submit50 | submit50/__main__.py | check_announcements | def check_announcements():
"""Check for any announcements from cs50.me, raise Error if so."""
res = requests.get("https://cs50.me/status/submit50") # TODO change this to submit50.io!
if res.status_code == 200 and res.text.strip():
raise Error(res.text.strip()) | python | def check_announcements():
"""Check for any announcements from cs50.me, raise Error if so."""
res = requests.get("https://cs50.me/status/submit50") # TODO change this to submit50.io!
if res.status_code == 200 and res.text.strip():
raise Error(res.text.strip()) | [
"def",
"check_announcements",
"(",
")",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"\"https://cs50.me/status/submit50\"",
")",
"# TODO change this to submit50.io!",
"if",
"res",
".",
"status_code",
"==",
"200",
"and",
"res",
".",
"text",
".",
"strip",
"(",
")... | Check for any announcements from cs50.me, raise Error if so. | [
"Check",
"for",
"any",
"announcements",
"from",
"cs50",
".",
"me",
"raise",
"Error",
"if",
"so",
"."
] | 5f4c8b3675e8e261c8422f76eacd6a6330c23831 | https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L28-L32 |
2,317 | cs50/submit50 | submit50/__main__.py | check_version | def check_version():
"""Check that submit50 is the latest version according to submit50.io."""
# Retrieve version info
res = requests.get("https://cs50.me/versions/submit50") # TODO change this to submit50.io!
if res.status_code != 200:
raise Error(_("You have an unknown version of submit50. "
... | python | def check_version():
"""Check that submit50 is the latest version according to submit50.io."""
# Retrieve version info
res = requests.get("https://cs50.me/versions/submit50") # TODO change this to submit50.io!
if res.status_code != 200:
raise Error(_("You have an unknown version of submit50. "
... | [
"def",
"check_version",
"(",
")",
":",
"# Retrieve version info",
"res",
"=",
"requests",
".",
"get",
"(",
"\"https://cs50.me/versions/submit50\"",
")",
"# TODO change this to submit50.io!",
"if",
"res",
".",
"status_code",
"!=",
"200",
":",
"raise",
"Error",
"(",
"... | Check that submit50 is the latest version according to submit50.io. | [
"Check",
"that",
"submit50",
"is",
"the",
"latest",
"version",
"according",
"to",
"submit50",
".",
"io",
"."
] | 5f4c8b3675e8e261c8422f76eacd6a6330c23831 | https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L35-L44 |
2,318 | cs50/submit50 | submit50/__main__.py | excepthook | def excepthook(type, value, tb):
"""Report an exception."""
if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value):
for line in str(value).split("\n"):
cprint(str(line), "yellow")
else:
cprint(_("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!... | python | def excepthook(type, value, tb):
"""Report an exception."""
if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value):
for line in str(value).split("\n"):
cprint(str(line), "yellow")
else:
cprint(_("Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!... | [
"def",
"excepthook",
"(",
"type",
",",
"value",
",",
"tb",
")",
":",
"if",
"(",
"issubclass",
"(",
"type",
",",
"Error",
")",
"or",
"issubclass",
"(",
"type",
",",
"lib50",
".",
"Error",
")",
")",
"and",
"str",
"(",
"value",
")",
":",
"for",
"lin... | Report an exception. | [
"Report",
"an",
"exception",
"."
] | 5f4c8b3675e8e261c8422f76eacd6a6330c23831 | https://github.com/cs50/submit50/blob/5f4c8b3675e8e261c8422f76eacd6a6330c23831/submit50/__main__.py#L93-L104 |
2,319 | kedder/ofxstatement | src/ofxstatement/statement.py | generate_transaction_id | def generate_transaction_id(stmt_line):
"""Generate pseudo-unique id for given statement line.
This function can be used in statement parsers when real transaction id is
not available in source statement.
"""
return str(abs(hash((stmt_line.date,
stmt_line.memo,
... | python | def generate_transaction_id(stmt_line):
"""Generate pseudo-unique id for given statement line.
This function can be used in statement parsers when real transaction id is
not available in source statement.
"""
return str(abs(hash((stmt_line.date,
stmt_line.memo,
... | [
"def",
"generate_transaction_id",
"(",
"stmt_line",
")",
":",
"return",
"str",
"(",
"abs",
"(",
"hash",
"(",
"(",
"stmt_line",
".",
"date",
",",
"stmt_line",
".",
"memo",
",",
"stmt_line",
".",
"amount",
")",
")",
")",
")"
] | Generate pseudo-unique id for given statement line.
This function can be used in statement parsers when real transaction id is
not available in source statement. | [
"Generate",
"pseudo",
"-",
"unique",
"id",
"for",
"given",
"statement",
"line",
"."
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L155-L163 |
2,320 | kedder/ofxstatement | src/ofxstatement/statement.py | recalculate_balance | def recalculate_balance(stmt):
"""Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement.
"""
total_amount = ... | python | def recalculate_balance(stmt):
"""Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement.
"""
total_amount = ... | [
"def",
"recalculate_balance",
"(",
"stmt",
")",
":",
"total_amount",
"=",
"sum",
"(",
"sl",
".",
"amount",
"for",
"sl",
"in",
"stmt",
".",
"lines",
")",
"stmt",
".",
"start_balance",
"=",
"stmt",
".",
"start_balance",
"or",
"D",
"(",
"0",
")",
"stmt",
... | Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement. | [
"Recalculate",
"statement",
"starting",
"and",
"ending",
"dates",
"and",
"balances",
"."
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L166-L180 |
2,321 | kedder/ofxstatement | src/ofxstatement/statement.py | StatementLine.assert_valid | def assert_valid(self):
"""Ensure that fields have valid values
"""
assert self.trntype in TRANSACTION_TYPES, \
"trntype must be one of %s" % TRANSACTION_TYPES
if self.bank_account_to:
self.bank_account_to.assert_valid() | python | def assert_valid(self):
"""Ensure that fields have valid values
"""
assert self.trntype in TRANSACTION_TYPES, \
"trntype must be one of %s" % TRANSACTION_TYPES
if self.bank_account_to:
self.bank_account_to.assert_valid() | [
"def",
"assert_valid",
"(",
"self",
")",
":",
"assert",
"self",
".",
"trntype",
"in",
"TRANSACTION_TYPES",
",",
"\"trntype must be one of %s\"",
"%",
"TRANSACTION_TYPES",
"if",
"self",
".",
"bank_account_to",
":",
"self",
".",
"bank_account_to",
".",
"assert_valid",... | Ensure that fields have valid values | [
"Ensure",
"that",
"fields",
"have",
"valid",
"values"
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L113-L120 |
2,322 | kedder/ofxstatement | src/ofxstatement/parser.py | StatementParser.parse | def parse(self):
"""Read and parse statement
Return Statement object
May raise exceptions.ParseException on malformed input.
"""
reader = self.split_records()
for line in reader:
self.cur_record += 1
if not line:
continue
... | python | def parse(self):
"""Read and parse statement
Return Statement object
May raise exceptions.ParseException on malformed input.
"""
reader = self.split_records()
for line in reader:
self.cur_record += 1
if not line:
continue
... | [
"def",
"parse",
"(",
"self",
")",
":",
"reader",
"=",
"self",
".",
"split_records",
"(",
")",
"for",
"line",
"in",
"reader",
":",
"self",
".",
"cur_record",
"+=",
"1",
"if",
"not",
"line",
":",
"continue",
"stmt_line",
"=",
"self",
".",
"parse_record",... | Read and parse statement
Return Statement object
May raise exceptions.ParseException on malformed input. | [
"Read",
"and",
"parse",
"statement"
] | 61f9dc1cfe6024874b859c8aec108b9d9acee57a | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/parser.py#L17-L33 |
2,323 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.acquire_auth_token_ticket | def acquire_auth_token_ticket(self, headers=None):
'''
Acquire an auth token from the CAS server.
'''
logging.debug('[CAS] Acquiring Auth token ticket')
url = self._get_auth_token_tickets_url()
text = self._perform_post(url, headers=headers)
auth_token_ticket = js... | python | def acquire_auth_token_ticket(self, headers=None):
'''
Acquire an auth token from the CAS server.
'''
logging.debug('[CAS] Acquiring Auth token ticket')
url = self._get_auth_token_tickets_url()
text = self._perform_post(url, headers=headers)
auth_token_ticket = js... | [
"def",
"acquire_auth_token_ticket",
"(",
"self",
",",
"headers",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"'[CAS] Acquiring Auth token ticket'",
")",
"url",
"=",
"self",
".",
"_get_auth_token_tickets_url",
"(",
")",
"text",
"=",
"self",
".",
"_perfor... | Acquire an auth token from the CAS server. | [
"Acquire",
"an",
"auth",
"token",
"from",
"the",
"CAS",
"server",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L53-L63 |
2,324 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.create_session | def create_session(self, ticket, payload=None, expires=None):
'''
Create a session record from a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Creating session for ticket {}'.format(ticket))
self.session_storag... | python | def create_session(self, ticket, payload=None, expires=None):
'''
Create a session record from a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Creating session for ticket {}'.format(ticket))
self.session_storag... | [
"def",
"create_session",
"(",
"self",
",",
"ticket",
",",
"payload",
"=",
"None",
",",
"expires",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"session_storage_adapter",
",",
"CASSessionAdapter",
")",
"logging",
".",
"debug",
"(",
"'[CAS]... | Create a session record from a service ticket. | [
"Create",
"a",
"session",
"record",
"from",
"a",
"service",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L65-L75 |
2,325 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.delete_session | def delete_session(self, ticket):
'''
Delete a session record associated with a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Deleting session for ticket {}'.format(ticket))
self.session_storage_adapter.delete(... | python | def delete_session(self, ticket):
'''
Delete a session record associated with a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Deleting session for ticket {}'.format(ticket))
self.session_storage_adapter.delete(... | [
"def",
"delete_session",
"(",
"self",
",",
"ticket",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"session_storage_adapter",
",",
"CASSessionAdapter",
")",
"logging",
".",
"debug",
"(",
"'[CAS] Deleting session for ticket {}'",
".",
"format",
"(",
"ticket",
... | Delete a session record associated with a service ticket. | [
"Delete",
"a",
"session",
"record",
"associated",
"with",
"a",
"service",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L77-L83 |
2,326 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.get_api_url | def get_api_url(
self,
api_resource,
auth_token_ticket,
authenticator,
private_key,
service_url=None,
**kwargs
):
'''
Build an auth-token-protected CAS API url.
'''
auth_token, auth_token_signature = self._build_auth_token_data(... | python | def get_api_url(
self,
api_resource,
auth_token_ticket,
authenticator,
private_key,
service_url=None,
**kwargs
):
'''
Build an auth-token-protected CAS API url.
'''
auth_token, auth_token_signature = self._build_auth_token_data(... | [
"def",
"get_api_url",
"(",
"self",
",",
"api_resource",
",",
"auth_token_ticket",
",",
"authenticator",
",",
"private_key",
",",
"service_url",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"auth_token",
",",
"auth_token_signature",
"=",
"self",
".",
"_build... | Build an auth-token-protected CAS API url. | [
"Build",
"an",
"auth",
"-",
"token",
"-",
"protected",
"CAS",
"API",
"url",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L85-L113 |
2,327 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.get_auth_token_login_url | def get_auth_token_login_url(
self,
auth_token_ticket,
authenticator,
private_key,
service_url,
username,
):
'''
Build an auth token login URL.
See https://github.com/rbCAS/CASino/wiki/Auth-Token-Login for details.
'''
auth_tok... | python | def get_auth_token_login_url(
self,
auth_token_ticket,
authenticator,
private_key,
service_url,
username,
):
'''
Build an auth token login URL.
See https://github.com/rbCAS/CASino/wiki/Auth-Token-Login for details.
'''
auth_tok... | [
"def",
"get_auth_token_login_url",
"(",
"self",
",",
"auth_token_ticket",
",",
"authenticator",
",",
"private_key",
",",
"service_url",
",",
"username",
",",
")",
":",
"auth_token",
",",
"auth_token_signature",
"=",
"self",
".",
"_build_auth_token_data",
"(",
"auth_... | Build an auth token login URL.
See https://github.com/rbCAS/CASino/wiki/Auth-Token-Login for details. | [
"Build",
"an",
"auth",
"token",
"login",
"URL",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L115-L141 |
2,328 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.parse_logout_request | def parse_logout_request(self, message_text):
'''
Parse the contents of a CAS `LogoutRequest` XML message.
::
>>> from cas_client import CASClient
>>> client = CASClient('https://logmein.com')
>>> message_text = """
... <samlp:LogoutRequest
... | python | def parse_logout_request(self, message_text):
'''
Parse the contents of a CAS `LogoutRequest` XML message.
::
>>> from cas_client import CASClient
>>> client = CASClient('https://logmein.com')
>>> message_text = """
... <samlp:LogoutRequest
... | [
"def",
"parse_logout_request",
"(",
"self",
",",
"message_text",
")",
":",
"result",
"=",
"{",
"}",
"xml_document",
"=",
"parseString",
"(",
"message_text",
")",
"for",
"node",
"in",
"xml_document",
".",
"getElementsByTagName",
"(",
"'saml:NameId'",
")",
":",
... | Parse the contents of a CAS `LogoutRequest` XML message.
::
>>> from cas_client import CASClient
>>> client = CASClient('https://logmein.com')
>>> message_text = """
... <samlp:LogoutRequest
... xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
... | [
"Parse",
"the",
"contents",
"of",
"a",
"CAS",
"LogoutRequest",
"XML",
"message",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L209-L254 |
2,329 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_api_request | def perform_api_request(
self,
url,
method='POST',
headers=None,
body=None,
**kwargs
):
'''
Perform an auth-token-protected request against a CAS API endpoint.
'''
assert method in ('GET', 'POST')
if method == 'GET':
... | python | def perform_api_request(
self,
url,
method='POST',
headers=None,
body=None,
**kwargs
):
'''
Perform an auth-token-protected request against a CAS API endpoint.
'''
assert method in ('GET', 'POST')
if method == 'GET':
... | [
"def",
"perform_api_request",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'POST'",
",",
"headers",
"=",
"None",
",",
"body",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"method",
"in",
"(",
"'GET'",
",",
"'POST'",
")",
"if",
"method",... | Perform an auth-token-protected request against a CAS API endpoint. | [
"Perform",
"an",
"auth",
"-",
"token",
"-",
"protected",
"request",
"against",
"a",
"CAS",
"API",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L256-L272 |
2,330 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_proxy | def perform_proxy(self, proxy_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxy` endpoint.
'''
url = self._get_proxy_url(ticket=proxy_ticket)
logging.debug('[CAS] Proxy URL: {}'.format(url))
return self._perform_cas_call(
url,
... | python | def perform_proxy(self, proxy_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxy` endpoint.
'''
url = self._get_proxy_url(ticket=proxy_ticket)
logging.debug('[CAS] Proxy URL: {}'.format(url))
return self._perform_cas_call(
url,
... | [
"def",
"perform_proxy",
"(",
"self",
",",
"proxy_ticket",
",",
"headers",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_get_proxy_url",
"(",
"ticket",
"=",
"proxy_ticket",
")",
"logging",
".",
"debug",
"(",
"'[CAS] Proxy URL: {}'",
".",
"format",
"(",
... | Fetch a response from the remote CAS `proxy` endpoint. | [
"Fetch",
"a",
"response",
"from",
"the",
"remote",
"CAS",
"proxy",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L274-L284 |
2,331 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_proxy_validate | def perform_proxy_validate(self, proxied_service_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxyValidate` endpoint.
'''
url = self._get_proxy_validate_url(ticket=proxied_service_ticket)
logging.debug('[CAS] ProxyValidate URL: {}'.format(url))
return... | python | def perform_proxy_validate(self, proxied_service_ticket, headers=None):
'''
Fetch a response from the remote CAS `proxyValidate` endpoint.
'''
url = self._get_proxy_validate_url(ticket=proxied_service_ticket)
logging.debug('[CAS] ProxyValidate URL: {}'.format(url))
return... | [
"def",
"perform_proxy_validate",
"(",
"self",
",",
"proxied_service_ticket",
",",
"headers",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_get_proxy_validate_url",
"(",
"ticket",
"=",
"proxied_service_ticket",
")",
"logging",
".",
"debug",
"(",
"'[CAS] ProxyVa... | Fetch a response from the remote CAS `proxyValidate` endpoint. | [
"Fetch",
"a",
"response",
"from",
"the",
"remote",
"CAS",
"proxyValidate",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L286-L296 |
2,332 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.perform_service_validate | def perform_service_validate(
self,
ticket=None,
service_url=None,
headers=None,
):
'''
Fetch a response from the remote CAS `serviceValidate` endpoint.
'''
url = self._get_service_validate_url(ticket, service_url=service_url)
logging.debug... | python | def perform_service_validate(
self,
ticket=None,
service_url=None,
headers=None,
):
'''
Fetch a response from the remote CAS `serviceValidate` endpoint.
'''
url = self._get_service_validate_url(ticket, service_url=service_url)
logging.debug... | [
"def",
"perform_service_validate",
"(",
"self",
",",
"ticket",
"=",
"None",
",",
"service_url",
"=",
"None",
",",
"headers",
"=",
"None",
",",
")",
":",
"url",
"=",
"self",
".",
"_get_service_validate_url",
"(",
"ticket",
",",
"service_url",
"=",
"service_ur... | Fetch a response from the remote CAS `serviceValidate` endpoint. | [
"Fetch",
"a",
"response",
"from",
"the",
"remote",
"CAS",
"serviceValidate",
"endpoint",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L298-L309 |
2,333 | discogs/python-cas-client | cas_client/cas_client.py | CASClient.session_exists | def session_exists(self, ticket):
'''
Test if a session records exists for a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
exists = self.session_storage_adapter.exists(ticket)
logging.debug('[CAS] Session [{}] exists: {}'.format(ti... | python | def session_exists(self, ticket):
'''
Test if a session records exists for a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
exists = self.session_storage_adapter.exists(ticket)
logging.debug('[CAS] Session [{}] exists: {}'.format(ti... | [
"def",
"session_exists",
"(",
"self",
",",
"ticket",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"session_storage_adapter",
",",
"CASSessionAdapter",
")",
"exists",
"=",
"self",
".",
"session_storage_adapter",
".",
"exists",
"(",
"ticket",
")",
"logging"... | Test if a session records exists for a service ticket. | [
"Test",
"if",
"a",
"session",
"records",
"exists",
"for",
"a",
"service",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L311-L318 |
2,334 | discogs/python-cas-client | cas_client/cas_client.py | MemcachedCASSessionAdapter.create | def create(self, ticket, payload=None, expires=None):
'''
Create a session identifier in memcache associated with ``ticket``.
'''
if not payload:
payload = True
self._client.set(str(ticket), payload, expires) | python | def create(self, ticket, payload=None, expires=None):
'''
Create a session identifier in memcache associated with ``ticket``.
'''
if not payload:
payload = True
self._client.set(str(ticket), payload, expires) | [
"def",
"create",
"(",
"self",
",",
"ticket",
",",
"payload",
"=",
"None",
",",
"expires",
"=",
"None",
")",
":",
"if",
"not",
"payload",
":",
"payload",
"=",
"True",
"self",
".",
"_client",
".",
"set",
"(",
"str",
"(",
"ticket",
")",
",",
"payload"... | Create a session identifier in memcache associated with ``ticket``. | [
"Create",
"a",
"session",
"identifier",
"in",
"memcache",
"associated",
"with",
"ticket",
"."
] | f1efa2f49a22d43135014cb1b8d9dd3875304318 | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L612-L618 |
2,335 | CZ-NIC/python-rt | rt.py | Rt.__check_response | def __check_response(self, msg):
""" Search general errors in server response and raise exceptions when found.
:keyword msg: Result message
:raises NotAllowed: Exception raised when operation was called with
insufficient privileges
:raises AuthorizationError:... | python | def __check_response(self, msg):
""" Search general errors in server response and raise exceptions when found.
:keyword msg: Result message
:raises NotAllowed: Exception raised when operation was called with
insufficient privileges
:raises AuthorizationError:... | [
"def",
"__check_response",
"(",
"self",
",",
"msg",
")",
":",
"if",
"not",
"isinstance",
"(",
"msg",
",",
"list",
")",
":",
"msg",
"=",
"msg",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"(",
"len",
"(",
"msg",
")",
">",
"2",
")",
"and",
"self",
"... | Search general errors in server response and raise exceptions when found.
:keyword msg: Result message
:raises NotAllowed: Exception raised when operation was called with
insufficient privileges
:raises AuthorizationError: Credentials are invalid or missing
:... | [
"Search",
"general",
"errors",
"in",
"server",
"response",
"and",
"raise",
"exceptions",
"when",
"found",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L313-L331 |
2,336 | CZ-NIC/python-rt | rt.py | Rt.__normalize_list | def __normalize_list(self, msg):
"""Split message to list by commas and trim whitespace."""
if isinstance(msg, list):
msg = "".join(msg)
return list(map(lambda x: x.strip(), msg.split(","))) | python | def __normalize_list(self, msg):
"""Split message to list by commas and trim whitespace."""
if isinstance(msg, list):
msg = "".join(msg)
return list(map(lambda x: x.strip(), msg.split(","))) | [
"def",
"__normalize_list",
"(",
"self",
",",
"msg",
")",
":",
"if",
"isinstance",
"(",
"msg",
",",
"list",
")",
":",
"msg",
"=",
"\"\"",
".",
"join",
"(",
"msg",
")",
"return",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"strip",
"(",
... | Split message to list by commas and trim whitespace. | [
"Split",
"message",
"to",
"list",
"by",
"commas",
"and",
"trim",
"whitespace",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L333-L337 |
2,337 | CZ-NIC/python-rt | rt.py | Rt.login | def login(self, login=None, password=None):
""" Login with default or supplied credetials.
.. note::
Calling this method is not necessary when HTTP basic or HTTP
digest_auth authentication is used and RT accepts it as external
authentication method, because the logi... | python | def login(self, login=None, password=None):
""" Login with default or supplied credetials.
.. note::
Calling this method is not necessary when HTTP basic or HTTP
digest_auth authentication is used and RT accepts it as external
authentication method, because the logi... | [
"def",
"login",
"(",
"self",
",",
"login",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"if",
"(",
"login",
"is",
"not",
"None",
")",
"and",
"(",
"password",
"is",
"not",
"None",
")",
":",
"login_data",
"=",
"{",
"'user'",
":",
"login",
"... | Login with default or supplied credetials.
.. note::
Calling this method is not necessary when HTTP basic or HTTP
digest_auth authentication is used and RT accepts it as external
authentication method, because the login in this case is done
transparently by requ... | [
"Login",
"with",
"default",
"or",
"supplied",
"credetials",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L339-L380 |
2,338 | CZ-NIC/python-rt | rt.py | Rt.logout | def logout(self):
""" Logout of user.
:returns: ``True``
Successful logout
``False``
Logout failed (mainly because user was not login)
"""
ret = False
if self.login_result is True:
ret = self.__get_status_... | python | def logout(self):
""" Logout of user.
:returns: ``True``
Successful logout
``False``
Logout failed (mainly because user was not login)
"""
ret = False
if self.login_result is True:
ret = self.__get_status_... | [
"def",
"logout",
"(",
"self",
")",
":",
"ret",
"=",
"False",
"if",
"self",
".",
"login_result",
"is",
"True",
":",
"ret",
"=",
"self",
".",
"__get_status_code",
"(",
"self",
".",
"__request",
"(",
"'logout'",
")",
")",
"==",
"200",
"self",
".",
"logi... | Logout of user.
:returns: ``True``
Successful logout
``False``
Logout failed (mainly because user was not login) | [
"Logout",
"of",
"user",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L382-L394 |
2,339 | CZ-NIC/python-rt | rt.py | Rt.new_correspondence | def new_correspondence(self, queue=None):
""" Obtains tickets changed by other users than the system one.
:keyword queue: Queue where to search
:returns: List of tickets which were last updated by other user than
the system one ordered in decreasing order by LastUpdated.
... | python | def new_correspondence(self, queue=None):
""" Obtains tickets changed by other users than the system one.
:keyword queue: Queue where to search
:returns: List of tickets which were last updated by other user than
the system one ordered in decreasing order by LastUpdated.
... | [
"def",
"new_correspondence",
"(",
"self",
",",
"queue",
"=",
"None",
")",
":",
"return",
"self",
".",
"search",
"(",
"Queue",
"=",
"queue",
",",
"order",
"=",
"'-LastUpdated'",
",",
"LastUpdatedBy__notexact",
"=",
"self",
".",
"default_login",
")"
] | Obtains tickets changed by other users than the system one.
:keyword queue: Queue where to search
:returns: List of tickets which were last updated by other user than
the system one ordered in decreasing order by LastUpdated.
Each ticket is dictionary, the same as i... | [
"Obtains",
"tickets",
"changed",
"by",
"other",
"users",
"than",
"the",
"system",
"one",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L396-L406 |
2,340 | CZ-NIC/python-rt | rt.py | Rt.last_updated | def last_updated(self, since, queue=None):
""" Obtains tickets changed after given date.
:param since: Date as string in form '2011-02-24'
:keyword queue: Queue where to search
:returns: List of tickets with LastUpdated parameter later than
*since* ordered in decreasi... | python | def last_updated(self, since, queue=None):
""" Obtains tickets changed after given date.
:param since: Date as string in form '2011-02-24'
:keyword queue: Queue where to search
:returns: List of tickets with LastUpdated parameter later than
*since* ordered in decreasi... | [
"def",
"last_updated",
"(",
"self",
",",
"since",
",",
"queue",
"=",
"None",
")",
":",
"return",
"self",
".",
"search",
"(",
"Queue",
"=",
"queue",
",",
"order",
"=",
"'-LastUpdated'",
",",
"LastUpdatedBy__notexact",
"=",
"self",
".",
"default_login",
",",... | Obtains tickets changed after given date.
:param since: Date as string in form '2011-02-24'
:keyword queue: Queue where to search
:returns: List of tickets with LastUpdated parameter later than
*since* ordered in decreasing order by LastUpdated.
Each tickets... | [
"Obtains",
"tickets",
"changed",
"after",
"given",
"date",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L408-L419 |
2,341 | CZ-NIC/python-rt | rt.py | Rt.get_ticket | def get_ticket(self, ticket_id):
""" Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* nume... | python | def get_ticket(self, ticket_id):
""" Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* nume... | [
"def",
"get_ticket",
"(",
"self",
",",
"ticket_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/show'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
")",
")",
"status_code",
"=",
"self",
".",
"__get_status_code",
"(",
"msg"... | Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* numerical_id
* Queue
... | [
"Fetch",
"ticket",
"by",
"its",
"ID",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L570-L640 |
2,342 | CZ-NIC/python-rt | rt.py | Rt.create_ticket | def create_ticket(self, Queue=None, files=[], **kwargs):
""" Create new ticket and set given parameters.
Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``::
content=id: ticket/new
Queue: General
Owner: Nobody
Requestors: som... | python | def create_ticket(self, Queue=None, files=[], **kwargs):
""" Create new ticket and set given parameters.
Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``::
content=id: ticket/new
Queue: General
Owner: Nobody
Requestors: som... | [
"def",
"create_ticket",
"(",
"self",
",",
"Queue",
"=",
"None",
",",
"files",
"=",
"[",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"post_data",
"=",
"'id: ticket/new\\nQueue: {}\\n'",
".",
"format",
"(",
"Queue",
"or",
"self",
".",
"default_queue",
",",
")"... | Create new ticket and set given parameters.
Example of message sended to ``http://tracker.example.com/REST/1.0/ticket/new``::
content=id: ticket/new
Queue: General
Owner: Nobody
Requestors: somebody@example.com
Subject: Ticket created through REST AP... | [
"Create",
"new",
"ticket",
"and",
"set",
"given",
"parameters",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L642-L700 |
2,343 | CZ-NIC/python-rt | rt.py | Rt.edit_ticket | def edit_ticket(self, ticket_id, **kwargs):
""" Edit ticket values.
:param ticket_id: ID of ticket to edit
:keyword kwargs: Other arguments possible to set:
Requestors, Subject, Cc, AdminCc, Owner, Status,
Priority, InitialPriority, FinalPriori... | python | def edit_ticket(self, ticket_id, **kwargs):
""" Edit ticket values.
:param ticket_id: ID of ticket to edit
:keyword kwargs: Other arguments possible to set:
Requestors, Subject, Cc, AdminCc, Owner, Status,
Priority, InitialPriority, FinalPriori... | [
"def",
"edit_ticket",
"(",
"self",
",",
"ticket_id",
",",
"*",
"*",
"kwargs",
")",
":",
"post_data",
"=",
"''",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
... | Edit ticket values.
:param ticket_id: ID of ticket to edit
:keyword kwargs: Other arguments possible to set:
Requestors, Subject, Cc, AdminCc, Owner, Status,
Priority, InitialPriority, FinalPriority,
TimeEstimated, Starts, Due,... | [
"Edit",
"ticket",
"values",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L702-L731 |
2,344 | CZ-NIC/python-rt | rt.py | Rt.get_history | def get_history(self, ticket_id, transaction_id=None):
""" Get set of history items.
:param ticket_id: ID of ticket
:keyword transaction_id: If set to None, all history items are
returned, if set to ID of valid transaction
just o... | python | def get_history(self, ticket_id, transaction_id=None):
""" Get set of history items.
:param ticket_id: ID of ticket
:keyword transaction_id: If set to None, all history items are
returned, if set to ID of valid transaction
just o... | [
"def",
"get_history",
"(",
"self",
",",
"ticket_id",
",",
"transaction_id",
"=",
"None",
")",
":",
"if",
"transaction_id",
"is",
"None",
":",
"# We are using \"long\" format to get all history items at once.",
"# Each history item is then separated by double dash.",
"msgs",
"... | Get set of history items.
:param ticket_id: ID of ticket
:keyword transaction_id: If set to None, all history items are
returned, if set to ID of valid transaction
just one history item is returned
:returns: List of history item... | [
"Get",
"set",
"of",
"history",
"items",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L733-L801 |
2,345 | CZ-NIC/python-rt | rt.py | Rt.get_short_history | def get_short_history(self, ticket_id):
""" Get set of short history items
:param ticket_id: ID of ticket
:returns: List of history items ordered increasingly by time of event.
Each history item is a tuple containing (id, Description).
Returns None if ticket ... | python | def get_short_history(self, ticket_id):
""" Get set of short history items
:param ticket_id: ID of ticket
:returns: List of history items ordered increasingly by time of event.
Each history item is a tuple containing (id, Description).
Returns None if ticket ... | [
"def",
"get_short_history",
"(",
"self",
",",
"ticket_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/history'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
")",
")",
"items",
"=",
"[",
"]",
"lines",
"=",
"msg",
".",
... | Get set of short history items
:param ticket_id: ID of ticket
:returns: List of history items ordered increasingly by time of event.
Each history item is a tuple containing (id, Description).
Returns None if ticket does not exist. | [
"Get",
"set",
"of",
"short",
"history",
"items"
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L803-L837 |
2,346 | CZ-NIC/python-rt | rt.py | Rt.reply | def reply(self, ticket_id, text='', cc='', bcc='', content_type='text/plain', files=[]):
""" Sends email message to the contacts in ``Requestors`` field of
given ticket with subject as is set in ``Subject`` field.
Form of message according to documentation::
id: <ticket-id>
... | python | def reply(self, ticket_id, text='', cc='', bcc='', content_type='text/plain', files=[]):
""" Sends email message to the contacts in ``Requestors`` field of
given ticket with subject as is set in ``Subject`` field.
Form of message according to documentation::
id: <ticket-id>
... | [
"def",
"reply",
"(",
"self",
",",
"ticket_id",
",",
"text",
"=",
"''",
",",
"cc",
"=",
"''",
",",
"bcc",
"=",
"''",
",",
"content_type",
"=",
"'text/plain'",
",",
"files",
"=",
"[",
"]",
")",
":",
"return",
"self",
".",
"__correspond",
"(",
"ticket... | Sends email message to the contacts in ``Requestors`` field of
given ticket with subject as is set in ``Subject`` field.
Form of message according to documentation::
id: <ticket-id>
Action: correspond
Text: the text comment
second line starts with ... | [
"Sends",
"email",
"message",
"to",
"the",
"contacts",
"in",
"Requestors",
"field",
"of",
"given",
"ticket",
"with",
"subject",
"as",
"is",
"set",
"in",
"Subject",
"field",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L868-L896 |
2,347 | CZ-NIC/python-rt | rt.py | Rt.get_attachments | def get_attachments(self, ticket_id):
""" Get attachment list for a given ticket
:param ticket_id: ID of ticket
:returns: List of tuples for attachments belonging to given ticket.
Tuple format: (id, name, content_type, size)
Returns None if ticket does not ex... | python | def get_attachments(self, ticket_id):
""" Get attachment list for a given ticket
:param ticket_id: ID of ticket
:returns: List of tuples for attachments belonging to given ticket.
Tuple format: (id, name, content_type, size)
Returns None if ticket does not ex... | [
"def",
"get_attachments",
"(",
"self",
",",
"ticket_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/attachments'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
")",
")",
"lines",
"=",
"msg",
".",
"split",
"(",
"'\\n'",
"... | Get attachment list for a given ticket
:param ticket_id: ID of ticket
:returns: List of tuples for attachments belonging to given ticket.
Tuple format: (id, name, content_type, size)
Returns None if ticket does not exist. | [
"Get",
"attachment",
"list",
"for",
"a",
"given",
"ticket"
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L933-L951 |
2,348 | CZ-NIC/python-rt | rt.py | Rt.get_attachments_ids | def get_attachments_ids(self, ticket_id):
""" Get IDs of attachments for given ticket.
:param ticket_id: ID of ticket
:returns: List of IDs (type int) of attachments belonging to given
ticket. Returns None if ticket does not exist.
"""
attachments = self.get_at... | python | def get_attachments_ids(self, ticket_id):
""" Get IDs of attachments for given ticket.
:param ticket_id: ID of ticket
:returns: List of IDs (type int) of attachments belonging to given
ticket. Returns None if ticket does not exist.
"""
attachments = self.get_at... | [
"def",
"get_attachments_ids",
"(",
"self",
",",
"ticket_id",
")",
":",
"attachments",
"=",
"self",
".",
"get_attachments",
"(",
"ticket_id",
")",
"return",
"[",
"int",
"(",
"at",
"[",
"0",
"]",
")",
"for",
"at",
"in",
"attachments",
"]",
"if",
"attachmen... | Get IDs of attachments for given ticket.
:param ticket_id: ID of ticket
:returns: List of IDs (type int) of attachments belonging to given
ticket. Returns None if ticket does not exist. | [
"Get",
"IDs",
"of",
"attachments",
"for",
"given",
"ticket",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L953-L961 |
2,349 | CZ-NIC/python-rt | rt.py | Rt.get_attachment | def get_attachment(self, ticket_id, attachment_id):
""" Get attachment.
:param ticket_id: ID of ticket
:param attachment_id: ID of attachment for obtain
:returns: Attachment as dictionary with these keys:
* Transaction
* ContentType
... | python | def get_attachment(self, ticket_id, attachment_id):
""" Get attachment.
:param ticket_id: ID of ticket
:param attachment_id: ID of attachment for obtain
:returns: Attachment as dictionary with these keys:
* Transaction
* ContentType
... | [
"def",
"get_attachment",
"(",
"self",
",",
"ticket_id",
",",
"attachment_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/attachments/{}'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
"str",
"(",
"attachment_id",
")",
")",
"... | Get attachment.
:param ticket_id: ID of ticket
:param attachment_id: ID of attachment for obtain
:returns: Attachment as dictionary with these keys:
* Transaction
* ContentType
* Parent
* Creator
... | [
"Get",
"attachment",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L963-L1051 |
2,350 | CZ-NIC/python-rt | rt.py | Rt.get_attachment_content | def get_attachment_content(self, ticket_id, attachment_id):
""" Get content of attachment without headers.
This function is necessary to use for binary attachment,
as it can contain ``\\n`` chars, which would disrupt parsing
of message if :py:meth:`~Rt.get_attachment` is used.
... | python | def get_attachment_content(self, ticket_id, attachment_id):
""" Get content of attachment without headers.
This function is necessary to use for binary attachment,
as it can contain ``\\n`` chars, which would disrupt parsing
of message if :py:meth:`~Rt.get_attachment` is used.
... | [
"def",
"get_attachment_content",
"(",
"self",
",",
"ticket_id",
",",
"attachment_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/attachments/{}/content'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
"str",
"(",
"attachment_id",
... | Get content of attachment without headers.
This function is necessary to use for binary attachment,
as it can contain ``\\n`` chars, which would disrupt parsing
of message if :py:meth:`~Rt.get_attachment` is used.
Format of message::
RT/3.8.7 200 Ok\n\nStart of the content... | [
"Get",
"content",
"of",
"attachment",
"without",
"headers",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1053-L1077 |
2,351 | CZ-NIC/python-rt | rt.py | Rt.get_user | def get_user(self, user_id):
""" Get user details.
:param user_id: Identification of user by username (str) or user ID
(int)
:returns: User details as strings in dictionary with these keys for RT
users:
* Lang
... | python | def get_user(self, user_id):
""" Get user details.
:param user_id: Identification of user by username (str) or user ID
(int)
:returns: User details as strings in dictionary with these keys for RT
users:
* Lang
... | [
"def",
"get_user",
"(",
"self",
",",
"user_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'user/{}'",
".",
"format",
"(",
"str",
"(",
"user_id",
")",
",",
")",
")",
"status_code",
"=",
"self",
".",
"__get_status_code",
"(",
"msg",
")",
"i... | Get user details.
:param user_id: Identification of user by username (str) or user ID
(int)
:returns: User details as strings in dictionary with these keys for RT
users:
* Lang
* RealName
* Priv... | [
"Get",
"user",
"details",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1079-L1123 |
2,352 | CZ-NIC/python-rt | rt.py | Rt.get_links | def get_links(self, ticket_id):
""" Gets the ticket links for a single ticket.
:param ticket_id: ticket ID
:returns: Links as lists of strings in dictionary with these keys
(just those which are defined):
* id
* Members
... | python | def get_links(self, ticket_id):
""" Gets the ticket links for a single ticket.
:param ticket_id: ticket ID
:returns: Links as lists of strings in dictionary with these keys
(just those which are defined):
* id
* Members
... | [
"def",
"get_links",
"(",
"self",
",",
"ticket_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/links/show'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
")",
")",
"status_code",
"=",
"self",
".",
"__get_status_code",
"(",
... | Gets the ticket links for a single ticket.
:param ticket_id: ticket ID
:returns: Links as lists of strings in dictionary with these keys
(just those which are defined):
* id
* Members
* MemberOf
*... | [
"Gets",
"the",
"ticket",
"links",
"for",
"a",
"single",
"ticket",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1286-L1329 |
2,353 | CZ-NIC/python-rt | rt.py | Rt.edit_ticket_links | def edit_ticket_links(self, ticket_id, **kwargs):
""" Edit ticket links.
.. warning:: This method is deprecated in favour of edit_link method, because
there exists bug in RT 3.8 REST API causing mapping created links to
ticket/1. The only drawback is that edit_link cannot process ... | python | def edit_ticket_links(self, ticket_id, **kwargs):
""" Edit ticket links.
.. warning:: This method is deprecated in favour of edit_link method, because
there exists bug in RT 3.8 REST API causing mapping created links to
ticket/1. The only drawback is that edit_link cannot process ... | [
"def",
"edit_ticket_links",
"(",
"self",
",",
"ticket_id",
",",
"*",
"*",
"kwargs",
")",
":",
"post_data",
"=",
"''",
"for",
"key",
"in",
"kwargs",
":",
"post_data",
"+=",
"\"{}: {}\\n\"",
".",
"format",
"(",
"key",
",",
"str",
"(",
"kwargs",
"[",
"key... | Edit ticket links.
.. warning:: This method is deprecated in favour of edit_link method, because
there exists bug in RT 3.8 REST API causing mapping created links to
ticket/1. The only drawback is that edit_link cannot process multiple
links all at once.
:param ticket_... | [
"Edit",
"ticket",
"links",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1331-L1357 |
2,354 | CZ-NIC/python-rt | rt.py | Rt.split_header | def split_header(line):
""" Split a header line into field name and field value.
Note that custom fields may contain colons inside the curly braces,
so we need a special test for them.
:param line: A message line to be split.
:returns: (Field name, field value) tuple.
... | python | def split_header(line):
""" Split a header line into field name and field value.
Note that custom fields may contain colons inside the curly braces,
so we need a special test for them.
:param line: A message line to be split.
:returns: (Field name, field value) tuple.
... | [
"def",
"split_header",
"(",
"line",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'^(CF\\.\\{.*?}): (.*)$'",
",",
"line",
")",
"if",
"match",
":",
"return",
"(",
"match",
".",
"group",
"(",
"1",
")",
",",
"match",
".",
"group",
"(",
"2",
")",
... | Split a header line into field name and field value.
Note that custom fields may contain colons inside the curly braces,
so we need a special test for them.
:param line: A message line to be split.
:returns: (Field name, field value) tuple. | [
"Split",
"a",
"header",
"line",
"into",
"field",
"name",
"and",
"field",
"value",
"."
] | e7a9f555e136708aec3317f857045145a2271e16 | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L1450-L1463 |
2,355 | CityOfZion/neo-python-core | neocore/KeyPair.py | KeyPair.PrivateKeyFromWIF | def PrivateKeyFromWIF(wif):
"""
Get the private key from a WIF key
Args:
wif (str): The wif key
Returns:
bytes: The private key
"""
if wif is None or len(wif) is not 52:
raise ValueError('Please provide a wif with a length of 52 bytes... | python | def PrivateKeyFromWIF(wif):
"""
Get the private key from a WIF key
Args:
wif (str): The wif key
Returns:
bytes: The private key
"""
if wif is None or len(wif) is not 52:
raise ValueError('Please provide a wif with a length of 52 bytes... | [
"def",
"PrivateKeyFromWIF",
"(",
"wif",
")",
":",
"if",
"wif",
"is",
"None",
"or",
"len",
"(",
"wif",
")",
"is",
"not",
"52",
":",
"raise",
"ValueError",
"(",
"'Please provide a wif with a length of 52 bytes (LEN: {0:d})'",
".",
"format",
"(",
"len",
"(",
"wif... | Get the private key from a WIF key
Args:
wif (str): The wif key
Returns:
bytes: The private key | [
"Get",
"the",
"private",
"key",
"from",
"a",
"WIF",
"key"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L81-L106 |
2,356 | CityOfZion/neo-python-core | neocore/KeyPair.py | KeyPair.PrivateKeyFromNEP2 | def PrivateKeyFromNEP2(nep2_key, passphrase):
"""
Gets the private key from a NEP-2 encrypted private key
Args:
nep2_key (str): The nep-2 encrypted private key
passphrase (str): The password to encrypt the private key with, as unicode string
Returns:
... | python | def PrivateKeyFromNEP2(nep2_key, passphrase):
"""
Gets the private key from a NEP-2 encrypted private key
Args:
nep2_key (str): The nep-2 encrypted private key
passphrase (str): The password to encrypt the private key with, as unicode string
Returns:
... | [
"def",
"PrivateKeyFromNEP2",
"(",
"nep2_key",
",",
"passphrase",
")",
":",
"if",
"not",
"nep2_key",
"or",
"len",
"(",
"nep2_key",
")",
"!=",
"58",
":",
"raise",
"ValueError",
"(",
"'Please provide a nep2_key with a length of 58 bytes (LEN: {0:d})'",
".",
"format",
"... | Gets the private key from a NEP-2 encrypted private key
Args:
nep2_key (str): The nep-2 encrypted private key
passphrase (str): The password to encrypt the private key with, as unicode string
Returns:
bytes: The private key | [
"Gets",
"the",
"private",
"key",
"from",
"a",
"NEP",
"-",
"2",
"encrypted",
"private",
"key"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L109-L157 |
2,357 | CityOfZion/neo-python-core | neocore/KeyPair.py | KeyPair.GetAddress | def GetAddress(self):
"""
Returns the public NEO address for this KeyPair
Returns:
str: The private key
"""
script = b'21' + self.PublicKey.encode_point(True) + b'ac'
script_hash = Crypto.ToScriptHash(script)
address = Crypto.ToAddress(script_hash)
... | python | def GetAddress(self):
"""
Returns the public NEO address for this KeyPair
Returns:
str: The private key
"""
script = b'21' + self.PublicKey.encode_point(True) + b'ac'
script_hash = Crypto.ToScriptHash(script)
address = Crypto.ToAddress(script_hash)
... | [
"def",
"GetAddress",
"(",
"self",
")",
":",
"script",
"=",
"b'21'",
"+",
"self",
".",
"PublicKey",
".",
"encode_point",
"(",
"True",
")",
"+",
"b'ac'",
"script_hash",
"=",
"Crypto",
".",
"ToScriptHash",
"(",
"script",
")",
"address",
"=",
"Crypto",
".",
... | Returns the public NEO address for this KeyPair
Returns:
str: The private key | [
"Returns",
"the",
"public",
"NEO",
"address",
"for",
"this",
"KeyPair"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L159-L169 |
2,358 | CityOfZion/neo-python-core | neocore/KeyPair.py | KeyPair.Export | def Export(self):
"""
Export this KeyPair's private key in WIF format.
Returns:
str: The key in wif format
"""
data = bytearray(38)
data[0] = 0x80
data[1:33] = self.PrivateKey[0:32]
data[33] = 0x01
checksum = Crypto.Default().Hash256(... | python | def Export(self):
"""
Export this KeyPair's private key in WIF format.
Returns:
str: The key in wif format
"""
data = bytearray(38)
data[0] = 0x80
data[1:33] = self.PrivateKey[0:32]
data[33] = 0x01
checksum = Crypto.Default().Hash256(... | [
"def",
"Export",
"(",
"self",
")",
":",
"data",
"=",
"bytearray",
"(",
"38",
")",
"data",
"[",
"0",
"]",
"=",
"0x80",
"data",
"[",
"1",
":",
"33",
"]",
"=",
"self",
".",
"PrivateKey",
"[",
"0",
":",
"32",
"]",
"data",
"[",
"33",
"]",
"=",
"... | Export this KeyPair's private key in WIF format.
Returns:
str: The key in wif format | [
"Export",
"this",
"KeyPair",
"s",
"private",
"key",
"in",
"WIF",
"format",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L171-L187 |
2,359 | CityOfZion/neo-python-core | neocore/KeyPair.py | KeyPair.ExportNEP2 | def ExportNEP2(self, passphrase):
"""
Export the encrypted private key in NEP-2 format.
Args:
passphrase (str): The password to encrypt the private key with, as unicode string
Returns:
str: The NEP-2 encrypted private key
"""
if len(passphrase) <... | python | def ExportNEP2(self, passphrase):
"""
Export the encrypted private key in NEP-2 format.
Args:
passphrase (str): The password to encrypt the private key with, as unicode string
Returns:
str: The NEP-2 encrypted private key
"""
if len(passphrase) <... | [
"def",
"ExportNEP2",
"(",
"self",
",",
"passphrase",
")",
":",
"if",
"len",
"(",
"passphrase",
")",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"\"Passphrase must have a minimum of 2 characters\"",
")",
"# Hash address twice, then only use the first 4 bytes",
"address_hash... | Export the encrypted private key in NEP-2 format.
Args:
passphrase (str): The password to encrypt the private key with, as unicode string
Returns:
str: The NEP-2 encrypted private key | [
"Export",
"the",
"encrypted",
"private",
"key",
"in",
"NEP",
"-",
"2",
"format",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/KeyPair.py#L189-L233 |
2,360 | CityOfZion/neo-python-core | neocore/IO/BinaryReader.py | BinaryReader.ReadByte | def ReadByte(self, do_ord=True):
"""
Read a single byte.
Args:
do_ord (bool): (default True) convert the byte to an ordinal first.
Returns:
bytes: a single byte if successful. 0 (int) if an exception occurred.
"""
try:
if do_ord:
... | python | def ReadByte(self, do_ord=True):
"""
Read a single byte.
Args:
do_ord (bool): (default True) convert the byte to an ordinal first.
Returns:
bytes: a single byte if successful. 0 (int) if an exception occurred.
"""
try:
if do_ord:
... | [
"def",
"ReadByte",
"(",
"self",
",",
"do_ord",
"=",
"True",
")",
":",
"try",
":",
"if",
"do_ord",
":",
"return",
"ord",
"(",
"self",
".",
"stream",
".",
"read",
"(",
"1",
")",
")",
"return",
"self",
".",
"stream",
".",
"read",
"(",
"1",
")",
"e... | Read a single byte.
Args:
do_ord (bool): (default True) convert the byte to an ordinal first.
Returns:
bytes: a single byte if successful. 0 (int) if an exception occurred. | [
"Read",
"a",
"single",
"byte",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryReader.py#L46-L62 |
2,361 | CityOfZion/neo-python-core | neocore/IO/BinaryReader.py | BinaryReader.SafeReadBytes | def SafeReadBytes(self, length):
"""
Read exactly `length` number of bytes from the stream.
Raises:
ValueError is not enough data
Returns:
bytes: `length` number of bytes
"""
data = self.ReadBytes(length)
if len(data) < length:
... | python | def SafeReadBytes(self, length):
"""
Read exactly `length` number of bytes from the stream.
Raises:
ValueError is not enough data
Returns:
bytes: `length` number of bytes
"""
data = self.ReadBytes(length)
if len(data) < length:
... | [
"def",
"SafeReadBytes",
"(",
"self",
",",
"length",
")",
":",
"data",
"=",
"self",
".",
"ReadBytes",
"(",
"length",
")",
"if",
"len",
"(",
"data",
")",
"<",
"length",
":",
"raise",
"ValueError",
"(",
"\"Not enough data available\"",
")",
"else",
":",
"re... | Read exactly `length` number of bytes from the stream.
Raises:
ValueError is not enough data
Returns:
bytes: `length` number of bytes | [
"Read",
"exactly",
"length",
"number",
"of",
"bytes",
"from",
"the",
"stream",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryReader.py#L77-L91 |
2,362 | CityOfZion/neo-python-core | neocore/Cryptography/Crypto.py | Crypto.ToScriptHash | def ToScriptHash(data, unhex=True):
"""
Get a script hash of the data.
Args:
data (bytes): data to hash.
unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb'
Returns:
UInt160: script hash.
... | python | def ToScriptHash(data, unhex=True):
"""
Get a script hash of the data.
Args:
data (bytes): data to hash.
unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb'
Returns:
UInt160: script hash.
... | [
"def",
"ToScriptHash",
"(",
"data",
",",
"unhex",
"=",
"True",
")",
":",
"if",
"len",
"(",
"data",
")",
">",
"1",
"and",
"unhex",
":",
"data",
"=",
"binascii",
".",
"unhexlify",
"(",
"data",
")",
"return",
"UInt160",
"(",
"data",
"=",
"binascii",
"... | Get a script hash of the data.
Args:
data (bytes): data to hash.
unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb'
Returns:
UInt160: script hash. | [
"Get",
"a",
"script",
"hash",
"of",
"the",
"data",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Crypto.py#L77-L90 |
2,363 | CityOfZion/neo-python-core | neocore/Cryptography/Crypto.py | Crypto.Sign | def Sign(message, private_key):
"""
Sign the message with the given private key.
Args:
message (str): message to be signed
private_key (str): 32 byte key as a double digit hex string (e.g. having a length of 64)
Returns:
bytearray: the signature of th... | python | def Sign(message, private_key):
"""
Sign the message with the given private key.
Args:
message (str): message to be signed
private_key (str): 32 byte key as a double digit hex string (e.g. having a length of 64)
Returns:
bytearray: the signature of th... | [
"def",
"Sign",
"(",
"message",
",",
"private_key",
")",
":",
"hash",
"=",
"hashlib",
".",
"sha256",
"(",
"binascii",
".",
"unhexlify",
"(",
"message",
")",
")",
".",
"hexdigest",
"(",
")",
"v",
",",
"r",
",",
"s",
"=",
"bitcoin",
".",
"ecdsa_raw_sign... | Sign the message with the given private key.
Args:
message (str): message to be signed
private_key (str): 32 byte key as a double digit hex string (e.g. having a length of 64)
Returns:
bytearray: the signature of the message. | [
"Sign",
"the",
"message",
"with",
"the",
"given",
"private",
"key",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Crypto.py#L106-L126 |
2,364 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | FiniteField.sqrt | def sqrt(self, val, flag):
"""
calculate the square root modulus p
"""
if val.iszero():
return val
sw = self.p % 8
if sw == 3 or sw == 7:
res = val ** ((self.p + 1) / 4)
elif sw == 5:
x = val ** ((self.p + 1) / 4)
if... | python | def sqrt(self, val, flag):
"""
calculate the square root modulus p
"""
if val.iszero():
return val
sw = self.p % 8
if sw == 3 or sw == 7:
res = val ** ((self.p + 1) / 4)
elif sw == 5:
x = val ** ((self.p + 1) / 4)
if... | [
"def",
"sqrt",
"(",
"self",
",",
"val",
",",
"flag",
")",
":",
"if",
"val",
".",
"iszero",
"(",
")",
":",
"return",
"val",
"sw",
"=",
"self",
".",
"p",
"%",
"8",
"if",
"sw",
"==",
"3",
"or",
"sw",
"==",
"7",
":",
"res",
"=",
"val",
"**",
... | calculate the square root modulus p | [
"calculate",
"the",
"square",
"root",
"modulus",
"p"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L287-L308 |
2,365 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | FiniteField.value | def value(self, x):
"""
converts an integer or FinitField.Value to a value of this FiniteField.
"""
return x if isinstance(x, FiniteField.Value) and x.field == self else FiniteField.Value(self, x) | python | def value(self, x):
"""
converts an integer or FinitField.Value to a value of this FiniteField.
"""
return x if isinstance(x, FiniteField.Value) and x.field == self else FiniteField.Value(self, x) | [
"def",
"value",
"(",
"self",
",",
"x",
")",
":",
"return",
"x",
"if",
"isinstance",
"(",
"x",
",",
"FiniteField",
".",
"Value",
")",
"and",
"x",
".",
"field",
"==",
"self",
"else",
"FiniteField",
".",
"Value",
"(",
"self",
",",
"x",
")"
] | converts an integer or FinitField.Value to a value of this FiniteField. | [
"converts",
"an",
"integer",
"or",
"FinitField",
".",
"Value",
"to",
"a",
"value",
"of",
"this",
"FiniteField",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L316-L320 |
2,366 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | FiniteField.integer | def integer(self, x):
"""
returns a plain integer
"""
if type(x) is str:
hex = binascii.unhexlify(x)
return int.from_bytes(hex, 'big')
return x.value if isinstance(x, FiniteField.Value) else x | python | def integer(self, x):
"""
returns a plain integer
"""
if type(x) is str:
hex = binascii.unhexlify(x)
return int.from_bytes(hex, 'big')
return x.value if isinstance(x, FiniteField.Value) else x | [
"def",
"integer",
"(",
"self",
",",
"x",
")",
":",
"if",
"type",
"(",
"x",
")",
"is",
"str",
":",
"hex",
"=",
"binascii",
".",
"unhexlify",
"(",
"x",
")",
"return",
"int",
".",
"from_bytes",
"(",
"hex",
",",
"'big'",
")",
"return",
"x",
".",
"v... | returns a plain integer | [
"returns",
"a",
"plain",
"integer"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L322-L330 |
2,367 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | EllipticCurve.add | def add(self, p, q):
"""
perform elliptic curve addition
"""
if p.iszero():
return q
if q.iszero():
return p
lft = 0
# calculate the slope of the intersection line
if p == q:
if p.y == 0:
return self.zer... | python | def add(self, p, q):
"""
perform elliptic curve addition
"""
if p.iszero():
return q
if q.iszero():
return p
lft = 0
# calculate the slope of the intersection line
if p == q:
if p.y == 0:
return self.zer... | [
"def",
"add",
"(",
"self",
",",
"p",
",",
"q",
")",
":",
"if",
"p",
".",
"iszero",
"(",
")",
":",
"return",
"q",
"if",
"q",
".",
"iszero",
"(",
")",
":",
"return",
"p",
"lft",
"=",
"0",
"# calculate the slope of the intersection line",
"if",
"p",
"... | perform elliptic curve addition | [
"perform",
"elliptic",
"curve",
"addition"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L486-L509 |
2,368 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | EllipticCurve.point | def point(self, x, y):
"""
construct a point from 2 values
"""
return EllipticCurve.ECPoint(self, self.field.value(x), self.field.value(y)) | python | def point(self, x, y):
"""
construct a point from 2 values
"""
return EllipticCurve.ECPoint(self, self.field.value(x), self.field.value(y)) | [
"def",
"point",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"return",
"EllipticCurve",
".",
"ECPoint",
"(",
"self",
",",
"self",
".",
"field",
".",
"value",
"(",
"x",
")",
",",
"self",
".",
"field",
".",
"value",
"(",
"y",
")",
")"
] | construct a point from 2 values | [
"construct",
"a",
"point",
"from",
"2",
"values"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L550-L554 |
2,369 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | EllipticCurve.isoncurve | def isoncurve(self, p):
"""
verifies if a point is on the curve
"""
return p.iszero() or p.y ** 2 == p.x ** 3 + self.a * p.x + self.b | python | def isoncurve(self, p):
"""
verifies if a point is on the curve
"""
return p.iszero() or p.y ** 2 == p.x ** 3 + self.a * p.x + self.b | [
"def",
"isoncurve",
"(",
"self",
",",
"p",
")",
":",
"return",
"p",
".",
"iszero",
"(",
")",
"or",
"p",
".",
"y",
"**",
"2",
"==",
"p",
".",
"x",
"**",
"3",
"+",
"self",
".",
"a",
"*",
"p",
".",
"x",
"+",
"self",
".",
"b"
] | verifies if a point is on the curve | [
"verifies",
"if",
"a",
"point",
"is",
"on",
"the",
"curve"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L556-L560 |
2,370 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | ECDSA.secp256r1 | def secp256r1():
"""
create the secp256r1 curve
"""
GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16))
ec = EllipticCurve(GFp, 115792089210356248762697446949407573530086143415290314195533631308867097853948, 41058363725152142129326129780... | python | def secp256r1():
"""
create the secp256r1 curve
"""
GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16))
ec = EllipticCurve(GFp, 115792089210356248762697446949407573530086143415290314195533631308867097853948, 41058363725152142129326129780... | [
"def",
"secp256r1",
"(",
")",
":",
"GFp",
"=",
"FiniteField",
"(",
"int",
"(",
"\"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF\"",
",",
"16",
")",
")",
"ec",
"=",
"EllipticCurve",
"(",
"GFp",
",",
"115792089210356248762697446949407573530086143415290314... | create the secp256r1 curve | [
"create",
"the",
"secp256r1",
"curve"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L805-L814 |
2,371 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | ECDSA.decode_secp256r1 | def decode_secp256r1(str, unhex=True, check_on_curve=True):
"""
decode a public key on the secp256r1 curve
"""
GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16))
ec = EllipticCurve(GFp, 1157920892103562487626974469494075735300861434152... | python | def decode_secp256r1(str, unhex=True, check_on_curve=True):
"""
decode a public key on the secp256r1 curve
"""
GFp = FiniteField(int("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16))
ec = EllipticCurve(GFp, 1157920892103562487626974469494075735300861434152... | [
"def",
"decode_secp256r1",
"(",
"str",
",",
"unhex",
"=",
"True",
",",
"check_on_curve",
"=",
"True",
")",
":",
"GFp",
"=",
"FiniteField",
"(",
"int",
"(",
"\"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF\"",
",",
"16",
")",
")",
"ec",
"=",
"E... | decode a public key on the secp256r1 curve | [
"decode",
"a",
"public",
"key",
"on",
"the",
"secp256r1",
"curve"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L817-L834 |
2,372 | CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | ECDSA.secp256k1 | def secp256k1():
"""
create the secp256k1 curve
"""
GFp = FiniteField(2 ** 256 - 2 ** 32 - 977) # This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
ec = EllipticCurve(GFp, 0, 7)
return ECDSA(ec, ec.point(0x79BE667EF9DCBBAC55A062... | python | def secp256k1():
"""
create the secp256k1 curve
"""
GFp = FiniteField(2 ** 256 - 2 ** 32 - 977) # This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
ec = EllipticCurve(GFp, 0, 7)
return ECDSA(ec, ec.point(0x79BE667EF9DCBBAC55A062... | [
"def",
"secp256k1",
"(",
")",
":",
"GFp",
"=",
"FiniteField",
"(",
"2",
"**",
"256",
"-",
"2",
"**",
"32",
"-",
"977",
")",
"# This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F",
"ec",
"=",
"EllipticCurve",
"(",
"GFp",
",",... | create the secp256k1 curve | [
"create",
"the",
"secp256k1",
"curve"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L864-L870 |
2,373 | CityOfZion/neo-python-core | neocore/Utils.py | isValidPublicAddress | def isValidPublicAddress(address: str) -> bool:
"""Check if address is a valid NEO address"""
valid = False
if len(address) == 34 and address[0] == 'A':
try:
base58.b58decode_check(address.encode())
valid = True
except ValueError:
# checksum mismatch
... | python | def isValidPublicAddress(address: str) -> bool:
"""Check if address is a valid NEO address"""
valid = False
if len(address) == 34 and address[0] == 'A':
try:
base58.b58decode_check(address.encode())
valid = True
except ValueError:
# checksum mismatch
... | [
"def",
"isValidPublicAddress",
"(",
"address",
":",
"str",
")",
"->",
"bool",
":",
"valid",
"=",
"False",
"if",
"len",
"(",
"address",
")",
"==",
"34",
"and",
"address",
"[",
"0",
"]",
"==",
"'A'",
":",
"try",
":",
"base58",
".",
"b58decode_check",
"... | Check if address is a valid NEO address | [
"Check",
"if",
"address",
"is",
"a",
"valid",
"NEO",
"address"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Utils.py#L4-L16 |
2,374 | CityOfZion/neo-python-core | neocore/Cryptography/MerkleTree.py | MerkleTree.__Build | def __Build(leaves):
"""
Build the merkle tree.
Args:
leaves (list): items are of type MerkleTreeNode.
Returns:
MerkleTreeNode: the root node.
"""
if len(leaves) < 1:
raise Exception('Leaves must have length')
if len(leaves) =... | python | def __Build(leaves):
"""
Build the merkle tree.
Args:
leaves (list): items are of type MerkleTreeNode.
Returns:
MerkleTreeNode: the root node.
"""
if len(leaves) < 1:
raise Exception('Leaves must have length')
if len(leaves) =... | [
"def",
"__Build",
"(",
"leaves",
")",
":",
"if",
"len",
"(",
"leaves",
")",
"<",
"1",
":",
"raise",
"Exception",
"(",
"'Leaves must have length'",
")",
"if",
"len",
"(",
"leaves",
")",
"==",
"1",
":",
"return",
"leaves",
"[",
"0",
"]",
"num_parents",
... | Build the merkle tree.
Args:
leaves (list): items are of type MerkleTreeNode.
Returns:
MerkleTreeNode: the root node. | [
"Build",
"the",
"merkle",
"tree",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L70-L101 |
2,375 | CityOfZion/neo-python-core | neocore/Cryptography/MerkleTree.py | MerkleTree.ComputeRoot | def ComputeRoot(hashes):
"""
Compute the root hash.
Args:
hashes (list): the list of hashes to build the root from.
Returns:
bytes: the root hash.
"""
if not len(hashes):
raise Exception('Hashes must have length')
if len(hashe... | python | def ComputeRoot(hashes):
"""
Compute the root hash.
Args:
hashes (list): the list of hashes to build the root from.
Returns:
bytes: the root hash.
"""
if not len(hashes):
raise Exception('Hashes must have length')
if len(hashe... | [
"def",
"ComputeRoot",
"(",
"hashes",
")",
":",
"if",
"not",
"len",
"(",
"hashes",
")",
":",
"raise",
"Exception",
"(",
"'Hashes must have length'",
")",
"if",
"len",
"(",
"hashes",
")",
"==",
"1",
":",
"return",
"hashes",
"[",
"0",
"]",
"tree",
"=",
... | Compute the root hash.
Args:
hashes (list): the list of hashes to build the root from.
Returns:
bytes: the root hash. | [
"Compute",
"the",
"root",
"hash",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L109-L125 |
2,376 | CityOfZion/neo-python-core | neocore/Cryptography/MerkleTree.py | MerkleTree.ToHashArray | def ToHashArray(self):
"""
Turn the tree into a list of hashes.
Returns:
list:
"""
hashes = set()
MerkleTree.__DepthFirstSearch(self.Root, hashes)
return list(hashes) | python | def ToHashArray(self):
"""
Turn the tree into a list of hashes.
Returns:
list:
"""
hashes = set()
MerkleTree.__DepthFirstSearch(self.Root, hashes)
return list(hashes) | [
"def",
"ToHashArray",
"(",
"self",
")",
":",
"hashes",
"=",
"set",
"(",
")",
"MerkleTree",
".",
"__DepthFirstSearch",
"(",
"self",
".",
"Root",
",",
"hashes",
")",
"return",
"list",
"(",
"hashes",
")"
] | Turn the tree into a list of hashes.
Returns:
list: | [
"Turn",
"the",
"tree",
"into",
"a",
"list",
"of",
"hashes",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L142-L151 |
2,377 | CityOfZion/neo-python-core | neocore/Cryptography/MerkleTree.py | MerkleTree.Trim | def Trim(self, flags):
"""
Trim the nodes from the tree keeping only the root hash.
Args:
flags: "0000" for trimming, any other value for keeping the nodes.
"""
logger.info("Trimming!")
flags = bytearray(flags)
length = 1 << self.Depth - 1
whi... | python | def Trim(self, flags):
"""
Trim the nodes from the tree keeping only the root hash.
Args:
flags: "0000" for trimming, any other value for keeping the nodes.
"""
logger.info("Trimming!")
flags = bytearray(flags)
length = 1 << self.Depth - 1
whi... | [
"def",
"Trim",
"(",
"self",
",",
"flags",
")",
":",
"logger",
".",
"info",
"(",
"\"Trimming!\"",
")",
"flags",
"=",
"bytearray",
"(",
"flags",
")",
"length",
"=",
"1",
"<<",
"self",
".",
"Depth",
"-",
"1",
"while",
"len",
"(",
"flags",
")",
"<",
... | Trim the nodes from the tree keeping only the root hash.
Args:
flags: "0000" for trimming, any other value for keeping the nodes. | [
"Trim",
"the",
"nodes",
"from",
"the",
"tree",
"keeping",
"only",
"the",
"root",
"hash",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L153-L166 |
2,378 | CityOfZion/neo-python-core | neocore/Cryptography/MerkleTree.py | MerkleTree._TrimNode | def _TrimNode(node, index, depth, flags):
"""
Internal helper method to trim a node.
Args:
node (MerkleTreeNode):
index (int): flag index.
depth (int): node tree depth to start trim from.
flags (bytearray): of left/right pairs. 1 byte for the left... | python | def _TrimNode(node, index, depth, flags):
"""
Internal helper method to trim a node.
Args:
node (MerkleTreeNode):
index (int): flag index.
depth (int): node tree depth to start trim from.
flags (bytearray): of left/right pairs. 1 byte for the left... | [
"def",
"_TrimNode",
"(",
"node",
",",
"index",
",",
"depth",
",",
"flags",
")",
":",
"if",
"depth",
"==",
"1",
"or",
"node",
".",
"LeftChild",
"is",
"None",
":",
"return",
"if",
"depth",
"==",
"2",
":",
"if",
"not",
"flags",
"[",
"index",
"*",
"2... | Internal helper method to trim a node.
Args:
node (MerkleTreeNode):
index (int): flag index.
depth (int): node tree depth to start trim from.
flags (bytearray): of left/right pairs. 1 byte for the left node, 1 byte for the right node.
... | [
"Internal",
"helper",
"method",
"to",
"trim",
"a",
"node",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/MerkleTree.py#L169-L195 |
2,379 | CityOfZion/neo-python-core | neocore/Cryptography/Helper.py | double_sha256 | def double_sha256(ba):
"""
Perform two SHA256 operations on the input.
Args:
ba (bytes): data to hash.
Returns:
str: hash as a double digit hex string.
"""
d1 = hashlib.sha256(ba)
d2 = hashlib.sha256()
d1.hexdigest()
d2.update(d1.digest())
return d2.hexdigest() | python | def double_sha256(ba):
"""
Perform two SHA256 operations on the input.
Args:
ba (bytes): data to hash.
Returns:
str: hash as a double digit hex string.
"""
d1 = hashlib.sha256(ba)
d2 = hashlib.sha256()
d1.hexdigest()
d2.update(d1.digest())
return d2.hexdigest() | [
"def",
"double_sha256",
"(",
"ba",
")",
":",
"d1",
"=",
"hashlib",
".",
"sha256",
"(",
"ba",
")",
"d2",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"d1",
".",
"hexdigest",
"(",
")",
"d2",
".",
"update",
"(",
"d1",
".",
"digest",
"(",
")",
")",
"re... | Perform two SHA256 operations on the input.
Args:
ba (bytes): data to hash.
Returns:
str: hash as a double digit hex string. | [
"Perform",
"two",
"SHA256",
"operations",
"on",
"the",
"input",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L28-L42 |
2,380 | CityOfZion/neo-python-core | neocore/Cryptography/Helper.py | scripthash_to_address | def scripthash_to_address(scripthash):
"""
Convert a script hash to a public address.
Args:
scripthash (bytes):
Returns:
str: base58 encoded string representing the wallet address.
"""
sb = bytearray([ADDRESS_VERSION]) + scripthash
c256 = bin_dbl_sha256(sb)[0:4]
outb = ... | python | def scripthash_to_address(scripthash):
"""
Convert a script hash to a public address.
Args:
scripthash (bytes):
Returns:
str: base58 encoded string representing the wallet address.
"""
sb = bytearray([ADDRESS_VERSION]) + scripthash
c256 = bin_dbl_sha256(sb)[0:4]
outb = ... | [
"def",
"scripthash_to_address",
"(",
"scripthash",
")",
":",
"sb",
"=",
"bytearray",
"(",
"[",
"ADDRESS_VERSION",
"]",
")",
"+",
"scripthash",
"c256",
"=",
"bin_dbl_sha256",
"(",
"sb",
")",
"[",
"0",
":",
"4",
"]",
"outb",
"=",
"sb",
"+",
"bytearray",
... | Convert a script hash to a public address.
Args:
scripthash (bytes):
Returns:
str: base58 encoded string representing the wallet address. | [
"Convert",
"a",
"script",
"hash",
"to",
"a",
"public",
"address",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L71-L84 |
2,381 | CityOfZion/neo-python-core | neocore/Cryptography/Helper.py | base256_encode | def base256_encode(n, minwidth=0): # int/long to byte array
"""
Encode the input with base256.
Args:
n (int): input value.
minwidth: minimum return value length.
Raises:
ValueError: if a negative number is provided.
Returns:
bytearray:
"""
if n > 0:
... | python | def base256_encode(n, minwidth=0): # int/long to byte array
"""
Encode the input with base256.
Args:
n (int): input value.
minwidth: minimum return value length.
Raises:
ValueError: if a negative number is provided.
Returns:
bytearray:
"""
if n > 0:
... | [
"def",
"base256_encode",
"(",
"n",
",",
"minwidth",
"=",
"0",
")",
":",
"# int/long to byte array",
"if",
"n",
">",
"0",
":",
"arr",
"=",
"[",
"]",
"while",
"n",
":",
"n",
",",
"rem",
"=",
"divmod",
"(",
"n",
",",
"256",
")",
"arr",
".",
"append"... | Encode the input with base256.
Args:
n (int): input value.
minwidth: minimum return value length.
Raises:
ValueError: if a negative number is provided.
Returns:
bytearray: | [
"Encode",
"the",
"input",
"with",
"base256",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L141-L171 |
2,382 | CityOfZion/neo-python-core | neocore/Cryptography/Helper.py | xor_bytes | def xor_bytes(a, b):
"""
XOR on two bytes objects
Args:
a (bytes): object 1
b (bytes): object 2
Returns:
bytes: The XOR result
"""
assert isinstance(a, bytes)
assert isinstance(b, bytes)
assert len(a) == len(b)
res = bytearray()
for i in range(len(a)):
... | python | def xor_bytes(a, b):
"""
XOR on two bytes objects
Args:
a (bytes): object 1
b (bytes): object 2
Returns:
bytes: The XOR result
"""
assert isinstance(a, bytes)
assert isinstance(b, bytes)
assert len(a) == len(b)
res = bytearray()
for i in range(len(a)):
... | [
"def",
"xor_bytes",
"(",
"a",
",",
"b",
")",
":",
"assert",
"isinstance",
"(",
"a",
",",
"bytes",
")",
"assert",
"isinstance",
"(",
"b",
",",
"bytes",
")",
"assert",
"len",
"(",
"a",
")",
"==",
"len",
"(",
"b",
")",
"res",
"=",
"bytearray",
"(",
... | XOR on two bytes objects
Args:
a (bytes): object 1
b (bytes): object 2
Returns:
bytes: The XOR result | [
"XOR",
"on",
"two",
"bytes",
"objects"
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/Helper.py#L174-L191 |
2,383 | CityOfZion/neo-python-core | neocore/IO/BinaryWriter.py | BinaryWriter.WriteBytes | def WriteBytes(self, value, unhex=True):
"""
Write a `bytes` type to the stream.
Args:
value (bytes): array of bytes to write to the stream.
unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb'
Returns:
... | python | def WriteBytes(self, value, unhex=True):
"""
Write a `bytes` type to the stream.
Args:
value (bytes): array of bytes to write to the stream.
unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb'
Returns:
... | [
"def",
"WriteBytes",
"(",
"self",
",",
"value",
",",
"unhex",
"=",
"True",
")",
":",
"if",
"unhex",
":",
"try",
":",
"value",
"=",
"binascii",
".",
"unhexlify",
"(",
"value",
")",
"except",
"binascii",
".",
"Error",
":",
"pass",
"return",
"self",
"."... | Write a `bytes` type to the stream.
Args:
value (bytes): array of bytes to write to the stream.
unhex (bool): (Default) True. Set to unhexlify the stream. Use when the bytes are not raw bytes; i.e. b'aabb'
Returns:
int: the number of bytes written. | [
"Write",
"a",
"bytes",
"type",
"to",
"the",
"stream",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L88-L104 |
2,384 | CityOfZion/neo-python-core | neocore/IO/BinaryWriter.py | BinaryWriter.WriteUInt160 | def WriteUInt160(self, value):
"""
Write a UInt160 type to the stream.
Args:
value (UInt160):
Raises:
Exception: when `value` is not of neocore.UInt160 type.
"""
if type(value) is UInt160:
value.Serialize(self)
else:
... | python | def WriteUInt160(self, value):
"""
Write a UInt160 type to the stream.
Args:
value (UInt160):
Raises:
Exception: when `value` is not of neocore.UInt160 type.
"""
if type(value) is UInt160:
value.Serialize(self)
else:
... | [
"def",
"WriteUInt160",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"UInt160",
":",
"value",
".",
"Serialize",
"(",
"self",
")",
"else",
":",
"raise",
"Exception",
"(",
"\"value must be UInt160 instance \"",
")"
] | Write a UInt160 type to the stream.
Args:
value (UInt160):
Raises:
Exception: when `value` is not of neocore.UInt160 type. | [
"Write",
"a",
"UInt160",
"type",
"to",
"the",
"stream",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L274-L287 |
2,385 | CityOfZion/neo-python-core | neocore/IO/BinaryWriter.py | BinaryWriter.WriteUInt256 | def WriteUInt256(self, value):
"""
Write a UInt256 type to the stream.
Args:
value (UInt256):
Raises:
Exception: when `value` is not of neocore.UInt256 type.
"""
if type(value) is UInt256:
value.Serialize(self)
else:
... | python | def WriteUInt256(self, value):
"""
Write a UInt256 type to the stream.
Args:
value (UInt256):
Raises:
Exception: when `value` is not of neocore.UInt256 type.
"""
if type(value) is UInt256:
value.Serialize(self)
else:
... | [
"def",
"WriteUInt256",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"UInt256",
":",
"value",
".",
"Serialize",
"(",
"self",
")",
"else",
":",
"raise",
"Exception",
"(",
"\"Cannot write value that is not UInt256\"",
")"
] | Write a UInt256 type to the stream.
Args:
value (UInt256):
Raises:
Exception: when `value` is not of neocore.UInt256 type. | [
"Write",
"a",
"UInt256",
"type",
"to",
"the",
"stream",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L289-L302 |
2,386 | CityOfZion/neo-python-core | neocore/IO/BinaryWriter.py | BinaryWriter.Write2000256List | def Write2000256List(self, arr):
"""
Write an array of 64 byte items to the stream.
Args:
arr (list): a list of 2000 items of 64 bytes in size.
"""
for item in arr:
ba = bytearray(binascii.unhexlify(item))
ba.reverse()
self.WriteBy... | python | def Write2000256List(self, arr):
"""
Write an array of 64 byte items to the stream.
Args:
arr (list): a list of 2000 items of 64 bytes in size.
"""
for item in arr:
ba = bytearray(binascii.unhexlify(item))
ba.reverse()
self.WriteBy... | [
"def",
"Write2000256List",
"(",
"self",
",",
"arr",
")",
":",
"for",
"item",
"in",
"arr",
":",
"ba",
"=",
"bytearray",
"(",
"binascii",
".",
"unhexlify",
"(",
"item",
")",
")",
"ba",
".",
"reverse",
"(",
")",
"self",
".",
"WriteBytes",
"(",
"ba",
"... | Write an array of 64 byte items to the stream.
Args:
arr (list): a list of 2000 items of 64 bytes in size. | [
"Write",
"an",
"array",
"of",
"64",
"byte",
"items",
"to",
"the",
"stream",
"."
] | 786c02cc2f41712d70b1f064ae3d67f86167107f | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/IO/BinaryWriter.py#L410-L420 |
2,387 | OTA-Insight/djangosaml2idp | djangosaml2idp/processors.py | BaseProcessor.get_user_id | def get_user_id(self, user):
""" Get identifier for a user. Take the one defined in settings.SAML_IDP_DJANGO_USERNAME_FIELD first, if not set
use the USERNAME_FIELD property which is set on the user Model. This defaults to the user.username field.
"""
user_field = getattr(settings, '... | python | def get_user_id(self, user):
""" Get identifier for a user. Take the one defined in settings.SAML_IDP_DJANGO_USERNAME_FIELD first, if not set
use the USERNAME_FIELD property which is set on the user Model. This defaults to the user.username field.
"""
user_field = getattr(settings, '... | [
"def",
"get_user_id",
"(",
"self",
",",
"user",
")",
":",
"user_field",
"=",
"getattr",
"(",
"settings",
",",
"'SAML_IDP_DJANGO_USERNAME_FIELD'",
",",
"None",
")",
"or",
"getattr",
"(",
"user",
",",
"'USERNAME_FIELD'",
",",
"'username'",
")",
"return",
"str",
... | Get identifier for a user. Take the one defined in settings.SAML_IDP_DJANGO_USERNAME_FIELD first, if not set
use the USERNAME_FIELD property which is set on the user Model. This defaults to the user.username field. | [
"Get",
"identifier",
"for",
"a",
"user",
".",
"Take",
"the",
"one",
"defined",
"in",
"settings",
".",
"SAML_IDP_DJANGO_USERNAME_FIELD",
"first",
"if",
"not",
"set",
"use",
"the",
"USERNAME_FIELD",
"property",
"which",
"is",
"set",
"on",
"the",
"user",
"Model",... | 8a238063da55bf4823bdc2192168171767c4e056 | https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/processors.py#L22-L28 |
2,388 | OTA-Insight/djangosaml2idp | djangosaml2idp/processors.py | BaseProcessor.create_identity | def create_identity(self, user, sp_mapping, **extra_config):
""" Generate an identity dictionary of the user based on the given mapping of desired user attributes by the SP
"""
return {
out_attr: getattr(user, user_attr)
for user_attr, out_attr in sp_mapping.items()
... | python | def create_identity(self, user, sp_mapping, **extra_config):
""" Generate an identity dictionary of the user based on the given mapping of desired user attributes by the SP
"""
return {
out_attr: getattr(user, user_attr)
for user_attr, out_attr in sp_mapping.items()
... | [
"def",
"create_identity",
"(",
"self",
",",
"user",
",",
"sp_mapping",
",",
"*",
"*",
"extra_config",
")",
":",
"return",
"{",
"out_attr",
":",
"getattr",
"(",
"user",
",",
"user_attr",
")",
"for",
"user_attr",
",",
"out_attr",
"in",
"sp_mapping",
".",
"... | Generate an identity dictionary of the user based on the given mapping of desired user attributes by the SP | [
"Generate",
"an",
"identity",
"dictionary",
"of",
"the",
"user",
"based",
"on",
"the",
"given",
"mapping",
"of",
"desired",
"user",
"attributes",
"by",
"the",
"SP"
] | 8a238063da55bf4823bdc2192168171767c4e056 | https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/processors.py#L30-L38 |
2,389 | OTA-Insight/djangosaml2idp | djangosaml2idp/views.py | sso_entry | def sso_entry(request):
""" Entrypoint view for SSO. Gathers the parameters from the HTTP request, stores them in the session
and redirects the requester to the login_process view.
"""
if request.method == 'POST':
passed_data = request.POST
binding = BINDING_HTTP_POST
else:
... | python | def sso_entry(request):
""" Entrypoint view for SSO. Gathers the parameters from the HTTP request, stores them in the session
and redirects the requester to the login_process view.
"""
if request.method == 'POST':
passed_data = request.POST
binding = BINDING_HTTP_POST
else:
... | [
"def",
"sso_entry",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"passed_data",
"=",
"request",
".",
"POST",
"binding",
"=",
"BINDING_HTTP_POST",
"else",
":",
"passed_data",
"=",
"request",
".",
"GET",
"binding",
"=",
"BIN... | Entrypoint view for SSO. Gathers the parameters from the HTTP request, stores them in the session
and redirects the requester to the login_process view. | [
"Entrypoint",
"view",
"for",
"SSO",
".",
"Gathers",
"the",
"parameters",
"from",
"the",
"HTTP",
"request",
"stores",
"them",
"in",
"the",
"session",
"and",
"redirects",
"the",
"requester",
"to",
"the",
"login_process",
"view",
"."
] | 8a238063da55bf4823bdc2192168171767c4e056 | https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L41-L63 |
2,390 | OTA-Insight/djangosaml2idp | djangosaml2idp/views.py | metadata | def metadata(request):
""" Returns an XML with the SAML 2.0 metadata for this Idp.
The metadata is constructed on-the-fly based on the config dict in the django settings.
"""
conf = IdPConfig()
conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG))
metadata = entity_descriptor(conf)
return H... | python | def metadata(request):
""" Returns an XML with the SAML 2.0 metadata for this Idp.
The metadata is constructed on-the-fly based on the config dict in the django settings.
"""
conf = IdPConfig()
conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG))
metadata = entity_descriptor(conf)
return H... | [
"def",
"metadata",
"(",
"request",
")",
":",
"conf",
"=",
"IdPConfig",
"(",
")",
"conf",
".",
"load",
"(",
"copy",
".",
"deepcopy",
"(",
"settings",
".",
"SAML_IDP_CONFIG",
")",
")",
"metadata",
"=",
"entity_descriptor",
"(",
"conf",
")",
"return",
"Http... | Returns an XML with the SAML 2.0 metadata for this Idp.
The metadata is constructed on-the-fly based on the config dict in the django settings. | [
"Returns",
"an",
"XML",
"with",
"the",
"SAML",
"2",
".",
"0",
"metadata",
"for",
"this",
"Idp",
".",
"The",
"metadata",
"is",
"constructed",
"on",
"-",
"the",
"-",
"fly",
"based",
"on",
"the",
"config",
"dict",
"in",
"the",
"django",
"settings",
"."
] | 8a238063da55bf4823bdc2192168171767c4e056 | https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L284-L291 |
2,391 | OTA-Insight/djangosaml2idp | djangosaml2idp/views.py | IdPHandlerViewMixin.dispatch | def dispatch(self, request, *args, **kwargs):
""" Construct IDP server with config from settings dict
"""
conf = IdPConfig()
try:
conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG))
self.IDP = Server(config=conf)
except Exception as e:
return se... | python | def dispatch(self, request, *args, **kwargs):
""" Construct IDP server with config from settings dict
"""
conf = IdPConfig()
try:
conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG))
self.IDP = Server(config=conf)
except Exception as e:
return se... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"conf",
"=",
"IdPConfig",
"(",
")",
"try",
":",
"conf",
".",
"load",
"(",
"copy",
".",
"deepcopy",
"(",
"settings",
".",
"SAML_IDP_CONFIG",
")",
")... | Construct IDP server with config from settings dict | [
"Construct",
"IDP",
"server",
"with",
"config",
"from",
"settings",
"dict"
] | 8a238063da55bf4823bdc2192168171767c4e056 | https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L74-L83 |
2,392 | OTA-Insight/djangosaml2idp | djangosaml2idp/views.py | IdPHandlerViewMixin.get_processor | def get_processor(self, entity_id, sp_config):
""" Instantiate user-specified processor or default to an all-access base processor.
Raises an exception if the configured processor class can not be found or initialized.
"""
processor_string = sp_config.get('processor', None)
i... | python | def get_processor(self, entity_id, sp_config):
""" Instantiate user-specified processor or default to an all-access base processor.
Raises an exception if the configured processor class can not be found or initialized.
"""
processor_string = sp_config.get('processor', None)
i... | [
"def",
"get_processor",
"(",
"self",
",",
"entity_id",
",",
"sp_config",
")",
":",
"processor_string",
"=",
"sp_config",
".",
"get",
"(",
"'processor'",
",",
"None",
")",
"if",
"processor_string",
":",
"try",
":",
"return",
"import_string",
"(",
"processor_str... | Instantiate user-specified processor or default to an all-access base processor.
Raises an exception if the configured processor class can not be found or initialized. | [
"Instantiate",
"user",
"-",
"specified",
"processor",
"or",
"default",
"to",
"an",
"all",
"-",
"access",
"base",
"processor",
".",
"Raises",
"an",
"exception",
"if",
"the",
"configured",
"processor",
"class",
"can",
"not",
"be",
"found",
"or",
"initialized",
... | 8a238063da55bf4823bdc2192168171767c4e056 | https://github.com/OTA-Insight/djangosaml2idp/blob/8a238063da55bf4823bdc2192168171767c4e056/djangosaml2idp/views.py#L85-L96 |
2,393 | MartijnBraam/python-isc-dhcp-leases | isc_dhcp_leases/iscdhcpleases.py | IscDhcpLeases.get | def get(self, include_backups=False):
"""
Parse the lease file and return a list of Lease instances.
"""
leases = []
with open(self.filename) if not self.gzip else gzip.open(self.filename) as lease_file:
lease_data = lease_file.read()
if self.gzip:
... | python | def get(self, include_backups=False):
"""
Parse the lease file and return a list of Lease instances.
"""
leases = []
with open(self.filename) if not self.gzip else gzip.open(self.filename) as lease_file:
lease_data = lease_file.read()
if self.gzip:
... | [
"def",
"get",
"(",
"self",
",",
"include_backups",
"=",
"False",
")",
":",
"leases",
"=",
"[",
"]",
"with",
"open",
"(",
"self",
".",
"filename",
")",
"if",
"not",
"self",
".",
"gzip",
"else",
"gzip",
".",
"open",
"(",
"self",
".",
"filename",
")",... | Parse the lease file and return a list of Lease instances. | [
"Parse",
"the",
"lease",
"file",
"and",
"return",
"a",
"list",
"of",
"Lease",
"instances",
"."
] | e96c00e31f3a52c01ef98193577d614d08a93285 | https://github.com/MartijnBraam/python-isc-dhcp-leases/blob/e96c00e31f3a52c01ef98193577d614d08a93285/isc_dhcp_leases/iscdhcpleases.py#L115-L151 |
2,394 | MartijnBraam/python-isc-dhcp-leases | isc_dhcp_leases/iscdhcpleases.py | IscDhcpLeases.get_current | def get_current(self):
"""
Parse the lease file and return a dict of active and valid Lease instances.
The key for this dict is the ethernet address of the lease.
"""
all_leases = self.get()
leases = {}
for lease in all_leases:
if lease.valid and lease... | python | def get_current(self):
"""
Parse the lease file and return a dict of active and valid Lease instances.
The key for this dict is the ethernet address of the lease.
"""
all_leases = self.get()
leases = {}
for lease in all_leases:
if lease.valid and lease... | [
"def",
"get_current",
"(",
"self",
")",
":",
"all_leases",
"=",
"self",
".",
"get",
"(",
")",
"leases",
"=",
"{",
"}",
"for",
"lease",
"in",
"all_leases",
":",
"if",
"lease",
".",
"valid",
"and",
"lease",
".",
"active",
":",
"if",
"type",
"(",
"lea... | Parse the lease file and return a dict of active and valid Lease instances.
The key for this dict is the ethernet address of the lease. | [
"Parse",
"the",
"lease",
"file",
"and",
"return",
"a",
"dict",
"of",
"active",
"and",
"valid",
"Lease",
"instances",
".",
"The",
"key",
"for",
"this",
"dict",
"is",
"the",
"ethernet",
"address",
"of",
"the",
"lease",
"."
] | e96c00e31f3a52c01ef98193577d614d08a93285 | https://github.com/MartijnBraam/python-isc-dhcp-leases/blob/e96c00e31f3a52c01ef98193577d614d08a93285/isc_dhcp_leases/iscdhcpleases.py#L153-L166 |
2,395 | crate/crash | src/crate/crash/layout.py | create_layout | def create_layout(lexer=None,
reserve_space_for_menu=8,
get_prompt_tokens=None,
get_bottom_toolbar_tokens=None,
extra_input_processors=None, multiline=False,
wrap_lines=True):
"""
Creates a custom `Layout` for the Crash in... | python | def create_layout(lexer=None,
reserve_space_for_menu=8,
get_prompt_tokens=None,
get_bottom_toolbar_tokens=None,
extra_input_processors=None, multiline=False,
wrap_lines=True):
"""
Creates a custom `Layout` for the Crash in... | [
"def",
"create_layout",
"(",
"lexer",
"=",
"None",
",",
"reserve_space_for_menu",
"=",
"8",
",",
"get_prompt_tokens",
"=",
"None",
",",
"get_bottom_toolbar_tokens",
"=",
"None",
",",
"extra_input_processors",
"=",
"None",
",",
"multiline",
"=",
"False",
",",
"wr... | Creates a custom `Layout` for the Crash input REPL
This layout includes:
* a bottom left-aligned session toolbar container
* a bottom right-aligned side-bar container
+-------------------------------------------+
| cr> select 1; |
| ... | [
"Creates",
"a",
"custom",
"Layout",
"for",
"the",
"Crash",
"input",
"REPL"
] | 32d3ddc78fd2f7848ed2b99d9cd8889e322528d9 | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/layout.py#L39-L157 |
2,396 | crate/crash | src/crate/crash/command.py | _parse_statements | def _parse_statements(lines):
"""Return a generator of statements
Args: A list of strings that can contain one or more statements.
Statements are separated using ';' at the end of a line
Everything after the last ';' will be treated as the last statement.
>>> list(_parse_statements(['s... | python | def _parse_statements(lines):
"""Return a generator of statements
Args: A list of strings that can contain one or more statements.
Statements are separated using ';' at the end of a line
Everything after the last ';' will be treated as the last statement.
>>> list(_parse_statements(['s... | [
"def",
"_parse_statements",
"(",
"lines",
")",
":",
"lines",
"=",
"(",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"lines",
"if",
"l",
")",
"lines",
"=",
"(",
"l",
"for",
"l",
"in",
"lines",
"if",
"l",
"and",
"not",
"l",
".",
"startswith",
"... | Return a generator of statements
Args: A list of strings that can contain one or more statements.
Statements are separated using ';' at the end of a line
Everything after the last ';' will be treated as the last statement.
>>> list(_parse_statements(['select * from ', 't1;', 'select name']... | [
"Return",
"a",
"generator",
"of",
"statements"
] | 32d3ddc78fd2f7848ed2b99d9cd8889e322528d9 | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/command.py#L191-L213 |
2,397 | crate/crash | src/crate/crash/command.py | CrateShell._show_tables | def _show_tables(self, *args):
""" print the existing tables within the 'doc' schema """
v = self.connection.lowest_server_version
schema_name = \
"table_schema" if v >= TABLE_SCHEMA_MIN_VERSION else "schema_name"
table_filter = \
" AND table_type = 'BASE TABLE'" ... | python | def _show_tables(self, *args):
""" print the existing tables within the 'doc' schema """
v = self.connection.lowest_server_version
schema_name = \
"table_schema" if v >= TABLE_SCHEMA_MIN_VERSION else "schema_name"
table_filter = \
" AND table_type = 'BASE TABLE'" ... | [
"def",
"_show_tables",
"(",
"self",
",",
"*",
"args",
")",
":",
"v",
"=",
"self",
".",
"connection",
".",
"lowest_server_version",
"schema_name",
"=",
"\"table_schema\"",
"if",
"v",
">=",
"TABLE_SCHEMA_MIN_VERSION",
"else",
"\"schema_name\"",
"table_filter",
"=",
... | print the existing tables within the 'doc' schema | [
"print",
"the",
"existing",
"tables",
"within",
"the",
"doc",
"schema"
] | 32d3ddc78fd2f7848ed2b99d9cd8889e322528d9 | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/command.py#L321-L333 |
2,398 | crate/crash | src/crate/crash/sysinfo.py | SysInfoCommand.execute | def execute(self):
""" print system and cluster info """
if not self.cmd.is_conn_available():
return
if self.cmd.connection.lowest_server_version >= SYSINFO_MIN_VERSION:
success, rows = self._sys_info()
self.cmd.exit_code = self.cmd.exit_code or int(not succes... | python | def execute(self):
""" print system and cluster info """
if not self.cmd.is_conn_available():
return
if self.cmd.connection.lowest_server_version >= SYSINFO_MIN_VERSION:
success, rows = self._sys_info()
self.cmd.exit_code = self.cmd.exit_code or int(not succes... | [
"def",
"execute",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"cmd",
".",
"is_conn_available",
"(",
")",
":",
"return",
"if",
"self",
".",
"cmd",
".",
"connection",
".",
"lowest_server_version",
">=",
"SYSINFO_MIN_VERSION",
":",
"success",
",",
"rows"... | print system and cluster info | [
"print",
"system",
"and",
"cluster",
"info"
] | 32d3ddc78fd2f7848ed2b99d9cd8889e322528d9 | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/sysinfo.py#L72-L87 |
2,399 | crate/crash | src/crate/crash/config.py | Configuration.bwc_bool_transform_from | def bwc_bool_transform_from(cls, x):
"""
Read boolean values from old config files correctly
and interpret 'True' and 'False' as correct booleans.
"""
if x.lower() == 'true':
return True
elif x.lower() == 'false':
return False
return bool(i... | python | def bwc_bool_transform_from(cls, x):
"""
Read boolean values from old config files correctly
and interpret 'True' and 'False' as correct booleans.
"""
if x.lower() == 'true':
return True
elif x.lower() == 'false':
return False
return bool(i... | [
"def",
"bwc_bool_transform_from",
"(",
"cls",
",",
"x",
")",
":",
"if",
"x",
".",
"lower",
"(",
")",
"==",
"'true'",
":",
"return",
"True",
"elif",
"x",
".",
"lower",
"(",
")",
"==",
"'false'",
":",
"return",
"False",
"return",
"bool",
"(",
"int",
... | Read boolean values from old config files correctly
and interpret 'True' and 'False' as correct booleans. | [
"Read",
"boolean",
"values",
"from",
"old",
"config",
"files",
"correctly",
"and",
"interpret",
"True",
"and",
"False",
"as",
"correct",
"booleans",
"."
] | 32d3ddc78fd2f7848ed2b99d9cd8889e322528d9 | https://github.com/crate/crash/blob/32d3ddc78fd2f7848ed2b99d9cd8889e322528d9/src/crate/crash/config.py#L44-L53 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.