repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
gawel/irc3
irc3/base.py
IrcObject.from_config
def from_config(cls, cfg, **kwargs): """return an instance configured with the ``cfg`` dict""" cfg = dict(cfg, **kwargs) pythonpath = cfg.get('pythonpath', []) if 'here' in cfg: pythonpath.append(cfg['here']) for path in pythonpath: sys.path.append(os.path...
python
def from_config(cls, cfg, **kwargs): """return an instance configured with the ``cfg`` dict""" cfg = dict(cfg, **kwargs) pythonpath = cfg.get('pythonpath', []) if 'here' in cfg: pythonpath.append(cfg['here']) for path in pythonpath: sys.path.append(os.path...
[ "def", "from_config", "(", "cls", ",", "cfg", ",", "*", "*", "kwargs", ")", ":", "cfg", "=", "dict", "(", "cfg", ",", "*", "*", "kwargs", ")", "pythonpath", "=", "cfg", ".", "get", "(", "'pythonpath'", ",", "[", "]", ")", "if", "'here'", "in", ...
return an instance configured with the ``cfg`` dict
[ "return", "an", "instance", "configured", "with", "the", "cfg", "dict" ]
train
https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L373-L392
Chetic/robotframework-async
AsyncLibrary/robot_async.py
AsyncLibrary.async_run
def async_run(self, keyword, *args, **kwargs): ''' Executes the provided Robot Framework keyword in a separate thread and immediately returns a handle to be used with async_get ''' handle = self._last_thread_handle thread = self._threaded(keyword, *args, **kwargs) thread.start() ...
python
def async_run(self, keyword, *args, **kwargs): ''' Executes the provided Robot Framework keyword in a separate thread and immediately returns a handle to be used with async_get ''' handle = self._last_thread_handle thread = self._threaded(keyword, *args, **kwargs) thread.start() ...
[ "def", "async_run", "(", "self", ",", "keyword", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "handle", "=", "self", ".", "_last_thread_handle", "thread", "=", "self", ".", "_threaded", "(", "keyword", ",", "*", "args", ",", "*", "*", "kwargs...
Executes the provided Robot Framework keyword in a separate thread and immediately returns a handle to be used with async_get
[ "Executes", "the", "provided", "Robot", "Framework", "keyword", "in", "a", "separate", "thread", "and", "immediately", "returns", "a", "handle", "to", "be", "used", "with", "async_get" ]
train
https://github.com/Chetic/robotframework-async/blob/1a2b19d1927f6cd3f62947a9b2b8a166a24278d1/AsyncLibrary/robot_async.py#L14-L21
Chetic/robotframework-async
AsyncLibrary/robot_async.py
AsyncLibrary.async_get
def async_get(self, handle): ''' Blocks until the thread created by async_run returns ''' assert handle in self._thread_pool, 'Invalid async call handle' result = self._thread_pool[handle].result_queue.get() del self._thread_pool[handle] return result
python
def async_get(self, handle): ''' Blocks until the thread created by async_run returns ''' assert handle in self._thread_pool, 'Invalid async call handle' result = self._thread_pool[handle].result_queue.get() del self._thread_pool[handle] return result
[ "def", "async_get", "(", "self", ",", "handle", ")", ":", "assert", "handle", "in", "self", ".", "_thread_pool", ",", "'Invalid async call handle'", "result", "=", "self", ".", "_thread_pool", "[", "handle", "]", ".", "result_queue", ".", "get", "(", ")", ...
Blocks until the thread created by async_run returns
[ "Blocks", "until", "the", "thread", "created", "by", "async_run", "returns" ]
train
https://github.com/Chetic/robotframework-async/blob/1a2b19d1927f6cd3f62947a9b2b8a166a24278d1/AsyncLibrary/robot_async.py#L23-L28
Chetic/robotframework-async
AsyncLibrary/robot_async.py
AsyncLibrary._get_handler_from_keyword
def _get_handler_from_keyword(self, keyword): ''' Gets the Robot Framework handler associated with the given keyword ''' if EXECUTION_CONTEXTS.current is None: raise RobotNotRunningError('Cannot access execution context') return EXECUTION_CONTEXTS.current.get_handler(keyword)
python
def _get_handler_from_keyword(self, keyword): ''' Gets the Robot Framework handler associated with the given keyword ''' if EXECUTION_CONTEXTS.current is None: raise RobotNotRunningError('Cannot access execution context') return EXECUTION_CONTEXTS.current.get_handler(keyword)
[ "def", "_get_handler_from_keyword", "(", "self", ",", "keyword", ")", ":", "if", "EXECUTION_CONTEXTS", ".", "current", "is", "None", ":", "raise", "RobotNotRunningError", "(", "'Cannot access execution context'", ")", "return", "EXECUTION_CONTEXTS", ".", "current", "....
Gets the Robot Framework handler associated with the given keyword
[ "Gets", "the", "Robot", "Framework", "handler", "associated", "with", "the", "given", "keyword" ]
train
https://github.com/Chetic/robotframework-async/blob/1a2b19d1927f6cd3f62947a9b2b8a166a24278d1/AsyncLibrary/robot_async.py#L30-L34
themartorana/python-postmark
postmark/core.py
PMMail._set_custom_headers
def _set_custom_headers(self, value): ''' A special set function to ensure we're setting with a dictionary ''' if value is None: setattr(self, '_PMMail__custom_headers', {}) elif isinstance(value, dict): setattr(self, '_PMMail__custom_headers', val...
python
def _set_custom_headers(self, value): ''' A special set function to ensure we're setting with a dictionary ''' if value is None: setattr(self, '_PMMail__custom_headers', {}) elif isinstance(value, dict): setattr(self, '_PMMail__custom_headers', val...
[ "def", "_set_custom_headers", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "setattr", "(", "self", ",", "'_PMMail__custom_headers'", ",", "{", "}", ")", "elif", "isinstance", "(", "value", ",", "dict", ")", ":", "setattr", "(", ...
A special set function to ensure we're setting with a dictionary
[ "A", "special", "set", "function", "to", "ensure", "we", "re", "setting", "with", "a", "dictionary" ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L146-L156
themartorana/python-postmark
postmark/core.py
PMMail._set_metadata
def _set_metadata(self, value): ''' A special set function to ensure we're setting with a dictionary ''' if value is None: setattr(self, '_PMMail__metadata', {}) elif isinstance(value, dict): for k, v in value.items(): if (not isins...
python
def _set_metadata(self, value): ''' A special set function to ensure we're setting with a dictionary ''' if value is None: setattr(self, '_PMMail__metadata', {}) elif isinstance(value, dict): for k, v in value.items(): if (not isins...
[ "def", "_set_metadata", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "setattr", "(", "self", ",", "'_PMMail__metadata'", ",", "{", "}", ")", "elif", "isinstance", "(", "value", ",", "dict", ")", ":", "for", "k", ",", "v", ...
A special set function to ensure we're setting with a dictionary
[ "A", "special", "set", "function", "to", "ensure", "we", "re", "setting", "with", "a", "dictionary" ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L158-L172
themartorana/python-postmark
postmark/core.py
PMMail._set_attachments
def _set_attachments(self, value): ''' A special set function to ensure we're setting with a list ''' if value is None: setattr(self, '_PMMail__attachments', []) elif isinstance(value, list): setattr(self, '_PMMail__attachments', value) els...
python
def _set_attachments(self, value): ''' A special set function to ensure we're setting with a list ''' if value is None: setattr(self, '_PMMail__attachments', []) elif isinstance(value, list): setattr(self, '_PMMail__attachments', value) els...
[ "def", "_set_attachments", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "setattr", "(", "self", ",", "'_PMMail__attachments'", ",", "[", "]", ")", "elif", "isinstance", "(", "value", ",", "list", ")", ":", "setattr", "(", "sel...
A special set function to ensure we're setting with a list
[ "A", "special", "set", "function", "to", "ensure", "we", "re", "setting", "with", "a", "list" ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L174-L184
themartorana/python-postmark
postmark/core.py
PMMail._check_values
def _check_values(self): ''' Make sure all values are of the appropriate type and are not missing. ''' if not self.__api_key: raise PMMailMissingValueException('Cannot send an e-mail without a Postmark API Key') elif not self.__sender: raise PMMail...
python
def _check_values(self): ''' Make sure all values are of the appropriate type and are not missing. ''' if not self.__api_key: raise PMMailMissingValueException('Cannot send an e-mail without a Postmark API Key') elif not self.__sender: raise PMMail...
[ "def", "_check_values", "(", "self", ")", ":", "if", "not", "self", ".", "__api_key", ":", "raise", "PMMailMissingValueException", "(", "'Cannot send an e-mail without a Postmark API Key'", ")", "elif", "not", "self", ".", "__sender", ":", "raise", "PMMailMissingValue...
Make sure all values are of the appropriate type and are not missing.
[ "Make", "sure", "all", "values", "are", "of", "the", "appropriate", "type", "and", "are", "not", "missing", "." ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L371-L390
themartorana/python-postmark
postmark/core.py
PMMail.send
def send(self, test=None): ''' Send the email through the Postmark system. Pass test=True to just print out the resulting JSON message being sent to Postmark ''' self._check_values() # Set up message dictionary json_message = self.to_json_message() ...
python
def send(self, test=None): ''' Send the email through the Postmark system. Pass test=True to just print out the resulting JSON message being sent to Postmark ''' self._check_values() # Set up message dictionary json_message = self.to_json_message() ...
[ "def", "send", "(", "self", ",", "test", "=", "None", ")", ":", "self", ".", "_check_values", "(", ")", "# Set up message dictionary", "json_message", "=", "self", ".", "to_json_message", "(", ")", "# if (self.__html_body and not self.__text_body) and self.__multipart:"...
Send the email through the Postmark system. Pass test=True to just print out the resulting JSON message being sent to Postmark
[ "Send", "the", "email", "through", "the", "Postmark", "system", ".", "Pass", "test", "=", "True", "to", "just", "print", "out", "the", "resulting", "JSON", "message", "being", "sent", "to", "Postmark" ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L472-L552
themartorana/python-postmark
postmark/core.py
PMBatchMail.remove_message
def remove_message(self, message): ''' Remove a message from the batch ''' if message in self.__messages: self.__messages.remove(message)
python
def remove_message(self, message): ''' Remove a message from the batch ''' if message in self.__messages: self.__messages.remove(message)
[ "def", "remove_message", "(", "self", ",", "message", ")", ":", "if", "message", "in", "self", ".", "__messages", ":", "self", ".", "__messages", ".", "remove", "(", "message", ")" ]
Remove a message from the batch
[ "Remove", "a", "message", "from", "the", "batch" ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L615-L620
themartorana/python-postmark
postmark/core.py
PMBounceManager.delivery_stats
def delivery_stats(self): ''' Returns a summary of inactive emails and bounces by type. ''' self._check_values() req = Request( __POSTMARK_URL__ + 'deliverystats', None, { 'Accept': 'application/json', 'Content-...
python
def delivery_stats(self): ''' Returns a summary of inactive emails and bounces by type. ''' self._check_values() req = Request( __POSTMARK_URL__ + 'deliverystats', None, { 'Accept': 'application/json', 'Content-...
[ "def", "delivery_stats", "(", "self", ")", ":", "self", ".", "_check_values", "(", ")", "req", "=", "Request", "(", "__POSTMARK_URL__", "+", "'deliverystats'", ",", "None", ",", "{", "'Accept'", ":", "'application/json'", ",", "'Content-Type'", ":", "'applicat...
Returns a summary of inactive emails and bounces by type.
[ "Returns", "a", "summary", "of", "inactive", "emails", "and", "bounces", "by", "type", "." ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L765-L793
themartorana/python-postmark
postmark/core.py
PMBounceManager.get_all
def get_all(self, inactive='', email_filter='', tag='', count=25, offset=0): ''' Fetches a portion of bounces according to the specified input criteria. The count and offset parameters are mandatory. You should never retrieve all bounces as that could be excessively slow for your applica...
python
def get_all(self, inactive='', email_filter='', tag='', count=25, offset=0): ''' Fetches a portion of bounces according to the specified input criteria. The count and offset parameters are mandatory. You should never retrieve all bounces as that could be excessively slow for your applica...
[ "def", "get_all", "(", "self", ",", "inactive", "=", "''", ",", "email_filter", "=", "''", ",", "tag", "=", "''", ",", "count", "=", "25", ",", "offset", "=", "0", ")", ":", "self", ".", "_check_values", "(", ")", "params", "=", "'?inactive='", "+"...
Fetches a portion of bounces according to the specified input criteria. The count and offset parameters are mandatory. You should never retrieve all bounces as that could be excessively slow for your application. To know how many bounces you have, you need to request a portion first, usually the...
[ "Fetches", "a", "portion", "of", "bounces", "according", "to", "the", "specified", "input", "criteria", ".", "The", "count", "and", "offset", "parameters", "are", "mandatory", ".", "You", "should", "never", "retrieve", "all", "bounces", "as", "that", "could", ...
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L795-L831
themartorana/python-postmark
postmark/core.py
PMBounceManager.activate
def activate(self, bounce_id): ''' Activates a deactivated bounce. ''' self._check_values() req_url = '/bounces/' + str(bounce_id) + '/activate' # print req_url h1 = HTTPConnection('api.postmarkapp.com') dta = urlencode({"data": "blank"}).encode('utf8') ...
python
def activate(self, bounce_id): ''' Activates a deactivated bounce. ''' self._check_values() req_url = '/bounces/' + str(bounce_id) + '/activate' # print req_url h1 = HTTPConnection('api.postmarkapp.com') dta = urlencode({"data": "blank"}).encode('utf8') ...
[ "def", "activate", "(", "self", ",", "bounce_id", ")", ":", "self", ".", "_check_values", "(", ")", "req_url", "=", "'/bounces/'", "+", "str", "(", "bounce_id", ")", "+", "'/activate'", "# print req_url", "h1", "=", "HTTPConnection", "(", "'api.postmarkapp.com...
Activates a deactivated bounce.
[ "Activates", "a", "deactivated", "bounce", "." ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/core.py#L928-L949
themartorana/python-postmark
postmark/django_backend.py
EmailBackend.send_messages
def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """ if not email_messages: return sent = self._send(email_messages) if sent: return len(email_messages) ...
python
def send_messages(self, email_messages): """ Sends one or more EmailMessage objects and returns the number of email messages sent. """ if not email_messages: return sent = self._send(email_messages) if sent: return len(email_messages) ...
[ "def", "send_messages", "(", "self", ",", "email_messages", ")", ":", "if", "not", "email_messages", ":", "return", "sent", "=", "self", ".", "_send", "(", "email_messages", ")", "if", "sent", ":", "return", "len", "(", "email_messages", ")", "return", "0"...
Sends one or more EmailMessage objects and returns the number of email messages sent.
[ "Sends", "one", "or", "more", "EmailMessage", "objects", "and", "returns", "the", "number", "of", "email", "messages", "sent", "." ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/django_backend.py#L57-L67
themartorana/python-postmark
postmark/django_backend.py
EmailBackend._build_message
def _build_message(self, message): """A helper method to convert a PMEmailMessage to a PMMail""" if not message.recipients(): return False recipients = ','.join(message.to) recipients_cc = ','.join(message.cc) recipients_bcc = ','.join(message.bcc) text_body ...
python
def _build_message(self, message): """A helper method to convert a PMEmailMessage to a PMMail""" if not message.recipients(): return False recipients = ','.join(message.to) recipients_cc = ','.join(message.cc) recipients_bcc = ','.join(message.bcc) text_body ...
[ "def", "_build_message", "(", "self", ",", "message", ")", ":", "if", "not", "message", ".", "recipients", "(", ")", ":", "return", "False", "recipients", "=", "','", ".", "join", "(", "message", ".", "to", ")", "recipients_cc", "=", "','", ".", "join"...
A helper method to convert a PMEmailMessage to a PMMail
[ "A", "helper", "method", "to", "convert", "a", "PMEmailMessage", "to", "a", "PMMail" ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/django_backend.py#L69-L128
themartorana/python-postmark
postmark/django_backend.py
EmailBackend._send
def _send(self, messages): """A helper method that does the actual sending.""" if len(messages) == 1: to_send = self._build_message(messages[0]) if to_send is False: # The message was missing recipients. # Bail. return False ...
python
def _send(self, messages): """A helper method that does the actual sending.""" if len(messages) == 1: to_send = self._build_message(messages[0]) if to_send is False: # The message was missing recipients. # Bail. return False ...
[ "def", "_send", "(", "self", ",", "messages", ")", ":", "if", "len", "(", "messages", ")", "==", "1", ":", "to_send", "=", "self", ".", "_build_message", "(", "messages", "[", "0", "]", ")", "if", "to_send", "is", "False", ":", "# The message was missi...
A helper method that does the actual sending.
[ "A", "helper", "method", "that", "does", "the", "actual", "sending", "." ]
train
https://github.com/themartorana/python-postmark/blob/3087f6894ec2790e295fd59eba9c57da9de78d1c/postmark/django_backend.py#L130-L152
olivettigroup/article-downloader
articledownloader/scrapers.py
Nature.handle_starttag
def handle_starttag(self, tag, attrs): ''' PDF link handler; never gets explicitly called by user ''' if tag == 'a' and ( ('class', 'download-pdf') in attrs or ('id', 'download-pdf') in attrs ): for attr in attrs: if attr[0] == 'href': self.download_link = 'http://www.natur...
python
def handle_starttag(self, tag, attrs): ''' PDF link handler; never gets explicitly called by user ''' if tag == 'a' and ( ('class', 'download-pdf') in attrs or ('id', 'download-pdf') in attrs ): for attr in attrs: if attr[0] == 'href': self.download_link = 'http://www.natur...
[ "def", "handle_starttag", "(", "self", ",", "tag", ",", "attrs", ")", ":", "if", "tag", "==", "'a'", "and", "(", "(", "'class'", ",", "'download-pdf'", ")", "in", "attrs", "or", "(", "'id'", ",", "'download-pdf'", ")", "in", "attrs", ")", ":", "for",...
PDF link handler; never gets explicitly called by user
[ "PDF", "link", "handler", ";", "never", "gets", "explicitly", "called", "by", "user" ]
train
https://github.com/olivettigroup/article-downloader/blob/2f56e498413072e2e3a9644d3703804c3cf297ad/articledownloader/scrapers.py#L49-L56
marcwebbie/passpie
passpie/utils.py
genpass
def genpass(pattern=r'[\w]{32}'): """generates a password with random chararcters """ try: return rstr.xeger(pattern) except re.error as e: raise ValueError(str(e))
python
def genpass(pattern=r'[\w]{32}'): """generates a password with random chararcters """ try: return rstr.xeger(pattern) except re.error as e: raise ValueError(str(e))
[ "def", "genpass", "(", "pattern", "=", "r'[\\w]{32}'", ")", ":", "try", ":", "return", "rstr", ".", "xeger", "(", "pattern", ")", "except", "re", ".", "error", "as", "e", ":", "raise", "ValueError", "(", "str", "(", "e", ")", ")" ]
generates a password with random chararcters
[ "generates", "a", "password", "with", "random", "chararcters" ]
train
https://github.com/marcwebbie/passpie/blob/421c40a57ad5f55e3f14b323c929a2c41dfb5527/passpie/utils.py#L18-L24
andreax79/python-cstruct
cstruct/__init__.py
CStruct.unpack
def unpack(self, string): """ Unpack the string containing packed C structure data """ if string is None: string = CHAR_ZERO * self.__size__ data = struct.unpack(self.__fmt__, string) i = 0 for field in self.__fields__: (vtype, vlen) = self...
python
def unpack(self, string): """ Unpack the string containing packed C structure data """ if string is None: string = CHAR_ZERO * self.__size__ data = struct.unpack(self.__fmt__, string) i = 0 for field in self.__fields__: (vtype, vlen) = self...
[ "def", "unpack", "(", "self", ",", "string", ")", ":", "if", "string", "is", "None", ":", "string", "=", "CHAR_ZERO", "*", "self", ".", "__size__", "data", "=", "struct", ".", "unpack", "(", "self", ".", "__fmt__", ",", "string", ")", "i", "=", "0"...
Unpack the string containing packed C structure data
[ "Unpack", "the", "string", "containing", "packed", "C", "structure", "data" ]
train
https://github.com/andreax79/python-cstruct/blob/9fba4f10de9045c34a605e187cd24520962450bf/cstruct/__init__.py#L318-L351
andreax79/python-cstruct
cstruct/__init__.py
CStruct.pack
def pack(self): """ Pack the structure data into a string """ data = [] for field in self.__fields__: (vtype, vlen) = self.__fields_types__[field] if vtype == 'char': # string data.append(getattr(self, field)) elif isinstance(vt...
python
def pack(self): """ Pack the structure data into a string """ data = [] for field in self.__fields__: (vtype, vlen) = self.__fields_types__[field] if vtype == 'char': # string data.append(getattr(self, field)) elif isinstance(vt...
[ "def", "pack", "(", "self", ")", ":", "data", "=", "[", "]", "for", "field", "in", "self", ".", "__fields__", ":", "(", "vtype", ",", "vlen", ")", "=", "self", ".", "__fields_types__", "[", "field", "]", "if", "vtype", "==", "'char'", ":", "# strin...
Pack the structure data into a string
[ "Pack", "the", "structure", "data", "into", "a", "string" ]
train
https://github.com/andreax79/python-cstruct/blob/9fba4f10de9045c34a605e187cd24520962450bf/cstruct/__init__.py#L353-L387
andreax79/python-cstruct
cstruct/examples/who.py
Utmp.print_info
def print_info(self): "andreax + pts/0 2013-08-21 08:58 . 32341 (l26.box)" " pts/34 2013-06-12 15:04 26396 id=s/34 term=0 exit=0" # if self.ut_type not in [6,7]: # return print("%-10s %-12s %15s %15s %-8s" % ( s...
python
def print_info(self): "andreax + pts/0 2013-08-21 08:58 . 32341 (l26.box)" " pts/34 2013-06-12 15:04 26396 id=s/34 term=0 exit=0" # if self.ut_type not in [6,7]: # return print("%-10s %-12s %15s %15s %-8s" % ( s...
[ "def", "print_info", "(", "self", ")", ":", "\" pts/34 2013-06-12 15:04 26396 id=s/34 term=0 exit=0\"", "# if self.ut_type not in [6,7]:", "# return", "print", "(", "\"%-10s %-12s %15s %15s %-8s\"", "%", "(", "str_from_c", "(", "self", ...
andreax + pts/0 2013-08-21 08:58 . 32341 (l26.box)
[ "andreax", "+", "pts", "/", "0", "2013", "-", "08", "-", "21", "08", ":", "58", ".", "32341", "(", "l26", ".", "box", ")" ]
train
https://github.com/andreax79/python-cstruct/blob/9fba4f10de9045c34a605e187cd24520962450bf/cstruct/examples/who.py#L89-L99
marcwebbie/passpie
passpie/importers/__init__.py
get_all
def get_all(): """Get all subclasses of BaseImporter from module and return and generator """ _import_all_importer_files() for module in (value for key, value in globals().items() if key in __all__): for klass_name, klass in inspect.getmembers(module, inspect.isclass): ...
python
def get_all(): """Get all subclasses of BaseImporter from module and return and generator """ _import_all_importer_files() for module in (value for key, value in globals().items() if key in __all__): for klass_name, klass in inspect.getmembers(module, inspect.isclass): ...
[ "def", "get_all", "(", ")", ":", "_import_all_importer_files", "(", ")", "for", "module", "in", "(", "value", "for", "key", ",", "value", "in", "globals", "(", ")", ".", "items", "(", ")", "if", "key", "in", "__all__", ")", ":", "for", "klass_name", ...
Get all subclasses of BaseImporter from module and return and generator
[ "Get", "all", "subclasses", "of", "BaseImporter", "from", "module", "and", "return", "and", "generator" ]
train
https://github.com/marcwebbie/passpie/blob/421c40a57ad5f55e3f14b323c929a2c41dfb5527/passpie/importers/__init__.py#L48-L61
marcwebbie/passpie
passpie/cli.py
list_database
def list_database(db): """Print credential as a table""" credentials = db.credentials() if credentials: table = Table( db.config['headers'], table_format=db.config['table_format'], colors=db.config['colors'], hidden=db.config['hidden'], hid...
python
def list_database(db): """Print credential as a table""" credentials = db.credentials() if credentials: table = Table( db.config['headers'], table_format=db.config['table_format'], colors=db.config['colors'], hidden=db.config['hidden'], hid...
[ "def", "list_database", "(", "db", ")", ":", "credentials", "=", "db", ".", "credentials", "(", ")", "if", "credentials", ":", "table", "=", "Table", "(", "db", ".", "config", "[", "'headers'", "]", ",", "table_format", "=", "db", ".", "config", "[", ...
Print credential as a table
[ "Print", "credential", "as", "a", "table" ]
train
https://github.com/marcwebbie/passpie/blob/421c40a57ad5f55e3f14b323c929a2c41dfb5527/passpie/cli.py#L127-L138
marcwebbie/passpie
passpie/cli.py
check_config
def check_config(db, level): """Show current configuration for shell""" if level == 'global': configuration = config.read(config.HOMEDIR, '.passpierc') elif level == 'local': configuration = config.read(os.path.join(db.path)) elif level == 'current': configuration = db.config ...
python
def check_config(db, level): """Show current configuration for shell""" if level == 'global': configuration = config.read(config.HOMEDIR, '.passpierc') elif level == 'local': configuration = config.read(os.path.join(db.path)) elif level == 'current': configuration = db.config ...
[ "def", "check_config", "(", "db", ",", "level", ")", ":", "if", "level", "==", "'global'", ":", "configuration", "=", "config", ".", "read", "(", "config", ".", "HOMEDIR", ",", "'.passpierc'", ")", "elif", "level", "==", "'local'", ":", "configuration", ...
Show current configuration for shell
[ "Show", "current", "configuration", "for", "shell" ]
train
https://github.com/marcwebbie/passpie/blob/421c40a57ad5f55e3f14b323c929a2c41dfb5527/passpie/cli.py#L146-L156
mikeywaites/flask-arrested
arrested/handlers.py
Handler.process
def process(self, data=None, **kwargs): """Process the provided data and invoke :meth:`Handler.handle` method for this Handler class. :params data: The data being processed. :returns: self :rtype: :class:`Handler` .. code-block:: python def post(self, *args...
python
def process(self, data=None, **kwargs): """Process the provided data and invoke :meth:`Handler.handle` method for this Handler class. :params data: The data being processed. :returns: self :rtype: :class:`Handler` .. code-block:: python def post(self, *args...
[ "def", "process", "(", "self", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "data", "=", "self", ".", "handle", "(", "data", ",", "*", "*", "kwargs", ")", "return", "self" ]
Process the provided data and invoke :meth:`Handler.handle` method for this Handler class. :params data: The data being processed. :returns: self :rtype: :class:`Handler` .. code-block:: python def post(self, *args, **kwargs): self.request = self.ge...
[ "Process", "the", "provided", "data", "and", "invoke", ":", "meth", ":", "Handler", ".", "handle", "method", "for", "this", "Handler", "class", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/handlers.py#L54-L73
mikeywaites/flask-arrested
arrested/handlers.py
RequestHandler.process
def process(self, data=None): """Fetch incoming data from the Flask request object when no data is supplied to the process method. By default, the RequestHandler expects the incoming data to be sent as JSON. """ return super(RequestHandler, self).process(data=data or self.get_r...
python
def process(self, data=None): """Fetch incoming data from the Flask request object when no data is supplied to the process method. By default, the RequestHandler expects the incoming data to be sent as JSON. """ return super(RequestHandler, self).process(data=data or self.get_r...
[ "def", "process", "(", "self", ",", "data", "=", "None", ")", ":", "return", "super", "(", "RequestHandler", ",", "self", ")", ".", "process", "(", "data", "=", "data", "or", "self", ".", "get_request_data", "(", ")", ")" ]
Fetch incoming data from the Flask request object when no data is supplied to the process method. By default, the RequestHandler expects the incoming data to be sent as JSON.
[ "Fetch", "incoming", "data", "from", "the", "Flask", "request", "object", "when", "no", "data", "is", "supplied", "to", "the", "process", "method", ".", "By", "default", "the", "RequestHandler", "expects", "the", "incoming", "data", "to", "be", "sent", "as",...
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/handlers.py#L116-L122
mikeywaites/flask-arrested
arrested/contrib/sql_alchemy.py
DBMixin.save
def save(self, obj): """Add ``obj`` to the SQLAlchemy session and commit the changes back to the database. :param obj: SQLAlchemy object being saved :returns: The saved object """ session = self.get_db_session() session.add(obj) session.commit() ...
python
def save(self, obj): """Add ``obj`` to the SQLAlchemy session and commit the changes back to the database. :param obj: SQLAlchemy object being saved :returns: The saved object """ session = self.get_db_session() session.add(obj) session.commit() ...
[ "def", "save", "(", "self", ",", "obj", ")", ":", "session", "=", "self", ".", "get_db_session", "(", ")", "session", ".", "add", "(", "obj", ")", "session", ".", "commit", "(", ")", "return", "obj" ]
Add ``obj`` to the SQLAlchemy session and commit the changes back to the database. :param obj: SQLAlchemy object being saved :returns: The saved object
[ "Add", "obj", "to", "the", "SQLAlchemy", "session", "and", "commit", "the", "changes", "back", "to", "the", "database", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/sql_alchemy.py#L52-L63
mikeywaites/flask-arrested
arrested/contrib/sql_alchemy.py
DBObjectMixin.filter_by_id
def filter_by_id(self, query): """Apply the primary key filter to query to filter the results for a specific instance by id. The filter applied by the this method by default can be controlled using the url_id_param :param query: SQLAlchemy Query :returns: A SQLAlchemy Q...
python
def filter_by_id(self, query): """Apply the primary key filter to query to filter the results for a specific instance by id. The filter applied by the this method by default can be controlled using the url_id_param :param query: SQLAlchemy Query :returns: A SQLAlchemy Q...
[ "def", "filter_by_id", "(", "self", ",", "query", ")", ":", "if", "self", ".", "model", "is", "None", ":", "raise", "ArrestedException", "(", "'DBObjectMixin requires a model to be set.'", ")", "idfield", "=", "getattr", "(", "self", ".", "model", ",", "self",...
Apply the primary key filter to query to filter the results for a specific instance by id. The filter applied by the this method by default can be controlled using the url_id_param :param query: SQLAlchemy Query :returns: A SQLAlchemy Query object
[ "Apply", "the", "primary", "key", "filter", "to", "query", "to", "filter", "the", "results", "for", "a", "specific", "instance", "by", "id", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/sql_alchemy.py#L177-L194
mikeywaites/flask-arrested
arrested/contrib/sql_alchemy.py
DBObjectMixin.get_object
def get_object(self): """Implements the GetObjectMixin interface and calls :meth:`DBObjectMixin.get_query`. Using this mixin requires usage of a response handler capable of serializing SQLAlchemy query result objects. :returns: Typically a SQLALchemy Query result. :rtype: mixed...
python
def get_object(self): """Implements the GetObjectMixin interface and calls :meth:`DBObjectMixin.get_query`. Using this mixin requires usage of a response handler capable of serializing SQLAlchemy query result objects. :returns: Typically a SQLALchemy Query result. :rtype: mixed...
[ "def", "get_object", "(", "self", ")", ":", "query", "=", "self", ".", "get_query", "(", ")", "query", "=", "self", ".", "filter_by_id", "(", "query", ")", "return", "self", ".", "get_result", "(", "query", ")" ]
Implements the GetObjectMixin interface and calls :meth:`DBObjectMixin.get_query`. Using this mixin requires usage of a response handler capable of serializing SQLAlchemy query result objects. :returns: Typically a SQLALchemy Query result. :rtype: mixed .. seealso:: ...
[ "Implements", "the", "GetObjectMixin", "interface", "and", "calls", ":", "meth", ":", "DBObjectMixin", ".", "get_query", ".", "Using", "this", "mixin", "requires", "usage", "of", "a", "response", "handler", "capable", "of", "serializing", "SQLAlchemy", "query", ...
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/sql_alchemy.py#L196-L212
mikeywaites/flask-arrested
arrested/contrib/sql_alchemy.py
DBObjectMixin.delete_object
def delete_object(self, obj): """Deletes an object from the session by calling session.delete and then commits the changes to the database. :param obj: The SQLAlchemy instance being deleted :returns: None """ session = self.get_db_session() session.delete(obj) ...
python
def delete_object(self, obj): """Deletes an object from the session by calling session.delete and then commits the changes to the database. :param obj: The SQLAlchemy instance being deleted :returns: None """ session = self.get_db_session() session.delete(obj) ...
[ "def", "delete_object", "(", "self", ",", "obj", ")", ":", "session", "=", "self", ".", "get_db_session", "(", ")", "session", ".", "delete", "(", "obj", ")", "session", ".", "commit", "(", ")" ]
Deletes an object from the session by calling session.delete and then commits the changes to the database. :param obj: The SQLAlchemy instance being deleted :returns: None
[ "Deletes", "an", "object", "from", "the", "session", "by", "calling", "session", ".", "delete", "and", "then", "commits", "the", "changes", "to", "the", "database", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/sql_alchemy.py#L226-L235
mikeywaites/flask-arrested
arrested/api.py
ArrestedAPI.init_app
def init_app(self, app): """Initialise the ArrestedAPI object by storing a pointer to a Flask app object. This method is typically used when initialisation is deferred. :param app: Flask application object Usage:: app = Flask(__name__) ap1_v1 = ArrestedAPI() ...
python
def init_app(self, app): """Initialise the ArrestedAPI object by storing a pointer to a Flask app object. This method is typically used when initialisation is deferred. :param app: Flask application object Usage:: app = Flask(__name__) ap1_v1 = ArrestedAPI() ...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "self", ".", "app", "=", "app", "if", "self", ".", "deferred", ":", "self", ".", "register_all", "(", "self", ".", "deferred", ")" ]
Initialise the ArrestedAPI object by storing a pointer to a Flask app object. This method is typically used when initialisation is deferred. :param app: Flask application object Usage:: app = Flask(__name__) ap1_v1 = ArrestedAPI() api_v1.init_app(app)
[ "Initialise", "the", "ArrestedAPI", "object", "by", "storing", "a", "pointer", "to", "a", "Flask", "app", "object", ".", "This", "method", "is", "typically", "used", "when", "initialisation", "is", "deferred", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/api.py#L37-L52
mikeywaites/flask-arrested
arrested/api.py
ArrestedAPI.register_resource
def register_resource(self, resource, defer=False): """Register a :class:`.Resource` blueprint object against the Flask app object. :param resource: :class:`.Resource` or :class:`flask.Blueprint` object. :param defer: Optionally specify that registering this resource should be ...
python
def register_resource(self, resource, defer=False): """Register a :class:`.Resource` blueprint object against the Flask app object. :param resource: :class:`.Resource` or :class:`flask.Blueprint` object. :param defer: Optionally specify that registering this resource should be ...
[ "def", "register_resource", "(", "self", ",", "resource", ",", "defer", "=", "False", ")", ":", "if", "defer", ":", "self", ".", "deferred", ".", "append", "(", "resource", ")", "else", ":", "resource", ".", "init_api", "(", "self", ")", "self", ".", ...
Register a :class:`.Resource` blueprint object against the Flask app object. :param resource: :class:`.Resource` or :class:`flask.Blueprint` object. :param defer: Optionally specify that registering this resource should be deferred. This option is useful when users are creating...
[ "Register", "a", ":", "class", ":", ".", "Resource", "blueprint", "object", "against", "the", "Flask", "app", "object", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/api.py#L54-L90
mikeywaites/flask-arrested
arrested/endpoint.py
Endpoint.process_before_request_hooks
def process_before_request_hooks(self): """Process the list of before_{method}_hooks and the before_all_hooks. The hooks will be processed in the following order 1 - any before_all_hooks defined on the :class:`arrested.ArrestedAPI` object 2 - any before_all_hooks defined on the :class:`...
python
def process_before_request_hooks(self): """Process the list of before_{method}_hooks and the before_all_hooks. The hooks will be processed in the following order 1 - any before_all_hooks defined on the :class:`arrested.ArrestedAPI` object 2 - any before_all_hooks defined on the :class:`...
[ "def", "process_before_request_hooks", "(", "self", ")", ":", "hooks", "=", "[", "]", "if", "self", ".", "resource", ":", "hooks", ".", "extend", "(", "self", ".", "resource", ".", "api", ".", "before_all_hooks", ")", "hooks", ".", "extend", "(", "self",...
Process the list of before_{method}_hooks and the before_all_hooks. The hooks will be processed in the following order 1 - any before_all_hooks defined on the :class:`arrested.ArrestedAPI` object 2 - any before_all_hooks defined on the :class:`arrested.Resource` object 3 - any before_al...
[ "Process", "the", "list", "of", "before_", "{", "method", "}", "_hooks", "and", "the", "before_all_hooks", ".", "The", "hooks", "will", "be", "processed", "in", "the", "following", "order" ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/endpoint.py#L69-L95
mikeywaites/flask-arrested
arrested/endpoint.py
Endpoint.process_after_request_hooks
def process_after_request_hooks(self, resp): """Process the list of before_{method}_hooks and the before_all_hooks. The hooks will be processed in the following order 1 - any after_{method}_hooks defined on the :class:`arrested.Endpoint` object 2 - any after_all_hooks defined on the :cl...
python
def process_after_request_hooks(self, resp): """Process the list of before_{method}_hooks and the before_all_hooks. The hooks will be processed in the following order 1 - any after_{method}_hooks defined on the :class:`arrested.Endpoint` object 2 - any after_all_hooks defined on the :cl...
[ "def", "process_after_request_hooks", "(", "self", ",", "resp", ")", ":", "hooks", "=", "[", "]", "meth_hooks", "=", "getattr", "(", "self", ",", "'after_{method}_hooks'", ".", "format", "(", "method", "=", "self", ".", "meth", ")", ",", "[", "]", ")", ...
Process the list of before_{method}_hooks and the before_all_hooks. The hooks will be processed in the following order 1 - any after_{method}_hooks defined on the :class:`arrested.Endpoint` object 2 - any after_all_hooks defined on the :class:`arrested.Endpoint` object 2 - any after_all...
[ "Process", "the", "list", "of", "before_", "{", "method", "}", "_hooks", "and", "the", "before_all_hooks", ".", "The", "hooks", "will", "be", "processed", "in", "the", "following", "order" ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/endpoint.py#L97-L124
mikeywaites/flask-arrested
arrested/endpoint.py
Endpoint.dispatch_request
def dispatch_request(self, *args, **kwargs): """Dispatch the incoming HTTP request to the appropriate handler. """ self.args = args self.kwargs = kwargs self.meth = request.method.lower() self.resource = current_app.blueprints.get(request.blueprint, None) if not ...
python
def dispatch_request(self, *args, **kwargs): """Dispatch the incoming HTTP request to the appropriate handler. """ self.args = args self.kwargs = kwargs self.meth = request.method.lower() self.resource = current_app.blueprints.get(request.blueprint, None) if not ...
[ "def", "dispatch_request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "args", "=", "args", "self", ".", "kwargs", "=", "kwargs", "self", ".", "meth", "=", "request", ".", "method", ".", "lower", "(", ")", "self",...
Dispatch the incoming HTTP request to the appropriate handler.
[ "Dispatch", "the", "incoming", "HTTP", "request", "to", "the", "appropriate", "handler", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/endpoint.py#L126-L144
mikeywaites/flask-arrested
arrested/endpoint.py
Endpoint.make_response
def make_response(self, rv, status=200, headers=None, mime='application/json'): """Create a response object using the :class:`flask.Response` class. :param rv: Response value. If the value is not an instance of :class:`werkzeug.wrappers.Response` it will be converted into a Res...
python
def make_response(self, rv, status=200, headers=None, mime='application/json'): """Create a response object using the :class:`flask.Response` class. :param rv: Response value. If the value is not an instance of :class:`werkzeug.wrappers.Response` it will be converted into a Res...
[ "def", "make_response", "(", "self", ",", "rv", ",", "status", "=", "200", ",", "headers", "=", "None", ",", "mime", "=", "'application/json'", ")", ":", "if", "not", "isinstance", "(", "rv", ",", "Response", ")", ":", "resp", "=", "Response", "(", "...
Create a response object using the :class:`flask.Response` class. :param rv: Response value. If the value is not an instance of :class:`werkzeug.wrappers.Response` it will be converted into a Response object. :param status: specify the HTTP status code for this response. ...
[ "Create", "a", "response", "object", "using", "the", ":", "class", ":", "flask", ".", "Response", "class", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/endpoint.py#L156-L177
mikeywaites/flask-arrested
arrested/endpoint.py
Endpoint.get_response_handler
def get_response_handler(self): """Return the Endpoints defined :attr:`Endpoint.response_handler`. :returns: A instance of the Endpoint specified :class:`ResonseHandler`. :rtype: :class:`ResponseHandler` """ assert self.response_handler is not None, \ 'Please define ...
python
def get_response_handler(self): """Return the Endpoints defined :attr:`Endpoint.response_handler`. :returns: A instance of the Endpoint specified :class:`ResonseHandler`. :rtype: :class:`ResponseHandler` """ assert self.response_handler is not None, \ 'Please define ...
[ "def", "get_response_handler", "(", "self", ")", ":", "assert", "self", ".", "response_handler", "is", "not", "None", ",", "'Please define a response_handler '", "' for Endpoint: %s'", "%", "self", ".", "__class__", ".", "__name__", "return", "self", ".", "response_...
Return the Endpoints defined :attr:`Endpoint.response_handler`. :returns: A instance of the Endpoint specified :class:`ResonseHandler`. :rtype: :class:`ResponseHandler`
[ "Return", "the", "Endpoints", "defined", ":", "attr", ":", "Endpoint", ".", "response_handler", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/endpoint.py#L188-L198
mikeywaites/flask-arrested
arrested/endpoint.py
Endpoint.get_request_handler
def get_request_handler(self): """Return the Endpoints defined :attr:`Endpoint.request_handler`. :returns: A instance of the Endpoint specified :class:`RequestHandler`. :rtype: :class:`RequestHandler` """ assert self.request_handler is not None, \ 'Please define a re...
python
def get_request_handler(self): """Return the Endpoints defined :attr:`Endpoint.request_handler`. :returns: A instance of the Endpoint specified :class:`RequestHandler`. :rtype: :class:`RequestHandler` """ assert self.request_handler is not None, \ 'Please define a re...
[ "def", "get_request_handler", "(", "self", ")", ":", "assert", "self", ".", "request_handler", "is", "not", "None", ",", "'Please define a request_handler '", "' for Endpoint: %s'", "%", "self", ".", "__class__", ".", "__name__", "return", "self", ".", "request_hand...
Return the Endpoints defined :attr:`Endpoint.request_handler`. :returns: A instance of the Endpoint specified :class:`RequestHandler`. :rtype: :class:`RequestHandler`
[ "Return", "the", "Endpoints", "defined", ":", "attr", ":", "Endpoint", ".", "request_handler", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/endpoint.py#L209-L219
mikeywaites/flask-arrested
arrested/endpoint.py
Endpoint.return_error
def return_error(self, status, payload=None): """Error handler called by request handlers when an error occurs and the request should be aborted. Usage:: def handle_post_request(self, *args, **kwargs): self.request_handler = self.get_request_handler() ...
python
def return_error(self, status, payload=None): """Error handler called by request handlers when an error occurs and the request should be aborted. Usage:: def handle_post_request(self, *args, **kwargs): self.request_handler = self.get_request_handler() ...
[ "def", "return_error", "(", "self", ",", "status", ",", "payload", "=", "None", ")", ":", "resp", "=", "None", "if", "payload", "is", "not", "None", ":", "payload", "=", "json", ".", "dumps", "(", "payload", ")", "resp", "=", "self", ".", "make_respo...
Error handler called by request handlers when an error occurs and the request should be aborted. Usage:: def handle_post_request(self, *args, **kwargs): self.request_handler = self.get_request_handler() try: self.request_handler.process(...
[ "Error", "handler", "called", "by", "request", "handlers", "when", "an", "error", "occurs", "and", "the", "request", "should", "be", "aborted", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/endpoint.py#L221-L245
mikeywaites/flask-arrested
arrested/contrib/kim_arrested.py
KimResponseHandler.handle
def handle(self, data, **kwargs): """Run serialization for the specified mapper_class. Supports both .serialize and .many().serialize Kim interfaces. :param data: Objects to be serialized. :returns: Serialized data according to mapper configuration """ if self.many: ...
python
def handle(self, data, **kwargs): """Run serialization for the specified mapper_class. Supports both .serialize and .many().serialize Kim interfaces. :param data: Objects to be serialized. :returns: Serialized data according to mapper configuration """ if self.many: ...
[ "def", "handle", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "many", ":", "return", "self", ".", "mapper", ".", "many", "(", "raw", "=", "self", ".", "raw", ",", "*", "*", "self", ".", "mapper_kwargs", ")", "...
Run serialization for the specified mapper_class. Supports both .serialize and .many().serialize Kim interfaces. :param data: Objects to be serialized. :returns: Serialized data according to mapper configuration
[ "Run", "serialization", "for", "the", "specified", "mapper_class", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/kim_arrested.py#L81-L96
mikeywaites/flask-arrested
arrested/contrib/kim_arrested.py
KimRequestHandler.handle_error
def handle_error(self, exp): """Called if a Mapper returns MappingInvalid. Should handle the error and return it in the appropriate format, can be overridden in order to change the error format. :param exp: MappingInvalid exception raised """ payload = { "mes...
python
def handle_error(self, exp): """Called if a Mapper returns MappingInvalid. Should handle the error and return it in the appropriate format, can be overridden in order to change the error format. :param exp: MappingInvalid exception raised """ payload = { "mes...
[ "def", "handle_error", "(", "self", ",", "exp", ")", ":", "payload", "=", "{", "\"message\"", ":", "\"Invalid or incomplete data provided.\"", ",", "\"errors\"", ":", "exp", ".", "errors", "}", "self", ".", "endpoint", ".", "return_error", "(", "self", ".", ...
Called if a Mapper returns MappingInvalid. Should handle the error and return it in the appropriate format, can be overridden in order to change the error format. :param exp: MappingInvalid exception raised
[ "Called", "if", "a", "Mapper", "returns", "MappingInvalid", ".", "Should", "handle", "the", "error", "and", "return", "it", "in", "the", "appropriate", "format", "can", "be", "overridden", "in", "order", "to", "change", "the", "error", "format", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/kim_arrested.py#L126-L137
mikeywaites/flask-arrested
arrested/contrib/kim_arrested.py
KimRequestHandler.handle
def handle(self, data, **kwargs): """Run marshalling for the specified mapper_class. Supports both .marshal and .many().marshal Kim interfaces. Handles errors raised during marshalling and automatically returns a HTTP error response. :param data: Data to be marshaled. :returns...
python
def handle(self, data, **kwargs): """Run marshalling for the specified mapper_class. Supports both .marshal and .many().marshal Kim interfaces. Handles errors raised during marshalling and automatically returns a HTTP error response. :param data: Data to be marshaled. :returns...
[ "def", "handle", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "try", ":", "if", "self", ".", "many", ":", "return", "self", ".", "mapper", ".", "many", "(", "raw", "=", "self", ".", "raw", ",", "*", "*", "self", ".", "mapper_kwa...
Run marshalling for the specified mapper_class. Supports both .marshal and .many().marshal Kim interfaces. Handles errors raised during marshalling and automatically returns a HTTP error response. :param data: Data to be marshaled. :returns: Marshaled object according to mapper config...
[ "Run", "marshalling", "for", "the", "specified", "mapper_class", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/kim_arrested.py#L139-L162
mikeywaites/flask-arrested
arrested/contrib/kim_arrested.py
KimEndpoint.get_response_handler_params
def get_response_handler_params(self, **params): """Return a config object that will be used to configure the KimResponseHandler :returns: a dictionary of config options :rtype: dict """ params = super(KimEndpoint, self).get_response_handler_params(**params) params['map...
python
def get_response_handler_params(self, **params): """Return a config object that will be used to configure the KimResponseHandler :returns: a dictionary of config options :rtype: dict """ params = super(KimEndpoint, self).get_response_handler_params(**params) params['map...
[ "def", "get_response_handler_params", "(", "self", ",", "*", "*", "params", ")", ":", "params", "=", "super", "(", "KimEndpoint", ",", "self", ")", ".", "get_response_handler_params", "(", "*", "*", "params", ")", "params", "[", "'mapper_class'", "]", "=", ...
Return a config object that will be used to configure the KimResponseHandler :returns: a dictionary of config options :rtype: dict
[ "Return", "a", "config", "object", "that", "will", "be", "used", "to", "configure", "the", "KimResponseHandler" ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/kim_arrested.py#L187-L208
mikeywaites/flask-arrested
arrested/contrib/kim_arrested.py
KimEndpoint.get_request_handler_params
def get_request_handler_params(self, **params): """Return a config object that will be used to configure the KimRequestHandler :returns: a dictionary of config options :rtype: dict """ params = super(KimEndpoint, self).get_request_handler_params(**params) params['mapper...
python
def get_request_handler_params(self, **params): """Return a config object that will be used to configure the KimRequestHandler :returns: a dictionary of config options :rtype: dict """ params = super(KimEndpoint, self).get_request_handler_params(**params) params['mapper...
[ "def", "get_request_handler_params", "(", "self", ",", "*", "*", "params", ")", ":", "params", "=", "super", "(", "KimEndpoint", ",", "self", ")", ".", "get_request_handler_params", "(", "*", "*", "params", ")", "params", "[", "'mapper_class'", "]", "=", "...
Return a config object that will be used to configure the KimRequestHandler :returns: a dictionary of config options :rtype: dict
[ "Return", "a", "config", "object", "that", "will", "be", "used", "to", "configure", "the", "KimRequestHandler" ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/contrib/kim_arrested.py#L210-L226
mikeywaites/flask-arrested
arrested/mixins.py
GetListMixin.list_response
def list_response(self, status=200): """Pull the processed data from the response_handler and return a response. :param status: The HTTP status code returned with the response .. seealso: :meth:`Endpoint.make_response` :meth:`Endpoint.handle_get_request` """ ...
python
def list_response(self, status=200): """Pull the processed data from the response_handler and return a response. :param status: The HTTP status code returned with the response .. seealso: :meth:`Endpoint.make_response` :meth:`Endpoint.handle_get_request` """ ...
[ "def", "list_response", "(", "self", ",", "status", "=", "200", ")", ":", "return", "self", ".", "_response", "(", "self", ".", "response", ".", "get_response_data", "(", ")", ",", "status", "=", "status", ")" ]
Pull the processed data from the response_handler and return a response. :param status: The HTTP status code returned with the response .. seealso: :meth:`Endpoint.make_response` :meth:`Endpoint.handle_get_request`
[ "Pull", "the", "processed", "data", "from", "the", "response_handler", "and", "return", "a", "response", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/mixins.py#L29-L39
mikeywaites/flask-arrested
arrested/mixins.py
GetListMixin.handle_get_request
def handle_get_request(self): """Handle incoming GET request to an Endpoint and return an array of results by calling :meth:`.GetListMixin.get_objects`. .. seealso:: :meth:`GetListMixin.get_objects` :meth:`Endpoint.get` """ self.objects = self.get_objects...
python
def handle_get_request(self): """Handle incoming GET request to an Endpoint and return an array of results by calling :meth:`.GetListMixin.get_objects`. .. seealso:: :meth:`GetListMixin.get_objects` :meth:`Endpoint.get` """ self.objects = self.get_objects...
[ "def", "handle_get_request", "(", "self", ")", ":", "self", ".", "objects", "=", "self", ".", "get_objects", "(", ")", "self", ".", "response", "=", "self", ".", "get_response_handler", "(", ")", "self", ".", "response", ".", "process", "(", "self", ".",...
Handle incoming GET request to an Endpoint and return an array of results by calling :meth:`.GetListMixin.get_objects`. .. seealso:: :meth:`GetListMixin.get_objects` :meth:`Endpoint.get`
[ "Handle", "incoming", "GET", "request", "to", "an", "Endpoint", "and", "return", "an", "array", "of", "results", "by", "calling", ":", "meth", ":", ".", "GetListMixin", ".", "get_objects", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/mixins.py#L41-L54
mikeywaites/flask-arrested
arrested/mixins.py
CreateMixin.create_response
def create_response(self, status=201): """Generate a Response object for a POST request. By default, the newly created object will be passed to the specified ResponseHandler and will be serialized as the response body. """ self.response = self.get_response_handler() self...
python
def create_response(self, status=201): """Generate a Response object for a POST request. By default, the newly created object will be passed to the specified ResponseHandler and will be serialized as the response body. """ self.response = self.get_response_handler() self...
[ "def", "create_response", "(", "self", ",", "status", "=", "201", ")", ":", "self", ".", "response", "=", "self", ".", "get_response_handler", "(", ")", "self", ".", "response", ".", "process", "(", "self", ".", "obj", ")", "return", "self", ".", "_res...
Generate a Response object for a POST request. By default, the newly created object will be passed to the specified ResponseHandler and will be serialized as the response body.
[ "Generate", "a", "Response", "object", "for", "a", "POST", "request", ".", "By", "default", "the", "newly", "created", "object", "will", "be", "passed", "to", "the", "specified", "ResponseHandler", "and", "will", "be", "serialized", "as", "the", "response", ...
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/mixins.py#L69-L77
mikeywaites/flask-arrested
arrested/mixins.py
CreateMixin.handle_post_request
def handle_post_request(self): """Handle incoming POST request to an Endpoint and marshal the request data via the specified RequestHandler. :meth:`.CreateMixin.save_object`. is then called and must be implemented by mixins implementing this interfce. .. seealso:: :meth:`Cr...
python
def handle_post_request(self): """Handle incoming POST request to an Endpoint and marshal the request data via the specified RequestHandler. :meth:`.CreateMixin.save_object`. is then called and must be implemented by mixins implementing this interfce. .. seealso:: :meth:`Cr...
[ "def", "handle_post_request", "(", "self", ")", ":", "self", ".", "request", "=", "self", ".", "get_request_handler", "(", ")", "self", ".", "obj", "=", "self", ".", "request", ".", "process", "(", ")", ".", "data", "self", ".", "save_object", "(", "se...
Handle incoming POST request to an Endpoint and marshal the request data via the specified RequestHandler. :meth:`.CreateMixin.save_object`. is then called and must be implemented by mixins implementing this interfce. .. seealso:: :meth:`CreateMixin.save_object` :meth:`...
[ "Handle", "incoming", "POST", "request", "to", "an", "Endpoint", "and", "marshal", "the", "request", "data", "via", "the", "specified", "RequestHandler", ".", ":", "meth", ":", ".", "CreateMixin", ".", "save_object", ".", "is", "then", "called", "and", "must...
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/mixins.py#L79-L92
mikeywaites/flask-arrested
arrested/mixins.py
ObjectMixin.obj
def obj(self): """Returns the value of :meth:`ObjectMixin.get_object` and sets a private property called _obj. This property ensures the logic around allow_none is enforced across Endpoints using the Object interface. :raises: :class:`werkzeug.exceptions.BadRequest` :returns: T...
python
def obj(self): """Returns the value of :meth:`ObjectMixin.get_object` and sets a private property called _obj. This property ensures the logic around allow_none is enforced across Endpoints using the Object interface. :raises: :class:`werkzeug.exceptions.BadRequest` :returns: T...
[ "def", "obj", "(", "self", ")", ":", "if", "not", "getattr", "(", "self", ",", "'_obj'", ",", "None", ")", ":", "self", ".", "_obj", "=", "self", ".", "get_object", "(", ")", "if", "self", ".", "_obj", "is", "None", "and", "not", "self", ".", "...
Returns the value of :meth:`ObjectMixin.get_object` and sets a private property called _obj. This property ensures the logic around allow_none is enforced across Endpoints using the Object interface. :raises: :class:`werkzeug.exceptions.BadRequest` :returns: The result of :meth:ObjectM...
[ "Returns", "the", "value", "of", ":", "meth", ":", "ObjectMixin", ".", "get_object", "and", "sets", "a", "private", "property", "called", "_obj", ".", "This", "property", "ensures", "the", "logic", "around", "allow_none", "is", "enforced", "across", "Endpoints...
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/mixins.py#L122-L135
qntm/greenery
greenery/fsm.py
null
def null(alphabet): ''' An FSM accepting nothing (not even the empty string). This is demonstrates that this is possible, and is also extremely useful in some situations ''' return fsm( alphabet = alphabet, states = {0}, initial = 0, finals = set(), map = { 0: dict([(symbol, 0) for symbo...
python
def null(alphabet): ''' An FSM accepting nothing (not even the empty string). This is demonstrates that this is possible, and is also extremely useful in some situations ''' return fsm( alphabet = alphabet, states = {0}, initial = 0, finals = set(), map = { 0: dict([(symbol, 0) for symbo...
[ "def", "null", "(", "alphabet", ")", ":", "return", "fsm", "(", "alphabet", "=", "alphabet", ",", "states", "=", "{", "0", "}", ",", "initial", "=", "0", ",", "finals", "=", "set", "(", ")", ",", "map", "=", "{", "0", ":", "dict", "(", "[", "...
An FSM accepting nothing (not even the empty string). This is demonstrates that this is possible, and is also extremely useful in some situations
[ "An", "FSM", "accepting", "nothing", "(", "not", "even", "the", "empty", "string", ")", ".", "This", "is", "demonstrates", "that", "this", "is", "possible", "and", "is", "also", "extremely", "useful", "in", "some", "situations" ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L686-L700
qntm/greenery
greenery/fsm.py
parallel
def parallel(fsms, test): ''' Crawl several FSMs in parallel, mapping the states of a larger meta-FSM. To determine whether a state in the larger FSM is final, pass all of the finality statuses (e.g. [True, False, False] to `test`. ''' alphabet = set().union(*[fsm.alphabet for fsm in fsms]) initial = dict([(...
python
def parallel(fsms, test): ''' Crawl several FSMs in parallel, mapping the states of a larger meta-FSM. To determine whether a state in the larger FSM is final, pass all of the finality statuses (e.g. [True, False, False] to `test`. ''' alphabet = set().union(*[fsm.alphabet for fsm in fsms]) initial = dict([(...
[ "def", "parallel", "(", "fsms", ",", "test", ")", ":", "alphabet", "=", "set", "(", ")", ".", "union", "(", "*", "[", "fsm", ".", "alphabet", "for", "fsm", "in", "fsms", "]", ")", "initial", "=", "dict", "(", "[", "(", "i", ",", "fsm", ".", "...
Crawl several FSMs in parallel, mapping the states of a larger meta-FSM. To determine whether a state in the larger FSM is final, pass all of the finality statuses (e.g. [True, False, False] to `test`.
[ "Crawl", "several", "FSMs", "in", "parallel", "mapping", "the", "states", "of", "a", "larger", "meta", "-", "FSM", ".", "To", "determine", "whether", "a", "state", "in", "the", "larger", "FSM", "is", "final", "pass", "all", "of", "the", "finality", "stat...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L715-L748
qntm/greenery
greenery/fsm.py
crawl
def crawl(alphabet, initial, final, follow): ''' Given the above conditions and instructions, crawl a new unknown FSM, mapping its states, final states and transitions. Return the new FSM. This is a pretty powerful procedure which could potentially go on forever if you supply an evil version of follow(). ''' ...
python
def crawl(alphabet, initial, final, follow): ''' Given the above conditions and instructions, crawl a new unknown FSM, mapping its states, final states and transitions. Return the new FSM. This is a pretty powerful procedure which could potentially go on forever if you supply an evil version of follow(). ''' ...
[ "def", "crawl", "(", "alphabet", ",", "initial", ",", "final", ",", "follow", ")", ":", "states", "=", "[", "initial", "]", "finals", "=", "set", "(", ")", "map", "=", "{", "}", "# iterate over a growing list", "i", "=", "0", "while", "i", "<", "len"...
Given the above conditions and instructions, crawl a new unknown FSM, mapping its states, final states and transitions. Return the new FSM. This is a pretty powerful procedure which could potentially go on forever if you supply an evil version of follow().
[ "Given", "the", "above", "conditions", "and", "instructions", "crawl", "a", "new", "unknown", "FSM", "mapping", "its", "states", "final", "states", "and", "transitions", ".", "Return", "the", "new", "FSM", ".", "This", "is", "a", "pretty", "powerful", "proce...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L750-L797
qntm/greenery
greenery/fsm.py
fsm.accepts
def accepts(self, input): ''' Test whether the present FSM accepts the supplied string (iterable of symbols). Equivalently, consider `self` as a possibly-infinite set of strings and test whether `string` is a member of it. This is actually mainly used for unit testing purposes. If `fsm.anything_else` i...
python
def accepts(self, input): ''' Test whether the present FSM accepts the supplied string (iterable of symbols). Equivalently, consider `self` as a possibly-infinite set of strings and test whether `string` is a member of it. This is actually mainly used for unit testing purposes. If `fsm.anything_else` i...
[ "def", "accepts", "(", "self", ",", "input", ")", ":", "state", "=", "self", ".", "initial", "for", "symbol", "in", "input", ":", "if", "anything_else", "in", "self", ".", "alphabet", "and", "not", "symbol", "in", "self", ".", "alphabet", ":", "symbol"...
Test whether the present FSM accepts the supplied string (iterable of symbols). Equivalently, consider `self` as a possibly-infinite set of strings and test whether `string` is a member of it. This is actually mainly used for unit testing purposes. If `fsm.anything_else` is in your alphabet, then any symbol...
[ "Test", "whether", "the", "present", "FSM", "accepts", "the", "supplied", "string", "(", "iterable", "of", "symbols", ")", ".", "Equivalently", "consider", "self", "as", "a", "possibly", "-", "infinite", "set", "of", "strings", "and", "test", "whether", "str...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L82-L101
qntm/greenery
greenery/fsm.py
fsm.concatenate
def concatenate(*fsms): ''' Concatenate arbitrarily many finite state machines together. ''' alphabet = set().union(*[fsm.alphabet for fsm in fsms]) def connect_all(i, substate): ''' Take a state in the numbered FSM and return a set containing it, plus (if it's final) the first state from the nex...
python
def concatenate(*fsms): ''' Concatenate arbitrarily many finite state machines together. ''' alphabet = set().union(*[fsm.alphabet for fsm in fsms]) def connect_all(i, substate): ''' Take a state in the numbered FSM and return a set containing it, plus (if it's final) the first state from the nex...
[ "def", "concatenate", "(", "*", "fsms", ")", ":", "alphabet", "=", "set", "(", ")", ".", "union", "(", "*", "[", "fsm", ".", "alphabet", "for", "fsm", "in", "fsms", "]", ")", "def", "connect_all", "(", "i", ",", "substate", ")", ":", "'''\n\t\t\t\t...
Concatenate arbitrarily many finite state machines together.
[ "Concatenate", "arbitrarily", "many", "finite", "state", "machines", "together", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L170-L219
qntm/greenery
greenery/fsm.py
fsm.star
def star(self): ''' If the present FSM accepts X, returns an FSM accepting X* (i.e. 0 or more Xes). This is NOT as simple as naively connecting the final states back to the initial state: see (b*ab)* for example. ''' alphabet = self.alphabet initial = {self.initial} def follow(state, symbol): ne...
python
def star(self): ''' If the present FSM accepts X, returns an FSM accepting X* (i.e. 0 or more Xes). This is NOT as simple as naively connecting the final states back to the initial state: see (b*ab)* for example. ''' alphabet = self.alphabet initial = {self.initial} def follow(state, symbol): ne...
[ "def", "star", "(", "self", ")", ":", "alphabet", "=", "self", ".", "alphabet", "initial", "=", "{", "self", ".", "initial", "}", "def", "follow", "(", "state", ",", "symbol", ")", ":", "next", "=", "set", "(", ")", "for", "substate", "in", "state"...
If the present FSM accepts X, returns an FSM accepting X* (i.e. 0 or more Xes). This is NOT as simple as naively connecting the final states back to the initial state: see (b*ab)* for example.
[ "If", "the", "present", "FSM", "accepts", "X", "returns", "an", "FSM", "accepting", "X", "*", "(", "i", ".", "e", ".", "0", "or", "more", "Xes", ")", ".", "This", "is", "NOT", "as", "simple", "as", "naively", "connecting", "the", "final", "states", ...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L231-L262
qntm/greenery
greenery/fsm.py
fsm.times
def times(self, multiplier): ''' Given an FSM and a multiplier, return the multiplied FSM. ''' if multiplier < 0: raise Exception("Can't multiply an FSM by " + repr(multiplier)) alphabet = self.alphabet # metastate is a set of iterations+states initial = {(self.initial, 0)} def final(state): '...
python
def times(self, multiplier): ''' Given an FSM and a multiplier, return the multiplied FSM. ''' if multiplier < 0: raise Exception("Can't multiply an FSM by " + repr(multiplier)) alphabet = self.alphabet # metastate is a set of iterations+states initial = {(self.initial, 0)} def final(state): '...
[ "def", "times", "(", "self", ",", "multiplier", ")", ":", "if", "multiplier", "<", "0", ":", "raise", "Exception", "(", "\"Can't multiply an FSM by \"", "+", "repr", "(", "multiplier", ")", ")", "alphabet", "=", "self", ".", "alphabet", "# metastate is a set o...
Given an FSM and a multiplier, return the multiplied FSM.
[ "Given", "an", "FSM", "and", "a", "multiplier", "return", "the", "multiplied", "FSM", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L264-L298
qntm/greenery
greenery/fsm.py
fsm.everythingbut
def everythingbut(self): ''' Return a finite state machine which will accept any string NOT accepted by self, and will not accept any string accepted by self. This is more complicated if there are missing transitions, because the missing "dead" state must now be reified. ''' alphabet = self.alphabet ...
python
def everythingbut(self): ''' Return a finite state machine which will accept any string NOT accepted by self, and will not accept any string accepted by self. This is more complicated if there are missing transitions, because the missing "dead" state must now be reified. ''' alphabet = self.alphabet ...
[ "def", "everythingbut", "(", "self", ")", ":", "alphabet", "=", "self", ".", "alphabet", "initial", "=", "{", "0", ":", "self", ".", "initial", "}", "def", "follow", "(", "current", ",", "symbol", ")", ":", "next", "=", "{", "}", "if", "0", "in", ...
Return a finite state machine which will accept any string NOT accepted by self, and will not accept any string accepted by self. This is more complicated if there are missing transitions, because the missing "dead" state must now be reified.
[ "Return", "a", "finite", "state", "machine", "which", "will", "accept", "any", "string", "NOT", "accepted", "by", "self", "and", "will", "not", "accept", "any", "string", "accepted", "by", "self", ".", "This", "is", "more", "complicated", "if", "there", "a...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L358-L379
qntm/greenery
greenery/fsm.py
fsm.reversed
def reversed(self): ''' Return a new FSM such that for every string that self accepts (e.g. "beer", the new FSM accepts the reversed string ("reeb"). ''' alphabet = self.alphabet # Start from a composite "state-set" consisting of all final states. # If there are no final states, this set is empty and w...
python
def reversed(self): ''' Return a new FSM such that for every string that self accepts (e.g. "beer", the new FSM accepts the reversed string ("reeb"). ''' alphabet = self.alphabet # Start from a composite "state-set" consisting of all final states. # If there are no final states, this set is empty and w...
[ "def", "reversed", "(", "self", ")", ":", "alphabet", "=", "self", ".", "alphabet", "# Start from a composite \"state-set\" consisting of all final states.", "# If there are no final states, this set is empty and we'll find that", "# no other states get generated.", "initial", "=", "...
Return a new FSM such that for every string that self accepts (e.g. "beer", the new FSM accepts the reversed string ("reeb").
[ "Return", "a", "new", "FSM", "such", "that", "for", "every", "string", "that", "self", "accepts", "(", "e", ".", "g", ".", "beer", "the", "new", "FSM", "accepts", "the", "reversed", "string", "(", "reeb", ")", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L381-L411
qntm/greenery
greenery/fsm.py
fsm.islive
def islive(self, state): '''A state is "live" if a final state can be reached from it.''' reachable = [state] i = 0 while i < len(reachable): current = reachable[i] if current in self.finals: return True if current in self.map: for symbol in self.map[current]: next = self.map[current][symb...
python
def islive(self, state): '''A state is "live" if a final state can be reached from it.''' reachable = [state] i = 0 while i < len(reachable): current = reachable[i] if current in self.finals: return True if current in self.map: for symbol in self.map[current]: next = self.map[current][symb...
[ "def", "islive", "(", "self", ",", "state", ")", ":", "reachable", "=", "[", "state", "]", "i", "=", "0", "while", "i", "<", "len", "(", "reachable", ")", ":", "current", "=", "reachable", "[", "i", "]", "if", "current", "in", "self", ".", "final...
A state is "live" if a final state can be reached from it.
[ "A", "state", "is", "live", "if", "a", "final", "state", "can", "be", "reached", "from", "it", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L421-L435
qntm/greenery
greenery/fsm.py
fsm.strings
def strings(self): ''' Generate strings (lists of symbols) that this FSM accepts. Since there may be infinitely many of these we use a generator instead of constructing a static list. Strings will be sorted in order of length and then lexically. This procedure uses arbitrary amounts of memory but is very ...
python
def strings(self): ''' Generate strings (lists of symbols) that this FSM accepts. Since there may be infinitely many of these we use a generator instead of constructing a static list. Strings will be sorted in order of length and then lexically. This procedure uses arbitrary amounts of memory but is very ...
[ "def", "strings", "(", "self", ")", ":", "# Many FSMs have \"dead states\". Once you reach a dead state, you can no", "# longer reach a final state. Since many strings may end up here, it's", "# advantageous to constrain our search to live states only.", "livestates", "=", "set", "(", "sta...
Generate strings (lists of symbols) that this FSM accepts. Since there may be infinitely many of these we use a generator instead of constructing a static list. Strings will be sorted in order of length and then lexically. This procedure uses arbitrary amounts of memory but is very fast. There may be more e...
[ "Generate", "strings", "(", "lists", "of", "symbols", ")", "that", "this", "FSM", "accepts", ".", "Since", "there", "may", "be", "infinitely", "many", "of", "these", "we", "use", "a", "generator", "instead", "of", "constructing", "a", "static", "list", "."...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L447-L488
qntm/greenery
greenery/fsm.py
fsm.cardinality
def cardinality(self): ''' Consider the FSM as a set of strings and return the cardinality of that set, or raise an OverflowError if there are infinitely many ''' num_strings = {} def get_num_strings(state): # Many FSMs have at least one oblivion state if self.islive(state): if state in num_stri...
python
def cardinality(self): ''' Consider the FSM as a set of strings and return the cardinality of that set, or raise an OverflowError if there are infinitely many ''' num_strings = {} def get_num_strings(state): # Many FSMs have at least one oblivion state if self.islive(state): if state in num_stri...
[ "def", "cardinality", "(", "self", ")", ":", "num_strings", "=", "{", "}", "def", "get_num_strings", "(", "state", ")", ":", "# Many FSMs have at least one oblivion state", "if", "self", ".", "islive", "(", "state", ")", ":", "if", "state", "in", "num_strings"...
Consider the FSM as a set of strings and return the cardinality of that set, or raise an OverflowError if there are infinitely many
[ "Consider", "the", "FSM", "as", "a", "set", "of", "strings", "and", "return", "the", "cardinality", "of", "that", "set", "or", "raise", "an", "OverflowError", "if", "there", "are", "infinitely", "many" ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L535-L565
qntm/greenery
greenery/fsm.py
fsm.copy
def copy(self): ''' For completeness only, since `set.copy()` also exists. FSM objects are immutable, so I can see only very odd reasons to need this. ''' return fsm( alphabet = self.alphabet, states = self.states, initial = self.initial, finals = self.finals, map = self.map, )
python
def copy(self): ''' For completeness only, since `set.copy()` also exists. FSM objects are immutable, so I can see only very odd reasons to need this. ''' return fsm( alphabet = self.alphabet, states = self.states, initial = self.initial, finals = self.finals, map = self.map, )
[ "def", "copy", "(", "self", ")", ":", "return", "fsm", "(", "alphabet", "=", "self", ".", "alphabet", ",", "states", "=", "self", ".", "states", ",", "initial", "=", "self", ".", "initial", ",", "finals", "=", "self", ".", "finals", ",", "map", "="...
For completeness only, since `set.copy()` also exists. FSM objects are immutable, so I can see only very odd reasons to need this.
[ "For", "completeness", "only", "since", "set", ".", "copy", "()", "also", "exists", ".", "FSM", "objects", "are", "immutable", "so", "I", "can", "see", "only", "very", "odd", "reasons", "to", "need", "this", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L636-L647
qntm/greenery
greenery/fsm.py
fsm.derive
def derive(self, input): ''' Compute the Brzozowski derivative of this FSM with respect to the input string of symbols. <https://en.wikipedia.org/wiki/Brzozowski_derivative> If any of the symbols are not members of the alphabet, that's a KeyError. If you fall into oblivion, then the derivative is an FSM a...
python
def derive(self, input): ''' Compute the Brzozowski derivative of this FSM with respect to the input string of symbols. <https://en.wikipedia.org/wiki/Brzozowski_derivative> If any of the symbols are not members of the alphabet, that's a KeyError. If you fall into oblivion, then the derivative is an FSM a...
[ "def", "derive", "(", "self", ",", "input", ")", ":", "try", ":", "# Consume the input string.", "state", "=", "self", ".", "initial", "for", "symbol", "in", "input", ":", "if", "not", "symbol", "in", "self", ".", "alphabet", ":", "if", "not", "anything_...
Compute the Brzozowski derivative of this FSM with respect to the input string of symbols. <https://en.wikipedia.org/wiki/Brzozowski_derivative> If any of the symbols are not members of the alphabet, that's a KeyError. If you fall into oblivion, then the derivative is an FSM accepting no strings.
[ "Compute", "the", "Brzozowski", "derivative", "of", "this", "FSM", "with", "respect", "to", "the", "input", "string", "of", "symbols", ".", "<https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Brzozowski_derivative", ">", "If", "any"...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/fsm.py#L649-L684
mikeywaites/flask-arrested
arrested/resource.py
Resource.add_endpoint
def add_endpoint(self, endpoint): """Register an :class:`.Endpoint` aginst this resource. :param endpoint: :class:`.Endpoint` API Endpoint class Usage:: foo_resource = Resource('example', __name__) class MyEndpoint(Endpoint): url = '/example' ...
python
def add_endpoint(self, endpoint): """Register an :class:`.Endpoint` aginst this resource. :param endpoint: :class:`.Endpoint` API Endpoint class Usage:: foo_resource = Resource('example', __name__) class MyEndpoint(Endpoint): url = '/example' ...
[ "def", "add_endpoint", "(", "self", ",", "endpoint", ")", ":", "if", "self", ".", "url_prefix", ":", "url", "=", "'{prefix}{url}'", ".", "format", "(", "prefix", "=", "self", ".", "url_prefix", ",", "url", "=", "endpoint", ".", "url", ")", "else", ":",...
Register an :class:`.Endpoint` aginst this resource. :param endpoint: :class:`.Endpoint` API Endpoint class Usage:: foo_resource = Resource('example', __name__) class MyEndpoint(Endpoint): url = '/example' name = 'myendpoint' foo_r...
[ "Register", "an", ":", "class", ":", ".", "Endpoint", "aginst", "this", "resource", "." ]
train
https://github.com/mikeywaites/flask-arrested/blob/6b97ce2ad2765f9acab10f4726e310258aa51de0/arrested/resource.py#L80-L104
qntm/greenery
greenery/lego.py
reduce_after
def reduce_after(method): '''reduce() the result of this method call (unless you already reduced it).''' def new_method(self, *args, **kwargs): result = method(self, *args, **kwargs) if result == self: return result return result.reduce() return new_method
python
def reduce_after(method): '''reduce() the result of this method call (unless you already reduced it).''' def new_method(self, *args, **kwargs): result = method(self, *args, **kwargs) if result == self: return result return result.reduce() return new_method
[ "def", "reduce_after", "(", "method", ")", ":", "def", "new_method", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "method", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "if", "result", "==", "se...
reduce() the result of this method call (unless you already reduced it).
[ "reduce", "()", "the", "result", "of", "this", "method", "call", "(", "unless", "you", "already", "reduced", "it", ")", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L41-L48
qntm/greenery
greenery/lego.py
call_fsm
def call_fsm(method): ''' Take a method which acts on 0 or more regular expression objects... return a new method which simply converts them all to FSMs, calls the FSM method on them instead, then converts the result back to a regular expression. We do this for several of the more annoying operations. ''' fs...
python
def call_fsm(method): ''' Take a method which acts on 0 or more regular expression objects... return a new method which simply converts them all to FSMs, calls the FSM method on them instead, then converts the result back to a regular expression. We do this for several of the more annoying operations. ''' fs...
[ "def", "call_fsm", "(", "method", ")", ":", "fsm_method", "=", "getattr", "(", "fsm", ".", "fsm", ",", "method", ".", "__name__", ")", "def", "new_method", "(", "*", "legos", ")", ":", "alphabet", "=", "set", "(", ")", ".", "union", "(", "*", "[", ...
Take a method which acts on 0 or more regular expression objects... return a new method which simply converts them all to FSMs, calls the FSM method on them instead, then converts the result back to a regular expression. We do this for several of the more annoying operations.
[ "Take", "a", "method", "which", "acts", "on", "0", "or", "more", "regular", "expression", "objects", "...", "return", "a", "new", "method", "which", "simply", "converts", "them", "all", "to", "FSMs", "calls", "the", "FSM", "method", "on", "them", "instead"...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L50-L61
qntm/greenery
greenery/lego.py
from_fsm
def from_fsm(f): ''' Turn the supplied finite state machine into a `lego` object. This is accomplished using the Brzozowski algebraic method. ''' # Make sure the supplied alphabet is kosher. It must contain only single- # character strings or `fsm.anything_else`. for symbol in f.alphabet: if symbol == fsm.an...
python
def from_fsm(f): ''' Turn the supplied finite state machine into a `lego` object. This is accomplished using the Brzozowski algebraic method. ''' # Make sure the supplied alphabet is kosher. It must contain only single- # character strings or `fsm.anything_else`. for symbol in f.alphabet: if symbol == fsm.an...
[ "def", "from_fsm", "(", "f", ")", ":", "# Make sure the supplied alphabet is kosher. It must contain only single-", "# character strings or `fsm.anything_else`.", "for", "symbol", "in", "f", ".", "alphabet", ":", "if", "symbol", "==", "fsm", ".", "anything_else", ":", "co...
Turn the supplied finite state machine into a `lego` object. This is accomplished using the Brzozowski algebraic method.
[ "Turn", "the", "supplied", "finite", "state", "machine", "into", "a", "lego", "object", ".", "This", "is", "accomplished", "using", "the", "Brzozowski", "algebraic", "method", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L70-L159
qntm/greenery
greenery/lego.py
lego.parse
def parse(cls, string): ''' Parse the entire supplied string as an instance of the present class. Mainly for internal use in unit tests because it drops through to match() in a convenient way. ''' obj, i = cls.match(string, 0) if i != len(string): raise Exception("Could not parse '" + string + "' be...
python
def parse(cls, string): ''' Parse the entire supplied string as an instance of the present class. Mainly for internal use in unit tests because it drops through to match() in a convenient way. ''' obj, i = cls.match(string, 0) if i != len(string): raise Exception("Could not parse '" + string + "' be...
[ "def", "parse", "(", "cls", ",", "string", ")", ":", "obj", ",", "i", "=", "cls", ".", "match", "(", "string", ",", "0", ")", "if", "i", "!=", "len", "(", "string", ")", ":", "raise", "Exception", "(", "\"Could not parse '\"", "+", "string", "+", ...
Parse the entire supplied string as an instance of the present class. Mainly for internal use in unit tests because it drops through to match() in a convenient way.
[ "Parse", "the", "entire", "supplied", "string", "as", "an", "instance", "of", "the", "present", "class", ".", "Mainly", "for", "internal", "use", "in", "unit", "tests", "because", "it", "drops", "through", "to", "match", "()", "in", "a", "convenient", "way...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L236-L245
qntm/greenery
greenery/lego.py
lego.strings
def strings(self, otherchar=None): ''' Each time next() is called on this iterator, a new string is returned which will the present lego piece can match. StopIteration is raised once all such strings have been returned, although a regex with a * in may match infinitely many strings. ''' # In the case...
python
def strings(self, otherchar=None): ''' Each time next() is called on this iterator, a new string is returned which will the present lego piece can match. StopIteration is raised once all such strings have been returned, although a regex with a * in may match infinitely many strings. ''' # In the case...
[ "def", "strings", "(", "self", ",", "otherchar", "=", "None", ")", ":", "# In the case of a regex like \"[^abc]\", there are infinitely many (well, a", "# very large finite number of) single characters which will match. It's not", "# productive to iterate over all of these giving every singl...
Each time next() is called on this iterator, a new string is returned which will the present lego piece can match. StopIteration is raised once all such strings have been returned, although a regex with a * in may match infinitely many strings.
[ "Each", "time", "next", "()", "is", "called", "on", "this", "iterator", "a", "new", "string", "is", "returned", "which", "will", "the", "present", "lego", "piece", "can", "match", ".", "StopIteration", "is", "raised", "once", "all", "such", "strings", "hav...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L395-L419
qntm/greenery
greenery/lego.py
multiplier.canmultiplyby
def canmultiplyby(self, other): ''' Multiplication is not well-defined for all pairs of multipliers because the resulting possibilities do not necessarily form a continuous range. For example: {0,x} * {0,y} = {0,x*y} {2} * {3} = {6} {2} * {1,2} = ERROR The proof isn't simple but suffice it to...
python
def canmultiplyby(self, other): ''' Multiplication is not well-defined for all pairs of multipliers because the resulting possibilities do not necessarily form a continuous range. For example: {0,x} * {0,y} = {0,x*y} {2} * {3} = {6} {2} * {1,2} = ERROR The proof isn't simple but suffice it to...
[ "def", "canmultiplyby", "(", "self", ",", "other", ")", ":", "return", "other", ".", "optional", "==", "bound", "(", "0", ")", "or", "self", ".", "optional", "*", "other", ".", "mandatory", "+", "bound", "(", "1", ")", ">=", "self", ".", "mandatory" ...
Multiplication is not well-defined for all pairs of multipliers because the resulting possibilities do not necessarily form a continuous range. For example: {0,x} * {0,y} = {0,x*y} {2} * {3} = {6} {2} * {1,2} = ERROR The proof isn't simple but suffice it to say that {p,p+q} * {r,r+s} is equal t...
[ "Multiplication", "is", "not", "well", "-", "defined", "for", "all", "pairs", "of", "multipliers", "because", "the", "resulting", "possibilities", "do", "not", "necessarily", "form", "a", "continuous", "range", ".", "For", "example", ":", "{", "0", "x", "}",...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1057-L1071
qntm/greenery
greenery/lego.py
multiplier.canintersect
def canintersect(self, other): ''' Intersection is not well-defined for all pairs of multipliers. For example: {2,3} & {3,4} = {3} {2,} & {1,7} = {2,7} {2} & {5} = ERROR ''' return not (self.max < other.min or other.max < self.min)
python
def canintersect(self, other): ''' Intersection is not well-defined for all pairs of multipliers. For example: {2,3} & {3,4} = {3} {2,} & {1,7} = {2,7} {2} & {5} = ERROR ''' return not (self.max < other.min or other.max < self.min)
[ "def", "canintersect", "(", "self", ",", "other", ")", ":", "return", "not", "(", "self", ".", "max", "<", "other", ".", "min", "or", "other", ".", "max", "<", "self", ".", "min", ")" ]
Intersection is not well-defined for all pairs of multipliers. For example: {2,3} & {3,4} = {3} {2,} & {1,7} = {2,7} {2} & {5} = ERROR
[ "Intersection", "is", "not", "well", "-", "defined", "for", "all", "pairs", "of", "multipliers", ".", "For", "example", ":", "{", "2", "3", "}", "&", "{", "3", "4", "}", "=", "{", "3", "}", "{", "2", "}", "&", "{", "1", "7", "}", "=", "{", ...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1093-L1101
qntm/greenery
greenery/lego.py
multiplier.canunion
def canunion(self, other): '''Union is not defined for all pairs of multipliers. e.g. {0,1} | {3,4}''' return not (self.max + bound(1) < other.min or other.max + bound(1) < self.min)
python
def canunion(self, other): '''Union is not defined for all pairs of multipliers. e.g. {0,1} | {3,4}''' return not (self.max + bound(1) < other.min or other.max + bound(1) < self.min)
[ "def", "canunion", "(", "self", ",", "other", ")", ":", "return", "not", "(", "self", ".", "max", "+", "bound", "(", "1", ")", "<", "other", ".", "min", "or", "other", ".", "max", "+", "bound", "(", "1", ")", "<", "self", ".", "min", ")" ]
Union is not defined for all pairs of multipliers. e.g. {0,1} | {3,4}
[ "Union", "is", "not", "defined", "for", "all", "pairs", "of", "multipliers", ".", "e", ".", "g", ".", "{", "0", "1", "}", "|", "{", "3", "4", "}" ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1115-L1117
qntm/greenery
greenery/lego.py
multiplier.common
def common(self, other): ''' Find the shared part of two multipliers. This is the largest multiplier which can be safely subtracted from both the originals. This may return the "zero" multiplier. ''' mandatory = min(self.mandatory, other.mandatory) optional = min(self.optional, other.optional) return...
python
def common(self, other): ''' Find the shared part of two multipliers. This is the largest multiplier which can be safely subtracted from both the originals. This may return the "zero" multiplier. ''' mandatory = min(self.mandatory, other.mandatory) optional = min(self.optional, other.optional) return...
[ "def", "common", "(", "self", ",", "other", ")", ":", "mandatory", "=", "min", "(", "self", ".", "mandatory", ",", "other", ".", "mandatory", ")", "optional", "=", "min", "(", "self", ".", "optional", ",", "other", ".", "optional", ")", "return", "mu...
Find the shared part of two multipliers. This is the largest multiplier which can be safely subtracted from both the originals. This may return the "zero" multiplier.
[ "Find", "the", "shared", "part", "of", "two", "multipliers", ".", "This", "is", "the", "largest", "multiplier", "which", "can", "be", "safely", "subtracted", "from", "both", "the", "originals", ".", "This", "may", "return", "the", "zero", "multiplier", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1131-L1139
qntm/greenery
greenery/lego.py
mult.dock
def dock(self, other): ''' "Dock" another mult from this one (i.e. remove part of the tail) and return the result. The reverse of concatenation. This is a lot trickier. e.g. a{4,5} - a{3} = a{1,2} ''' if other.multiplicand != self.multiplicand: raise Exception("Can't subtract " + repr(other) + " from ...
python
def dock(self, other): ''' "Dock" another mult from this one (i.e. remove part of the tail) and return the result. The reverse of concatenation. This is a lot trickier. e.g. a{4,5} - a{3} = a{1,2} ''' if other.multiplicand != self.multiplicand: raise Exception("Can't subtract " + repr(other) + " from ...
[ "def", "dock", "(", "self", ",", "other", ")", ":", "if", "other", ".", "multiplicand", "!=", "self", ".", "multiplicand", ":", "raise", "Exception", "(", "\"Can't subtract \"", "+", "repr", "(", "other", ")", "+", "\" from \"", "+", "repr", "(", "self",...
"Dock" another mult from this one (i.e. remove part of the tail) and return the result. The reverse of concatenation. This is a lot trickier. e.g. a{4,5} - a{3} = a{1,2}
[ "Dock", "another", "mult", "from", "this", "one", "(", "i", ".", "e", ".", "remove", "part", "of", "the", "tail", ")", "and", "return", "the", "result", ".", "The", "reverse", "of", "concatenation", ".", "This", "is", "a", "lot", "trickier", ".", "e"...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1189-L1197
qntm/greenery
greenery/lego.py
mult.common
def common(self, other): ''' Return the common part of these two mults. This is the largest mult which can be safely subtracted from both the originals. The multiplier on this mult could be zero: this is the case if, for example, the multiplicands disagree. ''' if self.multiplicand == other.multiplica...
python
def common(self, other): ''' Return the common part of these two mults. This is the largest mult which can be safely subtracted from both the originals. The multiplier on this mult could be zero: this is the case if, for example, the multiplicands disagree. ''' if self.multiplicand == other.multiplica...
[ "def", "common", "(", "self", ",", "other", ")", ":", "if", "self", ".", "multiplicand", "==", "other", ".", "multiplicand", ":", "return", "mult", "(", "self", ".", "multiplicand", ",", "self", ".", "multiplier", ".", "common", "(", "other", ".", "mul...
Return the common part of these two mults. This is the largest mult which can be safely subtracted from both the originals. The multiplier on this mult could be zero: this is the case if, for example, the multiplicands disagree.
[ "Return", "the", "common", "part", "of", "these", "two", "mults", ".", "This", "is", "the", "largest", "mult", "which", "can", "be", "safely", "subtracted", "from", "both", "the", "originals", ".", "The", "multiplier", "on", "this", "mult", "could", "be", ...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1199-L1210
qntm/greenery
greenery/lego.py
conc.common
def common(self, other, suffix=False): ''' Return the common prefix of these two concs; that is, the largest conc which can be safely beheaded() from the front of both. The result could be emptystring. "ZYAA, ZYBB" -> "ZY" "CZ, CZ" -> "CZ" "YC, ZC" -> "" With the "suffix" flag set, works from th...
python
def common(self, other, suffix=False): ''' Return the common prefix of these two concs; that is, the largest conc which can be safely beheaded() from the front of both. The result could be emptystring. "ZYAA, ZYBB" -> "ZY" "CZ, CZ" -> "CZ" "YC, ZC" -> "" With the "suffix" flag set, works from th...
[ "def", "common", "(", "self", ",", "other", ",", "suffix", "=", "False", ")", ":", "mults", "=", "[", "]", "indices", "=", "range", "(", "min", "(", "len", "(", "self", ".", "mults", ")", ",", "len", "(", "other", ".", "mults", ")", ")", ")", ...
Return the common prefix of these two concs; that is, the largest conc which can be safely beheaded() from the front of both. The result could be emptystring. "ZYAA, ZYBB" -> "ZY" "CZ, CZ" -> "CZ" "YC, ZC" -> "" With the "suffix" flag set, works from the end. E.g.: "AAZY, BBZY" -> "ZY" "CZ, CZ"...
[ "Return", "the", "common", "prefix", "of", "these", "two", "concs", ";", "that", "is", "the", "largest", "conc", "which", "can", "be", "safely", "beheaded", "()", "from", "the", "front", "of", "both", ".", "The", "result", "could", "be", "emptystring", "...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1528-L1569
qntm/greenery
greenery/lego.py
conc.dock
def dock(self, other): ''' Subtract another conc from this one. This is the opposite of concatenation. For example, if ABC + DEF = ABCDEF, then logically ABCDEF - DEF = ABC. ''' # e.g. self has mults at indices [0, 1, 2, 3, 4, 5, 6] len=7 # e.g. other has mults at indices [0, 1, 2] len=3 new = list(...
python
def dock(self, other): ''' Subtract another conc from this one. This is the opposite of concatenation. For example, if ABC + DEF = ABCDEF, then logically ABCDEF - DEF = ABC. ''' # e.g. self has mults at indices [0, 1, 2, 3, 4, 5, 6] len=7 # e.g. other has mults at indices [0, 1, 2] len=3 new = list(...
[ "def", "dock", "(", "self", ",", "other", ")", ":", "# e.g. self has mults at indices [0, 1, 2, 3, 4, 5, 6] len=7", "# e.g. other has mults at indices [0, 1, 2] len=3", "new", "=", "list", "(", "self", ".", "mults", ")", "for", "i", "in", "reversed", "(", "range", "("...
Subtract another conc from this one. This is the opposite of concatenation. For example, if ABC + DEF = ABCDEF, then logically ABCDEF - DEF = ABC.
[ "Subtract", "another", "conc", "from", "this", "one", ".", "This", "is", "the", "opposite", "of", "concatenation", ".", "For", "example", "if", "ABC", "+", "DEF", "=", "ABCDEF", "then", "logically", "ABCDEF", "-", "DEF", "=", "ABC", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1571-L1598
qntm/greenery
greenery/lego.py
pattern.dock
def dock(self, other): ''' The opposite of concatenation. Remove a common suffix from the present pattern; that is, from each of its constituent concs. AYZ|BYZ|CYZ - YZ = A|B|C. ''' return pattern(*[c.dock(other) for c in self.concs])
python
def dock(self, other): ''' The opposite of concatenation. Remove a common suffix from the present pattern; that is, from each of its constituent concs. AYZ|BYZ|CYZ - YZ = A|B|C. ''' return pattern(*[c.dock(other) for c in self.concs])
[ "def", "dock", "(", "self", ",", "other", ")", ":", "return", "pattern", "(", "*", "[", "c", ".", "dock", "(", "other", ")", "for", "c", "in", "self", ".", "concs", "]", ")" ]
The opposite of concatenation. Remove a common suffix from the present pattern; that is, from each of its constituent concs. AYZ|BYZ|CYZ - YZ = A|B|C.
[ "The", "opposite", "of", "concatenation", ".", "Remove", "a", "common", "suffix", "from", "the", "present", "pattern", ";", "that", "is", "from", "each", "of", "its", "constituent", "concs", ".", "AYZ|BYZ|CYZ", "-", "YZ", "=", "A|B|C", "." ]
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1831-L1837
qntm/greenery
greenery/lego.py
pattern.behead
def behead(self, other): ''' Like dock() but the other way around. Remove a common prefix from the present pattern; that is, from each of its constituent concs. ZA|ZB|ZC.behead(Z) = A|B|C ''' return pattern(*[c.behead(other) for c in self.concs])
python
def behead(self, other): ''' Like dock() but the other way around. Remove a common prefix from the present pattern; that is, from each of its constituent concs. ZA|ZB|ZC.behead(Z) = A|B|C ''' return pattern(*[c.behead(other) for c in self.concs])
[ "def", "behead", "(", "self", ",", "other", ")", ":", "return", "pattern", "(", "*", "[", "c", ".", "behead", "(", "other", ")", "for", "c", "in", "self", ".", "concs", "]", ")" ]
Like dock() but the other way around. Remove a common prefix from the present pattern; that is, from each of its constituent concs. ZA|ZB|ZC.behead(Z) = A|B|C
[ "Like", "dock", "()", "but", "the", "other", "way", "around", ".", "Remove", "a", "common", "prefix", "from", "the", "present", "pattern", ";", "that", "is", "from", "each", "of", "its", "constituent", "concs", ".", "ZA|ZB|ZC", ".", "behead", "(", "Z", ...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1839-L1845
qntm/greenery
greenery/lego.py
pattern._commonconc
def _commonconc(self, suffix=False): ''' Find the longest conc which acts as prefix to every conc in this pattern. This could be the empty string. Return the common prefix along with all the leftovers after truncating that common prefix from each conc. "ZA|ZB|ZC" -> "Z", "(A|B|C)" "ZA|ZB|ZC|Z" -> "Z", ...
python
def _commonconc(self, suffix=False): ''' Find the longest conc which acts as prefix to every conc in this pattern. This could be the empty string. Return the common prefix along with all the leftovers after truncating that common prefix from each conc. "ZA|ZB|ZC" -> "Z", "(A|B|C)" "ZA|ZB|ZC|Z" -> "Z", ...
[ "def", "_commonconc", "(", "self", ",", "suffix", "=", "False", ")", ":", "if", "len", "(", "self", ".", "concs", ")", "==", "0", ":", "raise", "Exception", "(", "\"Can't call _commonconc on \"", "+", "repr", "(", "self", ")", ")", "from", "functools", ...
Find the longest conc which acts as prefix to every conc in this pattern. This could be the empty string. Return the common prefix along with all the leftovers after truncating that common prefix from each conc. "ZA|ZB|ZC" -> "Z", "(A|B|C)" "ZA|ZB|ZC|Z" -> "Z", "(A|B|C|)" "CZ|CZ" -> "CZ", "()" If "su...
[ "Find", "the", "longest", "conc", "which", "acts", "as", "prefix", "to", "every", "conc", "in", "this", "pattern", ".", "This", "could", "be", "the", "empty", "string", ".", "Return", "the", "common", "prefix", "along", "with", "all", "the", "leftovers", ...
train
https://github.com/qntm/greenery/blob/f4dc7fb483825459d26e8fe9f417764469c56ee8/greenery/lego.py#L1847-L1865
iurisilvio/bottle-sqlalchemy
examples/basic.py
delete_name
def delete_name(name): ''' This function don't use the plugin. ''' session = create_session() try: user = session.query(User).filter_by(name=name).first() session.delete(user) session.commit() except SQLAlchemyError, e: session.rollback() raise bottle.HTTPError(50...
python
def delete_name(name): ''' This function don't use the plugin. ''' session = create_session() try: user = session.query(User).filter_by(name=name).first() session.delete(user) session.commit() except SQLAlchemyError, e: session.rollback() raise bottle.HTTPError(50...
[ "def", "delete_name", "(", "name", ")", ":", "session", "=", "create_session", "(", ")", "try", ":", "user", "=", "session", ".", "query", "(", "User", ")", ".", "filter_by", "(", "name", "=", "name", ")", ".", "first", "(", ")", "session", ".", "d...
This function don't use the plugin.
[ "This", "function", "don", "t", "use", "the", "plugin", "." ]
train
https://github.com/iurisilvio/bottle-sqlalchemy/blob/e14779472028c26ccde5f765fe4942df8e7314bb/examples/basic.py#L45-L56
iurisilvio/bottle-sqlalchemy
bottle_sqlalchemy.py
SQLAlchemyPlugin.setup
def setup(self, app): ''' Make sure that other installed plugins don't affect the same keyword argument and check if metadata is available.''' for other in app.plugins: if not isinstance(other, SQLAlchemyPlugin): continue if other.keyword == self.keywo...
python
def setup(self, app): ''' Make sure that other installed plugins don't affect the same keyword argument and check if metadata is available.''' for other in app.plugins: if not isinstance(other, SQLAlchemyPlugin): continue if other.keyword == self.keywo...
[ "def", "setup", "(", "self", ",", "app", ")", ":", "for", "other", "in", "app", ".", "plugins", ":", "if", "not", "isinstance", "(", "other", ",", "SQLAlchemyPlugin", ")", ":", "continue", "if", "other", ".", "keyword", "==", "self", ".", "keyword", ...
Make sure that other installed plugins don't affect the same keyword argument and check if metadata is available.
[ "Make", "sure", "that", "other", "installed", "plugins", "don", "t", "affect", "the", "same", "keyword", "argument", "and", "check", "if", "metadata", "is", "available", "." ]
train
https://github.com/iurisilvio/bottle-sqlalchemy/blob/e14779472028c26ccde5f765fe4942df8e7314bb/bottle_sqlalchemy.py#L101-L113
tmc/gevent-zeromq
gevent_zeromq/core.py
GreenSocket.send_multipart
def send_multipart(self, *args, **kwargs): """wrap send_multipart to prevent state_changed on each partial send""" self.__in_send_multipart = True try: msg = super(GreenSocket, self).send_multipart(*args, **kwargs) finally: self.__in_send_multipart = False ...
python
def send_multipart(self, *args, **kwargs): """wrap send_multipart to prevent state_changed on each partial send""" self.__in_send_multipart = True try: msg = super(GreenSocket, self).send_multipart(*args, **kwargs) finally: self.__in_send_multipart = False ...
[ "def", "send_multipart", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__in_send_multipart", "=", "True", "try", ":", "msg", "=", "super", "(", "GreenSocket", ",", "self", ")", ".", "send_multipart", "(", "*", "args", ...
wrap send_multipart to prevent state_changed on each partial send
[ "wrap", "send_multipart", "to", "prevent", "state_changed", "on", "each", "partial", "send" ]
train
https://github.com/tmc/gevent-zeromq/blob/b15d50deedda3d2cdb701106d4b315c7a06353e3/gevent_zeromq/core.py#L148-L156
tmc/gevent-zeromq
gevent_zeromq/core.py
GreenSocket.recv_multipart
def recv_multipart(self, *args, **kwargs): """wrap recv_multipart to prevent state_changed on each partial recv""" self.__in_recv_multipart = True try: msg = super(GreenSocket, self).recv_multipart(*args, **kwargs) finally: self.__in_recv_multipart = False ...
python
def recv_multipart(self, *args, **kwargs): """wrap recv_multipart to prevent state_changed on each partial recv""" self.__in_recv_multipart = True try: msg = super(GreenSocket, self).recv_multipart(*args, **kwargs) finally: self.__in_recv_multipart = False ...
[ "def", "recv_multipart", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__in_recv_multipart", "=", "True", "try", ":", "msg", "=", "super", "(", "GreenSocket", ",", "self", ")", ".", "recv_multipart", "(", "*", "args", ...
wrap recv_multipart to prevent state_changed on each partial recv
[ "wrap", "recv_multipart", "to", "prevent", "state_changed", "on", "each", "partial", "recv" ]
train
https://github.com/tmc/gevent-zeromq/blob/b15d50deedda3d2cdb701106d4b315c7a06353e3/gevent_zeromq/core.py#L158-L166
konstantinstadler/pymrio
pymrio/core/fileio.py
load_all
def load_all(path, include_core=True, subfolders=None, path_in_arc=None): """ Loads a full IO system with all extension in path Parameters ---------- path : pathlib.Path or string Path or path with para file name for the data to load. This must either point to the directory containing t...
python
def load_all(path, include_core=True, subfolders=None, path_in_arc=None): """ Loads a full IO system with all extension in path Parameters ---------- path : pathlib.Path or string Path or path with para file name for the data to load. This must either point to the directory containing t...
[ "def", "load_all", "(", "path", ",", "include_core", "=", "True", ",", "subfolders", "=", "None", ",", "path_in_arc", "=", "None", ")", ":", "def", "clean", "(", "varStr", ")", ":", "\"\"\" get valid python name from folder\n \"\"\"", "return", "re", ".",...
Loads a full IO system with all extension in path Parameters ---------- path : pathlib.Path or string Path or path with para file name for the data to load. This must either point to the directory containing the uncompressed data or the location of a compressed zip file with the dat...
[ "Loads", "a", "full", "IO", "system", "with", "all", "extension", "in", "path" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/fileio.py#L34-L181
konstantinstadler/pymrio
pymrio/core/fileio.py
load
def load(path, include_core=True, path_in_arc=''): """ Loads a IOSystem or Extension previously saved with pymrio This function can be used to load a IOSystem or Extension specified in a metadata file (as defined in DEFAULT_FILE_NAMES['filepara']: metadata.json) DataFrames (tables) are loaded from tex...
python
def load(path, include_core=True, path_in_arc=''): """ Loads a IOSystem or Extension previously saved with pymrio This function can be used to load a IOSystem or Extension specified in a metadata file (as defined in DEFAULT_FILE_NAMES['filepara']: metadata.json) DataFrames (tables) are loaded from tex...
[ "def", "load", "(", "path", ",", "include_core", "=", "True", ",", "path_in_arc", "=", "''", ")", ":", "path", "=", "Path", "(", "path", ")", "if", "not", "path", ".", "exists", "(", ")", ":", "raise", "ReadError", "(", "'Given path does not exist'", "...
Loads a IOSystem or Extension previously saved with pymrio This function can be used to load a IOSystem or Extension specified in a metadata file (as defined in DEFAULT_FILE_NAMES['filepara']: metadata.json) DataFrames (tables) are loaded from text or binary pickle files. For the latter, the extension...
[ "Loads", "a", "IOSystem", "or", "Extension", "previously", "saved", "with", "pymrio" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/fileio.py#L184-L289
konstantinstadler/pymrio
pymrio/core/fileio.py
archive
def archive(source, archive, path_in_arc=None, remove_source=False, compression=zipfile.ZIP_DEFLATED, compresslevel=-1): """Archives a MRIO database as zip file This function is a wrapper around zipfile.write, to ease the writing of an archive and removing the source data. Note ---- ...
python
def archive(source, archive, path_in_arc=None, remove_source=False, compression=zipfile.ZIP_DEFLATED, compresslevel=-1): """Archives a MRIO database as zip file This function is a wrapper around zipfile.write, to ease the writing of an archive and removing the source data. Note ---- ...
[ "def", "archive", "(", "source", ",", "archive", ",", "path_in_arc", "=", "None", ",", "remove_source", "=", "False", ",", "compression", "=", "zipfile", ".", "ZIP_DEFLATED", ",", "compresslevel", "=", "-", "1", ")", ":", "archive", "=", "Path", "(", "ar...
Archives a MRIO database as zip file This function is a wrapper around zipfile.write, to ease the writing of an archive and removing the source data. Note ---- In contrast to zipfile.write, this function raises an error if the data (path + filename) are identical in the zip archive. Backgr...
[ "Archives", "a", "MRIO", "database", "as", "zip", "file" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/fileio.py#L292-L408
konstantinstadler/pymrio
pymrio/core/fileio.py
_load_ini_based_io
def _load_ini_based_io(path, recursive=False, ini=None, subini={}, include_core=True, only_coefficients=False): """ DEPRECATED: For convert a previous version to the new json format Loads a IOSystem or Extension from a ini files This function can be used to lo...
python
def _load_ini_based_io(path, recursive=False, ini=None, subini={}, include_core=True, only_coefficients=False): """ DEPRECATED: For convert a previous version to the new json format Loads a IOSystem or Extension from a ini files This function can be used to lo...
[ "def", "_load_ini_based_io", "(", "path", ",", "recursive", "=", "False", ",", "ini", "=", "None", ",", "subini", "=", "{", "}", ",", "include_core", "=", "True", ",", "only_coefficients", "=", "False", ")", ":", "# check path and given parameter", "ini_file_n...
DEPRECATED: For convert a previous version to the new json format Loads a IOSystem or Extension from a ini files This function can be used to load a IOSystem or Extension specified in a ini file. DataFrames (tables) are loaded from text or binary pickle files. For the latter, the extension .pkl or .pi...
[ "DEPRECATED", ":", "For", "convert", "a", "previous", "version", "to", "the", "new", "json", "format" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/fileio.py#L434-L676
konstantinstadler/pymrio
pymrio/tools/ioparser.py
parse_exio12_ext
def parse_exio12_ext(ext_file, index_col, name, drop_compartment=True, version=None, year=None, iosystem=None, sep=','): """ Parse an EXIOBASE version 1 or 2 like extension file into pymrio.Extension EXIOBASE like extensions files are assumed to have two rows which are used as columns ...
python
def parse_exio12_ext(ext_file, index_col, name, drop_compartment=True, version=None, year=None, iosystem=None, sep=','): """ Parse an EXIOBASE version 1 or 2 like extension file into pymrio.Extension EXIOBASE like extensions files are assumed to have two rows which are used as columns ...
[ "def", "parse_exio12_ext", "(", "ext_file", ",", "index_col", ",", "name", ",", "drop_compartment", "=", "True", ",", "version", "=", "None", ",", "year", "=", "None", ",", "iosystem", "=", "None", ",", "sep", "=", "','", ")", ":", "ext_file", "=", "os...
Parse an EXIOBASE version 1 or 2 like extension file into pymrio.Extension EXIOBASE like extensions files are assumed to have two rows which are used as columns multiindex (region and sector) and up to three columns for the row index (see Parameters). For EXIOBASE 3 - extension can be loaded directly ...
[ "Parse", "an", "EXIOBASE", "version", "1", "or", "2", "like", "extension", "file", "into", "pymrio", ".", "Extension" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L66-L163
konstantinstadler/pymrio
pymrio/tools/ioparser.py
get_exiobase12_version
def get_exiobase12_version(filename): """ Returns the EXIOBASE version for the given filename, None if not found """ try: ver_match = re.search(r'(\d+\w*(\.|\-|\_))*\d+\w*', filename) version = ver_match.string[ver_match.start():ver_match.end()] if re.search('\_\d\d\d\d', ver...
python
def get_exiobase12_version(filename): """ Returns the EXIOBASE version for the given filename, None if not found """ try: ver_match = re.search(r'(\d+\w*(\.|\-|\_))*\d+\w*', filename) version = ver_match.string[ver_match.start():ver_match.end()] if re.search('\_\d\d\d\d', ver...
[ "def", "get_exiobase12_version", "(", "filename", ")", ":", "try", ":", "ver_match", "=", "re", ".", "search", "(", "r'(\\d+\\w*(\\.|\\-|\\_))*\\d+\\w*'", ",", "filename", ")", "version", "=", "ver_match", ".", "string", "[", "ver_match", ".", "start", "(", ")...
Returns the EXIOBASE version for the given filename, None if not found
[ "Returns", "the", "EXIOBASE", "version", "for", "the", "given", "filename", "None", "if", "not", "found" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L166-L178
konstantinstadler/pymrio
pymrio/tools/ioparser.py
get_exiobase_files
def get_exiobase_files(path, coefficients=True): """ Gets the EXIOBASE files in path (which can be a zip file) Parameters ---------- path: str or pathlib.Path Path to exiobase files or zip file coefficients: boolean, optional If True (default), considers the mrIot file as A matrix, ...
python
def get_exiobase_files(path, coefficients=True): """ Gets the EXIOBASE files in path (which can be a zip file) Parameters ---------- path: str or pathlib.Path Path to exiobase files or zip file coefficients: boolean, optional If True (default), considers the mrIot file as A matrix, ...
[ "def", "get_exiobase_files", "(", "path", ",", "coefficients", "=", "True", ")", ":", "path", "=", "os", ".", "path", ".", "normpath", "(", "str", "(", "path", ")", ")", "if", "coefficients", ":", "exio_core_regex", "=", "dict", "(", "# don’t match file if...
Gets the EXIOBASE files in path (which can be a zip file) Parameters ---------- path: str or pathlib.Path Path to exiobase files or zip file coefficients: boolean, optional If True (default), considers the mrIot file as A matrix, and the extensions as S matrices. Otherwise as Z ...
[ "Gets", "the", "EXIOBASE", "files", "in", "path", "(", "which", "can", "be", "a", "zip", "file", ")" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L181-L253
konstantinstadler/pymrio
pymrio/tools/ioparser.py
generic_exiobase12_parser
def generic_exiobase12_parser(exio_files, system=None): """ Generic EXIOBASE version 1 and 2 parser This is used internally by parse_exiobase1 / 2 functions to parse exiobase files. In most cases, these top-level functions should just work, but in case of archived exiobase versions it might be nece...
python
def generic_exiobase12_parser(exio_files, system=None): """ Generic EXIOBASE version 1 and 2 parser This is used internally by parse_exiobase1 / 2 functions to parse exiobase files. In most cases, these top-level functions should just work, but in case of archived exiobase versions it might be nece...
[ "def", "generic_exiobase12_parser", "(", "exio_files", ",", "system", "=", "None", ")", ":", "version", "=", "' & '", ".", "join", "(", "{", "dd", ".", "get", "(", "'version'", ",", "''", ")", "for", "dd", "in", "exio_files", ".", "values", "(", ")", ...
Generic EXIOBASE version 1 and 2 parser This is used internally by parse_exiobase1 / 2 functions to parse exiobase files. In most cases, these top-level functions should just work, but in case of archived exiobase versions it might be necessary to use low-level function here. Parameters ------...
[ "Generic", "EXIOBASE", "version", "1", "and", "2", "parser" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L256-L396
konstantinstadler/pymrio
pymrio/tools/ioparser.py
_get_MRIO_system
def _get_MRIO_system(path): """ Extract system information (ixi, pxp) from file path. Returns 'ixi' or 'pxp', None in undetermined """ ispxp = True if re.search('pxp', path, flags=re.IGNORECASE) else False isixi = True if re.search('ixi', path, flags=re.IGNORECASE) else False if ispxp == isixi...
python
def _get_MRIO_system(path): """ Extract system information (ixi, pxp) from file path. Returns 'ixi' or 'pxp', None in undetermined """ ispxp = True if re.search('pxp', path, flags=re.IGNORECASE) else False isixi = True if re.search('ixi', path, flags=re.IGNORECASE) else False if ispxp == isixi...
[ "def", "_get_MRIO_system", "(", "path", ")", ":", "ispxp", "=", "True", "if", "re", ".", "search", "(", "'pxp'", ",", "path", ",", "flags", "=", "re", ".", "IGNORECASE", ")", "else", "False", "isixi", "=", "True", "if", "re", ".", "search", "(", "'...
Extract system information (ixi, pxp) from file path. Returns 'ixi' or 'pxp', None in undetermined
[ "Extract", "system", "information", "(", "ixi", "pxp", ")", "from", "file", "path", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L399-L411
konstantinstadler/pymrio
pymrio/tools/ioparser.py
parse_exiobase1
def parse_exiobase1(path): """ Parse the exiobase1 raw data files. This function works with - pxp_ita_44_regions_coeff_txt - ixi_fpa_44_regions_coeff_txt - pxp_ita_44_regions_coeff_src_txt - ixi_fpa_44_regions_coeff_src_txt which can be found on www.exiobase.eu The parser works with ...
python
def parse_exiobase1(path): """ Parse the exiobase1 raw data files. This function works with - pxp_ita_44_regions_coeff_txt - ixi_fpa_44_regions_coeff_txt - pxp_ita_44_regions_coeff_src_txt - ixi_fpa_44_regions_coeff_src_txt which can be found on www.exiobase.eu The parser works with ...
[ "def", "parse_exiobase1", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "normpath", "(", "str", "(", "path", ")", ")", ")", "exio_files", "=", "get_exiobase_files", "(", "path", ")", "if", "len", ...
Parse the exiobase1 raw data files. This function works with - pxp_ita_44_regions_coeff_txt - ixi_fpa_44_regions_coeff_txt - pxp_ita_44_regions_coeff_src_txt - ixi_fpa_44_regions_coeff_src_txt which can be found on www.exiobase.eu The parser works with the compressed (zip) files as well ...
[ "Parse", "the", "exiobase1", "raw", "data", "files", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L414-L451
konstantinstadler/pymrio
pymrio/tools/ioparser.py
parse_exiobase2
def parse_exiobase2(path, charact=True, popvector='exio2'): """ Parse the exiobase 2.2.2 source files for the IOSystem The function parse product by product and industry by industry source file in the coefficient form (A and S). Filenames are hardcoded in the parser - for any other function the code h...
python
def parse_exiobase2(path, charact=True, popvector='exio2'): """ Parse the exiobase 2.2.2 source files for the IOSystem The function parse product by product and industry by industry source file in the coefficient form (A and S). Filenames are hardcoded in the parser - for any other function the code h...
[ "def", "parse_exiobase2", "(", "path", ",", "charact", "=", "True", ",", "popvector", "=", "'exio2'", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "normpath", "(", "str", "(", "path", ")", ")", ")", "exio_f...
Parse the exiobase 2.2.2 source files for the IOSystem The function parse product by product and industry by industry source file in the coefficient form (A and S). Filenames are hardcoded in the parser - for any other function the code has to be adopted. Check git comments to find older verions. ...
[ "Parse", "the", "exiobase", "2", ".", "2", ".", "2", "source", "files", "for", "the", "IOSystem" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L454-L651
konstantinstadler/pymrio
pymrio/tools/ioparser.py
parse_exiobase3
def parse_exiobase3(path): """ Parses the public EXIOBASE 3 system This parser works with either the compressed zip archive as downloaded or the extracted system. Note ---- The exiobase 3 parser does so far not include population and characterization data. Parameters ---------- ...
python
def parse_exiobase3(path): """ Parses the public EXIOBASE 3 system This parser works with either the compressed zip archive as downloaded or the extracted system. Note ---- The exiobase 3 parser does so far not include population and characterization data. Parameters ---------- ...
[ "def", "parse_exiobase3", "(", "path", ")", ":", "io", "=", "load_all", "(", "path", ")", "# need to rename the final demand satellite,", "# wrong name in the standard distribution", "try", ":", "io", ".", "satellite", ".", "FY", "=", "io", ".", "satellite", ".", ...
Parses the public EXIOBASE 3 system This parser works with either the compressed zip archive as downloaded or the extracted system. Note ---- The exiobase 3 parser does so far not include population and characterization data. Parameters ---------- path : string or pathlib.Path ...
[ "Parses", "the", "public", "EXIOBASE", "3", "system" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L654-L740
konstantinstadler/pymrio
pymrio/tools/ioparser.py
parse_wiod
def parse_wiod(path, year=None, names=('isic', 'c_codes'), popvector=None): """ Parse the wiod source files for the IOSystem WIOD provides the MRIO tables in excel - format (xlsx) at http://www.wiod.org/new_site/database/wiots.htm (release November 2013). To use WIOD in pymrio these (for...
python
def parse_wiod(path, year=None, names=('isic', 'c_codes'), popvector=None): """ Parse the wiod source files for the IOSystem WIOD provides the MRIO tables in excel - format (xlsx) at http://www.wiod.org/new_site/database/wiots.htm (release November 2013). To use WIOD in pymrio these (for...
[ "def", "parse_wiod", "(", "path", ",", "year", "=", "None", ",", "names", "=", "(", "'isic'", ",", "'c_codes'", ")", ",", "popvector", "=", "None", ")", ":", "# Path manipulation, should work cross platform", "path", "=", "os", ".", "path", ".", "abspath", ...
Parse the wiod source files for the IOSystem WIOD provides the MRIO tables in excel - format (xlsx) at http://www.wiod.org/new_site/database/wiots.htm (release November 2013). To use WIOD in pymrio these (for the year of analysis) must be downloaded. The interindustry matrix of these files gets parsed ...
[ "Parse", "the", "wiod", "source", "files", "for", "the", "IOSystem" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L743-L1173
konstantinstadler/pymrio
pymrio/tools/ioparser.py
__get_WIOD_env_extension
def __get_WIOD_env_extension(root_path, year, ll_co, para): """ Parses the wiod environmental extension Extension can either be given as original .zip files or as extracted data in a folder with the same name as the corresponding zip file (with- out the extension). This function is based on the st...
python
def __get_WIOD_env_extension(root_path, year, ll_co, para): """ Parses the wiod environmental extension Extension can either be given as original .zip files or as extracted data in a folder with the same name as the corresponding zip file (with- out the extension). This function is based on the st...
[ "def", "__get_WIOD_env_extension", "(", "root_path", ",", "year", ",", "ll_co", ",", "para", ")", ":", "ll_root_content", "=", "[", "ff", "for", "ff", "in", "os", ".", "listdir", "(", "root_path", ")", "if", "ff", ".", "startswith", "(", "para", "[", "...
Parses the wiod environmental extension Extension can either be given as original .zip files or as extracted data in a folder with the same name as the corresponding zip file (with- out the extension). This function is based on the structure of the extensions from _may12. Note ---- The fu...
[ "Parses", "the", "wiod", "environmental", "extension" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L1176-L1334
konstantinstadler/pymrio
pymrio/tools/ioparser.py
__get_WIOD_SEA_extension
def __get_WIOD_SEA_extension(root_path, year, data_sheet='DATA'): """ Utility function to get the extension data from the SEA file in WIOD This function is based on the structure in the WIOD_SEA_July14 file. Missing values are set to zero. The function works if the SEA file is either in path or in a s...
python
def __get_WIOD_SEA_extension(root_path, year, data_sheet='DATA'): """ Utility function to get the extension data from the SEA file in WIOD This function is based on the structure in the WIOD_SEA_July14 file. Missing values are set to zero. The function works if the SEA file is either in path or in a s...
[ "def", "__get_WIOD_SEA_extension", "(", "root_path", ",", "year", ",", "data_sheet", "=", "'DATA'", ")", ":", "sea_ext", "=", "'.xlsx'", "sea_start", "=", "'WIOD_SEA'", "_SEA_folder", "=", "os", ".", "path", ".", "join", "(", "root_path", ",", "'SEA'", ")", ...
Utility function to get the extension data from the SEA file in WIOD This function is based on the structure in the WIOD_SEA_July14 file. Missing values are set to zero. The function works if the SEA file is either in path or in a subfolder named 'SEA'. Parameters ---------- root_path : s...
[ "Utility", "function", "to", "get", "the", "extension", "data", "from", "the", "SEA", "file", "in", "WIOD" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L1337-L1434
konstantinstadler/pymrio
pymrio/tools/ioparser.py
parse_eora26
def parse_eora26(path, year=None, price='bp', country_names='eora'): """ Parse the Eora26 database Note ---- This parser deletes the statistical disrecpancy columns from the parsed Eora system (reports the amount of loss in the meta recors). Eora does not provide any information on the un...
python
def parse_eora26(path, year=None, price='bp', country_names='eora'): """ Parse the Eora26 database Note ---- This parser deletes the statistical disrecpancy columns from the parsed Eora system (reports the amount of loss in the meta recors). Eora does not provide any information on the un...
[ "def", "parse_eora26", "(", "path", ",", "year", "=", "None", ",", "price", "=", "'bp'", ",", "country_names", "=", "'eora'", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "normpath", "(", "str", "(", "path"...
Parse the Eora26 database Note ---- This parser deletes the statistical disrecpancy columns from the parsed Eora system (reports the amount of loss in the meta recors). Eora does not provide any information on the unit of the monetary values. Based on personal communication the unit i...
[ "Parse", "the", "Eora26", "database" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioparser.py#L1437-L1677