repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
akolpakov/paynova-api-python-client
paynova_api_python_client/paynova.py
Paynova.request
def request(self, method, resource, params=None): """ Make request to the server and parse response """ url = self.get_url(resource, params) # headers headers = { 'Content-Type': 'application/json' } auth = requests.auth.HTTPBasicAuth(s...
python
def request(self, method, resource, params=None): """ Make request to the server and parse response """ url = self.get_url(resource, params) # headers headers = { 'Content-Type': 'application/json' } auth = requests.auth.HTTPBasicAuth(s...
[ "def", "request", "(", "self", ",", "method", ",", "resource", ",", "params", "=", "None", ")", ":", "url", "=", "self", ".", "get_url", "(", "resource", ",", "params", ")", "# headers", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", "...
Make request to the server and parse response
[ "Make", "request", "to", "the", "server", "and", "parse", "response" ]
train
https://github.com/akolpakov/paynova-api-python-client/blob/930277623fc7b142ae9365a44f15a3a7b79bd974/paynova_api_python_client/paynova.py#L62-L91
TC01/calcpkg
calcrepo/calcpkg.py
main
def main(): """Core function for the script""" commands = ['update', 'list', 'get', 'info', 'count', 'search', 'download'] parser = argparse.ArgumentParser(description="Command line access to software repositories for TI calculators, primarily ticalc.org and Cemetech") parser.add_argument("action", metavar="ACTION"...
python
def main(): """Core function for the script""" commands = ['update', 'list', 'get', 'info', 'count', 'search', 'download'] parser = argparse.ArgumentParser(description="Command line access to software repositories for TI calculators, primarily ticalc.org and Cemetech") parser.add_argument("action", metavar="ACTION"...
[ "def", "main", "(", ")", ":", "commands", "=", "[", "'update'", ",", "'list'", ",", "'get'", ",", "'info'", ",", "'count'", ",", "'search'", ",", "'download'", "]", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Command line ...
Core function for the script
[ "Core", "function", "for", "the", "script" ]
train
https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/calcpkg.py#L12-L62
delfick/aws_syncr
aws_syncr/amazon/iam.py
Iam.modify_attached_policies
def modify_attached_policies(self, role_name, new_policies): """Make sure this role has just the new policies""" parts = role_name.split('/', 1) if len(parts) == 2: prefix, name = parts prefix = "/{0}/".format(prefix) else: prefix = "/" nam...
python
def modify_attached_policies(self, role_name, new_policies): """Make sure this role has just the new policies""" parts = role_name.split('/', 1) if len(parts) == 2: prefix, name = parts prefix = "/{0}/".format(prefix) else: prefix = "/" nam...
[ "def", "modify_attached_policies", "(", "self", ",", "role_name", ",", "new_policies", ")", ":", "parts", "=", "role_name", ".", "split", "(", "'/'", ",", "1", ")", "if", "len", "(", "parts", ")", "==", "2", ":", "prefix", ",", "name", "=", "parts", ...
Make sure this role has just the new policies
[ "Make", "sure", "this", "role", "has", "just", "the", "new", "policies" ]
train
https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/amazon/iam.py#L128-L156
delfick/aws_syncr
aws_syncr/amazon/iam.py
Iam.assume_role_credentials
def assume_role_credentials(self, arn): """Return the environment variables for an assumed role""" log.info("Assuming role as %s", arn) # Clear out empty values for name in ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_SECURITY_TOKEN', 'AWS_SESSION_TOKEN']: if name in ...
python
def assume_role_credentials(self, arn): """Return the environment variables for an assumed role""" log.info("Assuming role as %s", arn) # Clear out empty values for name in ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_SECURITY_TOKEN', 'AWS_SESSION_TOKEN']: if name in ...
[ "def", "assume_role_credentials", "(", "self", ",", "arn", ")", ":", "log", ".", "info", "(", "\"Assuming role as %s\"", ",", "arn", ")", "# Clear out empty values", "for", "name", "in", "[", "'AWS_ACCESS_KEY_ID'", ",", "'AWS_SECRET_ACCESS_KEY'", ",", "'AWS_SECURITY...
Return the environment variables for an assumed role
[ "Return", "the", "environment", "variables", "for", "an", "assumed", "role" ]
train
https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/amazon/iam.py#L158-L176
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._validate_token
def _validate_token(self): ''' a method to validate active access token ''' title = '%s._validate_token' % self.__class__.__name__ # construct access token url import requests url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=%s' % self.access_...
python
def _validate_token(self): ''' a method to validate active access token ''' title = '%s._validate_token' % self.__class__.__name__ # construct access token url import requests url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=%s' % self.access_...
[ "def", "_validate_token", "(", "self", ")", ":", "title", "=", "'%s._validate_token'", "%", "self", ".", "__class__", ".", "__name__", "# construct access token url", "import", "requests", "url", "=", "'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=%s'", "%", ...
a method to validate active access token
[ "a", "method", "to", "validate", "active", "access", "token" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L189-L234
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._get_id
def _get_id(self, file_path): ''' a helper method for retrieving id of file or folder ''' title = '%s._get_id' % self.__class__.__name__ # construct request kwargs list_kwargs = { 'spaces': self.drive_space, 'fields': 'files(id, parents)' ...
python
def _get_id(self, file_path): ''' a helper method for retrieving id of file or folder ''' title = '%s._get_id' % self.__class__.__name__ # construct request kwargs list_kwargs = { 'spaces': self.drive_space, 'fields': 'files(id, parents)' ...
[ "def", "_get_id", "(", "self", ",", "file_path", ")", ":", "title", "=", "'%s._get_id'", "%", "self", ".", "__class__", ".", "__name__", "# construct request kwargs", "list_kwargs", "=", "{", "'spaces'", ":", "self", ".", "drive_space", ",", "'fields'", ":", ...
a helper method for retrieving id of file or folder
[ "a", "helper", "method", "for", "retrieving", "id", "of", "file", "or", "folder" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L236-L271
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._get_space
def _get_space(self): ''' a helper method to retrieve id of drive space ''' title = '%s._space_id' % self.__class__.__name__ list_kwargs = { 'q': "'%s' in parents" % self.drive_space, 'spaces': self.drive_space, 'fields': 'files(name, parents...
python
def _get_space(self): ''' a helper method to retrieve id of drive space ''' title = '%s._space_id' % self.__class__.__name__ list_kwargs = { 'q': "'%s' in parents" % self.drive_space, 'spaces': self.drive_space, 'fields': 'files(name, parents...
[ "def", "_get_space", "(", "self", ")", ":", "title", "=", "'%s._space_id'", "%", "self", ".", "__class__", ".", "__name__", "list_kwargs", "=", "{", "'q'", ":", "\"'%s' in parents\"", "%", "self", ".", "drive_space", ",", "'spaces'", ":", "self", ".", "dri...
a helper method to retrieve id of drive space
[ "a", "helper", "method", "to", "retrieve", "id", "of", "drive", "space" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L273-L291
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._get_data
def _get_data(self, file_id): ''' a helper method for retrieving the byte data of a file ''' title = '%s._get_data' % self.__class__.__name__ # request file data try: record_data = self.drive.get_media(fileId=file_id).execute() except: r...
python
def _get_data(self, file_id): ''' a helper method for retrieving the byte data of a file ''' title = '%s._get_data' % self.__class__.__name__ # request file data try: record_data = self.drive.get_media(fileId=file_id).execute() except: r...
[ "def", "_get_data", "(", "self", ",", "file_id", ")", ":", "title", "=", "'%s._get_data'", "%", "self", ".", "__class__", ".", "__name__", "# request file data", "try", ":", "record_data", "=", "self", ".", "drive", ".", "get_media", "(", "fileId", "=", "f...
a helper method for retrieving the byte data of a file
[ "a", "helper", "method", "for", "retrieving", "the", "byte", "data", "of", "a", "file" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L293-L305
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._get_metadata
def _get_metadata(self, file_id, metadata_fields=''): ''' a helper method for retrieving the metadata of a file ''' title = '%s._get_metadata' % self.__class__.__name__ # construct fields arg if not metadata_fields: metadata_fields = ','.join(self.objec...
python
def _get_metadata(self, file_id, metadata_fields=''): ''' a helper method for retrieving the metadata of a file ''' title = '%s._get_metadata' % self.__class__.__name__ # construct fields arg if not metadata_fields: metadata_fields = ','.join(self.objec...
[ "def", "_get_metadata", "(", "self", ",", "file_id", ",", "metadata_fields", "=", "''", ")", ":", "title", "=", "'%s._get_metadata'", "%", "self", ".", "__class__", ".", "__name__", "# construct fields arg", "if", "not", "metadata_fields", ":", "metadata_fields", ...
a helper method for retrieving the metadata of a file
[ "a", "helper", "method", "for", "retrieving", "the", "metadata", "of", "a", "file" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L307-L328
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._list_directory
def _list_directory(self, folder_id=''): ''' a generator method for listing the contents of a directory ''' title = '%s._list_directory' % self.__class__.__name__ # construct default response file_list = [] # construct request kwargs list_kwargs = { ...
python
def _list_directory(self, folder_id=''): ''' a generator method for listing the contents of a directory ''' title = '%s._list_directory' % self.__class__.__name__ # construct default response file_list = [] # construct request kwargs list_kwargs = { ...
[ "def", "_list_directory", "(", "self", ",", "folder_id", "=", "''", ")", ":", "title", "=", "'%s._list_directory'", "%", "self", ".", "__class__", ".", "__name__", "# construct default response", "file_list", "=", "[", "]", "# construct request kwargs", "list_kwargs...
a generator method for listing the contents of a directory
[ "a", "generator", "method", "for", "listing", "the", "contents", "of", "a", "directory" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L330-L374
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._walk
def _walk(self, root_path='', root_id=''): ''' a generator method which walks the file structure of the dropbox collection ''' title = '%s._walk' % self.__class__.__name__ if root_id: pass elif root_path: root_id, root_parent = self._get...
python
def _walk(self, root_path='', root_id=''): ''' a generator method which walks the file structure of the dropbox collection ''' title = '%s._walk' % self.__class__.__name__ if root_id: pass elif root_path: root_id, root_parent = self._get...
[ "def", "_walk", "(", "self", ",", "root_path", "=", "''", ",", "root_id", "=", "''", ")", ":", "title", "=", "'%s._walk'", "%", "self", ".", "__class__", ".", "__name__", "if", "root_id", ":", "pass", "elif", "root_path", ":", "root_id", ",", "root_par...
a generator method which walks the file structure of the dropbox collection
[ "a", "generator", "method", "which", "walks", "the", "file", "structure", "of", "the", "dropbox", "collection" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L376-L392
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient._import
def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs): ''' a helper method for other storage clients to import into appdata :param record_key: string with key for record :param record_data: byte data for body of record :...
python
def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs): ''' a helper method for other storage clients to import into appdata :param record_key: string with key for record :param record_data: byte data for body of record :...
[ "def", "_import", "(", "self", ",", "record_key", ",", "record_data", ",", "overwrite", "=", "True", ",", "last_modified", "=", "0.0", ",", "*", "*", "kwargs", ")", ":", "title", "=", "'%s._import'", "%", "self", ".", "__class__", ".", "__name__", "# ver...
a helper method for other storage clients to import into appdata :param record_key: string with key for record :param record_data: byte data for body of record :param overwrite: [optional] boolean to overwrite existing records :param last_modified: [optional] float to record...
[ "a", "helper", "method", "for", "other", "storage", "clients", "to", "import", "into", "appdata", ":", "param", "record_key", ":", "string", "with", "key", "for", "record", ":", "param", "record_data", ":", "byte", "data", "for", "body", "of", "record", ":...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L394-L527
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient.exists
def exists(self, record_key): ''' a method to determine if a record exists in collection :param record_key: string with key of record :return: boolean indicating file existence ''' title = '%s.exists' % self.__class__.__name__ # validate i...
python
def exists(self, record_key): ''' a method to determine if a record exists in collection :param record_key: string with key of record :return: boolean indicating file existence ''' title = '%s.exists' % self.__class__.__name__ # validate i...
[ "def", "exists", "(", "self", ",", "record_key", ")", ":", "title", "=", "'%s.exists'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'record_key'", ":", "record_key", "}", "for", "key", ",", "value", "in", ...
a method to determine if a record exists in collection :param record_key: string with key of record :return: boolean indicating file existence
[ "a", "method", "to", "determine", "if", "a", "record", "exists", "in", "collection" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L529-L558
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient.save
def save(self, record_key, record_data, overwrite=True, secret_key=''): ''' a method to create a record in the collection folder :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overwrite: [optio...
python
def save(self, record_key, record_data, overwrite=True, secret_key=''): ''' a method to create a record in the collection folder :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overwrite: [optio...
[ "def", "save", "(", "self", ",", "record_key", ",", "record_data", ",", "overwrite", "=", "True", ",", "secret_key", "=", "''", ")", ":", "title", "=", "'%s.save'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "...
a method to create a record in the collection folder :param record_key: string with name to assign to record (see NOTES below) :param record_data: byte data for record body :param overwrite: [optional] boolean to overwrite records with same name :param secret_key: [optional] string with...
[ "a", "method", "to", "create", "a", "record", "in", "the", "collection", "folder" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L560-L725
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient.load
def load(self, record_key, secret_key=''): ''' a method to retrieve byte data of appdata record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body ''' title = '%s.load'...
python
def load(self, record_key, secret_key=''): ''' a method to retrieve byte data of appdata record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body ''' title = '%s.load'...
[ "def", "load", "(", "self", ",", "record_key", ",", "secret_key", "=", "''", ")", ":", "title", "=", "'%s.load'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'record_key'", ":", "record_key", ",", "'secret_...
a method to retrieve byte data of appdata record :param record_key: string with name of record :param secret_key: [optional] string used to decrypt data :return: byte data for record body
[ "a", "method", "to", "retrieve", "byte", "data", "of", "appdata", "record" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L727-L780
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient.list
def list(self, prefix='', delimiter='', filter_function=None, max_results=1, previous_key=''): ''' a method to list keys in the google drive collection :param prefix: string with prefix value to filter results :param delimiter: string with value which results must not cont...
python
def list(self, prefix='', delimiter='', filter_function=None, max_results=1, previous_key=''): ''' a method to list keys in the google drive collection :param prefix: string with prefix value to filter results :param delimiter: string with value which results must not cont...
[ "def", "list", "(", "self", ",", "prefix", "=", "''", ",", "delimiter", "=", "''", ",", "filter_function", "=", "None", ",", "max_results", "=", "1", ",", "previous_key", "=", "''", ")", ":", "title", "=", "'%s.list'", "%", "self", ".", "__class__", ...
a method to list keys in the google drive collection :param prefix: string with prefix value to filter results :param delimiter: string with value which results must not contain (after prefix) :param filter_function: (positional arguments) function used to filter results :param max_resu...
[ "a", "method", "to", "list", "keys", "in", "the", "google", "drive", "collection" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L815-L920
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient.delete
def delete(self, record_key): ''' a method to delete a file :param record_key: string with name of file :return: string reporting outcome ''' title = '%s.delete' % self.__class__.__name__ # validate inputs input_fields = { 'record_key': record_key ...
python
def delete(self, record_key): ''' a method to delete a file :param record_key: string with name of file :return: string reporting outcome ''' title = '%s.delete' % self.__class__.__name__ # validate inputs input_fields = { 'record_key': record_key ...
[ "def", "delete", "(", "self", ",", "record_key", ")", ":", "title", "=", "'%s.delete'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'record_key'", ":", "record_key", "}", "for", "key", ",", "value", "in", ...
a method to delete a file :param record_key: string with name of file :return: string reporting outcome
[ "a", "method", "to", "delete", "a", "file" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L922-L973
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient.remove
def remove(self): ''' a method to remove all records in the collection NOTE: this method removes all the files in the collection, but the collection folder itself created by oauth2 cannot be removed. only the user can remove access to the app fold...
python
def remove(self): ''' a method to remove all records in the collection NOTE: this method removes all the files in the collection, but the collection folder itself created by oauth2 cannot be removed. only the user can remove access to the app fold...
[ "def", "remove", "(", "self", ")", ":", "title", "=", "'%s.remove'", "%", "self", ".", "__class__", ".", "__name__", "# get contents of root", "for", "id", ",", "name", ",", "mimetype", "in", "self", ".", "_list_directory", "(", ")", ":", "try", ":", "se...
a method to remove all records in the collection NOTE: this method removes all the files in the collection, but the collection folder itself created by oauth2 cannot be removed. only the user can remove access to the app folder :return: string with con...
[ "a", "method", "to", "remove", "all", "records", "in", "the", "collection" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L975-L1004
collectiveacuity/labPack
labpack/storage/google/drive.py
driveClient.export
def export(self, storage_client, overwrite=True): ''' a method to export all the records in collection to another platform :param storage_client: class object with storage client methods :return: string with exit message ''' title = '%s....
python
def export(self, storage_client, overwrite=True): ''' a method to export all the records in collection to another platform :param storage_client: class object with storage client methods :return: string with exit message ''' title = '%s....
[ "def", "export", "(", "self", ",", "storage_client", ",", "overwrite", "=", "True", ")", ":", "title", "=", "'%s.export'", "%", "self", ".", "__class__", ".", "__name__", "# validate storage client", "method_list", "=", "[", "'save'", ",", "'load'", ",", "'l...
a method to export all the records in collection to another platform :param storage_client: class object with storage client methods :return: string with exit message
[ "a", "method", "to", "export", "all", "the", "records", "in", "collection", "to", "another", "platform", ":", "param", "storage_client", ":", "class", "object", "with", "storage", "client", "methods", ":", "return", ":", "string", "with", "exit", "message" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/google/drive.py#L1006-L1067
dsoprea/protobufp
protobufp/read_buffer.py
ReadBuffer.read_message
def read_message(self): """Try to read a message from the buffered data. A message is defined as a 32-bit integer size, followed that number of bytes. First we try to non-destructively read the integer. Then, we try to non- destructively read the remaining bytes. If both are successful,...
python
def read_message(self): """Try to read a message from the buffered data. A message is defined as a 32-bit integer size, followed that number of bytes. First we try to non-destructively read the integer. Then, we try to non- destructively read the remaining bytes. If both are successful,...
[ "def", "read_message", "(", "self", ")", ":", "with", "self", ".", "__class__", ".", "__locker", ":", "result", "=", "self", ".", "__passive_read", "(", "4", ")", "if", "result", "is", "None", ":", "return", "None", "(", "four_bytes", ",", "last_buffer_i...
Try to read a message from the buffered data. A message is defined as a 32-bit integer size, followed that number of bytes. First we try to non-destructively read the integer. Then, we try to non- destructively read the remaining bytes. If both are successful, we then go back to remove ...
[ "Try", "to", "read", "a", "message", "from", "the", "buffered", "data", ".", "A", "message", "is", "defined", "as", "a", "32", "-", "bit", "integer", "size", "followed", "that", "number", "of", "bytes", ".", "First", "we", "try", "to", "non", "-", "d...
train
https://github.com/dsoprea/protobufp/blob/3ba4d583d1002761ad316072bc0259b147584dcd/protobufp/read_buffer.py#L31-L68
dsoprea/protobufp
protobufp/read_buffer.py
ReadBuffer.__passive_read
def __passive_read(self, length, start_buffer_index=None): """Read the given length of bytes, or return None if we can't provide [all of] them yet. When the given length is available but ends in the middle of a buffer, we'll split the buffer. We do this to make it simpler to continue ...
python
def __passive_read(self, length, start_buffer_index=None): """Read the given length of bytes, or return None if we can't provide [all of] them yet. When the given length is available but ends in the middle of a buffer, we'll split the buffer. We do this to make it simpler to continue ...
[ "def", "__passive_read", "(", "self", ",", "length", ",", "start_buffer_index", "=", "None", ")", ":", "if", "length", ">", "self", ".", "__length", ":", "return", "None", "with", "self", ".", "__class__", ".", "__locker", ":", "collected", "=", "[", "]"...
Read the given length of bytes, or return None if we can't provide [all of] them yet. When the given length is available but ends in the middle of a buffer, we'll split the buffer. We do this to make it simpler to continue from that point next time (it's always simpler to start at th...
[ "Read", "the", "given", "length", "of", "bytes", "or", "return", "None", "if", "we", "can", "t", "provide", "[", "all", "of", "]", "them", "yet", ".", "When", "the", "given", "length", "is", "available", "but", "ends", "in", "the", "middle", "of", "a...
train
https://github.com/dsoprea/protobufp/blob/3ba4d583d1002761ad316072bc0259b147584dcd/protobufp/read_buffer.py#L70-L121
dsoprea/protobufp
protobufp/read_buffer.py
ReadBuffer.__cleanup
def __cleanup(self): """Clip buffers that the top of our list that have been completely exhausted. """ # TODO: Test this. with self.__class__.__locker: while self.__read_buffer_index > 0: del self.__buffers[0] self.__read_buffer_index -= 1
python
def __cleanup(self): """Clip buffers that the top of our list that have been completely exhausted. """ # TODO: Test this. with self.__class__.__locker: while self.__read_buffer_index > 0: del self.__buffers[0] self.__read_buffer_index -= 1
[ "def", "__cleanup", "(", "self", ")", ":", "# TODO: Test this.", "with", "self", ".", "__class__", ".", "__locker", ":", "while", "self", ".", "__read_buffer_index", ">", "0", ":", "del", "self", ".", "__buffers", "[", "0", "]", "self", ".", "__read_buffer...
Clip buffers that the top of our list that have been completely exhausted.
[ "Clip", "buffers", "that", "the", "top", "of", "our", "list", "that", "have", "been", "completely", "exhausted", "." ]
train
https://github.com/dsoprea/protobufp/blob/3ba4d583d1002761ad316072bc0259b147584dcd/protobufp/read_buffer.py#L123-L132
pip-services3-python/pip-services3-components-python
pip_services3_components/log/ConsoleLogger.py
ConsoleLogger._write
def _write(self, level, correlation_id, error, message): """ Writes a log message to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this me...
python
def _write(self, level, correlation_id, error, message): """ Writes a log message to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this me...
[ "def", "_write", "(", "self", ",", "level", ",", "correlation_id", ",", "error", ",", "message", ")", ":", "if", "(", "self", ".", "_level", "<", "level", ")", ":", "return", "output", "=", "\"[\"", "output", "+=", "correlation_id", "if", "correlation_id...
Writes a log message to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human-readable message to log.
[ "Writes", "a", "log", "message", "to", "the", "logger", "destination", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/ConsoleLogger.py#L62-L100
jic-dtool/dtool-info
dtool_info/overlay.py
ls
def ls(dataset_uri): """ List the overlays in the dataset. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) for overlay_name in dataset.list_overlay_names(): click.secho(overlay_name)
python
def ls(dataset_uri): """ List the overlays in the dataset. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) for overlay_name in dataset.list_overlay_names(): click.secho(overlay_name)
[ "def", "ls", "(", "dataset_uri", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "for", "overlay_name", "in", "dataset", ".", "list_overlay_names", "(", ")", ":", "click", ".", "secho", "(", "overlay_name", ...
List the overlays in the dataset.
[ "List", "the", "overlays", "in", "the", "dataset", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/overlay.py#L28-L34
jic-dtool/dtool-info
dtool_info/overlay.py
show
def show(dataset_uri, overlay_name): """ Show the content of a specific overlay. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) try: overlay = dataset.get_overlay(overlay_name) except: # NOQA click.secho( "No such overlay: {}".format(overlay_name), ...
python
def show(dataset_uri, overlay_name): """ Show the content of a specific overlay. """ dataset = dtoolcore.DataSet.from_uri(dataset_uri) try: overlay = dataset.get_overlay(overlay_name) except: # NOQA click.secho( "No such overlay: {}".format(overlay_name), ...
[ "def", "show", "(", "dataset_uri", ",", "overlay_name", ")", ":", "dataset", "=", "dtoolcore", ".", "DataSet", ".", "from_uri", "(", "dataset_uri", ")", "try", ":", "overlay", "=", "dataset", ".", "get_overlay", "(", "overlay_name", ")", "except", ":", "# ...
Show the content of a specific overlay.
[ "Show", "the", "content", "of", "a", "specific", "overlay", "." ]
train
https://github.com/jic-dtool/dtool-info/blob/3c6c7755f4c142e548bbfdf3b38230612fd4060a/dtool_info/overlay.py#L40-L60
baliame/http-hmac-python
httphmac/request.py
canonicalize_header
def canonicalize_header(key): """Returns the canonicalized header name for the header name provided as an argument. The canonicalized header name according to the HTTP RFC is Kebab-Camel-Case. Keyword arguments: key -- the name of the header """ bits = key.split('-') for idx, b in enumerate...
python
def canonicalize_header(key): """Returns the canonicalized header name for the header name provided as an argument. The canonicalized header name according to the HTTP RFC is Kebab-Camel-Case. Keyword arguments: key -- the name of the header """ bits = key.split('-') for idx, b in enumerate...
[ "def", "canonicalize_header", "(", "key", ")", ":", "bits", "=", "key", ".", "split", "(", "'-'", ")", "for", "idx", ",", "b", "in", "enumerate", "(", "bits", ")", ":", "bits", "[", "idx", "]", "=", "b", ".", "capitalize", "(", ")", "return", "'-...
Returns the canonicalized header name for the header name provided as an argument. The canonicalized header name according to the HTTP RFC is Kebab-Camel-Case. Keyword arguments: key -- the name of the header
[ "Returns", "the", "canonicalized", "header", "name", "for", "the", "header", "name", "provided", "as", "an", "argument", ".", "The", "canonicalized", "header", "name", "according", "to", "the", "HTTP", "RFC", "is", "Kebab", "-", "Camel", "-", "Case", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L99-L109
baliame/http-hmac-python
httphmac/request.py
URL.validate
def validate(self): """Validates the URL object. The URL object is invalid if it does not represent an absolute URL. Returns True or False based on this. """ if (self.scheme is None or self.scheme != '') \ and (self.host is None or self.host == ''): return False ...
python
def validate(self): """Validates the URL object. The URL object is invalid if it does not represent an absolute URL. Returns True or False based on this. """ if (self.scheme is None or self.scheme != '') \ and (self.host is None or self.host == ''): return False ...
[ "def", "validate", "(", "self", ")", ":", "if", "(", "self", ".", "scheme", "is", "None", "or", "self", ".", "scheme", "!=", "''", ")", "and", "(", "self", ".", "host", "is", "None", "or", "self", ".", "host", "==", "''", ")", ":", "return", "F...
Validates the URL object. The URL object is invalid if it does not represent an absolute URL. Returns True or False based on this.
[ "Validates", "the", "URL", "object", ".", "The", "URL", "object", "is", "invalid", "if", "it", "does", "not", "represent", "an", "absolute", "URL", ".", "Returns", "True", "or", "False", "based", "on", "this", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L37-L44
baliame/http-hmac-python
httphmac/request.py
URL.request_uri
def request_uri(self): """Returns the request URL element of the URL. This request URL is the path, the query and the fragment appended as a relative URL to the host. The request URL always contains at least a leading slash. """ result = '/{0}'.format(self.path.lstrip('/')) ...
python
def request_uri(self): """Returns the request URL element of the URL. This request URL is the path, the query and the fragment appended as a relative URL to the host. The request URL always contains at least a leading slash. """ result = '/{0}'.format(self.path.lstrip('/')) ...
[ "def", "request_uri", "(", "self", ")", ":", "result", "=", "'/{0}'", ".", "format", "(", "self", ".", "path", ".", "lstrip", "(", "'/'", ")", ")", "if", "self", ".", "query", "is", "not", "None", "and", "self", ".", "query", "!=", "''", "and", "...
Returns the request URL element of the URL. This request URL is the path, the query and the fragment appended as a relative URL to the host. The request URL always contains at least a leading slash.
[ "Returns", "the", "request", "URL", "element", "of", "the", "URL", ".", "This", "request", "URL", "is", "the", "path", "the", "query", "and", "the", "fragment", "appended", "as", "a", "relative", "URL", "to", "the", "host", ".", "The", "request", "URL", ...
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L68-L78
baliame/http-hmac-python
httphmac/request.py
URL.encoded_query
def encoded_query(self): """Returns the encoded query string of the URL. This may be different from the rawquery element, as that contains the query parsed by urllib but unmodified. The return value takes the form of key=value&key=value, and it never contains a leading question mark. """...
python
def encoded_query(self): """Returns the encoded query string of the URL. This may be different from the rawquery element, as that contains the query parsed by urllib but unmodified. The return value takes the form of key=value&key=value, and it never contains a leading question mark. """...
[ "def", "encoded_query", "(", "self", ")", ":", "if", "self", ".", "query", "is", "not", "None", "and", "self", ".", "query", "!=", "''", "and", "self", ".", "query", "!=", "{", "}", ":", "try", ":", "return", "urlencode", "(", "self", ".", "query",...
Returns the encoded query string of the URL. This may be different from the rawquery element, as that contains the query parsed by urllib but unmodified. The return value takes the form of key=value&key=value, and it never contains a leading question mark.
[ "Returns", "the", "encoded", "query", "string", "of", "the", "URL", ".", "This", "may", "be", "different", "from", "the", "rawquery", "element", "as", "that", "contains", "the", "query", "parsed", "by", "urllib", "but", "unmodified", ".", "The", "return", ...
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L85-L96
baliame/http-hmac-python
httphmac/request.py
Request.with_url
def with_url(self, url): """Sets the request's URL and returns the request itself. Automatically sets the Host header according to the URL. Keyword arguments: url -- a string representing the URL the set for the request """ self.url = URL(url) self.header["Host"]...
python
def with_url(self, url): """Sets the request's URL and returns the request itself. Automatically sets the Host header according to the URL. Keyword arguments: url -- a string representing the URL the set for the request """ self.url = URL(url) self.header["Host"]...
[ "def", "with_url", "(", "self", ",", "url", ")", ":", "self", ".", "url", "=", "URL", "(", "url", ")", "self", ".", "header", "[", "\"Host\"", "]", "=", "self", ".", "url", ".", "host", "return", "self" ]
Sets the request's URL and returns the request itself. Automatically sets the Host header according to the URL. Keyword arguments: url -- a string representing the URL the set for the request
[ "Sets", "the", "request", "s", "URL", "and", "returns", "the", "request", "itself", ".", "Automatically", "sets", "the", "Host", "header", "according", "to", "the", "URL", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L130-L139
baliame/http-hmac-python
httphmac/request.py
Request.with_header
def with_header(self, key, value): """Sets a header on the request and returns the request itself. The header key will be canonicalized before use. (see also: canonicalize_header) Keyword arguments: key -- the header's name value -- the string value for the header """ ...
python
def with_header(self, key, value): """Sets a header on the request and returns the request itself. The header key will be canonicalized before use. (see also: canonicalize_header) Keyword arguments: key -- the header's name value -- the string value for the header """ ...
[ "def", "with_header", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "header", "[", "canonicalize_header", "(", "key", ")", "]", "=", "value", "return", "self" ]
Sets a header on the request and returns the request itself. The header key will be canonicalized before use. (see also: canonicalize_header) Keyword arguments: key -- the header's name value -- the string value for the header
[ "Sets", "a", "header", "on", "the", "request", "and", "returns", "the", "request", "itself", ".", "The", "header", "key", "will", "be", "canonicalized", "before", "use", ".", "(", "see", "also", ":", "canonicalize_header", ")" ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L141-L150
baliame/http-hmac-python
httphmac/request.py
Request.with_headers
def with_headers(self, headers): """Sets multiple headers on the request and returns the request itself. Keyword arguments: headers -- a dict-like object which contains the headers to set. """ for key, value in headers.items(): self.with_header(key, value) re...
python
def with_headers(self, headers): """Sets multiple headers on the request and returns the request itself. Keyword arguments: headers -- a dict-like object which contains the headers to set. """ for key, value in headers.items(): self.with_header(key, value) re...
[ "def", "with_headers", "(", "self", ",", "headers", ")", ":", "for", "key", ",", "value", "in", "headers", ".", "items", "(", ")", ":", "self", ".", "with_header", "(", "key", ",", "value", ")", "return", "self" ]
Sets multiple headers on the request and returns the request itself. Keyword arguments: headers -- a dict-like object which contains the headers to set.
[ "Sets", "multiple", "headers", "on", "the", "request", "and", "returns", "the", "request", "itself", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L152-L160
baliame/http-hmac-python
httphmac/request.py
Request.with_time
def with_time(self): """Sets the time headers used by Acquia signature versions to the appropriate value and returns the request itself. These headers are X-Authorization-Timestamp (v2) and Date (v1). """ self.header["X-Authorization-Timestamp"] = str(int(time.time())) self.heade...
python
def with_time(self): """Sets the time headers used by Acquia signature versions to the appropriate value and returns the request itself. These headers are X-Authorization-Timestamp (v2) and Date (v1). """ self.header["X-Authorization-Timestamp"] = str(int(time.time())) self.heade...
[ "def", "with_time", "(", "self", ")", ":", "self", ".", "header", "[", "\"X-Authorization-Timestamp\"", "]", "=", "str", "(", "int", "(", "time", ".", "time", "(", ")", ")", ")", "self", ".", "header", "[", "\"Date\"", "]", "=", "str", "(", "int", ...
Sets the time headers used by Acquia signature versions to the appropriate value and returns the request itself. These headers are X-Authorization-Timestamp (v2) and Date (v1).
[ "Sets", "the", "time", "headers", "used", "by", "Acquia", "signature", "versions", "to", "the", "appropriate", "value", "and", "returns", "the", "request", "itself", ".", "These", "headers", "are", "X", "-", "Authorization", "-", "Timestamp", "(", "v2", ")",...
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L162-L168
baliame/http-hmac-python
httphmac/request.py
Request.with_body
def with_body(self, body): # @todo take encoding into account """Sets the request body to the provided value and returns the request itself. Keyword arguments: body -- A UTF-8 string or bytes-like object which represents the request body. """ try: self.body =...
python
def with_body(self, body): # @todo take encoding into account """Sets the request body to the provided value and returns the request itself. Keyword arguments: body -- A UTF-8 string or bytes-like object which represents the request body. """ try: self.body =...
[ "def", "with_body", "(", "self", ",", "body", ")", ":", "# @todo take encoding into account", "try", ":", "self", ".", "body", "=", "body", ".", "encode", "(", "'utf-8'", ")", "except", ":", "try", ":", "self", ".", "body", "=", "bytes", "(", "body", "...
Sets the request body to the provided value and returns the request itself. Keyword arguments: body -- A UTF-8 string or bytes-like object which represents the request body.
[ "Sets", "the", "request", "body", "to", "the", "provided", "value", "and", "returns", "the", "request", "itself", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L170-L188
baliame/http-hmac-python
httphmac/request.py
Request.with_json_body
def with_json_body(self, body): """Sets the request body to the provided value and returns the request itself. Also sets the Content-Type header to application/json. Keyword arguments: body -- A body that is either accepted by with_body or is convertible to (or is) a dict object. ...
python
def with_json_body(self, body): """Sets the request body to the provided value and returns the request itself. Also sets the Content-Type header to application/json. Keyword arguments: body -- A body that is either accepted by with_body or is convertible to (or is) a dict object. ...
[ "def", "with_json_body", "(", "self", ",", "body", ")", ":", "try", ":", "self", ".", "with_body", "(", "json", ".", "dumps", "(", "dict", "(", "body", ")", ")", ")", "except", ":", "try", ":", "self", ".", "with_body", "(", "body", ")", "except", ...
Sets the request body to the provided value and returns the request itself. Also sets the Content-Type header to application/json. Keyword arguments: body -- A body that is either accepted by with_body or is convertible to (or is) a dict object. If a dict-like object is provided, it...
[ "Sets", "the", "request", "body", "to", "the", "provided", "value", "and", "returns", "the", "request", "itself", ".", "Also", "sets", "the", "Content", "-", "Type", "header", "to", "application", "/", "json", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L190-L206
baliame/http-hmac-python
httphmac/request.py
Request.get_header
def get_header(self, key): """Returns the requested header, or an empty string if the header is not set. Keyword arguments: key -- The header name. It will be canonicalized before use. """ key = canonicalize_header(key) if key in self.header: return self.head...
python
def get_header(self, key): """Returns the requested header, or an empty string if the header is not set. Keyword arguments: key -- The header name. It will be canonicalized before use. """ key = canonicalize_header(key) if key in self.header: return self.head...
[ "def", "get_header", "(", "self", ",", "key", ")", ":", "key", "=", "canonicalize_header", "(", "key", ")", "if", "key", "in", "self", ".", "header", ":", "return", "self", ".", "header", "[", "key", "]", "return", "''" ]
Returns the requested header, or an empty string if the header is not set. Keyword arguments: key -- The header name. It will be canonicalized before use.
[ "Returns", "the", "requested", "header", "or", "an", "empty", "string", "if", "the", "header", "is", "not", "set", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L208-L217
baliame/http-hmac-python
httphmac/request.py
Request.do
def do(self): """Executes the request represented by this object. The requests library will be used for this purpose. Returns an instance of requests.Response. """ data = None if self.body is not None and self.body != b'': data = self.body return requests.requ...
python
def do(self): """Executes the request represented by this object. The requests library will be used for this purpose. Returns an instance of requests.Response. """ data = None if self.body is not None and self.body != b'': data = self.body return requests.requ...
[ "def", "do", "(", "self", ")", ":", "data", "=", "None", "if", "self", ".", "body", "is", "not", "None", "and", "self", ".", "body", "!=", "b''", ":", "data", "=", "self", ".", "body", "return", "requests", ".", "request", "(", "self", ".", "meth...
Executes the request represented by this object. The requests library will be used for this purpose. Returns an instance of requests.Response.
[ "Executes", "the", "request", "represented", "by", "this", "object", ".", "The", "requests", "library", "will", "be", "used", "for", "this", "purpose", ".", "Returns", "an", "instance", "of", "requests", ".", "Response", "." ]
train
https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/request.py#L219-L226
radjkarl/fancyTools
fancytools/utils/StreamSignal.py
StreamSignal.setWriteToShell
def setWriteToShell(self, writeToShell=True): """connect sysout to the qtSignal""" if writeToShell and not self._connected: self.message.connect(self.stdW) self._connected = True elif not writeToShell and self._connected: try: self.messa...
python
def setWriteToShell(self, writeToShell=True): """connect sysout to the qtSignal""" if writeToShell and not self._connected: self.message.connect(self.stdW) self._connected = True elif not writeToShell and self._connected: try: self.messa...
[ "def", "setWriteToShell", "(", "self", ",", "writeToShell", "=", "True", ")", ":", "if", "writeToShell", "and", "not", "self", ".", "_connected", ":", "self", ".", "message", ".", "connect", "(", "self", ".", "stdW", ")", "self", ".", "_connected", "=", ...
connect sysout to the qtSignal
[ "connect", "sysout", "to", "the", "qtSignal" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/utils/StreamSignal.py#L62-L72
synw/django-introspection
introspection/inspector/__init__.py
Inspector.query
def query(self, jsonq, operator="and", count=False): """ returns a Django orm query from json input: { "app": "auth", "model": "User", "filters": { "is_superuser": False, "username__icontains": "foo" } """ model = self._get_...
python
def query(self, jsonq, operator="and", count=False): """ returns a Django orm query from json input: { "app": "auth", "model": "User", "filters": { "is_superuser": False, "username__icontains": "foo" } """ model = self._get_...
[ "def", "query", "(", "self", ",", "jsonq", ",", "operator", "=", "\"and\"", ",", "count", "=", "False", ")", ":", "model", "=", "self", ".", "_get_model", "(", "jsonq", "[", "\"app\"", "]", ",", "jsonq", "[", "\"model\"", "]", ")", "fdict", "=", "j...
returns a Django orm query from json input: { "app": "auth", "model": "User", "filters": { "is_superuser": False, "username__icontains": "foo" }
[ "returns", "a", "Django", "orm", "query", "from", "json", "input", ":", "{", "app", ":", "auth", "model", ":", "User", "filters", ":", "{", "is_superuser", ":", "False", "username__icontains", ":", "foo", "}" ]
train
https://github.com/synw/django-introspection/blob/58a9c44af36965e0f203456891172d560140f83c/introspection/inspector/__init__.py#L193-L237
synw/django-introspection
introspection/inspector/__init__.py
Inspector._models
def _models(self, appname): """ return models_array """ try: app = self._get_app(appname) except Exception as e: self.err("Can not get app " + appname, e) return if appname not in self.appnames: self.err("App " + appname + "...
python
def _models(self, appname): """ return models_array """ try: app = self._get_app(appname) except Exception as e: self.err("Can not get app " + appname, e) return if appname not in self.appnames: self.err("App " + appname + "...
[ "def", "_models", "(", "self", ",", "appname", ")", ":", "try", ":", "app", "=", "self", ".", "_get_app", "(", "appname", ")", "except", "Exception", "as", "e", ":", "self", ".", "err", "(", "\"Can not get app \"", "+", "appname", ",", "e", ")", "ret...
return models_array
[ "return", "models_array" ]
train
https://github.com/synw/django-introspection/blob/58a9c44af36965e0f203456891172d560140f83c/introspection/inspector/__init__.py#L239-L252
synw/django-introspection
introspection/inspector/__init__.py
Inspector._get_app
def _get_app(self, appname): """ returns app object or None """ try: app = APPS.get_app_config(appname) except Exception as e: self.err(e) return return app
python
def _get_app(self, appname): """ returns app object or None """ try: app = APPS.get_app_config(appname) except Exception as e: self.err(e) return return app
[ "def", "_get_app", "(", "self", ",", "appname", ")", ":", "try", ":", "app", "=", "APPS", ".", "get_app_config", "(", "appname", ")", "except", "Exception", "as", "e", ":", "self", ".", "err", "(", "e", ")", "return", "return", "app" ]
returns app object or None
[ "returns", "app", "object", "or", "None" ]
train
https://github.com/synw/django-introspection/blob/58a9c44af36965e0f203456891172d560140f83c/introspection/inspector/__init__.py#L254-L263
synw/django-introspection
introspection/inspector/__init__.py
Inspector._get_model
def _get_model(self, appname, modelname): """ return model or None """ app = self._get_app(appname) models = app.get_models() model = None for mod in models: if mod.__name__ == modelname: model = mod return model ...
python
def _get_model(self, appname, modelname): """ return model or None """ app = self._get_app(appname) models = app.get_models() model = None for mod in models: if mod.__name__ == modelname: model = mod return model ...
[ "def", "_get_model", "(", "self", ",", "appname", ",", "modelname", ")", ":", "app", "=", "self", ".", "_get_app", "(", "appname", ")", "models", "=", "app", ".", "get_models", "(", ")", "model", "=", "None", "for", "mod", "in", "models", ":", "if", ...
return model or None
[ "return", "model", "or", "None" ]
train
https://github.com/synw/django-introspection/blob/58a9c44af36965e0f203456891172d560140f83c/introspection/inspector/__init__.py#L265-L276
synw/django-introspection
introspection/inspector/__init__.py
Inspector._get_models
def _get_models(self, app): """ return models_array """ try: app_models = app.get_models() appmods = [] for model in app_models: appmods.append(model) except Exception as e: self.err(e) return ret...
python
def _get_models(self, app): """ return models_array """ try: app_models = app.get_models() appmods = [] for model in app_models: appmods.append(model) except Exception as e: self.err(e) return ret...
[ "def", "_get_models", "(", "self", ",", "app", ")", ":", "try", ":", "app_models", "=", "app", ".", "get_models", "(", ")", "appmods", "=", "[", "]", "for", "model", "in", "app_models", ":", "appmods", ".", "append", "(", "model", ")", "except", "Exc...
return models_array
[ "return", "models_array" ]
train
https://github.com/synw/django-introspection/blob/58a9c44af36965e0f203456891172d560140f83c/introspection/inspector/__init__.py#L278-L290
synw/django-introspection
introspection/inspector/__init__.py
Inspector._count_model
def _count_model(self, model): """ return model count """ try: res = model.objects.all().count() except Exception as e: self.err(e) return return res
python
def _count_model(self, model): """ return model count """ try: res = model.objects.all().count() except Exception as e: self.err(e) return return res
[ "def", "_count_model", "(", "self", ",", "model", ")", ":", "try", ":", "res", "=", "model", ".", "objects", ".", "all", "(", ")", ".", "count", "(", ")", "except", "Exception", "as", "e", ":", "self", ".", "err", "(", "e", ")", "return", "return...
return model count
[ "return", "model", "count" ]
train
https://github.com/synw/django-introspection/blob/58a9c44af36965e0f203456891172d560140f83c/introspection/inspector/__init__.py#L292-L301
matthewdeanmartin/jiggle_version
jiggle_version/central_module_finder.py
CentralModuleFinder.find_setup_file_name
def find_setup_file_name(self): # type: () ->None """ Usually setup.py or setup """ for file_path in [ x for x in os.listdir(".") if os.path.isfile(x) and x in ["setup.py", "setup"] ]: if self.file_opener.is_python_inside(file_path...
python
def find_setup_file_name(self): # type: () ->None """ Usually setup.py or setup """ for file_path in [ x for x in os.listdir(".") if os.path.isfile(x) and x in ["setup.py", "setup"] ]: if self.file_opener.is_python_inside(file_path...
[ "def", "find_setup_file_name", "(", "self", ")", ":", "# type: () ->None", "for", "file_path", "in", "[", "x", "for", "x", "in", "os", ".", "listdir", "(", "\".\"", ")", "if", "os", ".", "path", ".", "isfile", "(", "x", ")", "and", "x", "in", "[", ...
Usually setup.py or setup
[ "Usually", "setup", ".", "py", "or", "setup" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/central_module_finder.py#L48-L59
matthewdeanmartin/jiggle_version
jiggle_version/central_module_finder.py
CentralModuleFinder._read_file
def _read_file(self, file): # type: (str) -> Optional[str] """ Read any file, deal with encoding. :param file: :return: """ if not self.setup_file_name: return None source = None if os.path.isfile(file): with self.file_opener.open_...
python
def _read_file(self, file): # type: (str) -> Optional[str] """ Read any file, deal with encoding. :param file: :return: """ if not self.setup_file_name: return None source = None if os.path.isfile(file): with self.file_opener.open_...
[ "def", "_read_file", "(", "self", ",", "file", ")", ":", "# type: (str) -> Optional[str]", "if", "not", "self", ".", "setup_file_name", ":", "return", "None", "source", "=", "None", "if", "os", ".", "path", ".", "isfile", "(", "file", ")", ":", "with", "...
Read any file, deal with encoding. :param file: :return:
[ "Read", "any", "file", "deal", "with", "encoding", ".", ":", "param", "file", ":", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/central_module_finder.py#L61-L73
matthewdeanmartin/jiggle_version
jiggle_version/central_module_finder.py
CentralModuleFinder.read_setup_py_source
def read_setup_py_source(self): # type: () -> None """ Read setup.py to string :return: """ if not self.setup_file_name: self.setup_source = "" if not self.setup_source: self.setup_source = self._read_file(self.setup_file_name)
python
def read_setup_py_source(self): # type: () -> None """ Read setup.py to string :return: """ if not self.setup_file_name: self.setup_source = "" if not self.setup_source: self.setup_source = self._read_file(self.setup_file_name)
[ "def", "read_setup_py_source", "(", "self", ")", ":", "# type: () -> None", "if", "not", "self", ".", "setup_file_name", ":", "self", ".", "setup_source", "=", "\"\"", "if", "not", "self", ".", "setup_source", ":", "self", ".", "setup_source", "=", "self", "...
Read setup.py to string :return:
[ "Read", "setup", ".", "py", "to", "string", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/central_module_finder.py#L75-L83
matthewdeanmartin/jiggle_version
jiggle_version/central_module_finder.py
CentralModuleFinder.parse_package_name
def parse_package_name(self): # type: () -> Optional[str] """ Extract likley module name from setup.py args :return: """ if not self.setup_source: return None for row in self.setup_source.split("\n"): simplified_row = row.replace(" ", "").replace(...
python
def parse_package_name(self): # type: () -> Optional[str] """ Extract likley module name from setup.py args :return: """ if not self.setup_source: return None for row in self.setup_source.split("\n"): simplified_row = row.replace(" ", "").replace(...
[ "def", "parse_package_name", "(", "self", ")", ":", "# type: () -> Optional[str]", "if", "not", "self", ".", "setup_source", ":", "return", "None", "for", "row", "in", "self", ".", "setup_source", ".", "split", "(", "\"\\n\"", ")", ":", "simplified_row", "=", ...
Extract likley module name from setup.py args :return:
[ "Extract", "likley", "module", "name", "from", "setup", ".", "py", "args", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/central_module_finder.py#L85-L102
matthewdeanmartin/jiggle_version
jiggle_version/central_module_finder.py
CentralModuleFinder.execute_setup_name
def execute_setup_name(self): # type: () -> Optional[str] """ Runs code, so this is a bit dangerous, especially if it isn't your own :return: """ try: name = execute_get_text("python setup.py --name") except subprocess.CalledProcessError: # setup....
python
def execute_setup_name(self): # type: () -> Optional[str] """ Runs code, so this is a bit dangerous, especially if it isn't your own :return: """ try: name = execute_get_text("python setup.py --name") except subprocess.CalledProcessError: # setup....
[ "def", "execute_setup_name", "(", "self", ")", ":", "# type: () -> Optional[str]", "try", ":", "name", "=", "execute_get_text", "(", "\"python setup.py --name\"", ")", "except", "subprocess", ".", "CalledProcessError", ":", "# setup.py is not always in an executable state", ...
Runs code, so this is a bit dangerous, especially if it isn't your own :return:
[ "Runs", "code", "so", "this", "is", "a", "bit", "dangerous", "especially", "if", "it", "isn", "t", "your", "own", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/central_module_finder.py#L104-L120
matthewdeanmartin/jiggle_version
jiggle_version/central_module_finder.py
CentralModuleFinder.find_central_module
def find_central_module(self): # type: () -> Optional[str] """ Get the module that is the sole module, or the module that matches the package name/version :return: """ # find modules. mf = ModuleFinder(self.file_opener) candidates = mf.find_by_any_method...
python
def find_central_module(self): # type: () -> Optional[str] """ Get the module that is the sole module, or the module that matches the package name/version :return: """ # find modules. mf = ModuleFinder(self.file_opener) candidates = mf.find_by_any_method...
[ "def", "find_central_module", "(", "self", ")", ":", "# type: () -> Optional[str]", "# find modules.", "mf", "=", "ModuleFinder", "(", "self", ".", "file_opener", ")", "candidates", "=", "mf", ".", "find_by_any_method", "(", ")", "sub_modules", "=", "[", "]", "r...
Get the module that is the sole module, or the module that matches the package name/version :return:
[ "Get", "the", "module", "that", "is", "the", "sole", "module", "or", "the", "module", "that", "matches", "the", "package", "name", "/", "version", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/central_module_finder.py#L122-L169
matthewdeanmartin/jiggle_version
jiggle_version/central_module_finder.py
CentralModuleFinder.remove_likely_non_central
def remove_likely_non_central(self, candidates): # type: (List[str]) -> List[str] """ Stuff that is likely to be in find_packages(exclude...) :param candidates: :return: """ if len(candidates) > 1: for unlikely in [ "test", "te...
python
def remove_likely_non_central(self, candidates): # type: (List[str]) -> List[str] """ Stuff that is likely to be in find_packages(exclude...) :param candidates: :return: """ if len(candidates) > 1: for unlikely in [ "test", "te...
[ "def", "remove_likely_non_central", "(", "self", ",", "candidates", ")", ":", "# type: (List[str]) -> List[str]", "if", "len", "(", "candidates", ")", ">", "1", ":", "for", "unlikely", "in", "[", "\"test\"", ",", "\"tests\"", ",", "\"example\"", ",", "\"examples...
Stuff that is likely to be in find_packages(exclude...) :param candidates: :return:
[ "Stuff", "that", "is", "likely", "to", "be", "in", "find_packages", "(", "exclude", "...", ")", ":", "param", "candidates", ":", ":", "return", ":" ]
train
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/central_module_finder.py#L171-L198
jeroyang/txttk
txttk/nlptools.py
sent_tokenize
def sent_tokenize(context): """ Cut the given context into sentences. Avoid a linebreak in between paried symbols, float numbers, and some abbrs. Nothing will be discard after sent_tokeinze, simply ''.join(sents) will get the original context. Evey whitespace, tab, linebreak will be kept. >>> c...
python
def sent_tokenize(context): """ Cut the given context into sentences. Avoid a linebreak in between paried symbols, float numbers, and some abbrs. Nothing will be discard after sent_tokeinze, simply ''.join(sents) will get the original context. Evey whitespace, tab, linebreak will be kept. >>> c...
[ "def", "sent_tokenize", "(", "context", ")", ":", "# Define the regular expression", "paired_symbols", "=", "[", "(", "\"(\"", ",", "\")\"", ")", ",", "(", "\"[\"", ",", "\"]\"", ")", ",", "(", "\"{\"", ",", "\"}\"", ")", "]", "paired_patterns", "=", "[", ...
Cut the given context into sentences. Avoid a linebreak in between paried symbols, float numbers, and some abbrs. Nothing will be discard after sent_tokeinze, simply ''.join(sents) will get the original context. Evey whitespace, tab, linebreak will be kept. >>> context = "I love you. Please don't leave...
[ "Cut", "the", "given", "context", "into", "sentences", ".", "Avoid", "a", "linebreak", "in", "between", "paried", "symbols", "float", "numbers", "and", "some", "abbrs", ".", "Nothing", "will", "be", "discard", "after", "sent_tokeinze", "simply", ".", "join", ...
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/nlptools.py#L12-L45
jeroyang/txttk
txttk/nlptools.py
clause_tokenize
def clause_tokenize(sentence): """ Split on comma or parenthesis, if there are more then three words for each clause >>> context = 'While I was walking home, this bird fell down in front of me.' >>> clause_tokenize(context) ['While I was walking home,', ' this bird fell down in front of me.'] ...
python
def clause_tokenize(sentence): """ Split on comma or parenthesis, if there are more then three words for each clause >>> context = 'While I was walking home, this bird fell down in front of me.' >>> clause_tokenize(context) ['While I was walking home,', ' this bird fell down in front of me.'] ...
[ "def", "clause_tokenize", "(", "sentence", ")", ":", "clause_re", "=", "re", ".", "compile", "(", "r'((?:\\S+\\s){2,}\\S+,|(?:\\S+\\s){3,}(?=\\((?:\\S+\\s){2,}\\S+\\)))'", ")", "clause_stem", "=", "clause_re", ".", "sub", "(", "r'\\1###clausebreak###'", ",", "sentence", ...
Split on comma or parenthesis, if there are more then three words for each clause >>> context = 'While I was walking home, this bird fell down in front of me.' >>> clause_tokenize(context) ['While I was walking home,', ' this bird fell down in front of me.']
[ "Split", "on", "comma", "or", "parenthesis", "if", "there", "are", "more", "then", "three", "words", "for", "each", "clause" ]
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/nlptools.py#L57-L68
jeroyang/txttk
txttk/nlptools.py
word_tokenize
def word_tokenize(sentence): """ A generator which yields tokens based on the given sentence without deleting anything. >>> context = "I love you. Please don't leave." >>> list(word_tokenize(context)) ['I', ' ', 'love', ' ', 'you', '.', ' ', 'Please', ' ', 'don', "'", 't', ' ', 'leave', '.'] "...
python
def word_tokenize(sentence): """ A generator which yields tokens based on the given sentence without deleting anything. >>> context = "I love you. Please don't leave." >>> list(word_tokenize(context)) ['I', ' ', 'love', ' ', 'you', '.', ' ', 'Please', ' ', 'don', "'", 't', ' ', 'leave', '.'] "...
[ "def", "word_tokenize", "(", "sentence", ")", ":", "date_pattern", "=", "r'\\d\\d(\\d\\d)?[\\\\-]\\d\\d[\\\\-]\\d\\d(\\d\\d)?'", "number_pattern", "=", "r'[\\+-]?(\\d+\\.\\d+|\\d{1,3},(\\d{3},)*\\d{3}|\\d+)'", "arr_pattern", "=", "r'(?: \\w\\.){2,3}|(?:\\A|\\s)(?:\\w\\.){2,3}|[A-Z]\\. [a...
A generator which yields tokens based on the given sentence without deleting anything. >>> context = "I love you. Please don't leave." >>> list(word_tokenize(context)) ['I', ' ', 'love', ' ', 'you', '.', ' ', 'Please', ' ', 'don', "'", 't', ' ', 'leave', '.']
[ "A", "generator", "which", "yields", "tokens", "based", "on", "the", "given", "sentence", "without", "deleting", "anything", "." ]
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/nlptools.py#L70-L89
jeroyang/txttk
txttk/nlptools.py
slim_stem
def slim_stem(token): """ A very simple stemmer, for entity of GO stemming. >>> token = 'interaction' >>> slim_stem(token) 'interact' """ target_sulfixs = ['ic', 'tic', 'e', 'ive', 'ing', 'ical', 'nal', 'al', 'ism', 'ion', 'ation', 'ar', 'sis', 'us', 'ment'] for sulfix in sorted(target...
python
def slim_stem(token): """ A very simple stemmer, for entity of GO stemming. >>> token = 'interaction' >>> slim_stem(token) 'interact' """ target_sulfixs = ['ic', 'tic', 'e', 'ive', 'ing', 'ical', 'nal', 'al', 'ism', 'ion', 'ation', 'ar', 'sis', 'us', 'ment'] for sulfix in sorted(target...
[ "def", "slim_stem", "(", "token", ")", ":", "target_sulfixs", "=", "[", "'ic'", ",", "'tic'", ",", "'e'", ",", "'ive'", ",", "'ing'", ",", "'ical'", ",", "'nal'", ",", "'al'", ",", "'ism'", ",", "'ion'", ",", "'ation'", ",", "'ar'", ",", "'sis'", "...
A very simple stemmer, for entity of GO stemming. >>> token = 'interaction' >>> slim_stem(token) 'interact'
[ "A", "very", "simple", "stemmer", "for", "entity", "of", "GO", "stemming", "." ]
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/nlptools.py#L91-L107
jeroyang/txttk
txttk/nlptools.py
ngram
def ngram(n, iter_tokens): """ Return a generator of n-gram from an iterable """ z = len(iter_tokens) return (iter_tokens[i:i+n] for i in range(z-n+1))
python
def ngram(n, iter_tokens): """ Return a generator of n-gram from an iterable """ z = len(iter_tokens) return (iter_tokens[i:i+n] for i in range(z-n+1))
[ "def", "ngram", "(", "n", ",", "iter_tokens", ")", ":", "z", "=", "len", "(", "iter_tokens", ")", "return", "(", "iter_tokens", "[", "i", ":", "i", "+", "n", "]", "for", "i", "in", "range", "(", "z", "-", "n", "+", "1", ")", ")" ]
Return a generator of n-gram from an iterable
[ "Return", "a", "generator", "of", "n", "-", "gram", "from", "an", "iterable" ]
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/nlptools.py#L116-L121
jeroyang/txttk
txttk/nlptools.py
power_ngram
def power_ngram(iter_tokens): """ Generate unigram, bigram, trigram ... and the max-gram, different from powerset(), this function will not generate skipped combinations such as (1,3) """ return chain.from_iterable(ngram(j, iter_tokens) for j in range(1, len(iter_tokens) + 1))
python
def power_ngram(iter_tokens): """ Generate unigram, bigram, trigram ... and the max-gram, different from powerset(), this function will not generate skipped combinations such as (1,3) """ return chain.from_iterable(ngram(j, iter_tokens) for j in range(1, len(iter_tokens) + 1))
[ "def", "power_ngram", "(", "iter_tokens", ")", ":", "return", "chain", ".", "from_iterable", "(", "ngram", "(", "j", ",", "iter_tokens", ")", "for", "j", "in", "range", "(", "1", ",", "len", "(", "iter_tokens", ")", "+", "1", ")", ")" ]
Generate unigram, bigram, trigram ... and the max-gram, different from powerset(), this function will not generate skipped combinations such as (1,3)
[ "Generate", "unigram", "bigram", "trigram", "...", "and", "the", "max", "-", "gram", "different", "from", "powerset", "()", "this", "function", "will", "not", "generate", "skipped", "combinations", "such", "as", "(", "1", "3", ")" ]
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/nlptools.py#L123-L128
jeroyang/txttk
txttk/nlptools.py
count_start
def count_start(tokenizer): """ A decorator which wrap the given tokenizer to yield (token, start). Notice! the decorated tokenizer must take a int arguments stands for the start position of the input context/sentence >>> tokenizer = lambda sentence: sentence.split(' ') >>> tokenizer('The quick bro...
python
def count_start(tokenizer): """ A decorator which wrap the given tokenizer to yield (token, start). Notice! the decorated tokenizer must take a int arguments stands for the start position of the input context/sentence >>> tokenizer = lambda sentence: sentence.split(' ') >>> tokenizer('The quick bro...
[ "def", "count_start", "(", "tokenizer", ")", ":", "def", "wrapper", "(", "context", ",", "base", ")", ":", "tokens", "=", "list", "(", "tokenizer", "(", "context", ")", ")", "flag", "=", "0", "for", "token", "in", "tokens", ":", "start", "=", "contex...
A decorator which wrap the given tokenizer to yield (token, start). Notice! the decorated tokenizer must take a int arguments stands for the start position of the input context/sentence >>> tokenizer = lambda sentence: sentence.split(' ') >>> tokenizer('The quick brown fox jumps over the lazy dog') ['T...
[ "A", "decorator", "which", "wrap", "the", "given", "tokenizer", "to", "yield", "(", "token", "start", ")", ".", "Notice!", "the", "decorated", "tokenizer", "must", "take", "a", "int", "arguments", "stands", "for", "the", "start", "position", "of", "the", "...
train
https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/nlptools.py#L130-L154
fictivekin/adept-python
adept/__init__.py
Adept.generate_url
def generate_url(self, bucket=None, asset_key=None, asset_url=None, operations=['identity'], secure=True): """ Given an S3 key and bucket/URL, perform given image operations on an image and return the URL. """ if len(operations) < 1: raise OperationError('You didn\'t provide ...
python
def generate_url(self, bucket=None, asset_key=None, asset_url=None, operations=['identity'], secure=True): """ Given an S3 key and bucket/URL, perform given image operations on an image and return the URL. """ if len(operations) < 1: raise OperationError('You didn\'t provide ...
[ "def", "generate_url", "(", "self", ",", "bucket", "=", "None", ",", "asset_key", "=", "None", ",", "asset_url", "=", "None", ",", "operations", "=", "[", "'identity'", "]", ",", "secure", "=", "True", ")", ":", "if", "len", "(", "operations", ")", "...
Given an S3 key and bucket/URL, perform given image operations on an image and return the URL.
[ "Given", "an", "S3", "key", "and", "bucket", "/", "URL", "perform", "given", "image", "operations", "on", "an", "image", "and", "return", "the", "URL", "." ]
train
https://github.com/fictivekin/adept-python/blob/56dad62922badd238fd1614fc27ba3ad31380446/adept/__init__.py#L39-L89
hweickert/where
where/__init__.py
iwhere
def iwhere( filename ): """ Like where() but returns an iterator. """ possible_paths = _gen_possible_matches( filename ) existing_file_paths = filter( os.path.isfile, possible_paths ) return existing_file_paths
python
def iwhere( filename ): """ Like where() but returns an iterator. """ possible_paths = _gen_possible_matches( filename ) existing_file_paths = filter( os.path.isfile, possible_paths ) return existing_file_paths
[ "def", "iwhere", "(", "filename", ")", ":", "possible_paths", "=", "_gen_possible_matches", "(", "filename", ")", "existing_file_paths", "=", "filter", "(", "os", ".", "path", ".", "isfile", ",", "possible_paths", ")", "return", "existing_file_paths" ]
Like where() but returns an iterator.
[ "Like", "where", "()", "but", "returns", "an", "iterator", "." ]
train
https://github.com/hweickert/where/blob/ff07c5df81a2e854e8e1b88c932b493452b9cb83/where/__init__.py#L32-L37
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/v1/overcloud_deploy.py
DeployOvercloud.set_overcloud_passwords
def set_overcloud_passwords(self, parameters, parsed_args): """Add passwords to the parameters dictionary :param parameters: A dictionary for the passwords to be added to :type parameters: dict """ undercloud_ceilometer_snmpd_password = utils.get_config_value( "auth...
python
def set_overcloud_passwords(self, parameters, parsed_args): """Add passwords to the parameters dictionary :param parameters: A dictionary for the passwords to be added to :type parameters: dict """ undercloud_ceilometer_snmpd_password = utils.get_config_value( "auth...
[ "def", "set_overcloud_passwords", "(", "self", ",", "parameters", ",", "parsed_args", ")", ":", "undercloud_ceilometer_snmpd_password", "=", "utils", ".", "get_config_value", "(", "\"auth\"", ",", "\"undercloud_ceilometer_snmpd_password\"", ")", "self", ".", "passwords", ...
Add passwords to the parameters dictionary :param parameters: A dictionary for the passwords to be added to :type parameters: dict
[ "Add", "passwords", "to", "the", "parameters", "dictionary" ]
train
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/overcloud_deploy.py#L104-L176
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/v1/overcloud_deploy.py
DeployOvercloud._get_stack
def _get_stack(self, orchestration_client, stack_name): """Get the ID for the current deployed overcloud stack if it exists.""" try: stack = orchestration_client.stacks.get(stack_name) self.log.info("Stack found, will be doing a stack update") return stack ex...
python
def _get_stack(self, orchestration_client, stack_name): """Get the ID for the current deployed overcloud stack if it exists.""" try: stack = orchestration_client.stacks.get(stack_name) self.log.info("Stack found, will be doing a stack update") return stack ex...
[ "def", "_get_stack", "(", "self", ",", "orchestration_client", ",", "stack_name", ")", ":", "try", ":", "stack", "=", "orchestration_client", ".", "stacks", ".", "get", "(", "stack_name", ")", "self", ".", "log", ".", "info", "(", "\"Stack found, will be doing...
Get the ID for the current deployed overcloud stack if it exists.
[ "Get", "the", "ID", "for", "the", "current", "deployed", "overcloud", "stack", "if", "it", "exists", "." ]
train
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/overcloud_deploy.py#L178-L186
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/v1/overcloud_deploy.py
DeployOvercloud._heat_deploy
def _heat_deploy(self, stack, stack_name, template_path, parameters, environments, timeout): """Verify the Baremetal nodes are available and do a stack update""" self.log.debug("Processing environment files") env_files, env = ( template_utils.process_multiple_en...
python
def _heat_deploy(self, stack, stack_name, template_path, parameters, environments, timeout): """Verify the Baremetal nodes are available and do a stack update""" self.log.debug("Processing environment files") env_files, env = ( template_utils.process_multiple_en...
[ "def", "_heat_deploy", "(", "self", ",", "stack", ",", "stack_name", ",", "template_path", ",", "parameters", ",", "environments", ",", "timeout", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Processing environment files\"", ")", "env_files", ",", "env"...
Verify the Baremetal nodes are available and do a stack update
[ "Verify", "the", "Baremetal", "nodes", "are", "available", "and", "do", "a", "stack", "update" ]
train
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/overcloud_deploy.py#L401-L451
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/v1/overcloud_deploy.py
DeployOvercloud._pre_heat_deploy
def _pre_heat_deploy(self): """Setup before the Heat stack create or update has been done.""" clients = self.app.client_manager compute_client = clients.compute self.log.debug("Checking hypervisor stats") if utils.check_hypervisor_stats(compute_client) is None: raise...
python
def _pre_heat_deploy(self): """Setup before the Heat stack create or update has been done.""" clients = self.app.client_manager compute_client = clients.compute self.log.debug("Checking hypervisor stats") if utils.check_hypervisor_stats(compute_client) is None: raise...
[ "def", "_pre_heat_deploy", "(", "self", ")", ":", "clients", "=", "self", ".", "app", ".", "client_manager", "compute_client", "=", "clients", ".", "compute", "self", ".", "log", ".", "debug", "(", "\"Checking hypervisor stats\"", ")", "if", "utils", ".", "c...
Setup before the Heat stack create or update has been done.
[ "Setup", "before", "the", "Heat", "stack", "create", "or", "update", "has", "been", "done", "." ]
train
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/overcloud_deploy.py#L464-L473
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/v1/overcloud_deploy.py
DeployOvercloud._deploy_tripleo_heat_templates
def _deploy_tripleo_heat_templates(self, stack, parsed_args): """Deploy the fixed templates in TripleO Heat Templates""" clients = self.app.client_manager network_client = clients.network parameters = self._update_paramaters( parsed_args, network_client, stack) util...
python
def _deploy_tripleo_heat_templates(self, stack, parsed_args): """Deploy the fixed templates in TripleO Heat Templates""" clients = self.app.client_manager network_client = clients.network parameters = self._update_paramaters( parsed_args, network_client, stack) util...
[ "def", "_deploy_tripleo_heat_templates", "(", "self", ",", "stack", ",", "parsed_args", ")", ":", "clients", "=", "self", ".", "app", ".", "client_manager", "network_client", "=", "clients", ".", "network", "parameters", "=", "self", ".", "_update_paramaters", "...
Deploy the fixed templates in TripleO Heat Templates
[ "Deploy", "the", "fixed", "templates", "in", "TripleO", "Heat", "Templates" ]
train
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/overcloud_deploy.py#L475-L520
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/v1/overcloud_deploy.py
DeployOvercloud._collect_node_profiles
def _collect_node_profiles(self): """Gather a map of profile -> [node_uuid] for ironic boot profiles""" bm_client = self.app.client_manager.rdomanager_oscplugin.baremetal() # map of profile capability -> [node_uuid, ...] profile_map = collections.defaultdict(list) for node in b...
python
def _collect_node_profiles(self): """Gather a map of profile -> [node_uuid] for ironic boot profiles""" bm_client = self.app.client_manager.rdomanager_oscplugin.baremetal() # map of profile capability -> [node_uuid, ...] profile_map = collections.defaultdict(list) for node in b...
[ "def", "_collect_node_profiles", "(", "self", ")", ":", "bm_client", "=", "self", ".", "app", ".", "client_manager", ".", "rdomanager_oscplugin", ".", "baremetal", "(", ")", "# map of profile capability -> [node_uuid, ...]", "profile_map", "=", "collections", ".", "de...
Gather a map of profile -> [node_uuid] for ironic boot profiles
[ "Gather", "a", "map", "of", "profile", "-", ">", "[", "node_uuid", "]", "for", "ironic", "boot", "profiles" ]
train
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/overcloud_deploy.py#L842-L858
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/v1/overcloud_deploy.py
DeployOvercloud._check_flavors_exist
def _check_flavors_exist(self, parsed_args): """Ensure that selected flavors (--ROLE-flavor) exist in nova.""" compute_client = self.app.client_manager.compute flavors = {f.name: f for f in compute_client.flavors.list()} message = "Provided --{}-flavor, '{}', does not exist" f...
python
def _check_flavors_exist(self, parsed_args): """Ensure that selected flavors (--ROLE-flavor) exist in nova.""" compute_client = self.app.client_manager.compute flavors = {f.name: f for f in compute_client.flavors.list()} message = "Provided --{}-flavor, '{}', does not exist" f...
[ "def", "_check_flavors_exist", "(", "self", ",", "parsed_args", ")", ":", "compute_client", "=", "self", ".", "app", ".", "client_manager", ".", "compute", "flavors", "=", "{", "f", ".", "name", ":", "f", "for", "f", "in", "compute_client", ".", "flavors",...
Ensure that selected flavors (--ROLE-flavor) exist in nova.
[ "Ensure", "that", "selected", "flavors", "(", "--", "ROLE", "-", "flavor", ")", "exist", "in", "nova", "." ]
train
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/overcloud_deploy.py#L929-L953
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.well_fields
def well_fields(self, well_x=1, well_y=1): """All ScanFieldData elements of given well. Parameters ---------- well_x : int well_y : int Returns ------- list of lxml.objectify.ObjectifiedElement All ScanFieldData elements of given well. ...
python
def well_fields(self, well_x=1, well_y=1): """All ScanFieldData elements of given well. Parameters ---------- well_x : int well_y : int Returns ------- list of lxml.objectify.ObjectifiedElement All ScanFieldData elements of given well. ...
[ "def", "well_fields", "(", "self", ",", "well_x", "=", "1", ",", "well_y", "=", "1", ")", ":", "xpath", "=", "'./ScanFieldArray/ScanFieldData'", "xpath", "+=", "_xpath_attrib", "(", "'WellX'", ",", "well_x", ")", "xpath", "+=", "_xpath_attrib", "(", "'WellY'...
All ScanFieldData elements of given well. Parameters ---------- well_x : int well_y : int Returns ------- list of lxml.objectify.ObjectifiedElement All ScanFieldData elements of given well.
[ "All", "ScanFieldData", "elements", "of", "given", "well", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L59-L75
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.well
def well(self, well_x=1, well_y=1): """ScanWellData of specific well. Parameters ---------- well_x : int well_y : int Returns ------- lxml.objectify.ObjectifiedElement """ xpath = './ScanWellData' xpath += _xpath_attrib('WellX', w...
python
def well(self, well_x=1, well_y=1): """ScanWellData of specific well. Parameters ---------- well_x : int well_y : int Returns ------- lxml.objectify.ObjectifiedElement """ xpath = './ScanWellData' xpath += _xpath_attrib('WellX', w...
[ "def", "well", "(", "self", ",", "well_x", "=", "1", ",", "well_y", "=", "1", ")", ":", "xpath", "=", "'./ScanWellData'", "xpath", "+=", "_xpath_attrib", "(", "'WellX'", ",", "well_x", ")", "xpath", "+=", "_xpath_attrib", "(", "'WellY'", ",", "well_y", ...
ScanWellData of specific well. Parameters ---------- well_x : int well_y : int Returns ------- lxml.objectify.ObjectifiedElement
[ "ScanWellData", "of", "specific", "well", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L78-L94
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.field
def field(self, well_x=1, well_y=1, field_x=1, field_y=1): """ScanFieldData of specified field. Parameters ---------- well_x : int well_y : int field_x : int field_y : int Returns ------- lxml.objectify.ObjectifiedElement Scan...
python
def field(self, well_x=1, well_y=1, field_x=1, field_y=1): """ScanFieldData of specified field. Parameters ---------- well_x : int well_y : int field_x : int field_y : int Returns ------- lxml.objectify.ObjectifiedElement Scan...
[ "def", "field", "(", "self", ",", "well_x", "=", "1", ",", "well_y", "=", "1", ",", "field_x", "=", "1", ",", "field_y", "=", "1", ")", ":", "xpath", "=", "'./ScanFieldArray/ScanFieldData'", "xpath", "+=", "_xpath_attrib", "(", "'WellX'", ",", "well_x", ...
ScanFieldData of specified field. Parameters ---------- well_x : int well_y : int field_x : int field_y : int Returns ------- lxml.objectify.ObjectifiedElement ScanFieldArray/ScanFieldData element.
[ "ScanFieldData", "of", "specified", "field", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L134-L155
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.update_start_position
def update_start_position(self): "Set start position of experiment to position of first field." x_start = self.field_array.ScanFieldData.FieldXCoordinate y_start = self.field_array.ScanFieldData.FieldYCoordinate # empty template have all fields positions set to zero # --> avoid ...
python
def update_start_position(self): "Set start position of experiment to position of first field." x_start = self.field_array.ScanFieldData.FieldXCoordinate y_start = self.field_array.ScanFieldData.FieldYCoordinate # empty template have all fields positions set to zero # --> avoid ...
[ "def", "update_start_position", "(", "self", ")", ":", "x_start", "=", "self", ".", "field_array", ".", "ScanFieldData", ".", "FieldXCoordinate", "y_start", "=", "self", ".", "field_array", ".", "ScanFieldData", ".", "FieldYCoordinate", "# empty template have all fiel...
Set start position of experiment to position of first field.
[ "Set", "start", "position", "of", "experiment", "to", "position", "of", "first", "field", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L158-L167
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.update_well_positions
def update_well_positions(self): """Set ``well_attrib['FieldXStartCoordinate']`` and ``well_attrib['FieldYStartCoordinate']`` to FieldXCoordinate and FieldYCoordinate of first field in well. """ for well in self.wells: well_x = well.attrib['WellX'] well_y ...
python
def update_well_positions(self): """Set ``well_attrib['FieldXStartCoordinate']`` and ``well_attrib['FieldYStartCoordinate']`` to FieldXCoordinate and FieldYCoordinate of first field in well. """ for well in self.wells: well_x = well.attrib['WellX'] well_y ...
[ "def", "update_well_positions", "(", "self", ")", ":", "for", "well", "in", "self", ".", "wells", ":", "well_x", "=", "well", ".", "attrib", "[", "'WellX'", "]", "well_y", "=", "well", ".", "attrib", "[", "'WellY'", "]", "first_field", "=", "self", "."...
Set ``well_attrib['FieldXStartCoordinate']`` and ``well_attrib['FieldYStartCoordinate']`` to FieldXCoordinate and FieldYCoordinate of first field in well.
[ "Set", "well_attrib", "[", "FieldXStartCoordinate", "]", "and", "well_attrib", "[", "FieldYStartCoordinate", "]", "to", "FieldXCoordinate", "and", "FieldYCoordinate", "of", "first", "field", "in", "well", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L170-L185
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.count_of_wells
def count_of_wells(self): """Number of wells in x/y-direction of template. Returns ------- tuple (xs, ys) number of wells in x and y direction. """ xs = set([w.attrib['WellX'] for w in self.wells]) ys = set([w.attrib['WellY'] for w in self.wells]) ...
python
def count_of_wells(self): """Number of wells in x/y-direction of template. Returns ------- tuple (xs, ys) number of wells in x and y direction. """ xs = set([w.attrib['WellX'] for w in self.wells]) ys = set([w.attrib['WellY'] for w in self.wells]) ...
[ "def", "count_of_wells", "(", "self", ")", ":", "xs", "=", "set", "(", "[", "w", ".", "attrib", "[", "'WellX'", "]", "for", "w", "in", "self", ".", "wells", "]", ")", "ys", "=", "set", "(", "[", "w", ".", "attrib", "[", "'WellY'", "]", "for", ...
Number of wells in x/y-direction of template. Returns ------- tuple (xs, ys) number of wells in x and y direction.
[ "Number", "of", "wells", "in", "x", "/", "y", "-", "direction", "of", "template", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L189-L199
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.count_of_assigned_jobs
def count_of_assigned_jobs(self): "Number of fields that have attrib['JobAssigned'] set to true." assigned = len([x.attrib['JobAssigned'] for x in self.fields if x.attrib['JobAssigned'] == 'true']) return assigned
python
def count_of_assigned_jobs(self): "Number of fields that have attrib['JobAssigned'] set to true." assigned = len([x.attrib['JobAssigned'] for x in self.fields if x.attrib['JobAssigned'] == 'true']) return assigned
[ "def", "count_of_assigned_jobs", "(", "self", ")", ":", "assigned", "=", "len", "(", "[", "x", ".", "attrib", "[", "'JobAssigned'", "]", "for", "x", "in", "self", ".", "fields", "if", "x", ".", "attrib", "[", "'JobAssigned'", "]", "==", "'true'", "]", ...
Number of fields that have attrib['JobAssigned'] set to true.
[ "Number", "of", "fields", "that", "have", "attrib", "[", "JobAssigned", "]", "set", "to", "true", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L203-L207
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.update_counts
def update_counts(self): "Update counts of fields and wells." # Properties.attrib['TotalCountOfFields'] fields = str(len(self.fields)) self.properties.attrib['TotalCountOfFields'] = fields # Properties.CountOfWellsX/Y wx, wy = (str(x) for x in self.count_of_wells) ...
python
def update_counts(self): "Update counts of fields and wells." # Properties.attrib['TotalCountOfFields'] fields = str(len(self.fields)) self.properties.attrib['TotalCountOfFields'] = fields # Properties.CountOfWellsX/Y wx, wy = (str(x) for x in self.count_of_wells) ...
[ "def", "update_counts", "(", "self", ")", ":", "# Properties.attrib['TotalCountOfFields']", "fields", "=", "str", "(", "len", "(", "self", ".", "fields", ")", ")", "self", ".", "properties", ".", "attrib", "[", "'TotalCountOfFields'", "]", "=", "fields", "# Pr...
Update counts of fields and wells.
[ "Update", "counts", "of", "fields", "and", "wells", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L210-L227
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.remove_well
def remove_well(self, well_x, well_y): """Remove well and associated scan fields. Parameters ---------- well_x : int well_y : int Raises ------ AttributeError If well not found. """ well = self.well(well_x, well_y) if ...
python
def remove_well(self, well_x, well_y): """Remove well and associated scan fields. Parameters ---------- well_x : int well_y : int Raises ------ AttributeError If well not found. """ well = self.well(well_x, well_y) if ...
[ "def", "remove_well", "(", "self", ",", "well_x", ",", "well_y", ")", ":", "well", "=", "self", ".", "well", "(", "well_x", ",", "well_y", ")", "if", "well", "==", "None", ":", "raise", "AttributeError", "(", "'Well not found'", ")", "self", ".", "well...
Remove well and associated scan fields. Parameters ---------- well_x : int well_y : int Raises ------ AttributeError If well not found.
[ "Remove", "well", "and", "associated", "scan", "fields", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L230-L251
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.field_exists
def field_exists(self, well_x, well_y, field_x, field_y): "Check if field exists ScanFieldArray." return self.field(well_x, well_y, field_x, field_y) != None
python
def field_exists(self, well_x, well_y, field_x, field_y): "Check if field exists ScanFieldArray." return self.field(well_x, well_y, field_x, field_y) != None
[ "def", "field_exists", "(", "self", ",", "well_x", ",", "well_y", ",", "field_x", ",", "field_y", ")", ":", "return", "self", ".", "field", "(", "well_x", ",", "well_y", ",", "field_x", ",", "field_y", ")", "!=", "None" ]
Check if field exists ScanFieldArray.
[ "Check", "if", "field", "exists", "ScanFieldArray", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L259-L261
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.add_well
def add_well(self, well_x, well_y, start_x, start_y): """Add well with associated scan fields. ``self.wells[0]`` and ``self.fields[0]`` will be used as base. ScanWellData will be added to ScanWellArray and ScanFieldData to ScanFieldArray. The amount of fields added is decided by Properti...
python
def add_well(self, well_x, well_y, start_x, start_y): """Add well with associated scan fields. ``self.wells[0]`` and ``self.fields[0]`` will be used as base. ScanWellData will be added to ScanWellArray and ScanFieldData to ScanFieldArray. The amount of fields added is decided by Properti...
[ "def", "add_well", "(", "self", ",", "well_x", ",", "well_y", ",", "start_x", ",", "start_y", ")", ":", "# raise ValueError if well already exists", "if", "self", ".", "well_exists", "(", "well_x", ",", "well_y", ")", ":", "raise", "ValueError", "(", "'Well al...
Add well with associated scan fields. ``self.wells[0]`` and ``self.fields[0]`` will be used as base. ScanWellData will be added to ScanWellArray and ScanFieldData to ScanFieldArray. The amount of fields added is decided by Properties/CountOfScanFields. Parameters ---------- ...
[ "Add", "well", "with", "associated", "scan", "fields", ".", "self", ".", "wells", "[", "0", "]", "and", "self", ".", "fields", "[", "0", "]", "will", "be", "used", "as", "base", ".", "ScanWellData", "will", "be", "added", "to", "ScanWellArray", "and", ...
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L264-L324
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.move_well
def move_well(self, well_x, well_y, start_x, start_y): """Move well and associated scan fields. Spacing between fields will be what Properties/ScanFieldStageDistance is set to. Parameters ---------- well_x : int well_y : int start_x : int In meters. F...
python
def move_well(self, well_x, well_y, start_x, start_y): """Move well and associated scan fields. Spacing between fields will be what Properties/ScanFieldStageDistance is set to. Parameters ---------- well_x : int well_y : int start_x : int In meters. F...
[ "def", "move_well", "(", "self", ",", "well_x", ",", "well_y", ",", "start_x", ",", "start_y", ")", ":", "# raise ValueError if well or fields doesnt exist", "if", "not", "self", ".", "well_exists", "(", "well_x", ",", "well_y", ")", ":", "raise", "ValueError", ...
Move well and associated scan fields. Spacing between fields will be what Properties/ScanFieldStageDistance is set to. Parameters ---------- well_x : int well_y : int start_x : int In meters. FieldXCoordinate of first field in well. start_y : int ...
[ "Move", "well", "and", "associated", "scan", "fields", ".", "Spacing", "between", "fields", "will", "be", "what", "Properties", "/", "ScanFieldStageDistance", "is", "set", "to", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L327-L367
arve0/leicascanningtemplate
leicascanningtemplate/template.py
ScanningTemplate.write
def write(self, filename=None): """Save template to xml. Before saving template will update date, start position, well positions, and counts. Parameters ---------- filename : str If not set, XML will be written to self.filename. """ if not filename: ...
python
def write(self, filename=None): """Save template to xml. Before saving template will update date, start position, well positions, and counts. Parameters ---------- filename : str If not set, XML will be written to self.filename. """ if not filename: ...
[ "def", "write", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "not", "filename", ":", "filename", "=", "self", ".", "filename", "# update time", "self", ".", "properties", ".", "CurrentDate", "=", "_current_time", "(", ")", "# set rubber band to...
Save template to xml. Before saving template will update date, start position, well positions, and counts. Parameters ---------- filename : str If not set, XML will be written to self.filename.
[ "Save", "template", "to", "xml", ".", "Before", "saving", "template", "will", "update", "date", "start", "position", "well", "positions", "and", "counts", "." ]
train
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L370-L415
mbodenhamer/syn
syn/base/a/meta.py
preserve_attr_data
def preserve_attr_data(A, B): '''Preserve attr data for combining B into A. ''' for attr, B_data in B.items(): # defined object attrs if getattr(B_data, 'override_parent', True): continue if attr in A: A_data = A[attr] for _attr in getattr(A_data, '_attrs'...
python
def preserve_attr_data(A, B): '''Preserve attr data for combining B into A. ''' for attr, B_data in B.items(): # defined object attrs if getattr(B_data, 'override_parent', True): continue if attr in A: A_data = A[attr] for _attr in getattr(A_data, '_attrs'...
[ "def", "preserve_attr_data", "(", "A", ",", "B", ")", ":", "for", "attr", ",", "B_data", "in", "B", ".", "items", "(", ")", ":", "# defined object attrs", "if", "getattr", "(", "B_data", ",", "'override_parent'", ",", "True", ")", ":", "continue", "if", ...
Preserve attr data for combining B into A.
[ "Preserve", "attr", "data", "for", "combining", "B", "into", "A", "." ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base/a/meta.py#L13-L27
mbodenhamer/syn
syn/base/a/meta.py
graft
def graft(coll, branch, index): '''Graft list branch into coll at index ''' pre = coll[:index] post = coll[index:] ret = pre + branch + post return ret
python
def graft(coll, branch, index): '''Graft list branch into coll at index ''' pre = coll[:index] post = coll[index:] ret = pre + branch + post return ret
[ "def", "graft", "(", "coll", ",", "branch", ",", "index", ")", ":", "pre", "=", "coll", "[", ":", "index", "]", "post", "=", "coll", "[", "index", ":", "]", "ret", "=", "pre", "+", "branch", "+", "post", "return", "ret" ]
Graft list branch into coll at index
[ "Graft", "list", "branch", "into", "coll", "at", "index" ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base/a/meta.py#L29-L35
mbodenhamer/syn
syn/base/a/meta.py
metaclasses
def metaclasses(bases): ''' Returns 'proper' metaclasses for the classes in bases ''' ret = [] metas = [type(base) for base in bases] for k,meta in enumerate(metas): if not any(issubclass(m, meta) for m in metas[k+1:]): ret.append(meta) if type in ret: ret.remove(typ...
python
def metaclasses(bases): ''' Returns 'proper' metaclasses for the classes in bases ''' ret = [] metas = [type(base) for base in bases] for k,meta in enumerate(metas): if not any(issubclass(m, meta) for m in metas[k+1:]): ret.append(meta) if type in ret: ret.remove(typ...
[ "def", "metaclasses", "(", "bases", ")", ":", "ret", "=", "[", "]", "metas", "=", "[", "type", "(", "base", ")", "for", "base", "in", "bases", "]", "for", "k", ",", "meta", "in", "enumerate", "(", "metas", ")", ":", "if", "not", "any", "(", "is...
Returns 'proper' metaclasses for the classes in bases
[ "Returns", "proper", "metaclasses", "for", "the", "classes", "in", "bases" ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base/a/meta.py#L37-L48
mbodenhamer/syn
syn/base/a/meta.py
sorted_bases
def sorted_bases(bases): '''If a class subclasses each class in bases (in that order), then this function returns the would-be python mro for the created class, minus <object>. ''' ret = [] for base in bases: # lst = [super(base), super(super(base)), ..., highest_base] lst = _ba...
python
def sorted_bases(bases): '''If a class subclasses each class in bases (in that order), then this function returns the would-be python mro for the created class, minus <object>. ''' ret = [] for base in bases: # lst = [super(base), super(super(base)), ..., highest_base] lst = _ba...
[ "def", "sorted_bases", "(", "bases", ")", ":", "ret", "=", "[", "]", "for", "base", "in", "bases", ":", "# lst = [super(base), super(super(base)), ..., highest_base]", "lst", "=", "_bases", "(", "base", ")", "if", "not", "ret", ":", "ret", "=", "lst", "elif"...
If a class subclasses each class in bases (in that order), then this function returns the would-be python mro for the created class, minus <object>.
[ "If", "a", "class", "subclasses", "each", "class", "in", "bases", "(", "in", "that", "order", ")", "then", "this", "function", "returns", "the", "would", "-", "be", "python", "mro", "for", "the", "created", "class", "minus", "<object", ">", "." ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base/a/meta.py#L56-L83
mbodenhamer/syn
syn/base/a/meta.py
Meta._combine_attr_fast_update
def _combine_attr_fast_update(self, attr, typ): '''Avoids having to call _update for each intermediate base. Only works for class attr of type UpdateDict. ''' values = dict(getattr(self, attr, {})) for base in self._class_data.bases: vals = dict(getattr(bas...
python
def _combine_attr_fast_update(self, attr, typ): '''Avoids having to call _update for each intermediate base. Only works for class attr of type UpdateDict. ''' values = dict(getattr(self, attr, {})) for base in self._class_data.bases: vals = dict(getattr(bas...
[ "def", "_combine_attr_fast_update", "(", "self", ",", "attr", ",", "typ", ")", ":", "values", "=", "dict", "(", "getattr", "(", "self", ",", "attr", ",", "{", "}", ")", ")", "for", "base", "in", "self", ".", "_class_data", ".", "bases", ":", "vals", ...
Avoids having to call _update for each intermediate base. Only works for class attr of type UpdateDict.
[ "Avoids", "having", "to", "call", "_update", "for", "each", "intermediate", "base", ".", "Only", "works", "for", "class", "attr", "of", "type", "UpdateDict", "." ]
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base/a/meta.py#L193-L205
pudo-attic/loadkit
loadkit/cli.py
cli
def cli(ctx, collections, threads, debug): """ A configurable data and document processing tool. """ ctx.obj = { 'collections': collections, 'debug': debug, 'threads': threads } if debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level...
python
def cli(ctx, collections, threads, debug): """ A configurable data and document processing tool. """ ctx.obj = { 'collections': collections, 'debug': debug, 'threads': threads } if debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level...
[ "def", "cli", "(", "ctx", ",", "collections", ",", "threads", ",", "debug", ")", ":", "ctx", ".", "obj", "=", "{", "'collections'", ":", "collections", ",", "'debug'", ":", "debug", ",", "'threads'", ":", "threads", "}", "if", "debug", ":", "logging", ...
A configurable data and document processing tool.
[ "A", "configurable", "data", "and", "document", "processing", "tool", "." ]
train
https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/cli.py#L50-L60
pudo-attic/loadkit
loadkit/node.py
resolve_dependencies
def resolve_dependencies(nodes): """ Figure out which order the nodes in the graph can be executed in to satisfy all requirements. """ done = set() while True: if len(done) == len(nodes): break for node in nodes: if node.name not in done: match = d...
python
def resolve_dependencies(nodes): """ Figure out which order the nodes in the graph can be executed in to satisfy all requirements. """ done = set() while True: if len(done) == len(nodes): break for node in nodes: if node.name not in done: match = d...
[ "def", "resolve_dependencies", "(", "nodes", ")", ":", "done", "=", "set", "(", ")", "while", "True", ":", "if", "len", "(", "done", ")", "==", "len", "(", "nodes", ")", ":", "break", "for", "node", "in", "nodes", ":", "if", "node", ".", "name", ...
Figure out which order the nodes in the graph can be executed in to satisfy all requirements.
[ "Figure", "out", "which", "order", "the", "nodes", "in", "the", "graph", "can", "be", "executed", "in", "to", "satisfy", "all", "requirements", "." ]
train
https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/node.py#L9-L24
samastur/pyimagediet
pyimagediet/process.py
read_yaml_configuration
def read_yaml_configuration(filename): '''Parse configuration in YAML format into a Python dict :param filename: filename of a file with configuration in YAML format :return: unprocessed configuration object :rtype: dict ''' with open(filename, 'r') as f: config = yaml.load(f.read()) ...
python
def read_yaml_configuration(filename): '''Parse configuration in YAML format into a Python dict :param filename: filename of a file with configuration in YAML format :return: unprocessed configuration object :rtype: dict ''' with open(filename, 'r') as f: config = yaml.load(f.read()) ...
[ "def", "read_yaml_configuration", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "config", "=", "yaml", ".", "load", "(", "f", ".", "read", "(", ")", ")", "return", "config" ]
Parse configuration in YAML format into a Python dict :param filename: filename of a file with configuration in YAML format :return: unprocessed configuration object :rtype: dict
[ "Parse", "configuration", "in", "YAML", "format", "into", "a", "Python", "dict" ]
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L34-L43
samastur/pyimagediet
pyimagediet/process.py
determine_type
def determine_type(filename): '''Determine the file type and return it.''' ftype = magic.from_file(filename, mime=True).decode('utf8') if ftype == 'text/plain': ftype = 'text' elif ftype == 'image/svg+xml': ftype = 'svg' else: ftype = ftype.split('/')[1] return ftype
python
def determine_type(filename): '''Determine the file type and return it.''' ftype = magic.from_file(filename, mime=True).decode('utf8') if ftype == 'text/plain': ftype = 'text' elif ftype == 'image/svg+xml': ftype = 'svg' else: ftype = ftype.split('/')[1] return ftype
[ "def", "determine_type", "(", "filename", ")", ":", "ftype", "=", "magic", ".", "from_file", "(", "filename", ",", "mime", "=", "True", ")", ".", "decode", "(", "'utf8'", ")", "if", "ftype", "==", "'text/plain'", ":", "ftype", "=", "'text'", "elif", "f...
Determine the file type and return it.
[ "Determine", "the", "file", "type", "and", "return", "it", "." ]
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L46-L55
samastur/pyimagediet
pyimagediet/process.py
parse_configuration
def parse_configuration(config): ''' Parse and fix configuration: - processed file should end up being same as input - pipelines should contain CLI commands to run - add missing sections :param config: raw configuration object :type config: dict :return: configuration ready ...
python
def parse_configuration(config): ''' Parse and fix configuration: - processed file should end up being same as input - pipelines should contain CLI commands to run - add missing sections :param config: raw configuration object :type config: dict :return: configuration ready ...
[ "def", "parse_configuration", "(", "config", ")", ":", "new_config", "=", "copy", ".", "deepcopy", "(", "config", ")", "required_parts", "=", "(", "'commands'", ",", "'parameters'", ",", "'pipelines'", ")", "for", "part", "in", "required_parts", ":", "new_conf...
Parse and fix configuration: - processed file should end up being same as input - pipelines should contain CLI commands to run - add missing sections :param config: raw configuration object :type config: dict :return: configuration ready for `diet()` :rtype: dict
[ "Parse", "and", "fix", "configuration", ":", "-", "processed", "file", "should", "end", "up", "being", "same", "as", "input", "-", "pipelines", "should", "contain", "CLI", "commands", "to", "run", "-", "add", "missing", "sections" ]
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L58-L101
samastur/pyimagediet
pyimagediet/process.py
update_configuration
def update_configuration(orig, new): '''Update existing configuration with new values. Needed because dict.update is shallow and would overwrite nested dicts. Function updates sections commands, parameters and pipelines and adds any new items listed in updates. :param orig: configuration to update...
python
def update_configuration(orig, new): '''Update existing configuration with new values. Needed because dict.update is shallow and would overwrite nested dicts. Function updates sections commands, parameters and pipelines and adds any new items listed in updates. :param orig: configuration to update...
[ "def", "update_configuration", "(", "orig", ",", "new", ")", ":", "dicts", "=", "(", "'commands'", ",", "'parameters'", ",", "'pipelines'", ")", "for", "key", "in", "dicts", ":", "if", "key", "in", "new", ":", "orig", "[", "key", "]", ".", "update", ...
Update existing configuration with new values. Needed because dict.update is shallow and would overwrite nested dicts. Function updates sections commands, parameters and pipelines and adds any new items listed in updates. :param orig: configuration to update :type orig: dict :param new: new up...
[ "Update", "existing", "configuration", "with", "new", "values", ".", "Needed", "because", "dict", ".", "update", "is", "shallow", "and", "would", "overwrite", "nested", "dicts", "." ]
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L104-L123
samastur/pyimagediet
pyimagediet/process.py
check_configuration
def check_configuration(config): '''Check if configuration object is not malformed. :param config: configuration :type config: dict :return: is configuration correct? :rtype: bool ''' sections = ('commands', 'parameters', 'pipelines') # Check all sections are there and contain dicts ...
python
def check_configuration(config): '''Check if configuration object is not malformed. :param config: configuration :type config: dict :return: is configuration correct? :rtype: bool ''' sections = ('commands', 'parameters', 'pipelines') # Check all sections are there and contain dicts ...
[ "def", "check_configuration", "(", "config", ")", ":", "sections", "=", "(", "'commands'", ",", "'parameters'", ",", "'pipelines'", ")", "# Check all sections are there and contain dicts", "for", "section", "in", "sections", ":", "if", "section", "not", "in", "confi...
Check if configuration object is not malformed. :param config: configuration :type config: dict :return: is configuration correct? :rtype: bool
[ "Check", "if", "configuration", "object", "is", "not", "malformed", "." ]
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L128-L167
samastur/pyimagediet
pyimagediet/process.py
backup_file
def backup_file(filename, backup_ext): ''' Make a file backup if: - backup extension is defined - backup file does not exist yet If backup file exists: - do nothing if it is same - complain loudly otherwise Return file name of the back up if successful. None otherwise. ''' ext =...
python
def backup_file(filename, backup_ext): ''' Make a file backup if: - backup extension is defined - backup file does not exist yet If backup file exists: - do nothing if it is same - complain loudly otherwise Return file name of the back up if successful. None otherwise. ''' ext =...
[ "def", "backup_file", "(", "filename", ",", "backup_ext", ")", ":", "ext", "=", "backup_ext", ".", "strip", "(", "\" .\"", ")", "if", "ext", ":", "backup_filename", "=", "\".\"", ".", "join", "(", "[", "filename", ",", "ext", "]", ")", "if", "not", "...
Make a file backup if: - backup extension is defined - backup file does not exist yet If backup file exists: - do nothing if it is same - complain loudly otherwise Return file name of the back up if successful. None otherwise.
[ "Make", "a", "file", "backup", "if", ":", "-", "backup", "extension", "is", "defined", "-", "backup", "file", "does", "not", "exist", "yet", "If", "backup", "file", "exists", ":", "-", "do", "nothing", "if", "it", "is", "same", "-", "complain", "loudly...
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L171-L192
samastur/pyimagediet
pyimagediet/process.py
diet
def diet(filename, configuration): ''' Squeeze files if there is a pipeline defined for them or leave them be otherwise. :param filename: filename of the file to process :param configuration: configuration dict describing commands and pipelines :type configuration: dict :return: has file ch...
python
def diet(filename, configuration): ''' Squeeze files if there is a pipeline defined for them or leave them be otherwise. :param filename: filename of the file to process :param configuration: configuration dict describing commands and pipelines :type configuration: dict :return: has file ch...
[ "def", "diet", "(", "filename", ",", "configuration", ")", ":", "changed", "=", "False", "if", "not", "isfile", "(", "filename", ")", ":", "raise", "NotFileDietException", "(", "'Passed filename does not point to a file'", ")", "conf", "=", "copy", ".", "deepcop...
Squeeze files if there is a pipeline defined for them or leave them be otherwise. :param filename: filename of the file to process :param configuration: configuration dict describing commands and pipelines :type configuration: dict :return: has file changed :rtype: bool
[ "Squeeze", "files", "if", "there", "is", "a", "pipeline", "defined", "for", "them", "or", "leave", "them", "be", "otherwise", "." ]
train
https://github.com/samastur/pyimagediet/blob/480c6e171577df36e166590b031bc8891b3c9e7b/pyimagediet/process.py#L220-L262
radjkarl/fancyTools
fancytools/utils/countLines.py
countLines
def countLines(paths, exclude_files_containing=[], exclude_folders_containing=[], exclude_blank_lines=True, exclude_commented_lines=True, count_only_py_files=True): """ count and return lines of all *.py files in the given directory/-ies [paths] ...
python
def countLines(paths, exclude_files_containing=[], exclude_folders_containing=[], exclude_blank_lines=True, exclude_commented_lines=True, count_only_py_files=True): """ count and return lines of all *.py files in the given directory/-ies [paths] ...
[ "def", "countLines", "(", "paths", ",", "exclude_files_containing", "=", "[", "]", ",", "exclude_folders_containing", "=", "[", "]", ",", "exclude_blank_lines", "=", "True", ",", "exclude_commented_lines", "=", "True", ",", "count_only_py_files", "=", "True", ")",...
count and return lines of all *.py files in the given directory/-ies [paths] --> file path or list of paths to recursively count code line [exclude_(files/folders)_containing] --> list of phases in folder/file name to be excluded e.g. ['test', 'build']
[ "count", "and", "return", "lines", "of", "all", "*", ".", "py", "files", "in", "the", "given", "directory", "/", "-", "ies" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/utils/countLines.py#L8-L71
sassoo/goldman
goldman/request.py
Request.auth_scheme
def auth_scheme(self): """ If an Authorization header is present get the scheme It is expected to be the first string in a space separated list & will always be returned lowercase. :return: str or None """ try: auth = getattr(self, 'auth') retur...
python
def auth_scheme(self): """ If an Authorization header is present get the scheme It is expected to be the first string in a space separated list & will always be returned lowercase. :return: str or None """ try: auth = getattr(self, 'auth') retur...
[ "def", "auth_scheme", "(", "self", ")", ":", "try", ":", "auth", "=", "getattr", "(", "self", ",", "'auth'", ")", "return", "naked", "(", "auth", ".", "split", "(", "' '", ")", "[", "0", "]", ")", ".", "lower", "(", ")", "except", "(", "Attribute...
If an Authorization header is present get the scheme It is expected to be the first string in a space separated list & will always be returned lowercase. :return: str or None
[ "If", "an", "Authorization", "header", "is", "present", "get", "the", "scheme" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/request.py#L45-L58
sassoo/goldman
goldman/request.py
Request._init_content_type_params
def _init_content_type_params(self): """ Return the Content-Type request header parameters Convert all of the semi-colon separated parameters into a dict of key/vals. If for some stupid reason duplicate & conflicting params are present then the last one wins. If a parti...
python
def _init_content_type_params(self): """ Return the Content-Type request header parameters Convert all of the semi-colon separated parameters into a dict of key/vals. If for some stupid reason duplicate & conflicting params are present then the last one wins. If a parti...
[ "def", "_init_content_type_params", "(", "self", ")", ":", "ret", "=", "{", "}", "if", "self", ".", "content_type", ":", "params", "=", "self", ".", "content_type", ".", "split", "(", "';'", ")", "[", "1", ":", "]", "for", "param", "in", "params", ":...
Return the Content-Type request header parameters Convert all of the semi-colon separated parameters into a dict of key/vals. If for some stupid reason duplicate & conflicting params are present then the last one wins. If a particular content-type param is non-compliant ...
[ "Return", "the", "Content", "-", "Type", "request", "header", "parameters" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/request.py#L102-L130
narfman0/helga-markovify
helga_markovify/plugin.py
_handle_match
def _handle_match(client, channel, nick, message, matches): """ Match stores all channel info. If helga is asked something to stimulate a markov response about channel data, then we shall graciously provide it. """ generate_interrogative = _CHANNEL_GENERATE_REGEX.match(message) if generate_inter...
python
def _handle_match(client, channel, nick, message, matches): """ Match stores all channel info. If helga is asked something to stimulate a markov response about channel data, then we shall graciously provide it. """ generate_interrogative = _CHANNEL_GENERATE_REGEX.match(message) if generate_inter...
[ "def", "_handle_match", "(", "client", ",", "channel", ",", "nick", ",", "message", ",", "matches", ")", ":", "generate_interrogative", "=", "_CHANNEL_GENERATE_REGEX", ".", "match", "(", "message", ")", "if", "generate_interrogative", ":", "return", "generate", ...
Match stores all channel info. If helga is asked something to stimulate a markov response about channel data, then we shall graciously provide it.
[ "Match", "stores", "all", "channel", "info", ".", "If", "helga", "is", "asked", "something", "to", "stimulate", "a", "markov", "response", "about", "channel", "data", "then", "we", "shall", "graciously", "provide", "it", "." ]
train
https://github.com/narfman0/helga-markovify/blob/b5a82de070102e6da1fd3f5f81cad12d0a9185d8/helga_markovify/plugin.py#L70-L85
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/api.py
require_root
def require_root(fn): """ Decorator to make sure, that user is root. """ @wraps(fn) def xex(*args, **kwargs): assert os.geteuid() == 0, \ "You have to be root to run function '%s'." % fn.__name__ return fn(*args, **kwargs) return xex
python
def require_root(fn): """ Decorator to make sure, that user is root. """ @wraps(fn) def xex(*args, **kwargs): assert os.geteuid() == 0, \ "You have to be root to run function '%s'." % fn.__name__ return fn(*args, **kwargs) return xex
[ "def", "require_root", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "xex", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "os", ".", "geteuid", "(", ")", "==", "0", ",", "\"You have to be root to run function '%s'.\"", "%",...
Decorator to make sure, that user is root.
[ "Decorator", "to", "make", "sure", "that", "user", "is", "root", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/api.py#L37-L47
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/api.py
recursive_chmod
def recursive_chmod(path, mode=0755): """ Recursively change ``mode`` for given ``path``. Same as ``chmod -R mode``. Args: path (str): Path of the directory/file. mode (octal int, default 0755): New mode of the file. Warning: Don't forget to add ``0`` at the beginning of the nu...
python
def recursive_chmod(path, mode=0755): """ Recursively change ``mode`` for given ``path``. Same as ``chmod -R mode``. Args: path (str): Path of the directory/file. mode (octal int, default 0755): New mode of the file. Warning: Don't forget to add ``0`` at the beginning of the nu...
[ "def", "recursive_chmod", "(", "path", ",", "mode", "=", "0755", ")", ":", "passwd_reader", ".", "set_permissions", "(", "path", ",", "mode", "=", "mode", ")", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "return", "# recursively change...
Recursively change ``mode`` for given ``path``. Same as ``chmod -R mode``. Args: path (str): Path of the directory/file. mode (octal int, default 0755): New mode of the file. Warning: Don't forget to add ``0`` at the beginning of the numbers of `mode`, or `Unspeakable hOrRoRs` ...
[ "Recursively", "change", "mode", "for", "given", "path", ".", "Same", "as", "chmod", "-", "R", "mode", "." ]
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/api.py#L58-L78