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
42,100
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.deletegroup
def deletegroup(self, group_id): """ Deletes an group by ID :param group_id: id of the group to delete :return: True if it deleted, False if it couldn't. False could happen for several reasons, but there isn't a good way of differentiating them """ request = requests.del...
python
def deletegroup(self, group_id): """ Deletes an group by ID :param group_id: id of the group to delete :return: True if it deleted, False if it couldn't. False could happen for several reasons, but there isn't a good way of differentiating them """ request = requests.del...
[ "def", "deletegroup", "(", "self", ",", "group_id", ")", ":", "request", "=", "requests", ".", "delete", "(", "'{0}/{1}'", ".", "format", "(", "self", ".", "groups_url", ",", "group_id", ")", ",", "headers", "=", "self", ".", "headers", ",", "verify", ...
Deletes an group by ID :param group_id: id of the group to delete :return: True if it deleted, False if it couldn't. False could happen for several reasons, but there isn't a good way of differentiating them
[ "Deletes", "an", "group", "by", "ID" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1682-L1693
42,101
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.getgroupmembers
def getgroupmembers(self, group_id, page=1, per_page=20): """ Lists the members of a given group id :param group_id: the group id :param page: which page to return (default is 1) :param per_page: number of items to return per page (default is 20) :return: the group's mem...
python
def getgroupmembers(self, group_id, page=1, per_page=20): """ Lists the members of a given group id :param group_id: the group id :param page: which page to return (default is 1) :param per_page: number of items to return per page (default is 20) :return: the group's mem...
[ "def", "getgroupmembers", "(", "self", ",", "group_id", ",", "page", "=", "1", ",", "per_page", "=", "20", ")", ":", "data", "=", "{", "'page'", ":", "page", ",", "'per_page'", ":", "per_page", "}", "request", "=", "requests", ".", "get", "(", "'{0}/...
Lists the members of a given group id :param group_id: the group id :param page: which page to return (default is 1) :param per_page: number of items to return per page (default is 20) :return: the group's members
[ "Lists", "the", "members", "of", "a", "given", "group", "id" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1695-L1713
42,102
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.deletegroupmember
def deletegroupmember(self, group_id, user_id): """ Delete a group member :param group_id: group id to remove the member from :param user_id: user id :return: always true """ request = requests.delete( '{0}/{1}/members/{2}'.format(self.groups_url, gro...
python
def deletegroupmember(self, group_id, user_id): """ Delete a group member :param group_id: group id to remove the member from :param user_id: user id :return: always true """ request = requests.delete( '{0}/{1}/members/{2}'.format(self.groups_url, gro...
[ "def", "deletegroupmember", "(", "self", ",", "group_id", ",", "user_id", ")", ":", "request", "=", "requests", ".", "delete", "(", "'{0}/{1}/members/{2}'", ".", "format", "(", "self", ".", "groups_url", ",", "group_id", ",", "user_id", ")", ",", "headers", ...
Delete a group member :param group_id: group id to remove the member from :param user_id: user id :return: always true
[ "Delete", "a", "group", "member" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1776-L1789
42,103
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.addldapgrouplink
def addldapgrouplink(self, group_id, cn, group_access, provider): """ Add LDAP group link :param id: The ID of a group :param cn: The CN of a LDAP group :param group_access: Minimum access level for members of the LDAP group :param provider: LDAP provider for the LDAP gr...
python
def addldapgrouplink(self, group_id, cn, group_access, provider): """ Add LDAP group link :param id: The ID of a group :param cn: The CN of a LDAP group :param group_access: Minimum access level for members of the LDAP group :param provider: LDAP provider for the LDAP gr...
[ "def", "addldapgrouplink", "(", "self", ",", "group_id", ",", "cn", ",", "group_access", ",", "provider", ")", ":", "data", "=", "{", "'id'", ":", "group_id", ",", "'cn'", ":", "cn", ",", "'group_access'", ":", "group_access", ",", "'provider'", ":", "pr...
Add LDAP group link :param id: The ID of a group :param cn: The CN of a LDAP group :param group_access: Minimum access level for members of the LDAP group :param provider: LDAP provider for the LDAP group (when using several providers) :return: True if success
[ "Add", "LDAP", "group", "link" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1791-L1807
42,104
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.createissuewallnote
def createissuewallnote(self, project_id, issue_id, content): """Create a new note :param project_id: Project ID :param issue_id: Issue ID :param content: Contents :return: Json or False """ data = {'body': content} request = requests.post( '...
python
def createissuewallnote(self, project_id, issue_id, content): """Create a new note :param project_id: Project ID :param issue_id: Issue ID :param content: Contents :return: Json or False """ data = {'body': content} request = requests.post( '...
[ "def", "createissuewallnote", "(", "self", ",", "project_id", ",", "issue_id", ",", "content", ")", ":", "data", "=", "{", "'body'", ":", "content", "}", "request", "=", "requests", ".", "post", "(", "'{0}/{1}/issues/{2}/notes'", ".", "format", "(", "self", ...
Create a new note :param project_id: Project ID :param issue_id: Issue ID :param content: Contents :return: Json or False
[ "Create", "a", "new", "note" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1864-L1880
42,105
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.createfile
def createfile(self, project_id, file_path, branch_name, encoding, content, commit_message): """ Creates a new file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param con...
python
def createfile(self, project_id, file_path, branch_name, encoding, content, commit_message): """ Creates a new file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param con...
[ "def", "createfile", "(", "self", ",", "project_id", ",", "file_path", ",", "branch_name", ",", "encoding", ",", "content", ",", "commit_message", ")", ":", "data", "=", "{", "'file_path'", ":", "file_path", ",", "'branch_name'", ":", "branch_name", ",", "'e...
Creates a new file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param content: File content :param commit_message: Commit message :return: true if success, false if not
[ "Creates", "a", "new", "file", "in", "the", "repository" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L1999-L2022
42,106
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.updatefile
def updatefile(self, project_id, file_path, branch_name, content, commit_message): """ Updates an existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param content...
python
def updatefile(self, project_id, file_path, branch_name, content, commit_message): """ Updates an existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param content...
[ "def", "updatefile", "(", "self", ",", "project_id", ",", "file_path", ",", "branch_name", ",", "content", ",", "commit_message", ")", ":", "data", "=", "{", "'file_path'", ":", "file_path", ",", "'branch_name'", ":", "branch_name", ",", "'content'", ":", "c...
Updates an existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param content: File content :param commit_message: Commit message :return: true if success, false if...
[ "Updates", "an", "existing", "file", "in", "the", "repository" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2024-L2046
42,107
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.getfile
def getfile(self, project_id, file_path, ref): """ Allows you to receive information about file in repository like name, size, content. Note that file content is Base64 encoded. :param project_id: project_id :param file_path: Full path to file. Ex. lib/class.rb :param re...
python
def getfile(self, project_id, file_path, ref): """ Allows you to receive information about file in repository like name, size, content. Note that file content is Base64 encoded. :param project_id: project_id :param file_path: Full path to file. Ex. lib/class.rb :param re...
[ "def", "getfile", "(", "self", ",", "project_id", ",", "file_path", ",", "ref", ")", ":", "data", "=", "{", "'file_path'", ":", "file_path", ",", "'ref'", ":", "ref", "}", "request", "=", "requests", ".", "get", "(", "'{0}/{1}/repository/files'", ".", "f...
Allows you to receive information about file in repository like name, size, content. Note that file content is Base64 encoded. :param project_id: project_id :param file_path: Full path to file. Ex. lib/class.rb :param ref: The name of branch, tag or commit :return:
[ "Allows", "you", "to", "receive", "information", "about", "file", "in", "repository", "like", "name", "size", "content", ".", "Note", "that", "file", "content", "is", "Base64", "encoded", "." ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2048-L2067
42,108
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.deletefile
def deletefile(self, project_id, file_path, branch_name, commit_message): """ Deletes existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param commit_message: Com...
python
def deletefile(self, project_id, file_path, branch_name, commit_message): """ Deletes existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param commit_message: Com...
[ "def", "deletefile", "(", "self", ",", "project_id", ",", "file_path", ",", "branch_name", ",", "commit_message", ")", ":", "data", "=", "{", "'file_path'", ":", "file_path", ",", "'branch_name'", ":", "branch_name", ",", "'commit_message'", ":", "commit_message...
Deletes existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param commit_message: Commit message :return: true if success, false if not
[ "Deletes", "existing", "file", "in", "the", "repository" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2069-L2089
42,109
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.setgitlabciservice
def setgitlabciservice(self, project_id, token, project_url): """ Set GitLab CI service for project :param project_id: project id :param token: CI project token :param project_url: CI project url :return: true if success, false if not """ data = {'token':...
python
def setgitlabciservice(self, project_id, token, project_url): """ Set GitLab CI service for project :param project_id: project id :param token: CI project token :param project_url: CI project url :return: true if success, false if not """ data = {'token':...
[ "def", "setgitlabciservice", "(", "self", ",", "project_id", ",", "token", ",", "project_url", ")", ":", "data", "=", "{", "'token'", ":", "token", ",", "'project_url'", ":", "project_url", "}", "request", "=", "requests", ".", "put", "(", "'{0}/{1}/services...
Set GitLab CI service for project :param project_id: project id :param token: CI project token :param project_url: CI project url :return: true if success, false if not
[ "Set", "GitLab", "CI", "service", "for", "project" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2091-L2106
42,110
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.deletegitlabciservice
def deletegitlabciservice(self, project_id, token, project_url): """ Delete GitLab CI service settings :param project_id: Project ID :param token: Token :param project_url: Project URL :return: true if success, false if not """ request = requests.delete( ...
python
def deletegitlabciservice(self, project_id, token, project_url): """ Delete GitLab CI service settings :param project_id: Project ID :param token: Token :param project_url: Project URL :return: true if success, false if not """ request = requests.delete( ...
[ "def", "deletegitlabciservice", "(", "self", ",", "project_id", ",", "token", ",", "project_url", ")", ":", "request", "=", "requests", ".", "delete", "(", "'{0}/{1}/services/gitlab-ci'", ".", "format", "(", "self", ".", "projects_url", ",", "project_id", ")", ...
Delete GitLab CI service settings :param project_id: Project ID :param token: Token :param project_url: Project URL :return: true if success, false if not
[ "Delete", "GitLab", "CI", "service", "settings" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2108-L2121
42,111
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.createlabel
def createlabel(self, project_id, name, color): """ Creates a new label for given repository with given name and color. :param project_id: The ID of a project :param name: The name of the label :param color: Color of the label given in 6-digit hex notation with leading '#' sign ...
python
def createlabel(self, project_id, name, color): """ Creates a new label for given repository with given name and color. :param project_id: The ID of a project :param name: The name of the label :param color: Color of the label given in 6-digit hex notation with leading '#' sign ...
[ "def", "createlabel", "(", "self", ",", "project_id", ",", "name", ",", "color", ")", ":", "data", "=", "{", "'name'", ":", "name", ",", "'color'", ":", "color", "}", "request", "=", "requests", ".", "post", "(", "'{0}/{1}/labels'", ".", "format", "(",...
Creates a new label for given repository with given name and color. :param project_id: The ID of a project :param name: The name of the label :param color: Color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) :return:
[ "Creates", "a", "new", "label", "for", "given", "repository", "with", "given", "name", "and", "color", "." ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2139-L2157
42,112
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.deletelabel
def deletelabel(self, project_id, name): """ Deletes a label given by its name. :param project_id: The ID of a project :param name: The name of the label :return: True if succeed """ data = {'name': name} request = requests.delete( '{0}/{1}/l...
python
def deletelabel(self, project_id, name): """ Deletes a label given by its name. :param project_id: The ID of a project :param name: The name of the label :return: True if succeed """ data = {'name': name} request = requests.delete( '{0}/{1}/l...
[ "def", "deletelabel", "(", "self", ",", "project_id", ",", "name", ")", ":", "data", "=", "{", "'name'", ":", "name", "}", "request", "=", "requests", ".", "delete", "(", "'{0}/{1}/labels'", ".", "format", "(", "self", ".", "projects_url", ",", "project_...
Deletes a label given by its name. :param project_id: The ID of a project :param name: The name of the label :return: True if succeed
[ "Deletes", "a", "label", "given", "by", "its", "name", "." ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2159-L2173
42,113
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.editlabel
def editlabel(self, project_id, name, new_name=None, color=None): """ Updates an existing label with new name or now color. At least one parameter is required, to update the label. :param project_id: The ID of a project :param name: The name of the label :return: True if...
python
def editlabel(self, project_id, name, new_name=None, color=None): """ Updates an existing label with new name or now color. At least one parameter is required, to update the label. :param project_id: The ID of a project :param name: The name of the label :return: True if...
[ "def", "editlabel", "(", "self", ",", "project_id", ",", "name", ",", "new_name", "=", "None", ",", "color", "=", "None", ")", ":", "data", "=", "{", "'name'", ":", "name", ",", "'new_name'", ":", "new_name", ",", "'color'", ":", "color", "}", "reque...
Updates an existing label with new name or now color. At least one parameter is required, to update the label. :param project_id: The ID of a project :param name: The name of the label :return: True if succeed
[ "Updates", "an", "existing", "label", "with", "new", "name", "or", "now", "color", ".", "At", "least", "one", "parameter", "is", "required", "to", "update", "the", "label", "." ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2175-L2193
42,114
pyapi-gitlab/pyapi-gitlab
gitlab/__init__.py
Gitlab.getnamespaces
def getnamespaces(self, search=None, page=1, per_page=20): """ Return a namespace list :param search: Optional search query :param page: Which page to return (default is 1) :param per_page: Number of items to return per page (default is 20) :return: returns a list of nam...
python
def getnamespaces(self, search=None, page=1, per_page=20): """ Return a namespace list :param search: Optional search query :param page: Which page to return (default is 1) :param per_page: Number of items to return per page (default is 20) :return: returns a list of nam...
[ "def", "getnamespaces", "(", "self", ",", "search", "=", "None", ",", "page", "=", "1", ",", "per_page", "=", "20", ")", ":", "data", "=", "{", "'page'", ":", "page", ",", "'per_page'", ":", "per_page", "}", "if", "search", ":", "data", "[", "'sear...
Return a namespace list :param search: Optional search query :param page: Which page to return (default is 1) :param per_page: Number of items to return per page (default is 20) :return: returns a list of namespaces, false if there is an error
[ "Return", "a", "namespace", "list" ]
f74b6fb5c13cecae9524997847e928905cc60acf
https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2195-L2215
42,115
HazardDede/argresolver
argresolver/utils.py
get_field_mro
def get_field_mro(cls, field_name): """Goes up the mro and looks for the specified field.""" res = set() if hasattr(cls, '__mro__'): for _class in inspect.getmro(cls): values_ = getattr(_class, field_name, None) if values_ is not None: res = res.union(set(make...
python
def get_field_mro(cls, field_name): """Goes up the mro and looks for the specified field.""" res = set() if hasattr(cls, '__mro__'): for _class in inspect.getmro(cls): values_ = getattr(_class, field_name, None) if values_ is not None: res = res.union(set(make...
[ "def", "get_field_mro", "(", "cls", ",", "field_name", ")", ":", "res", "=", "set", "(", ")", "if", "hasattr", "(", "cls", ",", "'__mro__'", ")", ":", "for", "_class", "in", "inspect", ".", "getmro", "(", "cls", ")", ":", "values_", "=", "getattr", ...
Goes up the mro and looks for the specified field.
[ "Goes", "up", "the", "mro", "and", "looks", "for", "the", "specified", "field", "." ]
b5801af01ae3926ed1289d80826fec92ce7facbc
https://github.com/HazardDede/argresolver/blob/b5801af01ae3926ed1289d80826fec92ce7facbc/argresolver/utils.py#L32-L40
42,116
Duke-GCB/lando-messaging
lando_messaging/workqueue.py
WorkQueueConnection.connect
def connect(self): """ Create internal connection to AMQP service. """ logging.info("Connecting to {} with user {}.".format(self.host, self.username)) credentials = pika.PlainCredentials(self.username, self.password) connection_params = pika.ConnectionParameters(host=self...
python
def connect(self): """ Create internal connection to AMQP service. """ logging.info("Connecting to {} with user {}.".format(self.host, self.username)) credentials = pika.PlainCredentials(self.username, self.password) connection_params = pika.ConnectionParameters(host=self...
[ "def", "connect", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Connecting to {} with user {}.\"", ".", "format", "(", "self", ".", "host", ",", "self", ".", "username", ")", ")", "credentials", "=", "pika", ".", "PlainCredentials", "(", "self", "...
Create internal connection to AMQP service.
[ "Create", "internal", "connection", "to", "AMQP", "service", "." ]
b90ccc79a874714e0776af8badf505bb2b56c0ec
https://github.com/Duke-GCB/lando-messaging/blob/b90ccc79a874714e0776af8badf505bb2b56c0ec/lando_messaging/workqueue.py#L52-L61
42,117
Duke-GCB/lando-messaging
lando_messaging/workqueue.py
WorkQueueConnection.close
def close(self): """ Close internal connection to AMQP if connected. """ if self.connection: logging.info("Closing connection to {}.".format(self.host)) self.connection.close() self.connection = None
python
def close(self): """ Close internal connection to AMQP if connected. """ if self.connection: logging.info("Closing connection to {}.".format(self.host)) self.connection.close() self.connection = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "connection", ":", "logging", ".", "info", "(", "\"Closing connection to {}.\"", ".", "format", "(", "self", ".", "host", ")", ")", "self", ".", "connection", ".", "close", "(", ")", "self", "."...
Close internal connection to AMQP if connected.
[ "Close", "internal", "connection", "to", "AMQP", "if", "connected", "." ]
b90ccc79a874714e0776af8badf505bb2b56c0ec
https://github.com/Duke-GCB/lando-messaging/blob/b90ccc79a874714e0776af8badf505bb2b56c0ec/lando_messaging/workqueue.py#L63-L70
42,118
Duke-GCB/lando-messaging
lando_messaging/workqueue.py
WorkQueueProcessor.process_messages_loop
def process_messages_loop(self): """ Processes incoming WorkRequest messages one at a time via functions specified by add_command. """ self.receiving_messages = True try: self.process_messages_loop_internal() except pika.exceptions.ConnectionClosed as ex: ...
python
def process_messages_loop(self): """ Processes incoming WorkRequest messages one at a time via functions specified by add_command. """ self.receiving_messages = True try: self.process_messages_loop_internal() except pika.exceptions.ConnectionClosed as ex: ...
[ "def", "process_messages_loop", "(", "self", ")", ":", "self", ".", "receiving_messages", "=", "True", "try", ":", "self", ".", "process_messages_loop_internal", "(", ")", "except", "pika", ".", "exceptions", ".", "ConnectionClosed", "as", "ex", ":", "logging", ...
Processes incoming WorkRequest messages one at a time via functions specified by add_command.
[ "Processes", "incoming", "WorkRequest", "messages", "one", "at", "a", "time", "via", "functions", "specified", "by", "add_command", "." ]
b90ccc79a874714e0776af8badf505bb2b56c0ec
https://github.com/Duke-GCB/lando-messaging/blob/b90ccc79a874714e0776af8badf505bb2b56c0ec/lando_messaging/workqueue.py#L251-L260
42,119
Duke-GCB/lando-messaging
lando_messaging/workqueue.py
WorkQueueProcessor.process_messages_loop_internal
def process_messages_loop_internal(self): """ Busy loop that processes incoming WorkRequest messages via functions specified by add_command. Terminates if a command runs shutdown method """ logging.info("Starting work queue loop.") self.connection.receive_loop_with_callba...
python
def process_messages_loop_internal(self): """ Busy loop that processes incoming WorkRequest messages via functions specified by add_command. Terminates if a command runs shutdown method """ logging.info("Starting work queue loop.") self.connection.receive_loop_with_callba...
[ "def", "process_messages_loop_internal", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Starting work queue loop.\"", ")", "self", ".", "connection", ".", "receive_loop_with_callback", "(", "self", ".", "queue_name", ",", "self", ".", "process_message", ")" ...
Busy loop that processes incoming WorkRequest messages via functions specified by add_command. Terminates if a command runs shutdown method
[ "Busy", "loop", "that", "processes", "incoming", "WorkRequest", "messages", "via", "functions", "specified", "by", "add_command", ".", "Terminates", "if", "a", "command", "runs", "shutdown", "method" ]
b90ccc79a874714e0776af8badf505bb2b56c0ec
https://github.com/Duke-GCB/lando-messaging/blob/b90ccc79a874714e0776af8badf505bb2b56c0ec/lando_messaging/workqueue.py#L262-L268
42,120
Duke-GCB/lando-messaging
lando_messaging/workqueue.py
DisconnectingWorkQueueProcessor.process_messages_loop_internal
def process_messages_loop_internal(self): """ Busy loop that processes incoming WorkRequest messages via functions specified by add_command. Disconnects while servicing a message, reconnects once finished processing a message Terminates if a command runs shutdown method """ ...
python
def process_messages_loop_internal(self): """ Busy loop that processes incoming WorkRequest messages via functions specified by add_command. Disconnects while servicing a message, reconnects once finished processing a message Terminates if a command runs shutdown method """ ...
[ "def", "process_messages_loop_internal", "(", "self", ")", ":", "while", "self", ".", "receiving_messages", ":", "# connect to AMQP server and listen for 1 message then disconnect", "self", ".", "work_request", "=", "None", "self", ".", "connection", ".", "receive_loop_with...
Busy loop that processes incoming WorkRequest messages via functions specified by add_command. Disconnects while servicing a message, reconnects once finished processing a message Terminates if a command runs shutdown method
[ "Busy", "loop", "that", "processes", "incoming", "WorkRequest", "messages", "via", "functions", "specified", "by", "add_command", ".", "Disconnects", "while", "servicing", "a", "message", "reconnects", "once", "finished", "processing", "a", "message", "Terminates", ...
b90ccc79a874714e0776af8badf505bb2b56c0ec
https://github.com/Duke-GCB/lando-messaging/blob/b90ccc79a874714e0776af8badf505bb2b56c0ec/lando_messaging/workqueue.py#L314-L325
42,121
Duke-GCB/lando-messaging
lando_messaging/workqueue.py
DisconnectingWorkQueueProcessor.save_work_request_and_close
def save_work_request_and_close(self, ch, method, properties, body): """ Save message body and close connection """ self.work_request = pickle.loads(body) ch.basic_ack(delivery_tag=method.delivery_tag) ch.stop_consuming() self.connection.close()
python
def save_work_request_and_close(self, ch, method, properties, body): """ Save message body and close connection """ self.work_request = pickle.loads(body) ch.basic_ack(delivery_tag=method.delivery_tag) ch.stop_consuming() self.connection.close()
[ "def", "save_work_request_and_close", "(", "self", ",", "ch", ",", "method", ",", "properties", ",", "body", ")", ":", "self", ".", "work_request", "=", "pickle", ".", "loads", "(", "body", ")", "ch", ".", "basic_ack", "(", "delivery_tag", "=", "method", ...
Save message body and close connection
[ "Save", "message", "body", "and", "close", "connection" ]
b90ccc79a874714e0776af8badf505bb2b56c0ec
https://github.com/Duke-GCB/lando-messaging/blob/b90ccc79a874714e0776af8badf505bb2b56c0ec/lando_messaging/workqueue.py#L327-L334
42,122
tBaxter/tango-photos
build/lib/photos/templatetags/gallery_tags.py
get_related_galleries
def get_related_galleries(gallery, count=5): """ Gets latest related galleries from same section as originating gallery. Count defaults to five but can be overridden. Usage: {% get_related_galleries gallery <10> %} """ # just get the first cat. If they assigned to more than one, tough try:...
python
def get_related_galleries(gallery, count=5): """ Gets latest related galleries from same section as originating gallery. Count defaults to five but can be overridden. Usage: {% get_related_galleries gallery <10> %} """ # just get the first cat. If they assigned to more than one, tough try:...
[ "def", "get_related_galleries", "(", "gallery", ",", "count", "=", "5", ")", ":", "# just get the first cat. If they assigned to more than one, tough", "try", ":", "cat", "=", "gallery", ".", "sections", ".", "all", "(", ")", "[", "0", "]", "related", "=", "cat"...
Gets latest related galleries from same section as originating gallery. Count defaults to five but can be overridden. Usage: {% get_related_galleries gallery <10> %}
[ "Gets", "latest", "related", "galleries", "from", "same", "section", "as", "originating", "gallery", "." ]
aca52c6d6425cd6016468107a677479216285fc3
https://github.com/tBaxter/tango-photos/blob/aca52c6d6425cd6016468107a677479216285fc3/build/lib/photos/templatetags/gallery_tags.py#L20-L34
42,123
ministryofjustice/django-moj-irat
moj_irat/healthchecks.py
HealthcheckRegistry.load_healthchecks
def load_healthchecks(self): """ Loads healthchecks. """ self.load_default_healthchecks() if getattr(settings, 'AUTODISCOVER_HEALTHCHECKS', True): self.autodiscover_healthchecks() self._registry_loaded = True
python
def load_healthchecks(self): """ Loads healthchecks. """ self.load_default_healthchecks() if getattr(settings, 'AUTODISCOVER_HEALTHCHECKS', True): self.autodiscover_healthchecks() self._registry_loaded = True
[ "def", "load_healthchecks", "(", "self", ")", ":", "self", ".", "load_default_healthchecks", "(", ")", "if", "getattr", "(", "settings", ",", "'AUTODISCOVER_HEALTHCHECKS'", ",", "True", ")", ":", "self", ".", "autodiscover_healthchecks", "(", ")", "self", ".", ...
Loads healthchecks.
[ "Loads", "healthchecks", "." ]
c1588426fffce783bef6d8b9d73395a5e9a833c9
https://github.com/ministryofjustice/django-moj-irat/blob/c1588426fffce783bef6d8b9d73395a5e9a833c9/moj_irat/healthchecks.py#L162-L169
42,124
ministryofjustice/django-moj-irat
moj_irat/healthchecks.py
HealthcheckRegistry.load_default_healthchecks
def load_default_healthchecks(self): """ Loads healthchecks specified in settings.HEALTHCHECKS as dotted import paths to the classes. Defaults are listed in `DEFAULT_HEALTHCHECKS`. """ default_healthchecks = getattr(settings, 'HEALTHCHECKS', DEFAULT_HEALTHCHECKS) for heal...
python
def load_default_healthchecks(self): """ Loads healthchecks specified in settings.HEALTHCHECKS as dotted import paths to the classes. Defaults are listed in `DEFAULT_HEALTHCHECKS`. """ default_healthchecks = getattr(settings, 'HEALTHCHECKS', DEFAULT_HEALTHCHECKS) for heal...
[ "def", "load_default_healthchecks", "(", "self", ")", ":", "default_healthchecks", "=", "getattr", "(", "settings", ",", "'HEALTHCHECKS'", ",", "DEFAULT_HEALTHCHECKS", ")", "for", "healthcheck", "in", "default_healthchecks", ":", "healthcheck", "=", "import_string", "...
Loads healthchecks specified in settings.HEALTHCHECKS as dotted import paths to the classes. Defaults are listed in `DEFAULT_HEALTHCHECKS`.
[ "Loads", "healthchecks", "specified", "in", "settings", ".", "HEALTHCHECKS", "as", "dotted", "import", "paths", "to", "the", "classes", ".", "Defaults", "are", "listed", "in", "DEFAULT_HEALTHCHECKS", "." ]
c1588426fffce783bef6d8b9d73395a5e9a833c9
https://github.com/ministryofjustice/django-moj-irat/blob/c1588426fffce783bef6d8b9d73395a5e9a833c9/moj_irat/healthchecks.py#L171-L179
42,125
ministryofjustice/django-moj-irat
moj_irat/healthchecks.py
HealthcheckRegistry.run_healthchecks
def run_healthchecks(self): """ Runs all registered healthchecks and returns a list of HealthcheckResponse. """ if not self._registry_loaded: self.load_healthchecks() def get_healthcheck_name(hc): if hasattr(hc, 'name'): return hc....
python
def run_healthchecks(self): """ Runs all registered healthchecks and returns a list of HealthcheckResponse. """ if not self._registry_loaded: self.load_healthchecks() def get_healthcheck_name(hc): if hasattr(hc, 'name'): return hc....
[ "def", "run_healthchecks", "(", "self", ")", ":", "if", "not", "self", ".", "_registry_loaded", ":", "self", ".", "load_healthchecks", "(", ")", "def", "get_healthcheck_name", "(", "hc", ")", ":", "if", "hasattr", "(", "hc", ",", "'name'", ")", ":", "ret...
Runs all registered healthchecks and returns a list of HealthcheckResponse.
[ "Runs", "all", "registered", "healthchecks", "and", "returns", "a", "list", "of", "HealthcheckResponse", "." ]
c1588426fffce783bef6d8b9d73395a5e9a833c9
https://github.com/ministryofjustice/django-moj-irat/blob/c1588426fffce783bef6d8b9d73395a5e9a833c9/moj_irat/healthchecks.py#L196-L228
42,126
astralblue/asynciotimemachine
asynciotimemachine.py
TimeMachine.advance_by
def advance_by(self, amount): """Advance the time reference by the given amount. :param `float` amount: number of seconds to advance. :raise `ValueError`: if *amount* is negative. """ if amount < 0: raise ValueError("cannot retreat time reference: amount {} < 0" ...
python
def advance_by(self, amount): """Advance the time reference by the given amount. :param `float` amount: number of seconds to advance. :raise `ValueError`: if *amount* is negative. """ if amount < 0: raise ValueError("cannot retreat time reference: amount {} < 0" ...
[ "def", "advance_by", "(", "self", ",", "amount", ")", ":", "if", "amount", "<", "0", ":", "raise", "ValueError", "(", "\"cannot retreat time reference: amount {} < 0\"", ".", "format", "(", "amount", ")", ")", "self", ".", "__delta", "+=", "amount" ]
Advance the time reference by the given amount. :param `float` amount: number of seconds to advance. :raise `ValueError`: if *amount* is negative.
[ "Advance", "the", "time", "reference", "by", "the", "given", "amount", "." ]
0fef71f45ce467f3112f6f9eea18272162f46447
https://github.com/astralblue/asynciotimemachine/blob/0fef71f45ce467f3112f6f9eea18272162f46447/asynciotimemachine.py#L27-L36
42,127
astralblue/asynciotimemachine
asynciotimemachine.py
TimeMachine.advance_to
def advance_to(self, timestamp): """Advance the time reference so that now is the given timestamp. :param `float` timestamp: the new current timestamp. :raise `ValueError`: if *timestamp* is in the past. """ now = self.__original_time() if timestamp < now: ra...
python
def advance_to(self, timestamp): """Advance the time reference so that now is the given timestamp. :param `float` timestamp: the new current timestamp. :raise `ValueError`: if *timestamp* is in the past. """ now = self.__original_time() if timestamp < now: ra...
[ "def", "advance_to", "(", "self", ",", "timestamp", ")", ":", "now", "=", "self", ".", "__original_time", "(", ")", "if", "timestamp", "<", "now", ":", "raise", "ValueError", "(", "\"cannot retreat time reference: \"", "\"target {} < now {}\"", ".", "format", "(...
Advance the time reference so that now is the given timestamp. :param `float` timestamp: the new current timestamp. :raise `ValueError`: if *timestamp* is in the past.
[ "Advance", "the", "time", "reference", "so", "that", "now", "is", "the", "given", "timestamp", "." ]
0fef71f45ce467f3112f6f9eea18272162f46447
https://github.com/astralblue/asynciotimemachine/blob/0fef71f45ce467f3112f6f9eea18272162f46447/asynciotimemachine.py#L38-L49
42,128
jpatrickdill/faste
faste/caches.py
LFUCache.reset_frequencies
def reset_frequencies(self, frequency=0): """Resets all stored frequencies for the cache :keyword int frequency: Frequency to reset to, must be >= 0""" frequency = max(frequency, 0) for key in self._store.keys(): self._store[key] = (self._store[key][0], frequency) ...
python
def reset_frequencies(self, frequency=0): """Resets all stored frequencies for the cache :keyword int frequency: Frequency to reset to, must be >= 0""" frequency = max(frequency, 0) for key in self._store.keys(): self._store[key] = (self._store[key][0], frequency) ...
[ "def", "reset_frequencies", "(", "self", ",", "frequency", "=", "0", ")", ":", "frequency", "=", "max", "(", "frequency", ",", "0", ")", "for", "key", "in", "self", ".", "_store", ".", "keys", "(", ")", ":", "self", ".", "_store", "[", "key", "]", ...
Resets all stored frequencies for the cache :keyword int frequency: Frequency to reset to, must be >= 0
[ "Resets", "all", "stored", "frequencies", "for", "the", "cache" ]
9d2ec1a670bc8d9889c3982d423c49d149f13dae
https://github.com/jpatrickdill/faste/blob/9d2ec1a670bc8d9889c3982d423c49d149f13dae/faste/caches.py#L427-L437
42,129
jpatrickdill/faste
faste/caches.py
TimeoutCache.oldest
def oldest(self): """ Gets key, value pair for oldest item in cache :returns: tuple """ if len(self._store) == 0: return kv = min(self._store.items(), key=lambda x: x[1][1]) return kv[0], kv[1][0]
python
def oldest(self): """ Gets key, value pair for oldest item in cache :returns: tuple """ if len(self._store) == 0: return kv = min(self._store.items(), key=lambda x: x[1][1]) return kv[0], kv[1][0]
[ "def", "oldest", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_store", ")", "==", "0", ":", "return", "kv", "=", "min", "(", "self", ".", "_store", ".", "items", "(", ")", ",", "key", "=", "lambda", "x", ":", "x", "[", "1", "]", "...
Gets key, value pair for oldest item in cache :returns: tuple
[ "Gets", "key", "value", "pair", "for", "oldest", "item", "in", "cache" ]
9d2ec1a670bc8d9889c3982d423c49d149f13dae
https://github.com/jpatrickdill/faste/blob/9d2ec1a670bc8d9889c3982d423c49d149f13dae/faste/caches.py#L543-L554
42,130
bernii/querystring-parser
querystring_parser/parser.py
parser_helper
def parser_helper(key, val): ''' Helper for parser function @param key: @param val: ''' start_bracket = key.find("[") end_bracket = key.find("]") pdict = {} if has_variable_name(key): # var['key'][3] pdict[key[:key.find("[")]] = parser_helper(key[start_bracket:], v...
python
def parser_helper(key, val): ''' Helper for parser function @param key: @param val: ''' start_bracket = key.find("[") end_bracket = key.find("]") pdict = {} if has_variable_name(key): # var['key'][3] pdict[key[:key.find("[")]] = parser_helper(key[start_bracket:], v...
[ "def", "parser_helper", "(", "key", ",", "val", ")", ":", "start_bracket", "=", "key", ".", "find", "(", "\"[\"", ")", "end_bracket", "=", "key", ".", "find", "(", "\"]\"", ")", "pdict", "=", "{", "}", "if", "has_variable_name", "(", "key", ")", ":",...
Helper for parser function @param key: @param val:
[ "Helper", "for", "parser", "function" ]
1d3b652512d55622a37b5f5712909ea41490454b
https://github.com/bernii/querystring-parser/blob/1d3b652512d55622a37b5f5712909ea41490454b/querystring_parser/parser.py#L88-L113
42,131
bernii/querystring-parser
querystring_parser/parser.py
parse
def parse(query_string, unquote=True, normalized=False, encoding=DEFAULT_ENCODING): ''' Main parse function @param query_string: @param unquote: unquote html query string ? @param encoding: An optional encoding used to decode the keys and values. Defaults to utf-8, which the W3C declares as a d...
python
def parse(query_string, unquote=True, normalized=False, encoding=DEFAULT_ENCODING): ''' Main parse function @param query_string: @param unquote: unquote html query string ? @param encoding: An optional encoding used to decode the keys and values. Defaults to utf-8, which the W3C declares as a d...
[ "def", "parse", "(", "query_string", ",", "unquote", "=", "True", ",", "normalized", "=", "False", ",", "encoding", "=", "DEFAULT_ENCODING", ")", ":", "mydict", "=", "{", "}", "plist", "=", "[", "]", "if", "query_string", "==", "\"\"", ":", "return", "...
Main parse function @param query_string: @param unquote: unquote html query string ? @param encoding: An optional encoding used to decode the keys and values. Defaults to utf-8, which the W3C declares as a defaul in the W3C algorithm for encoding. @see http://www.w3.org/TR/html5/forms.html#applicati...
[ "Main", "parse", "function" ]
1d3b652512d55622a37b5f5712909ea41490454b
https://github.com/bernii/querystring-parser/blob/1d3b652512d55622a37b5f5712909ea41490454b/querystring_parser/parser.py#L115-L166
42,132
striglia/pyramid_swagger
pyramid_swagger/spec.py
validate_swagger_schema
def validate_swagger_schema(schema_dir, resource_listing): """Validate the structure of Swagger schemas against the spec. **Valid only for Swagger v1.2 spec** Note: It is possible that resource_listing is not present in the schema_dir. The path is passed in the call so that ssv can fetch the api-d...
python
def validate_swagger_schema(schema_dir, resource_listing): """Validate the structure of Swagger schemas against the spec. **Valid only for Swagger v1.2 spec** Note: It is possible that resource_listing is not present in the schema_dir. The path is passed in the call so that ssv can fetch the api-d...
[ "def", "validate_swagger_schema", "(", "schema_dir", ",", "resource_listing", ")", ":", "schema_filepath", "=", "os", ".", "path", ".", "join", "(", "schema_dir", ",", "API_DOCS_FILENAME", ")", "swagger_spec_validator", ".", "validator12", ".", "validate_spec", "(",...
Validate the structure of Swagger schemas against the spec. **Valid only for Swagger v1.2 spec** Note: It is possible that resource_listing is not present in the schema_dir. The path is passed in the call so that ssv can fetch the api-declaration files from the path. :param resource_listing: Swag...
[ "Validate", "the", "structure", "of", "Swagger", "schemas", "against", "the", "spec", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/spec.py#L18-L37
42,133
striglia/pyramid_swagger
pyramid_swagger/load_schema.py
build_param_schema
def build_param_schema(schema, param_type): """Turn a swagger endpoint schema into an equivalent one to validate our request. As an example, this would take this swagger schema: { "paramType": "query", "name": "query", "description": "Location to query", ...
python
def build_param_schema(schema, param_type): """Turn a swagger endpoint schema into an equivalent one to validate our request. As an example, this would take this swagger schema: { "paramType": "query", "name": "query", "description": "Location to query", ...
[ "def", "build_param_schema", "(", "schema", ",", "param_type", ")", ":", "properties", "=", "filter_params_by_type", "(", "schema", ",", "param_type", ")", "if", "not", "properties", ":", "return", "# Generate a jsonschema that describes the set of all query parameters. We"...
Turn a swagger endpoint schema into an equivalent one to validate our request. As an example, this would take this swagger schema: { "paramType": "query", "name": "query", "description": "Location to query", "type": "string", "required": true ...
[ "Turn", "a", "swagger", "endpoint", "schema", "into", "an", "equivalent", "one", "to", "validate", "our", "request", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/load_schema.py#L28-L65
42,134
striglia/pyramid_swagger
pyramid_swagger/load_schema.py
required_validator
def required_validator(validator, req, instance, schema): """Swagger 1.2 expects `required` to be a bool in the Parameter object, but a list of properties in a Model object. """ if schema.get('paramType'): if req is True and not instance: return [ValidationError("%s is required" % sc...
python
def required_validator(validator, req, instance, schema): """Swagger 1.2 expects `required` to be a bool in the Parameter object, but a list of properties in a Model object. """ if schema.get('paramType'): if req is True and not instance: return [ValidationError("%s is required" % sc...
[ "def", "required_validator", "(", "validator", ",", "req", ",", "instance", ",", "schema", ")", ":", "if", "schema", ".", "get", "(", "'paramType'", ")", ":", "if", "req", "is", "True", "and", "not", "instance", ":", "return", "[", "ValidationError", "("...
Swagger 1.2 expects `required` to be a bool in the Parameter object, but a list of properties in a Model object.
[ "Swagger", "1", ".", "2", "expects", "required", "to", "be", "a", "bool", "in", "the", "Parameter", "object", "but", "a", "list", "of", "properties", "in", "a", "Model", "object", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/load_schema.py#L103-L111
42,135
striglia/pyramid_swagger
pyramid_swagger/load_schema.py
load_schema
def load_schema(schema_path): """Prepare the api specification for request and response validation. :returns: a mapping from :class:`RequestMatcher` to :class:`ValidatorMap` for every operation in the api specification. :rtype: dict """ with open(schema_path, 'r') as schema_file: sc...
python
def load_schema(schema_path): """Prepare the api specification for request and response validation. :returns: a mapping from :class:`RequestMatcher` to :class:`ValidatorMap` for every operation in the api specification. :rtype: dict """ with open(schema_path, 'r') as schema_file: sc...
[ "def", "load_schema", "(", "schema_path", ")", ":", "with", "open", "(", "schema_path", ",", "'r'", ")", "as", "schema_file", ":", "schema", "=", "simplejson", ".", "load", "(", "schema_file", ")", "resolver", "=", "RefResolver", "(", "''", ",", "''", ",...
Prepare the api specification for request and response validation. :returns: a mapping from :class:`RequestMatcher` to :class:`ValidatorMap` for every operation in the api specification. :rtype: dict
[ "Prepare", "the", "api", "specification", "for", "request", "and", "response", "validation", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/load_schema.py#L269-L279
42,136
striglia/pyramid_swagger
pyramid_swagger/tween.py
get_swagger_objects
def get_swagger_objects(settings, route_info, registry): """Returns appropriate swagger handler and swagger spec schema. Swagger Handler contains callables that isolate implementation differences in the tween to handle both Swagger 1.2 and Swagger 2.0. Exception is made when `settings.prefer_20_routes...
python
def get_swagger_objects(settings, route_info, registry): """Returns appropriate swagger handler and swagger spec schema. Swagger Handler contains callables that isolate implementation differences in the tween to handle both Swagger 1.2 and Swagger 2.0. Exception is made when `settings.prefer_20_routes...
[ "def", "get_swagger_objects", "(", "settings", ",", "route_info", ",", "registry", ")", ":", "enabled_swagger_versions", "=", "get_swagger_versions", "(", "registry", ".", "settings", ")", "schema12", "=", "registry", ".", "settings", "[", "'pyramid_swagger.schema12'"...
Returns appropriate swagger handler and swagger spec schema. Swagger Handler contains callables that isolate implementation differences in the tween to handle both Swagger 1.2 and Swagger 2.0. Exception is made when `settings.prefer_20_routes` are non-empty and ['1.2', '2.0'] both are present in avail...
[ "Returns", "appropriate", "swagger", "handler", "and", "swagger", "spec", "schema", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L107-L141
42,137
striglia/pyramid_swagger
pyramid_swagger/tween.py
validation_tween_factory
def validation_tween_factory(handler, registry): """Pyramid tween for performing validation. Note this is very simple -- it validates requests, responses, and paths while delegating to the relevant matching view. """ settings = load_settings(registry) route_mapper = registry.queryUtility(IRoute...
python
def validation_tween_factory(handler, registry): """Pyramid tween for performing validation. Note this is very simple -- it validates requests, responses, and paths while delegating to the relevant matching view. """ settings = load_settings(registry) route_mapper = registry.queryUtility(IRoute...
[ "def", "validation_tween_factory", "(", "handler", ",", "registry", ")", ":", "settings", "=", "load_settings", "(", "registry", ")", "route_mapper", "=", "registry", ".", "queryUtility", "(", "IRoutesMapper", ")", "validation_context", "=", "_get_validation_context",...
Pyramid tween for performing validation. Note this is very simple -- it validates requests, responses, and paths while delegating to the relevant matching view.
[ "Pyramid", "tween", "for", "performing", "validation", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L144-L201
42,138
striglia/pyramid_swagger
pyramid_swagger/tween.py
handle_request
def handle_request(request, validator_map, **kwargs): """Validate the request against the swagger spec and return a dict with all parameter values available in the request, casted to the expected python type. :param request: a :class:`PyramidSwaggerRequest` to validate :param validator_map: a :clas...
python
def handle_request(request, validator_map, **kwargs): """Validate the request against the swagger spec and return a dict with all parameter values available in the request, casted to the expected python type. :param request: a :class:`PyramidSwaggerRequest` to validate :param validator_map: a :clas...
[ "def", "handle_request", "(", "request", ",", "validator_map", ",", "*", "*", "kwargs", ")", ":", "request_data", "=", "{", "}", "validation_pairs", "=", "[", "]", "for", "validator", ",", "values", "in", "[", "(", "validator_map", ".", "query", ",", "re...
Validate the request against the swagger spec and return a dict with all parameter values available in the request, casted to the expected python type. :param request: a :class:`PyramidSwaggerRequest` to validate :param validator_map: a :class:`pyramid_swagger.load_schema.ValidatorMap` used to ...
[ "Validate", "the", "request", "against", "the", "swagger", "spec", "and", "return", "a", "dict", "with", "all", "parameter", "values", "available", "in", "the", "request", "casted", "to", "the", "expected", "python", "type", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L328-L363
42,139
striglia/pyramid_swagger
pyramid_swagger/tween.py
build_swagger12_handler
def build_swagger12_handler(schema): """Builds a swagger12 handler or returns None if no schema is present. :type schema: :class:`pyramid_swagger.model.SwaggerSchema` :rtype: :class:`SwaggerHandler` or None """ if schema: return SwaggerHandler( op_for_request=schema.validators_f...
python
def build_swagger12_handler(schema): """Builds a swagger12 handler or returns None if no schema is present. :type schema: :class:`pyramid_swagger.model.SwaggerSchema` :rtype: :class:`SwaggerHandler` or None """ if schema: return SwaggerHandler( op_for_request=schema.validators_f...
[ "def", "build_swagger12_handler", "(", "schema", ")", ":", "if", "schema", ":", "return", "SwaggerHandler", "(", "op_for_request", "=", "schema", ".", "validators_for_request", ",", "handle_request", "=", "handle_request", ",", "handle_response", "=", "validate_respon...
Builds a swagger12 handler or returns None if no schema is present. :type schema: :class:`pyramid_swagger.model.SwaggerSchema` :rtype: :class:`SwaggerHandler` or None
[ "Builds", "a", "swagger12", "handler", "or", "returns", "None", "if", "no", "schema", "is", "present", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L404-L415
42,140
striglia/pyramid_swagger
pyramid_swagger/tween.py
validate_response
def validate_response(response, validator_map): """Validates response against our schemas. :param response: the response object to validate :type response: :class:`pyramid.response.Response` :type validator_map: :class:`pyramid_swagger.load_schema.ValidatorMap` """ validator = validator_map.res...
python
def validate_response(response, validator_map): """Validates response against our schemas. :param response: the response object to validate :type response: :class:`pyramid.response.Response` :type validator_map: :class:`pyramid_swagger.load_schema.ValidatorMap` """ validator = validator_map.res...
[ "def", "validate_response", "(", "response", ",", "validator_map", ")", ":", "validator", "=", "validator_map", ".", "response", "# Short circuit if we are supposed to not validate anything.", "returns_nothing", "=", "validator", ".", "schema", ".", "get", "(", "'type'", ...
Validates response against our schemas. :param response: the response object to validate :type response: :class:`pyramid.response.Response` :type validator_map: :class:`pyramid_swagger.load_schema.ValidatorMap`
[ "Validates", "response", "against", "our", "schemas", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L542-L561
42,141
striglia/pyramid_swagger
pyramid_swagger/tween.py
swaggerize_response
def swaggerize_response(response, op): """ Delegate handling the Swagger concerns of the response to bravado-core. :type response: :class:`pyramid.response.Response` :type op: :class:`bravado_core.operation.Operation` """ response_spec = get_response_spec(response.status_int, op) bravado_co...
python
def swaggerize_response(response, op): """ Delegate handling the Swagger concerns of the response to bravado-core. :type response: :class:`pyramid.response.Response` :type op: :class:`bravado_core.operation.Operation` """ response_spec = get_response_spec(response.status_int, op) bravado_co...
[ "def", "swaggerize_response", "(", "response", ",", "op", ")", ":", "response_spec", "=", "get_response_spec", "(", "response", ".", "status_int", ",", "op", ")", "bravado_core", ".", "response", ".", "validate_response", "(", "response_spec", ",", "op", ",", ...
Delegate handling the Swagger concerns of the response to bravado-core. :type response: :class:`pyramid.response.Response` :type op: :class:`bravado_core.operation.Operation`
[ "Delegate", "handling", "the", "Swagger", "concerns", "of", "the", "response", "to", "bravado", "-", "core", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L592-L601
42,142
striglia/pyramid_swagger
pyramid_swagger/tween.py
get_op_for_request
def get_op_for_request(request, route_info, spec): """ Find out which operation in the Swagger schema corresponds to the given pyramid request. :type request: :class:`pyramid.request.Request` :type route_info: dict (usually has 'match' and 'route' keys) :type spec: :class:`bravado_core.spec.Spe...
python
def get_op_for_request(request, route_info, spec): """ Find out which operation in the Swagger schema corresponds to the given pyramid request. :type request: :class:`pyramid.request.Request` :type route_info: dict (usually has 'match' and 'route' keys) :type spec: :class:`bravado_core.spec.Spe...
[ "def", "get_op_for_request", "(", "request", ",", "route_info", ",", "spec", ")", ":", "# pyramid.urldispath.Route", "route", "=", "route_info", "[", "'route'", "]", "if", "hasattr", "(", "route", ",", "'path'", ")", ":", "route_path", "=", "route", ".", "pa...
Find out which operation in the Swagger schema corresponds to the given pyramid request. :type request: :class:`pyramid.request.Request` :type route_info: dict (usually has 'match' and 'route' keys) :type spec: :class:`bravado_core.spec.Spec` :rtype: :class:`bravado_core.operation.Operation` :r...
[ "Find", "out", "which", "operation", "in", "the", "Swagger", "schema", "corresponds", "to", "the", "given", "pyramid", "request", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L604-L634
42,143
striglia/pyramid_swagger
pyramid_swagger/tween.py
get_swagger_versions
def get_swagger_versions(settings): """ Validates and returns the versions of the Swagger Spec that this pyramid application supports. :type settings: dict :return: list of strings. eg ['1.2', '2.0'] :raises: ValueError when an unsupported Swagger version is encountered. """ swagger_ver...
python
def get_swagger_versions(settings): """ Validates and returns the versions of the Swagger Spec that this pyramid application supports. :type settings: dict :return: list of strings. eg ['1.2', '2.0'] :raises: ValueError when an unsupported Swagger version is encountered. """ swagger_ver...
[ "def", "get_swagger_versions", "(", "settings", ")", ":", "swagger_versions", "=", "set", "(", "aslist", "(", "settings", ".", "get", "(", "'pyramid_swagger.swagger_versions'", ",", "DEFAULT_SWAGGER_VERSIONS", ")", ")", ")", "if", "len", "(", "swagger_versions", "...
Validates and returns the versions of the Swagger Spec that this pyramid application supports. :type settings: dict :return: list of strings. eg ['1.2', '2.0'] :raises: ValueError when an unsupported Swagger version is encountered.
[ "Validates", "and", "returns", "the", "versions", "of", "the", "Swagger", "Spec", "that", "this", "pyramid", "application", "supports", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/tween.py#L637-L656
42,144
striglia/pyramid_swagger
pyramid_swagger/api.py
register_api_doc_endpoints
def register_api_doc_endpoints(config, endpoints, base_path='/api-docs'): """Create and register pyramid endpoints to service swagger api docs. Routes and views will be registered on the `config` at `path`. :param config: a pyramid configuration to register the new views and routes :type config: :clas...
python
def register_api_doc_endpoints(config, endpoints, base_path='/api-docs'): """Create and register pyramid endpoints to service swagger api docs. Routes and views will be registered on the `config` at `path`. :param config: a pyramid configuration to register the new views and routes :type config: :clas...
[ "def", "register_api_doc_endpoints", "(", "config", ",", "endpoints", ",", "base_path", "=", "'/api-docs'", ")", ":", "for", "endpoint", "in", "endpoints", ":", "path", "=", "base_path", ".", "rstrip", "(", "'/'", ")", "+", "endpoint", ".", "path", "config",...
Create and register pyramid endpoints to service swagger api docs. Routes and views will be registered on the `config` at `path`. :param config: a pyramid configuration to register the new views and routes :type config: :class:`pyramid.config.Configurator` :param endpoints: a list of endpoints to regi...
[ "Create", "and", "register", "pyramid", "endpoints", "to", "service", "swagger", "api", "docs", ".", "Routes", "and", "views", "will", "be", "registered", "on", "the", "config", "at", "path", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/api.py#L19-L37
42,145
striglia/pyramid_swagger
pyramid_swagger/api.py
build_swagger_12_api_declaration_view
def build_swagger_12_api_declaration_view(api_declaration_json): """Thanks to the magic of closures, this means we gracefully return JSON without file IO at request time. """ def view_for_api_declaration(request): # Note that we rewrite basePath to always point at this server's root. ret...
python
def build_swagger_12_api_declaration_view(api_declaration_json): """Thanks to the magic of closures, this means we gracefully return JSON without file IO at request time. """ def view_for_api_declaration(request): # Note that we rewrite basePath to always point at this server's root. ret...
[ "def", "build_swagger_12_api_declaration_view", "(", "api_declaration_json", ")", ":", "def", "view_for_api_declaration", "(", "request", ")", ":", "# Note that we rewrite basePath to always point at this server's root.", "return", "dict", "(", "api_declaration_json", ",", "baseP...
Thanks to the magic of closures, this means we gracefully return JSON without file IO at request time.
[ "Thanks", "to", "the", "magic", "of", "closures", "this", "means", "we", "gracefully", "return", "JSON", "without", "file", "IO", "at", "request", "time", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/api.py#L93-L103
42,146
striglia/pyramid_swagger
pyramid_swagger/model.py
partial_path_match
def partial_path_match(path1, path2, kwarg_re=r'\{.*\}'): """Validates if path1 and path2 matches, ignoring any kwargs in the string. We need this to ensure we can match Swagger patterns like: /foo/{id} against the observed pyramid path /foo/1 :param path1: path of a url :type path...
python
def partial_path_match(path1, path2, kwarg_re=r'\{.*\}'): """Validates if path1 and path2 matches, ignoring any kwargs in the string. We need this to ensure we can match Swagger patterns like: /foo/{id} against the observed pyramid path /foo/1 :param path1: path of a url :type path...
[ "def", "partial_path_match", "(", "path1", ",", "path2", ",", "kwarg_re", "=", "r'\\{.*\\}'", ")", ":", "split_p1", "=", "path1", ".", "split", "(", "'/'", ")", "split_p2", "=", "path2", ".", "split", "(", "'/'", ")", "pat", "=", "re", ".", "compile", ...
Validates if path1 and path2 matches, ignoring any kwargs in the string. We need this to ensure we can match Swagger patterns like: /foo/{id} against the observed pyramid path /foo/1 :param path1: path of a url :type path1: string :param path2: path of a url :type path2: string...
[ "Validates", "if", "path1", "and", "path2", "matches", "ignoring", "any", "kwargs", "in", "the", "string", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/model.py#L61-L87
42,147
striglia/pyramid_swagger
pyramid_swagger/model.py
SwaggerSchema.validators_for_request
def validators_for_request(self, request, **kwargs): """Takes a request and returns a validator mapping for the request. :param request: A Pyramid request to fetch schemas for :type request: :class:`pyramid.request.Request` :returns: a :class:`pyramid_swagger.load_schema.ValidatorMap` w...
python
def validators_for_request(self, request, **kwargs): """Takes a request and returns a validator mapping for the request. :param request: A Pyramid request to fetch schemas for :type request: :class:`pyramid.request.Request` :returns: a :class:`pyramid_swagger.load_schema.ValidatorMap` w...
[ "def", "validators_for_request", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "for", "resource_validator", "in", "self", ".", "resource_validators", ":", "for", "matcher", ",", "validator_map", "in", "resource_validator", ".", "items", "(", ...
Takes a request and returns a validator mapping for the request. :param request: A Pyramid request to fetch schemas for :type request: :class:`pyramid.request.Request` :returns: a :class:`pyramid_swagger.load_schema.ValidatorMap` which can be used to validate `request`
[ "Takes", "a", "request", "and", "returns", "a", "validator", "mapping", "for", "the", "request", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/model.py#L39-L55
42,148
striglia/pyramid_swagger
pyramid_swagger/ingest.py
build_schema_mapping
def build_schema_mapping(schema_dir, resource_listing): """Discovers schema file locations and relations. :param schema_dir: the directory schema files live inside :type schema_dir: string :param resource_listing: A swagger resource listing :type resource_listing: dict :returns: a mapping from...
python
def build_schema_mapping(schema_dir, resource_listing): """Discovers schema file locations and relations. :param schema_dir: the directory schema files live inside :type schema_dir: string :param resource_listing: A swagger resource listing :type resource_listing: dict :returns: a mapping from...
[ "def", "build_schema_mapping", "(", "schema_dir", ",", "resource_listing", ")", ":", "def", "resource_name_to_filepath", "(", "name", ")", ":", "return", "os", ".", "path", ".", "join", "(", "schema_dir", ",", "'{0}.json'", ".", "format", "(", "name", ")", "...
Discovers schema file locations and relations. :param schema_dir: the directory schema files live inside :type schema_dir: string :param resource_listing: A swagger resource listing :type resource_listing: dict :returns: a mapping from resource name to file path :rtype: dict
[ "Discovers", "schema", "file", "locations", "and", "relations", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/ingest.py#L63-L79
42,149
striglia/pyramid_swagger
pyramid_swagger/ingest.py
_load_resource_listing
def _load_resource_listing(resource_listing): """Load the resource listing from file, handling errors. :param resource_listing: path to the api-docs resource listing file :type resource_listing: string :returns: contents of the resource listing file :rtype: dict """ try: with open(...
python
def _load_resource_listing(resource_listing): """Load the resource listing from file, handling errors. :param resource_listing: path to the api-docs resource listing file :type resource_listing: string :returns: contents of the resource listing file :rtype: dict """ try: with open(...
[ "def", "_load_resource_listing", "(", "resource_listing", ")", ":", "try", ":", "with", "open", "(", "resource_listing", ")", "as", "resource_listing_file", ":", "return", "simplejson", ".", "load", "(", "resource_listing_file", ")", "# If not found, raise a more user-f...
Load the resource listing from file, handling errors. :param resource_listing: path to the api-docs resource listing file :type resource_listing: string :returns: contents of the resource listing file :rtype: dict
[ "Load", "the", "resource", "listing", "from", "file", "handling", "errors", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/ingest.py#L82-L98
42,150
striglia/pyramid_swagger
pyramid_swagger/ingest.py
get_resource_listing
def get_resource_listing(schema_dir, should_generate_resource_listing): """Return the resource listing document. :param schema_dir: the directory which contains swagger spec files :type schema_dir: string :param should_generate_resource_listing: when True a resource listing will be generated f...
python
def get_resource_listing(schema_dir, should_generate_resource_listing): """Return the resource listing document. :param schema_dir: the directory which contains swagger spec files :type schema_dir: string :param should_generate_resource_listing: when True a resource listing will be generated f...
[ "def", "get_resource_listing", "(", "schema_dir", ",", "should_generate_resource_listing", ")", ":", "listing_filename", "=", "os", ".", "path", ".", "join", "(", "schema_dir", ",", "API_DOCS_FILENAME", ")", "resource_listing", "=", "_load_resource_listing", "(", "lis...
Return the resource listing document. :param schema_dir: the directory which contains swagger spec files :type schema_dir: string :param should_generate_resource_listing: when True a resource listing will be generated from the list of *.json files in the schema_dir. Otherwise return the co...
[ "Return", "the", "resource", "listing", "document", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/ingest.py#L113-L129
42,151
striglia/pyramid_swagger
pyramid_swagger/ingest.py
compile_swagger_schema
def compile_swagger_schema(schema_dir, resource_listing): """Build a SwaggerSchema from various files. :param schema_dir: the directory schema files live inside :type schema_dir: string :returns: a SwaggerSchema object """ mapping = build_schema_mapping(schema_dir, resource_listing) resourc...
python
def compile_swagger_schema(schema_dir, resource_listing): """Build a SwaggerSchema from various files. :param schema_dir: the directory schema files live inside :type schema_dir: string :returns: a SwaggerSchema object """ mapping = build_schema_mapping(schema_dir, resource_listing) resourc...
[ "def", "compile_swagger_schema", "(", "schema_dir", ",", "resource_listing", ")", ":", "mapping", "=", "build_schema_mapping", "(", "schema_dir", ",", "resource_listing", ")", "resource_validators", "=", "ingest_resources", "(", "mapping", ",", "schema_dir", ")", "end...
Build a SwaggerSchema from various files. :param schema_dir: the directory schema files live inside :type schema_dir: string :returns: a SwaggerSchema object
[ "Build", "a", "SwaggerSchema", "from", "various", "files", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/ingest.py#L132-L142
42,152
striglia/pyramid_swagger
pyramid_swagger/ingest.py
create_bravado_core_config
def create_bravado_core_config(settings): """Create a configuration dict for bravado_core based on pyramid_swagger settings. :param settings: pyramid registry settings with configuration for building a swagger schema :type settings: dict :returns: config dict suitable for passing into ...
python
def create_bravado_core_config(settings): """Create a configuration dict for bravado_core based on pyramid_swagger settings. :param settings: pyramid registry settings with configuration for building a swagger schema :type settings: dict :returns: config dict suitable for passing into ...
[ "def", "create_bravado_core_config", "(", "settings", ")", ":", "# Map pyramid_swagger config key -> bravado_core config key", "config_keys", "=", "{", "'pyramid_swagger.enable_request_validation'", ":", "'validate_requests'", ",", "'pyramid_swagger.enable_response_validation'", ":", ...
Create a configuration dict for bravado_core based on pyramid_swagger settings. :param settings: pyramid registry settings with configuration for building a swagger schema :type settings: dict :returns: config dict suitable for passing into bravado_core.spec.Spec.from_dict(..) :rtyp...
[ "Create", "a", "configuration", "dict", "for", "bravado_core", "based", "on", "pyramid_swagger", "settings", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/ingest.py#L195-L244
42,153
striglia/pyramid_swagger
pyramid_swagger/ingest.py
ingest_resources
def ingest_resources(mapping, schema_dir): """Consume the Swagger schemas and produce a queryable datastructure. :param mapping: Map from resource name to filepath of its api declaration :type mapping: dict :param schema_dir: the directory schema files live inside :type schema_dir: string :retu...
python
def ingest_resources(mapping, schema_dir): """Consume the Swagger schemas and produce a queryable datastructure. :param mapping: Map from resource name to filepath of its api declaration :type mapping: dict :param schema_dir: the directory schema files live inside :type schema_dir: string :retu...
[ "def", "ingest_resources", "(", "mapping", ",", "schema_dir", ")", ":", "ingested_resources", "=", "[", "]", "for", "name", ",", "filepath", "in", "iteritems", "(", "mapping", ")", ":", "try", ":", "ingested_resources", ".", "append", "(", "load_schema", "("...
Consume the Swagger schemas and produce a queryable datastructure. :param mapping: Map from resource name to filepath of its api declaration :type mapping: dict :param schema_dir: the directory schema files live inside :type schema_dir: string :returns: A list of mapping from :class:`RequestMatcher...
[ "Consume", "the", "Swagger", "schemas", "and", "produce", "a", "queryable", "datastructure", "." ]
1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45
https://github.com/striglia/pyramid_swagger/blob/1dbc0b4f23e2e5f4ed575c116f3f7d0e83e30d45/pyramid_swagger/ingest.py#L247-L270
42,154
nco/pynco
nco/nco.py
Nco.read_array
def read_array(self, infile, var_name): """Directly return a numpy array for a given variable name""" file_handle = self.read_cdf(infile) try: # return the data array return file_handle.variables[var_name][:] except KeyError: print("Cannot find variabl...
python
def read_array(self, infile, var_name): """Directly return a numpy array for a given variable name""" file_handle = self.read_cdf(infile) try: # return the data array return file_handle.variables[var_name][:] except KeyError: print("Cannot find variabl...
[ "def", "read_array", "(", "self", ",", "infile", ",", "var_name", ")", ":", "file_handle", "=", "self", ".", "read_cdf", "(", "infile", ")", "try", ":", "# return the data array", "return", "file_handle", ".", "variables", "[", "var_name", "]", "[", ":", "...
Directly return a numpy array for a given variable name
[ "Directly", "return", "a", "numpy", "array", "for", "a", "given", "variable", "name" ]
4161de9755b531825e83f684c964441bff9ffa7d
https://github.com/nco/pynco/blob/4161de9755b531825e83f684c964441bff9ffa7d/nco/nco.py#L493-L501
42,155
nco/pynco
nco/nco.py
Nco.read_ma_array
def read_ma_array(self, infile, var_name): """Create a masked array based on cdf's FillValue""" file_obj = self.read_cdf(infile) # .data is not backwards compatible to old scipy versions, [:] is data = file_obj.variables[var_name][:] # load numpy if available try: ...
python
def read_ma_array(self, infile, var_name): """Create a masked array based on cdf's FillValue""" file_obj = self.read_cdf(infile) # .data is not backwards compatible to old scipy versions, [:] is data = file_obj.variables[var_name][:] # load numpy if available try: ...
[ "def", "read_ma_array", "(", "self", ",", "infile", ",", "var_name", ")", ":", "file_obj", "=", "self", ".", "read_cdf", "(", "infile", ")", "# .data is not backwards compatible to old scipy versions, [:] is", "data", "=", "file_obj", ".", "variables", "[", "var_nam...
Create a masked array based on cdf's FillValue
[ "Create", "a", "masked", "array", "based", "on", "cdf", "s", "FillValue" ]
4161de9755b531825e83f684c964441bff9ffa7d
https://github.com/nco/pynco/blob/4161de9755b531825e83f684c964441bff9ffa7d/nco/nco.py#L503-L524
42,156
vbwagner/ctypescrypto
ctypescrypto/mac.py
MAC.digest
def digest(self,data=None): """ Method digest is redefined to return keyed MAC value instead of just digest. """ if data is not None: self.update(data) b=create_string_buffer(256) size=c_size_t(256) if libcrypto.EVP_DigestSignFinal(self.ctx,b,p...
python
def digest(self,data=None): """ Method digest is redefined to return keyed MAC value instead of just digest. """ if data is not None: self.update(data) b=create_string_buffer(256) size=c_size_t(256) if libcrypto.EVP_DigestSignFinal(self.ctx,b,p...
[ "def", "digest", "(", "self", ",", "data", "=", "None", ")", ":", "if", "data", "is", "not", "None", ":", "self", ".", "update", "(", "data", ")", "b", "=", "create_string_buffer", "(", "256", ")", "size", "=", "c_size_t", "(", "256", ")", "if", ...
Method digest is redefined to return keyed MAC value instead of just digest.
[ "Method", "digest", "is", "redefined", "to", "return", "keyed", "MAC", "value", "instead", "of", "just", "digest", "." ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/mac.py#L72-L84
42,157
vbwagner/ctypescrypto
ctypescrypto/rand.py
bytes
def bytes(num, check_result=False): """ Returns num bytes of cryptographically strong pseudo-random bytes. If checkc_result is True, raises error if PRNG is not seeded enough """ if num <= 0: raise ValueError("'num' should be > 0") buf = create_string_buffer(num) result = libcry...
python
def bytes(num, check_result=False): """ Returns num bytes of cryptographically strong pseudo-random bytes. If checkc_result is True, raises error if PRNG is not seeded enough """ if num <= 0: raise ValueError("'num' should be > 0") buf = create_string_buffer(num) result = libcry...
[ "def", "bytes", "(", "num", ",", "check_result", "=", "False", ")", ":", "if", "num", "<=", "0", ":", "raise", "ValueError", "(", "\"'num' should be > 0\"", ")", "buf", "=", "create_string_buffer", "(", "num", ")", "result", "=", "libcrypto", ".", "RAND_by...
Returns num bytes of cryptographically strong pseudo-random bytes. If checkc_result is True, raises error if PRNG is not seeded enough
[ "Returns", "num", "bytes", "of", "cryptographically", "strong", "pseudo", "-", "random", "bytes", ".", "If", "checkc_result", "is", "True", "raises", "error", "if", "PRNG", "is", "not", "seeded", "enough" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/rand.py#L15-L28
42,158
vbwagner/ctypescrypto
ctypescrypto/oid.py
create
def create(dotted, shortname, longname): """ Creates new OID in the database @param dotted - dotted-decimal representation of new OID @param shortname - short name for new OID @param longname - long name for new OID @returns Oid object corresponding to new OID This function should be used...
python
def create(dotted, shortname, longname): """ Creates new OID in the database @param dotted - dotted-decimal representation of new OID @param shortname - short name for new OID @param longname - long name for new OID @returns Oid object corresponding to new OID This function should be used...
[ "def", "create", "(", "dotted", ",", "shortname", ",", "longname", ")", ":", "if", "pyver", ">", "2", ":", "dotted", "=", "dotted", ".", "encode", "(", "'ascii'", ")", "shortname", "=", "shortname", ".", "encode", "(", "'utf-8'", ")", "longname", "=", ...
Creates new OID in the database @param dotted - dotted-decimal representation of new OID @param shortname - short name for new OID @param longname - long name for new OID @returns Oid object corresponding to new OID This function should be used with exreme care. Whenever possible, it is bette...
[ "Creates", "new", "OID", "in", "the", "database" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/oid.py#L125-L150
42,159
vbwagner/ctypescrypto
ctypescrypto/oid.py
Oid.dotted
def dotted(self): " Returns dotted-decimal reperesentation " obj = libcrypto.OBJ_nid2obj(self.nid) buf = create_string_buffer(256) libcrypto.OBJ_obj2txt(buf, 256, obj, 1) if pyver == 2: return buf.value else: return buf.value.decode('ascii')
python
def dotted(self): " Returns dotted-decimal reperesentation " obj = libcrypto.OBJ_nid2obj(self.nid) buf = create_string_buffer(256) libcrypto.OBJ_obj2txt(buf, 256, obj, 1) if pyver == 2: return buf.value else: return buf.value.decode('ascii')
[ "def", "dotted", "(", "self", ")", ":", "obj", "=", "libcrypto", ".", "OBJ_nid2obj", "(", "self", ".", "nid", ")", "buf", "=", "create_string_buffer", "(", "256", ")", "libcrypto", ".", "OBJ_obj2txt", "(", "buf", ",", "256", ",", "obj", ",", "1", ")"...
Returns dotted-decimal reperesentation
[ "Returns", "dotted", "-", "decimal", "reperesentation" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/oid.py#L99-L107
42,160
vbwagner/ctypescrypto
ctypescrypto/oid.py
Oid.fromobj
def fromobj(obj): """ Creates an OID object from the pointer to ASN1_OBJECT c structure. This method intended for internal use for submodules which deal with libcrypto ASN1 parsing functions, such as x509 or CMS """ nid = libcrypto.OBJ_obj2nid(obj) if nid == 0: ...
python
def fromobj(obj): """ Creates an OID object from the pointer to ASN1_OBJECT c structure. This method intended for internal use for submodules which deal with libcrypto ASN1 parsing functions, such as x509 or CMS """ nid = libcrypto.OBJ_obj2nid(obj) if nid == 0: ...
[ "def", "fromobj", "(", "obj", ")", ":", "nid", "=", "libcrypto", ".", "OBJ_obj2nid", "(", "obj", ")", "if", "nid", "==", "0", ":", "buf", "=", "create_string_buffer", "(", "80", ")", "dotted_len", "=", "libcrypto", ".", "OBJ_obj2txt", "(", "buf", ",", ...
Creates an OID object from the pointer to ASN1_OBJECT c structure. This method intended for internal use for submodules which deal with libcrypto ASN1 parsing functions, such as x509 or CMS
[ "Creates", "an", "OID", "object", "from", "the", "pointer", "to", "ASN1_OBJECT", "c", "structure", ".", "This", "method", "intended", "for", "internal", "use", "for", "submodules", "which", "deal", "with", "libcrypto", "ASN1", "parsing", "functions", "such", "...
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/oid.py#L109-L123
42,161
vbwagner/ctypescrypto
ctypescrypto/pkey.py
_password_callback
def _password_callback(c): """ Converts given user function or string to C password callback function, passable to openssl. IF function is passed, it would be called upon reading or writing PEM format private key with one argument which is True if we are writing key and should verify passphrase...
python
def _password_callback(c): """ Converts given user function or string to C password callback function, passable to openssl. IF function is passed, it would be called upon reading or writing PEM format private key with one argument which is True if we are writing key and should verify passphrase...
[ "def", "_password_callback", "(", "c", ")", ":", "if", "c", "is", "None", ":", "return", "PW_CALLBACK_FUNC", "(", "0", ")", "if", "callable", "(", "c", ")", ":", "if", "pyver", "==", "2", ":", "def", "__cb", "(", "buf", ",", "length", ",", "rwflag"...
Converts given user function or string to C password callback function, passable to openssl. IF function is passed, it would be called upon reading or writing PEM format private key with one argument which is True if we are writing key and should verify passphrase and false if we are reading
[ "Converts", "given", "user", "function", "or", "string", "to", "C", "password", "callback", "function", "passable", "to", "openssl", "." ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/pkey.py#L22-L54
42,162
vbwagner/ctypescrypto
ctypescrypto/pkey.py
PKey.verify
def verify(self, digest, signature, **kwargs): """ Verifies given signature on given digest Returns True if Ok, False if don't match Keyword arguments allows to set algorithm-specific parameters """ ctx = libcrypto.EVP_PKEY_CTX_new(self.key, None) if ctx i...
python
def verify(self, digest, signature, **kwargs): """ Verifies given signature on given digest Returns True if Ok, False if don't match Keyword arguments allows to set algorithm-specific parameters """ ctx = libcrypto.EVP_PKEY_CTX_new(self.key, None) if ctx i...
[ "def", "verify", "(", "self", ",", "digest", ",", "signature", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "libcrypto", ".", "EVP_PKEY_CTX_new", "(", "self", ".", "key", ",", "None", ")", "if", "ctx", "is", "None", ":", "raise", "PKeyError", "(", ...
Verifies given signature on given digest Returns True if Ok, False if don't match Keyword arguments allows to set algorithm-specific parameters
[ "Verifies", "given", "signature", "on", "given", "digest", "Returns", "True", "if", "Ok", "False", "if", "don", "t", "match", "Keyword", "arguments", "allows", "to", "set", "algorithm", "-", "specific", "parameters" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/pkey.py#L195-L213
42,163
vbwagner/ctypescrypto
ctypescrypto/pkey.py
PKey.exportpub
def exportpub(self, format="PEM"): """ Returns public key as PEM or DER structure. """ bio = Membio() if format == "PEM": retcode = libcrypto.PEM_write_bio_PUBKEY(bio.bio, self.key) else: retcode = libcrypto.i2d_PUBKEY_bio(bio.bio, self.key) ...
python
def exportpub(self, format="PEM"): """ Returns public key as PEM or DER structure. """ bio = Membio() if format == "PEM": retcode = libcrypto.PEM_write_bio_PUBKEY(bio.bio, self.key) else: retcode = libcrypto.i2d_PUBKEY_bio(bio.bio, self.key) ...
[ "def", "exportpub", "(", "self", ",", "format", "=", "\"PEM\"", ")", ":", "bio", "=", "Membio", "(", ")", "if", "format", "==", "\"PEM\"", ":", "retcode", "=", "libcrypto", ".", "PEM_write_bio_PUBKEY", "(", "bio", ".", "bio", ",", "self", ".", "key", ...
Returns public key as PEM or DER structure.
[ "Returns", "public", "key", "as", "PEM", "or", "DER", "structure", "." ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/pkey.py#L307-L318
42,164
vbwagner/ctypescrypto
ctypescrypto/pkey.py
PKey.exportpriv
def exportpriv(self, format="PEM", password=None, cipher=None): """ Returns private key as PEM or DER Structure. If password and cipher are specified, encrypts key on given password, using given algorithm. Cipher must be an ctypescrypto.cipher.CipherType object Password ...
python
def exportpriv(self, format="PEM", password=None, cipher=None): """ Returns private key as PEM or DER Structure. If password and cipher are specified, encrypts key on given password, using given algorithm. Cipher must be an ctypescrypto.cipher.CipherType object Password ...
[ "def", "exportpriv", "(", "self", ",", "format", "=", "\"PEM\"", ",", "password", "=", "None", ",", "cipher", "=", "None", ")", ":", "bio", "=", "Membio", "(", ")", "if", "cipher", "is", "None", ":", "evp_cipher", "=", "None", "else", ":", "evp_ciphe...
Returns private key as PEM or DER Structure. If password and cipher are specified, encrypts key on given password, using given algorithm. Cipher must be an ctypescrypto.cipher.CipherType object Password can be either string or function with one argument, which returns password. ...
[ "Returns", "private", "key", "as", "PEM", "or", "DER", "Structure", ".", "If", "password", "and", "cipher", "are", "specified", "encrypts", "key", "on", "given", "password", "using", "given", "algorithm", ".", "Cipher", "must", "be", "an", "ctypescrypto", "....
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/pkey.py#L320-L352
42,165
vbwagner/ctypescrypto
ctypescrypto/pkey.py
PKey._configure_context
def _configure_context(ctx, opts, skip=()): """ Configures context of public key operations @param ctx - context to configure @param opts - dictionary of options (from kwargs of calling function) @param skip - list of options which shouldn't be passed to c...
python
def _configure_context(ctx, opts, skip=()): """ Configures context of public key operations @param ctx - context to configure @param opts - dictionary of options (from kwargs of calling function) @param skip - list of options which shouldn't be passed to c...
[ "def", "_configure_context", "(", "ctx", ",", "opts", ",", "skip", "=", "(", ")", ")", ":", "for", "oper", "in", "opts", ":", "if", "oper", "in", "skip", ":", "continue", "if", "isinstance", "(", "oper", ",", "chartype", ")", ":", "op", "=", "oper"...
Configures context of public key operations @param ctx - context to configure @param opts - dictionary of options (from kwargs of calling function) @param skip - list of options which shouldn't be passed to context
[ "Configures", "context", "of", "public", "key", "operations" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/pkey.py#L355-L385
42,166
vbwagner/ctypescrypto
ctypescrypto/bio.py
Membio.read
def read(self, length=None): """ Reads data from readble BIO. For test purposes. @param length - if specifed, limits amount of data read. If not BIO is read until end of buffer """ if not length is None: if not isinstance(length, inttype) : rai...
python
def read(self, length=None): """ Reads data from readble BIO. For test purposes. @param length - if specifed, limits amount of data read. If not BIO is read until end of buffer """ if not length is None: if not isinstance(length, inttype) : rai...
[ "def", "read", "(", "self", ",", "length", "=", "None", ")", ":", "if", "not", "length", "is", "None", ":", "if", "not", "isinstance", "(", "length", ",", "inttype", ")", ":", "raise", "TypeError", "(", "\"length to read should be number\"", ")", "buf", ...
Reads data from readble BIO. For test purposes. @param length - if specifed, limits amount of data read. If not BIO is read until end of buffer
[ "Reads", "data", "from", "readble", "BIO", ".", "For", "test", "purposes", "." ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/bio.py#L62-L94
42,167
vbwagner/ctypescrypto
ctypescrypto/bio.py
Membio.write
def write(self, data): """ Writes data to writable bio. For test purposes """ if pyver == 2: if isinstance(data, unicode): data = data.encode("utf-8") else: data = str(data) else: if not isinstance(data, bytes...
python
def write(self, data): """ Writes data to writable bio. For test purposes """ if pyver == 2: if isinstance(data, unicode): data = data.encode("utf-8") else: data = str(data) else: if not isinstance(data, bytes...
[ "def", "write", "(", "self", ",", "data", ")", ":", "if", "pyver", "==", "2", ":", "if", "isinstance", "(", "data", ",", "unicode", ")", ":", "data", "=", "data", ".", "encode", "(", "\"utf-8\"", ")", "else", ":", "data", "=", "str", "(", "data",...
Writes data to writable bio. For test purposes
[ "Writes", "data", "to", "writable", "bio", ".", "For", "test", "purposes" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/bio.py#L96-L113
42,168
vbwagner/ctypescrypto
ctypescrypto/cms.py
CMS
def CMS(data, format="PEM"): """ Factory function to create CMS objects from received messages. Parses CMS data and returns either SignedData or EnvelopedData object. format argument can be either "PEM" or "DER". It determines object type from the contents of received CMS structure. ""...
python
def CMS(data, format="PEM"): """ Factory function to create CMS objects from received messages. Parses CMS data and returns either SignedData or EnvelopedData object. format argument can be either "PEM" or "DER". It determines object type from the contents of received CMS structure. ""...
[ "def", "CMS", "(", "data", ",", "format", "=", "\"PEM\"", ")", ":", "bio", "=", "Membio", "(", "data", ")", "if", "format", "==", "\"PEM\"", ":", "ptr", "=", "libcrypto", ".", "PEM_read_bio_CMS", "(", "bio", ".", "bio", ",", "None", ",", "None", ",...
Factory function to create CMS objects from received messages. Parses CMS data and returns either SignedData or EnvelopedData object. format argument can be either "PEM" or "DER". It determines object type from the contents of received CMS structure.
[ "Factory", "function", "to", "create", "CMS", "objects", "from", "received", "messages", ".", "Parses", "CMS", "data", "and", "returns", "either", "SignedData", "or", "EnvelopedData", "object", ".", "format", "argument", "can", "be", "either", "PEM", "or", "DE...
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L58-L83
42,169
vbwagner/ctypescrypto
ctypescrypto/cms.py
CMSBase.pem
def pem(self): """ Serialize in PEM format """ bio = Membio() if not libcrypto.PEM_write_bio_CMS(bio.bio, self.ptr): raise CMSError("writing CMS to PEM") return str(bio)
python
def pem(self): """ Serialize in PEM format """ bio = Membio() if not libcrypto.PEM_write_bio_CMS(bio.bio, self.ptr): raise CMSError("writing CMS to PEM") return str(bio)
[ "def", "pem", "(", "self", ")", ":", "bio", "=", "Membio", "(", ")", "if", "not", "libcrypto", ".", "PEM_write_bio_CMS", "(", "bio", ".", "bio", ",", "self", ".", "ptr", ")", ":", "raise", "CMSError", "(", "\"writing CMS to PEM\"", ")", "return", "str"...
Serialize in PEM format
[ "Serialize", "in", "PEM", "format" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L107-L114
42,170
vbwagner/ctypescrypto
ctypescrypto/cms.py
SignedData.create
def create(data, cert, pkey, flags=Flags.BINARY, certs=None): """ Creates SignedData message by signing data with pkey and certificate. @param data - data to sign @param cert - signer's certificate @param pkey - pkey object with private key to sign ...
python
def create(data, cert, pkey, flags=Flags.BINARY, certs=None): """ Creates SignedData message by signing data with pkey and certificate. @param data - data to sign @param cert - signer's certificate @param pkey - pkey object with private key to sign ...
[ "def", "create", "(", "data", ",", "cert", ",", "pkey", ",", "flags", "=", "Flags", ".", "BINARY", ",", "certs", "=", "None", ")", ":", "if", "not", "pkey", ".", "cansign", ":", "raise", "ValueError", "(", "\"Specified keypair has no private part\"", ")", ...
Creates SignedData message by signing data with pkey and certificate. @param data - data to sign @param cert - signer's certificate @param pkey - pkey object with private key to sign @param flags - OReed combination of Flags constants @param certs...
[ "Creates", "SignedData", "message", "by", "signing", "data", "with", "pkey", "and", "certificate", "." ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L131-L155
42,171
vbwagner/ctypescrypto
ctypescrypto/cms.py
SignedData.sign
def sign(self, cert, pkey, digest_type=None, data=None, flags=Flags.BINARY): """ Adds another signer to already signed message @param cert - signer's certificate @param pkey - signer's private key @param digest_type - message digest to use as DigestType object ...
python
def sign(self, cert, pkey, digest_type=None, data=None, flags=Flags.BINARY): """ Adds another signer to already signed message @param cert - signer's certificate @param pkey - signer's private key @param digest_type - message digest to use as DigestType object ...
[ "def", "sign", "(", "self", ",", "cert", ",", "pkey", ",", "digest_type", "=", "None", ",", "data", "=", "None", ",", "flags", "=", "Flags", ".", "BINARY", ")", ":", "if", "not", "pkey", ".", "cansign", ":", "raise", "ValueError", "(", "\"Specified k...
Adds another signer to already signed message @param cert - signer's certificate @param pkey - signer's private key @param digest_type - message digest to use as DigestType object (if None - default for key would be used) @param data - data to sign (if det...
[ "Adds", "another", "signer", "to", "already", "signed", "message" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L156-L182
42,172
vbwagner/ctypescrypto
ctypescrypto/cms.py
SignedData.verify
def verify(self, store, flags, data=None, certs=None): """ Verifies signature under CMS message using trusted cert store @param store - X509Store object with trusted certs @param flags - OR-ed combination of flag consants @param data - message data, if messge has detached signa...
python
def verify(self, store, flags, data=None, certs=None): """ Verifies signature under CMS message using trusted cert store @param store - X509Store object with trusted certs @param flags - OR-ed combination of flag consants @param data - message data, if messge has detached signa...
[ "def", "verify", "(", "self", ",", "store", ",", "flags", ",", "data", "=", "None", ",", "certs", "=", "None", ")", ":", "bio", "=", "None", "if", "data", "!=", "None", ":", "bio_obj", "=", "Membio", "(", "data", ")", "bio", "=", "bio_obj", ".", ...
Verifies signature under CMS message using trusted cert store @param store - X509Store object with trusted certs @param flags - OR-ed combination of flag consants @param data - message data, if messge has detached signature param certs - list of certificates to use during verification ...
[ "Verifies", "signature", "under", "CMS", "message", "using", "trusted", "cert", "store" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L183-L206
42,173
vbwagner/ctypescrypto
ctypescrypto/cms.py
SignedData.signers
def signers(self): """ Return list of signer's certificates """ signerlist = libcrypto.CMS_get0_signers(self.ptr) if signerlist is None: raise CMSError("Cannot get signers") return StackOfX509(ptr=signerlist, disposable=False)
python
def signers(self): """ Return list of signer's certificates """ signerlist = libcrypto.CMS_get0_signers(self.ptr) if signerlist is None: raise CMSError("Cannot get signers") return StackOfX509(ptr=signerlist, disposable=False)
[ "def", "signers", "(", "self", ")", ":", "signerlist", "=", "libcrypto", ".", "CMS_get0_signers", "(", "self", ".", "ptr", ")", "if", "signerlist", "is", "None", ":", "raise", "CMSError", "(", "\"Cannot get signers\"", ")", "return", "StackOfX509", "(", "ptr...
Return list of signer's certificates
[ "Return", "list", "of", "signer", "s", "certificates" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L209-L216
42,174
vbwagner/ctypescrypto
ctypescrypto/cms.py
SignedData.data
def data(self): """ Returns signed data if present in the message """ # Check if signatire is detached if self.detached: return None bio = Membio() if not libcrypto.CMS_verify(self.ptr, None, None, None, bio.bio, Fla...
python
def data(self): """ Returns signed data if present in the message """ # Check if signatire is detached if self.detached: return None bio = Membio() if not libcrypto.CMS_verify(self.ptr, None, None, None, bio.bio, Fla...
[ "def", "data", "(", "self", ")", ":", "# Check if signatire is detached", "if", "self", ".", "detached", ":", "return", "None", "bio", "=", "Membio", "(", ")", "if", "not", "libcrypto", ".", "CMS_verify", "(", "self", ".", "ptr", ",", "None", ",", "None"...
Returns signed data if present in the message
[ "Returns", "signed", "data", "if", "present", "in", "the", "message" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L226-L237
42,175
vbwagner/ctypescrypto
ctypescrypto/cms.py
SignedData.certs
def certs(self): """ List of the certificates contained in the structure """ certstack = libcrypto.CMS_get1_certs(self.ptr) if certstack is None: raise CMSError("getting certs") return StackOfX509(ptr=certstack, disposable=True)
python
def certs(self): """ List of the certificates contained in the structure """ certstack = libcrypto.CMS_get1_certs(self.ptr) if certstack is None: raise CMSError("getting certs") return StackOfX509(ptr=certstack, disposable=True)
[ "def", "certs", "(", "self", ")", ":", "certstack", "=", "libcrypto", ".", "CMS_get1_certs", "(", "self", ".", "ptr", ")", "if", "certstack", "is", "None", ":", "raise", "CMSError", "(", "\"getting certs\"", ")", "return", "StackOfX509", "(", "ptr", "=", ...
List of the certificates contained in the structure
[ "List", "of", "the", "certificates", "contained", "in", "the", "structure" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L252-L259
42,176
vbwagner/ctypescrypto
ctypescrypto/cms.py
EnvelopedData.create
def create(recipients, data, cipher, flags=0): """ Creates and encrypts message @param recipients - list of X509 objects @param data - contents of the message @param cipher - CipherType object @param flags - flag """ recp = StackOfX509(recipients) ...
python
def create(recipients, data, cipher, flags=0): """ Creates and encrypts message @param recipients - list of X509 objects @param data - contents of the message @param cipher - CipherType object @param flags - flag """ recp = StackOfX509(recipients) ...
[ "def", "create", "(", "recipients", ",", "data", ",", "cipher", ",", "flags", "=", "0", ")", ":", "recp", "=", "StackOfX509", "(", "recipients", ")", "bio", "=", "Membio", "(", "data", ")", "cms_ptr", "=", "libcrypto", ".", "CMS_encrypt", "(", "recp", ...
Creates and encrypts message @param recipients - list of X509 objects @param data - contents of the message @param cipher - CipherType object @param flags - flag
[ "Creates", "and", "encrypts", "message" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L281-L295
42,177
vbwagner/ctypescrypto
ctypescrypto/cms.py
EncryptedData.create
def create(data, cipher, key, flags=0): """ Creates an EncryptedData message. @param data data to encrypt @param cipher cipher.CipherType object represening required cipher type @param key - byte array used as simmetic key @param flags - OR-ed combination ...
python
def create(data, cipher, key, flags=0): """ Creates an EncryptedData message. @param data data to encrypt @param cipher cipher.CipherType object represening required cipher type @param key - byte array used as simmetic key @param flags - OR-ed combination ...
[ "def", "create", "(", "data", ",", "cipher", ",", "key", ",", "flags", "=", "0", ")", ":", "bio", "=", "Membio", "(", "data", ")", "ptr", "=", "libcrypto", ".", "CMS_EncryptedData_encrypt", "(", "bio", ".", "bio", ",", "cipher", ".", "cipher", ",", ...
Creates an EncryptedData message. @param data data to encrypt @param cipher cipher.CipherType object represening required cipher type @param key - byte array used as simmetic key @param flags - OR-ed combination of Flags constant
[ "Creates", "an", "EncryptedData", "message", "." ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L323-L337
42,178
vbwagner/ctypescrypto
ctypescrypto/cms.py
EncryptedData.decrypt
def decrypt(self, key, flags=0): """ Decrypts encrypted data message @param key - symmetic key to decrypt @param flags - OR-ed combination of Flags constant """ bio = Membio() if libcrypto.CMS_EncryptedData_decrypt(self.ptr, key, len(key), None, ...
python
def decrypt(self, key, flags=0): """ Decrypts encrypted data message @param key - symmetic key to decrypt @param flags - OR-ed combination of Flags constant """ bio = Membio() if libcrypto.CMS_EncryptedData_decrypt(self.ptr, key, len(key), None, ...
[ "def", "decrypt", "(", "self", ",", "key", ",", "flags", "=", "0", ")", ":", "bio", "=", "Membio", "(", ")", "if", "libcrypto", ".", "CMS_EncryptedData_decrypt", "(", "self", ".", "ptr", ",", "key", ",", "len", "(", "key", ")", ",", "None", ",", ...
Decrypts encrypted data message @param key - symmetic key to decrypt @param flags - OR-ed combination of Flags constant
[ "Decrypts", "encrypted", "data", "message" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cms.py#L339-L349
42,179
vbwagner/ctypescrypto
ctypescrypto/digest.py
DigestType.name
def name(self): """ Returns name of the digest """ if not hasattr(self, 'digest_name'): self.digest_name = Oid(libcrypto.EVP_MD_type(self.digest) ).longname() return self.digest_name
python
def name(self): """ Returns name of the digest """ if not hasattr(self, 'digest_name'): self.digest_name = Oid(libcrypto.EVP_MD_type(self.digest) ).longname() return self.digest_name
[ "def", "name", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'digest_name'", ")", ":", "self", ".", "digest_name", "=", "Oid", "(", "libcrypto", ".", "EVP_MD_type", "(", "self", ".", "digest", ")", ")", ".", "longname", "(", ")", ...
Returns name of the digest
[ "Returns", "name", "of", "the", "digest" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/digest.py#L64-L69
42,180
vbwagner/ctypescrypto
ctypescrypto/digest.py
Digest.update
def update(self, data, length=None): """ Hashes given byte string @param data - string to hash @param length - if not specifed, entire string is hashed, otherwise only first length bytes """ if self.digest_finalized: raise DigestError("No upda...
python
def update(self, data, length=None): """ Hashes given byte string @param data - string to hash @param length - if not specifed, entire string is hashed, otherwise only first length bytes """ if self.digest_finalized: raise DigestError("No upda...
[ "def", "update", "(", "self", ",", "data", ",", "length", "=", "None", ")", ":", "if", "self", ".", "digest_finalized", ":", "raise", "DigestError", "(", "\"No updates allowed\"", ")", "if", "not", "isinstance", "(", "data", ",", "bintype", ")", ":", "ra...
Hashes given byte string @param data - string to hash @param length - if not specifed, entire string is hashed, otherwise only first length bytes
[ "Hashes", "given", "byte", "string" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/digest.py#L117-L135
42,181
vbwagner/ctypescrypto
ctypescrypto/digest.py
Digest.digest
def digest(self, data=None): """ Finalizes digest operation and return digest value Optionally hashes more data before finalizing """ if self.digest_finalized: return self.digest_out.raw[:self.digest_size] if data is not None: self.update(data) ...
python
def digest(self, data=None): """ Finalizes digest operation and return digest value Optionally hashes more data before finalizing """ if self.digest_finalized: return self.digest_out.raw[:self.digest_size] if data is not None: self.update(data) ...
[ "def", "digest", "(", "self", ",", "data", "=", "None", ")", ":", "if", "self", ".", "digest_finalized", ":", "return", "self", ".", "digest_out", ".", "raw", "[", ":", "self", ".", "digest_size", "]", "if", "data", "is", "not", "None", ":", "self", ...
Finalizes digest operation and return digest value Optionally hashes more data before finalizing
[ "Finalizes", "digest", "operation", "and", "return", "digest", "value", "Optionally", "hashes", "more", "data", "before", "finalizing" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/digest.py#L137-L153
42,182
vbwagner/ctypescrypto
ctypescrypto/digest.py
Digest.copy
def copy(self): """ Creates copy of the digest CTX to allow to compute digest while being able to hash more data """ new_digest = Digest(self.digest_type) libcrypto.EVP_MD_CTX_copy(new_digest.ctx, self.ctx) return new_digest
python
def copy(self): """ Creates copy of the digest CTX to allow to compute digest while being able to hash more data """ new_digest = Digest(self.digest_type) libcrypto.EVP_MD_CTX_copy(new_digest.ctx, self.ctx) return new_digest
[ "def", "copy", "(", "self", ")", ":", "new_digest", "=", "Digest", "(", "self", ".", "digest_type", ")", "libcrypto", ".", "EVP_MD_CTX_copy", "(", "new_digest", ".", "ctx", ",", "self", ".", "ctx", ")", "return", "new_digest" ]
Creates copy of the digest CTX to allow to compute digest while being able to hash more data
[ "Creates", "copy", "of", "the", "digest", "CTX", "to", "allow", "to", "compute", "digest", "while", "being", "able", "to", "hash", "more", "data" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/digest.py#L154-L162
42,183
vbwagner/ctypescrypto
ctypescrypto/digest.py
Digest._clean_ctx
def _clean_ctx(self): """ Clears and deallocates context """ try: if self.ctx is not None: libcrypto.EVP_MD_CTX_free(self.ctx) del self.ctx except AttributeError: pass self.digest_out = None self.digest_final...
python
def _clean_ctx(self): """ Clears and deallocates context """ try: if self.ctx is not None: libcrypto.EVP_MD_CTX_free(self.ctx) del self.ctx except AttributeError: pass self.digest_out = None self.digest_final...
[ "def", "_clean_ctx", "(", "self", ")", ":", "try", ":", "if", "self", ".", "ctx", "is", "not", "None", ":", "libcrypto", ".", "EVP_MD_CTX_free", "(", "self", ".", "ctx", ")", "del", "self", ".", "ctx", "except", "AttributeError", ":", "pass", "self", ...
Clears and deallocates context
[ "Clears", "and", "deallocates", "context" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/digest.py#L164-L175
42,184
vbwagner/ctypescrypto
ctypescrypto/digest.py
Digest.hexdigest
def hexdigest(self, data=None): """ Returns digest in the hexadecimal form. For compatibility with hashlib """ from base64 import b16encode if pyver == 2: return b16encode(self.digest(data)) else: return b16encode(self.digest(data))...
python
def hexdigest(self, data=None): """ Returns digest in the hexadecimal form. For compatibility with hashlib """ from base64 import b16encode if pyver == 2: return b16encode(self.digest(data)) else: return b16encode(self.digest(data))...
[ "def", "hexdigest", "(", "self", ",", "data", "=", "None", ")", ":", "from", "base64", "import", "b16encode", "if", "pyver", "==", "2", ":", "return", "b16encode", "(", "self", ".", "digest", "(", "data", ")", ")", "else", ":", "return", "b16encode", ...
Returns digest in the hexadecimal form. For compatibility with hashlib
[ "Returns", "digest", "in", "the", "hexadecimal", "form", ".", "For", "compatibility", "with", "hashlib" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/digest.py#L177-L186
42,185
vbwagner/ctypescrypto
ctypescrypto/x509.py
_X509__asn1date_to_datetime
def _X509__asn1date_to_datetime(asn1date): """ Converts openssl ASN1_TIME object to python datetime.datetime """ bio = Membio() libcrypto.ASN1_TIME_print(bio.bio, asn1date) pydate = datetime.strptime(str(bio), "%b %d %H:%M:%S %Y %Z") return pydate.replace(tzinfo=utc)
python
def _X509__asn1date_to_datetime(asn1date): """ Converts openssl ASN1_TIME object to python datetime.datetime """ bio = Membio() libcrypto.ASN1_TIME_print(bio.bio, asn1date) pydate = datetime.strptime(str(bio), "%b %d %H:%M:%S %Y %Z") return pydate.replace(tzinfo=utc)
[ "def", "_X509__asn1date_to_datetime", "(", "asn1date", ")", ":", "bio", "=", "Membio", "(", ")", "libcrypto", ".", "ASN1_TIME_print", "(", "bio", ".", "bio", ",", "asn1date", ")", "pydate", "=", "datetime", ".", "strptime", "(", "str", "(", "bio", ")", "...
Converts openssl ASN1_TIME object to python datetime.datetime
[ "Converts", "openssl", "ASN1_TIME", "object", "to", "python", "datetime", ".", "datetime" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L344-L351
42,186
vbwagner/ctypescrypto
ctypescrypto/x509.py
_X509extlist.find
def find(self, oid): """ Return list of extensions with given Oid """ if not isinstance(oid, Oid): raise TypeError("Need crytypescrypto.oid.Oid as argument") found = [] index = -1 end = len(self) while True: index = libcrypto.X509_g...
python
def find(self, oid): """ Return list of extensions with given Oid """ if not isinstance(oid, Oid): raise TypeError("Need crytypescrypto.oid.Oid as argument") found = [] index = -1 end = len(self) while True: index = libcrypto.X509_g...
[ "def", "find", "(", "self", ",", "oid", ")", ":", "if", "not", "isinstance", "(", "oid", ",", "Oid", ")", ":", "raise", "TypeError", "(", "\"Need crytypescrypto.oid.Oid as argument\"", ")", "found", "=", "[", "]", "index", "=", "-", "1", "end", "=", "l...
Return list of extensions with given Oid
[ "Return", "list", "of", "extensions", "with", "given", "Oid" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L307-L322
42,187
vbwagner/ctypescrypto
ctypescrypto/x509.py
_X509extlist.find_critical
def find_critical(self, crit=True): """ Return list of critical extensions (or list of non-cricital, if optional second argument is False """ if crit: flag = 1 else: flag = 0 found = [] end = len(self) index = -1 whi...
python
def find_critical(self, crit=True): """ Return list of critical extensions (or list of non-cricital, if optional second argument is False """ if crit: flag = 1 else: flag = 0 found = [] end = len(self) index = -1 whi...
[ "def", "find_critical", "(", "self", ",", "crit", "=", "True", ")", ":", "if", "crit", ":", "flag", "=", "1", "else", ":", "flag", "=", "0", "found", "=", "[", "]", "end", "=", "len", "(", "self", ")", "index", "=", "-", "1", "while", "True", ...
Return list of critical extensions (or list of non-cricital, if optional second argument is False
[ "Return", "list", "of", "critical", "extensions", "(", "or", "list", "of", "non", "-", "cricital", "if", "optional", "second", "argument", "is", "False" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L324-L342
42,188
vbwagner/ctypescrypto
ctypescrypto/x509.py
X509.pem
def pem(self): """ Returns PEM represntation of the certificate """ bio = Membio() if libcrypto.PEM_write_bio_X509(bio.bio, self.cert) == 0: raise X509Error("error serializing certificate") return str(bio)
python
def pem(self): """ Returns PEM represntation of the certificate """ bio = Membio() if libcrypto.PEM_write_bio_X509(bio.bio, self.cert) == 0: raise X509Error("error serializing certificate") return str(bio)
[ "def", "pem", "(", "self", ")", ":", "bio", "=", "Membio", "(", ")", "if", "libcrypto", ".", "PEM_write_bio_X509", "(", "bio", ".", "bio", ",", "self", ".", "cert", ")", "==", "0", ":", "raise", "X509Error", "(", "\"error serializing certificate\"", ")",...
Returns PEM represntation of the certificate
[ "Returns", "PEM", "represntation", "of", "the", "certificate" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L401-L406
42,189
vbwagner/ctypescrypto
ctypescrypto/x509.py
X509.serial
def serial(self): """ Serial number of certificate as integer """ asnint = libcrypto.X509_get_serialNumber(self.cert) bio = Membio() libcrypto.i2a_ASN1_INTEGER(bio.bio, asnint) return int(str(bio), 16)
python
def serial(self): """ Serial number of certificate as integer """ asnint = libcrypto.X509_get_serialNumber(self.cert) bio = Membio() libcrypto.i2a_ASN1_INTEGER(bio.bio, asnint) return int(str(bio), 16)
[ "def", "serial", "(", "self", ")", ":", "asnint", "=", "libcrypto", ".", "X509_get_serialNumber", "(", "self", ".", "cert", ")", "bio", "=", "Membio", "(", ")", "libcrypto", ".", "i2a_ASN1_INTEGER", "(", "bio", ".", "bio", ",", "asnint", ")", "return", ...
Serial number of certificate as integer
[ "Serial", "number", "of", "certificate", "as", "integer" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L456-L461
42,190
vbwagner/ctypescrypto
ctypescrypto/x509.py
X509Store.add_cert
def add_cert(self, cert): """ Explicitely adds certificate to set of trusted in the store @param cert - X509 object to add """ if not isinstance(cert, X509): raise TypeError("cert should be X509") libcrypto.X509_STORE_add_cert(self.store, cert.cert)
python
def add_cert(self, cert): """ Explicitely adds certificate to set of trusted in the store @param cert - X509 object to add """ if not isinstance(cert, X509): raise TypeError("cert should be X509") libcrypto.X509_STORE_add_cert(self.store, cert.cert)
[ "def", "add_cert", "(", "self", ",", "cert", ")", ":", "if", "not", "isinstance", "(", "cert", ",", "X509", ")", ":", "raise", "TypeError", "(", "\"cert should be X509\"", ")", "libcrypto", ".", "X509_STORE_add_cert", "(", "self", ".", "store", ",", "cert"...
Explicitely adds certificate to set of trusted in the store @param cert - X509 object to add
[ "Explicitely", "adds", "certificate", "to", "set", "of", "trusted", "in", "the", "store" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L531-L538
42,191
vbwagner/ctypescrypto
ctypescrypto/x509.py
X509Store.setpurpose
def setpurpose(self, purpose): """ Sets certificate purpose which verified certificate should match @param purpose - number from 1 to 9 or standard strind defined in Openssl possible strings - sslcient,sslserver, nssslserver, smimesign,i ...
python
def setpurpose(self, purpose): """ Sets certificate purpose which verified certificate should match @param purpose - number from 1 to 9 or standard strind defined in Openssl possible strings - sslcient,sslserver, nssslserver, smimesign,i ...
[ "def", "setpurpose", "(", "self", ",", "purpose", ")", ":", "if", "isinstance", "(", "purpose", ",", "str", ")", ":", "purp_no", "=", "libcrypto", ".", "X509_PURPOSE_get_by_sname", "(", "purpose", ")", "if", "purp_no", "<=", "0", ":", "raise", "X509Error",...
Sets certificate purpose which verified certificate should match @param purpose - number from 1 to 9 or standard strind defined in Openssl possible strings - sslcient,sslserver, nssslserver, smimesign,i smimeencrypt, crlsign, any, ocsphelper
[ "Sets", "certificate", "purpose", "which", "verified", "certificate", "should", "match" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L551-L566
42,192
vbwagner/ctypescrypto
ctypescrypto/x509.py
X509Store.settime
def settime(self, time): """ Set point in time used to check validity of certificates for Time can be either python datetime object or number of seconds sinse epoch """ if isinstance(time, datetime) or isinstance(time, ...
python
def settime(self, time): """ Set point in time used to check validity of certificates for Time can be either python datetime object or number of seconds sinse epoch """ if isinstance(time, datetime) or isinstance(time, ...
[ "def", "settime", "(", "self", ",", "time", ")", ":", "if", "isinstance", "(", "time", ",", "datetime", ")", "or", "isinstance", "(", "time", ",", "datetime", ".", "date", ")", ":", "seconds", "=", "int", "(", "time", ".", "strftime", "(", "\"%s\"", ...
Set point in time used to check validity of certificates for Time can be either python datetime object or number of seconds sinse epoch
[ "Set", "point", "in", "time", "used", "to", "check", "validity", "of", "certificates", "for", "Time", "can", "be", "either", "python", "datetime", "object", "or", "number", "of", "seconds", "sinse", "epoch" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L573-L587
42,193
vbwagner/ctypescrypto
ctypescrypto/x509.py
StackOfX509.append
def append(self, value): """ Adds certificate to stack """ if not self.need_free: raise ValueError("Stack is read-only") if not isinstance(value, X509): raise TypeError('StackOfX509 can contain only X509 objects') sk_push(self.ptr, libcrypto.X509_dup(value.cert))
python
def append(self, value): """ Adds certificate to stack """ if not self.need_free: raise ValueError("Stack is read-only") if not isinstance(value, X509): raise TypeError('StackOfX509 can contain only X509 objects') sk_push(self.ptr, libcrypto.X509_dup(value.cert))
[ "def", "append", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "need_free", ":", "raise", "ValueError", "(", "\"Stack is read-only\"", ")", "if", "not", "isinstance", "(", "value", ",", "X509", ")", ":", "raise", "TypeError", "(", "'Stac...
Adds certificate to stack
[ "Adds", "certificate", "to", "stack" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L644-L650
42,194
vbwagner/ctypescrypto
ctypescrypto/ec.py
create
def create(curve, data): """ Creates EC keypair from the just secret key and curve name @param curve - name of elliptic curve @param num - byte array or long number representing key """ ec_key = libcrypto.EC_KEY_new_by_curve_name(curve.nid) if ec_key is None: raise PKeyError("EC_KEY...
python
def create(curve, data): """ Creates EC keypair from the just secret key and curve name @param curve - name of elliptic curve @param num - byte array or long number representing key """ ec_key = libcrypto.EC_KEY_new_by_curve_name(curve.nid) if ec_key is None: raise PKeyError("EC_KEY...
[ "def", "create", "(", "curve", ",", "data", ")", ":", "ec_key", "=", "libcrypto", ".", "EC_KEY_new_by_curve_name", "(", "curve", ".", "nid", ")", "if", "ec_key", "is", "None", ":", "raise", "PKeyError", "(", "\"EC_KEY_new_by_curvename\"", ")", "group", "=", ...
Creates EC keypair from the just secret key and curve name @param curve - name of elliptic curve @param num - byte array or long number representing key
[ "Creates", "EC", "keypair", "from", "the", "just", "secret", "key", "and", "curve", "name" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/ec.py#L10-L64
42,195
vbwagner/ctypescrypto
ctypescrypto/cipher.py
new
def new(algname, key, encrypt=True, iv=None): """ Returns new cipher object ready to encrypt-decrypt data @param algname - string algorithm name like in opemssl command line @param key - binary string representing ciher key @param encrypt - if True (default) cipher would be ini...
python
def new(algname, key, encrypt=True, iv=None): """ Returns new cipher object ready to encrypt-decrypt data @param algname - string algorithm name like in opemssl command line @param key - binary string representing ciher key @param encrypt - if True (default) cipher would be ini...
[ "def", "new", "(", "algname", ",", "key", ",", "encrypt", "=", "True", ",", "iv", "=", "None", ")", ":", "ciph_type", "=", "CipherType", "(", "algname", ")", "return", "Cipher", "(", "ciph_type", ",", "key", ",", "iv", ",", "encrypt", ")" ]
Returns new cipher object ready to encrypt-decrypt data @param algname - string algorithm name like in opemssl command line @param key - binary string representing ciher key @param encrypt - if True (default) cipher would be initialized for encryption, otherwise - f...
[ "Returns", "new", "cipher", "object", "ready", "to", "encrypt", "-", "decrypt", "data" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cipher.py#L24-L36
42,196
vbwagner/ctypescrypto
ctypescrypto/cipher.py
Cipher.padding
def padding(self, padding=True): """ Sets padding mode of the cipher """ padding_flag = 1 if padding else 0 libcrypto.EVP_CIPHER_CTX_set_padding(self.ctx, padding_flag)
python
def padding(self, padding=True): """ Sets padding mode of the cipher """ padding_flag = 1 if padding else 0 libcrypto.EVP_CIPHER_CTX_set_padding(self.ctx, padding_flag)
[ "def", "padding", "(", "self", ",", "padding", "=", "True", ")", ":", "padding_flag", "=", "1", "if", "padding", "else", "0", "libcrypto", ".", "EVP_CIPHER_CTX_set_padding", "(", "self", ".", "ctx", ",", "padding_flag", ")" ]
Sets padding mode of the cipher
[ "Sets", "padding", "mode", "of", "the", "cipher" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cipher.py#L174-L179
42,197
vbwagner/ctypescrypto
ctypescrypto/cipher.py
Cipher.finish
def finish(self): """ Finalizes processing. If some data are kept in the internal state, they would be processed and returned. """ if self.cipher_finalized: raise CipherError("Cipher operation is already completed") outbuf = create_string_buffer(self.block_siz...
python
def finish(self): """ Finalizes processing. If some data are kept in the internal state, they would be processed and returned. """ if self.cipher_finalized: raise CipherError("Cipher operation is already completed") outbuf = create_string_buffer(self.block_siz...
[ "def", "finish", "(", "self", ")", ":", "if", "self", ".", "cipher_finalized", ":", "raise", "CipherError", "(", "\"Cipher operation is already completed\"", ")", "outbuf", "=", "create_string_buffer", "(", "self", ".", "block_size", ")", "self", ".", "cipher_fina...
Finalizes processing. If some data are kept in the internal state, they would be processed and returned.
[ "Finalizes", "processing", ".", "If", "some", "data", "are", "kept", "in", "the", "internal", "state", "they", "would", "be", "processed", "and", "returned", "." ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cipher.py#L209-L226
42,198
vbwagner/ctypescrypto
ctypescrypto/cipher.py
Cipher._clean_ctx
def _clean_ctx(self): """ Cleans up cipher ctx and deallocates it """ try: if self.ctx is not None: self.__ctxcleanup(self.ctx) libcrypto.EVP_CIPHER_CTX_free(self.ctx) del self.ctx except AttributeError: pass...
python
def _clean_ctx(self): """ Cleans up cipher ctx and deallocates it """ try: if self.ctx is not None: self.__ctxcleanup(self.ctx) libcrypto.EVP_CIPHER_CTX_free(self.ctx) del self.ctx except AttributeError: pass...
[ "def", "_clean_ctx", "(", "self", ")", ":", "try", ":", "if", "self", ".", "ctx", "is", "not", "None", ":", "self", ".", "__ctxcleanup", "(", "self", ".", "ctx", ")", "libcrypto", ".", "EVP_CIPHER_CTX_free", "(", "self", ".", "ctx", ")", "del", "self...
Cleans up cipher ctx and deallocates it
[ "Cleans", "up", "cipher", "ctx", "and", "deallocates", "it" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/cipher.py#L228-L239
42,199
vbwagner/ctypescrypto
ctypescrypto/engine.py
set_default
def set_default(eng, algorithms=0xFFFF): """ Sets specified engine as default for all algorithms, supported by it For compatibility with 0.2.x if string is passed instead of engine, attempts to load engine with this id """ if not isinstance(eng,Engine): eng=Engine(eng) global d...
python
def set_default(eng, algorithms=0xFFFF): """ Sets specified engine as default for all algorithms, supported by it For compatibility with 0.2.x if string is passed instead of engine, attempts to load engine with this id """ if not isinstance(eng,Engine): eng=Engine(eng) global d...
[ "def", "set_default", "(", "eng", ",", "algorithms", "=", "0xFFFF", ")", ":", "if", "not", "isinstance", "(", "eng", ",", "Engine", ")", ":", "eng", "=", "Engine", "(", "eng", ")", "global", "default", "libcrypto", ".", "ENGINE_set_default", "(", "eng", ...
Sets specified engine as default for all algorithms, supported by it For compatibility with 0.2.x if string is passed instead of engine, attempts to load engine with this id
[ "Sets", "specified", "engine", "as", "default", "for", "all", "algorithms", "supported", "by", "it" ]
33c32904cf5e04901f87f90e2499634b8feecd3e
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/engine.py#L53-L65