partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
EventQueue.add_event
Adds events to the queue. Will ignore events that occur before the settle time for that pin/direction. Such events are assumed to be bouncing.
pifacecommon/interrupts.py
def add_event(self, event): """Adds events to the queue. Will ignore events that occur before the settle time for that pin/direction. Such events are assumed to be bouncing. """ # print("Trying to add event:") # print(event) # find out the pin settle time ...
def add_event(self, event): """Adds events to the queue. Will ignore events that occur before the settle time for that pin/direction. Such events are assumed to be bouncing. """ # print("Trying to add event:") # print(event) # find out the pin settle time ...
[ "Adds", "events", "to", "the", "queue", ".", "Will", "ignore", "events", "that", "occur", "before", "the", "settle", "time", "for", "that", "pin", "/", "direction", ".", "Such", "events", "are", "assumed", "to", "be", "bouncing", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L102-L128
[ "def", "add_event", "(", "self", ",", "event", ")", ":", "# print(\"Trying to add event:\")", "# print(event)", "# find out the pin settle time", "for", "pin_function_map", "in", "self", ".", "pin_function_maps", ":", "if", "_event_matches_pin_function_map", "(", "event", ...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
PortEventListener.register
Registers a pin number and direction to a callback function. :param pin_num: The pin pin number. :type pin_num: int :param direction: The event direction (use: IODIR_ON/IODIR_OFF/IODIR_BOTH) :type direction: int :param callback: The function to run when event is dete...
pifacecommon/interrupts.py
def register(self, pin_num, direction, callback, settle_time=DEFAULT_SETTLE_TIME): """Registers a pin number and direction to a callback function. :param pin_num: The pin pin number. :type pin_num: int :param direction: The event direction (use: IODIR_ON/IOD...
def register(self, pin_num, direction, callback, settle_time=DEFAULT_SETTLE_TIME): """Registers a pin number and direction to a callback function. :param pin_num: The pin pin number. :type pin_num: int :param direction: The event direction (use: IODIR_ON/IOD...
[ "Registers", "a", "pin", "number", "and", "direction", "to", "a", "callback", "function", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L174-L189
[ "def", "register", "(", "self", ",", "pin_num", ",", "direction", ",", "callback", ",", "settle_time", "=", "DEFAULT_SETTLE_TIME", ")", ":", "self", ".", "pin_function_maps", ".", "append", "(", "PinFunctionMap", "(", "pin_num", ",", "direction", ",", "callbac...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
PortEventListener.deregister
De-registers callback functions :param pin_num: The pin number. If None then all functions are de-registered :type pin_num: int :param direction: The event direction. If None then all functions for the given pin are de-registered :type direction:int
pifacecommon/interrupts.py
def deregister(self, pin_num=None, direction=None): """De-registers callback functions :param pin_num: The pin number. If None then all functions are de-registered :type pin_num: int :param direction: The event direction. If None then all functions for the give...
def deregister(self, pin_num=None, direction=None): """De-registers callback functions :param pin_num: The pin number. If None then all functions are de-registered :type pin_num: int :param direction: The event direction. If None then all functions for the give...
[ "De", "-", "registers", "callback", "functions" ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L191-L208
[ "def", "deregister", "(", "self", ",", "pin_num", "=", "None", ",", "direction", "=", "None", ")", ":", "to_delete", "=", "[", "]", "for", "i", ",", "function_map", "in", "enumerate", "(", "self", ".", "pin_function_maps", ")", ":", "if", "(", "pin_num...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
PortEventListener.deactivate
When deactivated the :class:`PortEventListener` will not run anything.
pifacecommon/interrupts.py
def deactivate(self): """When deactivated the :class:`PortEventListener` will not run anything. """ self.event_queue.put(self.TERMINATE_SIGNAL) self.dispatcher.join() self.detector.terminate() self.detector.join()
def deactivate(self): """When deactivated the :class:`PortEventListener` will not run anything. """ self.event_queue.put(self.TERMINATE_SIGNAL) self.dispatcher.join() self.detector.terminate() self.detector.join()
[ "When", "deactivated", "the", ":", "class", ":", "PortEventListener", "will", "not", "run", "anything", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L217-L224
[ "def", "deactivate", "(", "self", ")", ":", "self", ".", "event_queue", ".", "put", "(", "self", ".", "TERMINATE_SIGNAL", ")", "self", ".", "dispatcher", ".", "join", "(", ")", "self", ".", "detector", ".", "terminate", "(", ")", "self", ".", "detector...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
GPIOInterruptDevice.gpio_interrupts_enable
Enables GPIO interrupts.
pifacecommon/interrupts.py
def gpio_interrupts_enable(self): """Enables GPIO interrupts.""" try: bring_gpio_interrupt_into_userspace() set_gpio_interrupt_edge() except Timeout as e: raise InterruptEnableException( "There was an error bringing gpio%d into userspace. %s" %...
def gpio_interrupts_enable(self): """Enables GPIO interrupts.""" try: bring_gpio_interrupt_into_userspace() set_gpio_interrupt_edge() except Timeout as e: raise InterruptEnableException( "There was an error bringing gpio%d into userspace. %s" %...
[ "Enables", "GPIO", "interrupts", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/interrupts.py#L229-L238
[ "def", "gpio_interrupts_enable", "(", "self", ")", ":", "try", ":", "bring_gpio_interrupt_into_userspace", "(", ")", "set_gpio_interrupt_edge", "(", ")", "except", "Timeout", "as", "e", ":", "raise", "InterruptEnableException", "(", "\"There was an error bringing gpio%d i...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
SPIDevice.spisend
Sends bytes via the SPI bus. :param bytes_to_send: The bytes to send on the SPI device. :type bytes_to_send: bytes :returns: bytes -- returned bytes from SPI device :raises: InitError
pifacecommon/spi.py
def spisend(self, bytes_to_send): """Sends bytes via the SPI bus. :param bytes_to_send: The bytes to send on the SPI device. :type bytes_to_send: bytes :returns: bytes -- returned bytes from SPI device :raises: InitError """ # make some buffer space to store read...
def spisend(self, bytes_to_send): """Sends bytes via the SPI bus. :param bytes_to_send: The bytes to send on the SPI device. :type bytes_to_send: bytes :returns: bytes -- returned bytes from SPI device :raises: InitError """ # make some buffer space to store read...
[ "Sends", "bytes", "via", "the", "SPI", "bus", "." ]
piface/pifacecommon
python
https://github.com/piface/pifacecommon/blob/006bca14c18d43ba2d9eafaa84ef83b512c51cf6/pifacecommon/spi.py#L52-L77
[ "def", "spisend", "(", "self", ",", "bytes_to_send", ")", ":", "# make some buffer space to store reading/writing", "wbuffer", "=", "ctypes", ".", "create_string_buffer", "(", "bytes_to_send", ",", "len", "(", "bytes_to_send", ")", ")", "rbuffer", "=", "ctypes", "."...
006bca14c18d43ba2d9eafaa84ef83b512c51cf6
test
TabHolder.render
Re-implement almost the same code from crispy_forms but passing ``form`` instance to item ``render_link`` method.
crispy_forms_foundation/layout/containers.py
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK): """ Re-implement almost the same code from crispy_forms but passing ``form`` instance to item ``render_link`` method. """ links, content = '', '' # accordion group needs the parent div id to set `d...
def render(self, form, form_style, context, template_pack=TEMPLATE_PACK): """ Re-implement almost the same code from crispy_forms but passing ``form`` instance to item ``render_link`` method. """ links, content = '', '' # accordion group needs the parent div id to set `d...
[ "Re", "-", "implement", "almost", "the", "same", "code", "from", "crispy_forms", "but", "passing", "form", "instance", "to", "item", "render_link", "method", "." ]
sveetch/crispy-forms-foundation
python
https://github.com/sveetch/crispy-forms-foundation/blob/835a4152ef9b2a096b9a27748341ef751823b9f0/crispy_forms_foundation/layout/containers.py#L112-L144
[ "def", "render", "(", "self", ",", "form", ",", "form_style", ",", "context", ",", "template_pack", "=", "TEMPLATE_PACK", ")", ":", "links", ",", "content", "=", "''", ",", "''", "# accordion group needs the parent div id to set `data-parent` (I don't", "# know why). ...
835a4152ef9b2a096b9a27748341ef751823b9f0
test
TabItem.has_errors
Find tab fields listed as invalid
crispy_forms_foundation/layout/containers.py
def has_errors(self, form): """ Find tab fields listed as invalid """ return any([fieldname_error for fieldname_error in form.errors.keys() if fieldname_error in self])
def has_errors(self, form): """ Find tab fields listed as invalid """ return any([fieldname_error for fieldname_error in form.errors.keys() if fieldname_error in self])
[ "Find", "tab", "fields", "listed", "as", "invalid" ]
sveetch/crispy-forms-foundation
python
https://github.com/sveetch/crispy-forms-foundation/blob/835a4152ef9b2a096b9a27748341ef751823b9f0/crispy_forms_foundation/layout/containers.py#L173-L178
[ "def", "has_errors", "(", "self", ",", "form", ")", ":", "return", "any", "(", "[", "fieldname_error", "for", "fieldname_error", "in", "form", ".", "errors", ".", "keys", "(", ")", "if", "fieldname_error", "in", "self", "]", ")" ]
835a4152ef9b2a096b9a27748341ef751823b9f0
test
TabItem.render_link
Render the link for the tab-pane. It must be called after render so ``css_class`` is updated with ``active`` class name if needed.
crispy_forms_foundation/layout/containers.py
def render_link(self, form, template_pack=TEMPLATE_PACK, **kwargs): """ Render the link for the tab-pane. It must be called after render so ``css_class`` is updated with ``active`` class name if needed. """ link_template = self.link_template % template_pack return render_...
def render_link(self, form, template_pack=TEMPLATE_PACK, **kwargs): """ Render the link for the tab-pane. It must be called after render so ``css_class`` is updated with ``active`` class name if needed. """ link_template = self.link_template % template_pack return render_...
[ "Render", "the", "link", "for", "the", "tab", "-", "pane", ".", "It", "must", "be", "called", "after", "render", "so", "css_class", "is", "updated", "with", "active", "class", "name", "if", "needed", "." ]
sveetch/crispy-forms-foundation
python
https://github.com/sveetch/crispy-forms-foundation/blob/835a4152ef9b2a096b9a27748341ef751823b9f0/crispy_forms_foundation/layout/containers.py#L180-L190
[ "def", "render_link", "(", "self", ",", "form", ",", "template_pack", "=", "TEMPLATE_PACK", ",", "*", "*", "kwargs", ")", ":", "link_template", "=", "self", ".", "link_template", "%", "template_pack", "return", "render_to_string", "(", "link_template", ",", "{...
835a4152ef9b2a096b9a27748341ef751823b9f0
test
_extract_version
Get package version from installed distribution or configuration file if not installed
crispy_forms_foundation/__init__.py
def _extract_version(package_name): """ Get package version from installed distribution or configuration file if not installed """ try: return pkg_resources.get_distribution(package_name).version except pkg_resources.DistributionNotFound: _conf = read_configuration(os.path.join(P...
def _extract_version(package_name): """ Get package version from installed distribution or configuration file if not installed """ try: return pkg_resources.get_distribution(package_name).version except pkg_resources.DistributionNotFound: _conf = read_configuration(os.path.join(P...
[ "Get", "package", "version", "from", "installed", "distribution", "or", "configuration", "file", "if", "not", "installed" ]
sveetch/crispy-forms-foundation
python
https://github.com/sveetch/crispy-forms-foundation/blob/835a4152ef9b2a096b9a27748341ef751823b9f0/crispy_forms_foundation/__init__.py#L13-L22
[ "def", "_extract_version", "(", "package_name", ")", ":", "try", ":", "return", "pkg_resources", ".", "get_distribution", "(", "package_name", ")", ".", "version", "except", "pkg_resources", ".", "DistributionNotFound", ":", "_conf", "=", "read_configuration", "(", ...
835a4152ef9b2a096b9a27748341ef751823b9f0
test
FormContainersMixin.get_form_kwargs
Pass template pack argument
sandbox/demo/views.py
def get_form_kwargs(self): """ Pass template pack argument """ kwargs = super(FormContainersMixin, self).get_form_kwargs() kwargs.update({ 'pack': "foundation-{}".format(self.kwargs.get('foundation_version')) }) return kwargs
def get_form_kwargs(self): """ Pass template pack argument """ kwargs = super(FormContainersMixin, self).get_form_kwargs() kwargs.update({ 'pack': "foundation-{}".format(self.kwargs.get('foundation_version')) }) return kwargs
[ "Pass", "template", "pack", "argument" ]
sveetch/crispy-forms-foundation
python
https://github.com/sveetch/crispy-forms-foundation/blob/835a4152ef9b2a096b9a27748341ef751823b9f0/sandbox/demo/views.py#L40-L48
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", "FormContainersMixin", ",", "self", ")", ".", "get_form_kwargs", "(", ")", "kwargs", ".", "update", "(", "{", "'pack'", ":", "\"foundation-{}\"", ".", "format", "(", "self", ".",...
835a4152ef9b2a096b9a27748341ef751823b9f0
test
OpenLoad._check_status
Check the status of the incoming response, raise exception if status is not 200. Args: response_json (dict): results of the response of the GET request. Returns: None
openload/openload.py
def _check_status(cls, response_json): """Check the status of the incoming response, raise exception if status is not 200. Args: response_json (dict): results of the response of the GET request. Returns: None """ status = response_json['status'] ...
def _check_status(cls, response_json): """Check the status of the incoming response, raise exception if status is not 200. Args: response_json (dict): results of the response of the GET request. Returns: None """ status = response_json['status'] ...
[ "Check", "the", "status", "of", "the", "incoming", "response", "raise", "exception", "if", "status", "is", "not", "200", "." ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L31-L55
[ "def", "_check_status", "(", "cls", ",", "response_json", ")", ":", "status", "=", "response_json", "[", "'status'", "]", "msg", "=", "response_json", "[", "'msg'", "]", "if", "status", "==", "400", ":", "raise", "BadRequestException", "(", "msg", ")", "el...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad._get
Used by every other method, it makes a GET request with the given params. Args: url (str): relative path of a specific service (account_info, ...). params (:obj:`dict`, optional): contains parameters to be sent in the GET request. Returns: dict: results of the respo...
openload/openload.py
def _get(self, url, params=None): """Used by every other method, it makes a GET request with the given params. Args: url (str): relative path of a specific service (account_info, ...). params (:obj:`dict`, optional): contains parameters to be sent in the GET request. Re...
def _get(self, url, params=None): """Used by every other method, it makes a GET request with the given params. Args: url (str): relative path of a specific service (account_info, ...). params (:obj:`dict`, optional): contains parameters to be sent in the GET request. Re...
[ "Used", "by", "every", "other", "method", "it", "makes", "a", "GET", "request", "with", "the", "given", "params", "." ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L72-L90
[ "def", "_get", "(", "self", ",", "url", ",", "params", "=", "None", ")", ":", "if", "not", "params", ":", "params", "=", "{", "}", "params", ".", "update", "(", "{", "'login'", ":", "self", ".", "login", ",", "'key'", ":", "self", ".", "key", "...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad.get_download_link
Requests direct download link for requested file, this method makes use of the response of prepare_download, prepare_download must be called first. Args: file_id (str): id of the file to be downloaded. ticket (str): preparation ticket is found in prepare_download response,\ ...
openload/openload.py
def get_download_link(self, file_id, ticket, captcha_response=None): """Requests direct download link for requested file, this method makes use of the response of prepare_download, prepare_download must be called first. Args: file_id (str): id of the file to be downloaded. ...
def get_download_link(self, file_id, ticket, captcha_response=None): """Requests direct download link for requested file, this method makes use of the response of prepare_download, prepare_download must be called first. Args: file_id (str): id of the file to be downloaded. ...
[ "Requests", "direct", "download", "link", "for", "requested", "file", "this", "method", "makes", "use", "of", "the", "response", "of", "prepare_download", "prepare_download", "must", "be", "called", "first", "." ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L136-L168
[ "def", "get_download_link", "(", "self", ",", "file_id", ",", "ticket", ",", "captcha_response", "=", "None", ")", ":", "params", "=", "{", "'ticket'", ":", "ticket", ",", "'file'", ":", "file_id", "}", "if", "captcha_response", ":", "params", "[", "'captc...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad.upload_link
Makes a request to prepare for file upload. Note: If folder_id is not provided, it will make and upload link to the ``Home`` folder. Args: folder_id (:obj:`str`, optional): folder-ID to upload to. sha1 (:obj:`str`, optional): expected sha1 If sha1 of uploaded file d...
openload/openload.py
def upload_link(self, folder_id=None, sha1=None, httponly=False): """Makes a request to prepare for file upload. Note: If folder_id is not provided, it will make and upload link to the ``Home`` folder. Args: folder_id (:obj:`str`, optional): folder-ID to upload to. ...
def upload_link(self, folder_id=None, sha1=None, httponly=False): """Makes a request to prepare for file upload. Note: If folder_id is not provided, it will make and upload link to the ``Home`` folder. Args: folder_id (:obj:`str`, optional): folder-ID to upload to. ...
[ "Makes", "a", "request", "to", "prepare", "for", "file", "upload", "." ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L202-L225
[ "def", "upload_link", "(", "self", ",", "folder_id", "=", "None", ",", "sha1", "=", "None", ",", "httponly", "=", "False", ")", ":", "kwargs", "=", "{", "'folder'", ":", "folder_id", ",", "'sha1'", ":", "sha1", ",", "'httponly'", ":", "httponly", "}", ...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad.upload_file
Calls upload_link request to get valid url, then it makes a post request with given file to be uploaded. No need to call upload_link explicitly since upload_file calls it. Note: If folder_id is not provided, the file will be uploaded to ``Home`` folder. Args: file_path ...
openload/openload.py
def upload_file(self, file_path, folder_id=None, sha1=None, httponly=False): """Calls upload_link request to get valid url, then it makes a post request with given file to be uploaded. No need to call upload_link explicitly since upload_file calls it. Note: If folder_id is not provi...
def upload_file(self, file_path, folder_id=None, sha1=None, httponly=False): """Calls upload_link request to get valid url, then it makes a post request with given file to be uploaded. No need to call upload_link explicitly since upload_file calls it. Note: If folder_id is not provi...
[ "Calls", "upload_link", "request", "to", "get", "valid", "url", "then", "it", "makes", "a", "post", "request", "with", "given", "file", "to", "be", "uploaded", ".", "No", "need", "to", "call", "upload_link", "explicitly", "since", "upload_file", "calls", "it...
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L227-L261
[ "def", "upload_file", "(", "self", ",", "file_path", ",", "folder_id", "=", "None", ",", "sha1", "=", "None", ",", "httponly", "=", "False", ")", ":", "upload_url_response_json", "=", "self", ".", "upload_link", "(", "folder_id", "=", "folder_id", ",", "sh...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad.remote_upload
Used to make a remote file upload to openload.co Note: If folder_id is not provided, the file will be uploaded to ``Home`` folder. Args: remote_url (str): direct link of file to be remotely downloaded. folder_id (:obj:`str`, optional): folder-ID to upload to. ...
openload/openload.py
def remote_upload(self, remote_url, folder_id=None, headers=None): """Used to make a remote file upload to openload.co Note: If folder_id is not provided, the file will be uploaded to ``Home`` folder. Args: remote_url (str): direct link of file to be remotely downloaded...
def remote_upload(self, remote_url, folder_id=None, headers=None): """Used to make a remote file upload to openload.co Note: If folder_id is not provided, the file will be uploaded to ``Home`` folder. Args: remote_url (str): direct link of file to be remotely downloaded...
[ "Used", "to", "make", "a", "remote", "file", "upload", "to", "openload", ".", "co" ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L263-L288
[ "def", "remote_upload", "(", "self", ",", "remote_url", ",", "folder_id", "=", "None", ",", "headers", "=", "None", ")", ":", "kwargs", "=", "{", "'folder'", ":", "folder_id", ",", "'headers'", ":", "headers", "}", "params", "=", "{", "'url'", ":", "re...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad.remote_upload_status
Checks a remote file upload to status. Args: limit (:obj:`int`, optional): Maximum number of results (Default: 5, Maximum: 100). remote_upload_id (:obj:`str`, optional): Remote Upload ID. Returns: dict: dictionary containing all remote uploads, each dictionary eleme...
openload/openload.py
def remote_upload_status(self, limit=None, remote_upload_id=None): """Checks a remote file upload to status. Args: limit (:obj:`int`, optional): Maximum number of results (Default: 5, Maximum: 100). remote_upload_id (:obj:`str`, optional): Remote Upload ID. Returns: ...
def remote_upload_status(self, limit=None, remote_upload_id=None): """Checks a remote file upload to status. Args: limit (:obj:`int`, optional): Maximum number of results (Default: 5, Maximum: 100). remote_upload_id (:obj:`str`, optional): Remote Upload ID. Returns: ...
[ "Checks", "a", "remote", "file", "upload", "to", "status", "." ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L290-L331
[ "def", "remote_upload_status", "(", "self", ",", "limit", "=", "None", ",", "remote_upload_id", "=", "None", ")", ":", "kwargs", "=", "{", "'limit'", ":", "limit", ",", "'id'", ":", "remote_upload_id", "}", "params", "=", "{", "key", ":", "value", "for",...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad.list_folder
Request a list of files and folders in specified folder. Note: if folder_id is not provided, ``Home`` folder will be listed Args: folder_id (:obj:`str`, optional): id of the folder to be listed. Returns: dict: dictionary containing only two keys ("folders",...
openload/openload.py
def list_folder(self, folder_id=None): """Request a list of files and folders in specified folder. Note: if folder_id is not provided, ``Home`` folder will be listed Args: folder_id (:obj:`str`, optional): id of the folder to be listed. Returns: dic...
def list_folder(self, folder_id=None): """Request a list of files and folders in specified folder. Note: if folder_id is not provided, ``Home`` folder will be listed Args: folder_id (:obj:`str`, optional): id of the folder to be listed. Returns: dic...
[ "Request", "a", "list", "of", "files", "and", "folders", "in", "specified", "folder", "." ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L333-L379
[ "def", "list_folder", "(", "self", ",", "folder_id", "=", "None", ")", ":", "params", "=", "{", "'folder'", ":", "folder_id", "}", "if", "folder_id", "else", "{", "}", "return", "self", ".", "_get", "(", "'file/listfolder'", ",", "params", "=", "params",...
7f9353915ca5546926ef07be9395c6de60e761b1
test
OpenLoad.running_conversions
Shows running file converts by folder Note: If folder_id is not provided, ``Home`` folder will be used. Args: folder_id (:obj:`str`, optional): id of the folder to list conversions of files exist in it. Returns: list: list of dictionaries, each dictionary r...
openload/openload.py
def running_conversions(self, folder_id=None): """Shows running file converts by folder Note: If folder_id is not provided, ``Home`` folder will be used. Args: folder_id (:obj:`str`, optional): id of the folder to list conversions of files exist in it. Returns:...
def running_conversions(self, folder_id=None): """Shows running file converts by folder Note: If folder_id is not provided, ``Home`` folder will be used. Args: folder_id (:obj:`str`, optional): id of the folder to list conversions of files exist in it. Returns:...
[ "Shows", "running", "file", "converts", "by", "folder" ]
mohan3d/PyOpenload
python
https://github.com/mohan3d/PyOpenload/blob/7f9353915ca5546926ef07be9395c6de60e761b1/openload/openload.py#L434-L462
[ "def", "running_conversions", "(", "self", ",", "folder_id", "=", "None", ")", ":", "params", "=", "{", "'folder'", ":", "folder_id", "}", "if", "folder_id", "else", "{", "}", "return", "self", ".", "_get", "(", "'file/runningconverts'", ",", "params", "="...
7f9353915ca5546926ef07be9395c6de60e761b1
test
calc_heat_index
calculates the heat index based upon temperature (in F) and humidity. http://www.srh.noaa.gov/bmx/tables/heat_index.html returns the heat index in degrees F.
weather/units/temp.py
def calc_heat_index(temp, hum): ''' calculates the heat index based upon temperature (in F) and humidity. http://www.srh.noaa.gov/bmx/tables/heat_index.html returns the heat index in degrees F. ''' if (temp < 80): return temp else: return -42.379 + 2.04901523 * temp + 1...
def calc_heat_index(temp, hum): ''' calculates the heat index based upon temperature (in F) and humidity. http://www.srh.noaa.gov/bmx/tables/heat_index.html returns the heat index in degrees F. ''' if (temp < 80): return temp else: return -42.379 + 2.04901523 * temp + 1...
[ "calculates", "the", "heat", "index", "based", "upon", "temperature", "(", "in", "F", ")", "and", "humidity", ".", "http", ":", "//", "www", ".", "srh", ".", "noaa", ".", "gov", "/", "bmx", "/", "tables", "/", "heat_index", ".", "html" ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/units/temp.py#L71-L86
[ "def", "calc_heat_index", "(", "temp", ",", "hum", ")", ":", "if", "(", "temp", "<", "80", ")", ":", "return", "temp", "else", ":", "return", "-", "42.379", "+", "2.04901523", "*", "temp", "+", "10.14333127", "*", "hum", "-", "0.22475541", "*", "temp...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
calc_wind_chill
calculates the wind chill value based upon the temperature (F) and wind. returns the wind chill in degrees F.
weather/units/temp.py
def calc_wind_chill(t, windspeed, windspeed10min=None): ''' calculates the wind chill value based upon the temperature (F) and wind. returns the wind chill in degrees F. ''' w = max(windspeed10min, windspeed) return 35.74 + 0.6215 * t - 35.75 * (w ** 0.16) + 0.4275 * t * (w ** 0.16);
def calc_wind_chill(t, windspeed, windspeed10min=None): ''' calculates the wind chill value based upon the temperature (F) and wind. returns the wind chill in degrees F. ''' w = max(windspeed10min, windspeed) return 35.74 + 0.6215 * t - 35.75 * (w ** 0.16) + 0.4275 * t * (w ** 0.16);
[ "calculates", "the", "wind", "chill", "value", "based", "upon", "the", "temperature", "(", "F", ")", "and", "wind", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/units/temp.py#L89-L98
[ "def", "calc_wind_chill", "(", "t", ",", "windspeed", ",", "windspeed10min", "=", "None", ")", ":", "w", "=", "max", "(", "windspeed10min", ",", "windspeed", ")", "return", "35.74", "+", "0.6215", "*", "t", "-", "35.75", "*", "(", "w", "**", "0.16", ...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
calc_humidity
calculates the humidity via the formula from weatherwise.org return the relative humidity
weather/units/temp.py
def calc_humidity(temp, dewpoint): ''' calculates the humidity via the formula from weatherwise.org return the relative humidity ''' t = fahrenheit_to_celsius(temp) td = fahrenheit_to_celsius(dewpoint) num = 112 - (0.1 * t) + td denom = 112 + (0.9 * t) rh = math.pow((num / denom),...
def calc_humidity(temp, dewpoint): ''' calculates the humidity via the formula from weatherwise.org return the relative humidity ''' t = fahrenheit_to_celsius(temp) td = fahrenheit_to_celsius(dewpoint) num = 112 - (0.1 * t) + td denom = 112 + (0.9 * t) rh = math.pow((num / denom),...
[ "calculates", "the", "humidity", "via", "the", "formula", "from", "weatherwise", ".", "org", "return", "the", "relative", "humidity" ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/units/temp.py#L101-L115
[ "def", "calc_humidity", "(", "temp", ",", "dewpoint", ")", ":", "t", "=", "fahrenheit_to_celsius", "(", "temp", ")", "td", "=", "fahrenheit_to_celsius", "(", "dewpoint", ")", "num", "=", "112", "-", "(", "0.1", "*", "t", ")", "+", "td", "denom", "=", ...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
calc_dewpoint
calculates the dewpoint via the formula from weatherwise.org return the dewpoint in degrees F.
weather/units/temp.py
def calc_dewpoint(temp, hum): ''' calculates the dewpoint via the formula from weatherwise.org return the dewpoint in degrees F. ''' c = fahrenheit_to_celsius(temp) x = 1 - 0.01 * hum; dewpoint = (14.55 + 0.114 * c) * x; dewpoint = dewpoint + ((2.5 + 0.007 * c) * x) ** 3; dewpoint ...
def calc_dewpoint(temp, hum): ''' calculates the dewpoint via the formula from weatherwise.org return the dewpoint in degrees F. ''' c = fahrenheit_to_celsius(temp) x = 1 - 0.01 * hum; dewpoint = (14.55 + 0.114 * c) * x; dewpoint = dewpoint + ((2.5 + 0.007 * c) * x) ** 3; dewpoint ...
[ "calculates", "the", "dewpoint", "via", "the", "formula", "from", "weatherwise", ".", "org", "return", "the", "dewpoint", "in", "degrees", "F", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/units/temp.py#L118-L132
[ "def", "calc_dewpoint", "(", "temp", ",", "hum", ")", ":", "c", "=", "fahrenheit_to_celsius", "(", "temp", ")", "x", "=", "1", "-", "0.01", "*", "hum", "dewpoint", "=", "(", "14.55", "+", "0.114", "*", "c", ")", "*", "x", "dewpoint", "=", "dewpoint...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
HttpPublisher.publish
Perform HTTP session to transmit defined weather values.
weather/services/_base.py
def publish(self): ''' Perform HTTP session to transmit defined weather values. ''' return self._publish( self.args, self.server, self.URI)
def publish(self): ''' Perform HTTP session to transmit defined weather values. ''' return self._publish( self.args, self.server, self.URI)
[ "Perform", "HTTP", "session", "to", "transmit", "defined", "weather", "values", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/services/_base.py#L63-L67
[ "def", "publish", "(", "self", ")", ":", "return", "self", ".", "_publish", "(", "self", ".", "args", ",", "self", ".", "server", ",", "self", ".", "URI", ")" ]
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VProCRC.get
return CRC calc value from raw serial data
weather/stations/davis.py
def get(data): ''' return CRC calc value from raw serial data ''' crc = 0 for byte in array('B', data): crc = (VProCRC.CRC_TABLE[(crc >> 8) ^ byte] ^ ((crc & 0xFF) << 8)) return crc
def get(data): ''' return CRC calc value from raw serial data ''' crc = 0 for byte in array('B', data): crc = (VProCRC.CRC_TABLE[(crc >> 8) ^ byte] ^ ((crc & 0xFF) << 8)) return crc
[ "return", "CRC", "calc", "value", "from", "raw", "serial", "data" ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L93-L100
[ "def", "get", "(", "data", ")", ":", "crc", "=", "0", "for", "byte", "in", "array", "(", "'B'", ",", "data", ")", ":", "crc", "=", "(", "VProCRC", ".", "CRC_TABLE", "[", "(", "crc", ">>", "8", ")", "^", "byte", "]", "^", "(", "(", "crc", "&...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VProCRC.verify
perform CRC check on raw serial data, return true if valid. a valid CRC == 0.
weather/stations/davis.py
def verify(data): ''' perform CRC check on raw serial data, return true if valid. a valid CRC == 0. ''' if len(data) == 0: return False crc = VProCRC.get(data) if crc: log.info("CRC Bad") else: log.debug("CRC OK") ...
def verify(data): ''' perform CRC check on raw serial data, return true if valid. a valid CRC == 0. ''' if len(data) == 0: return False crc = VProCRC.get(data) if crc: log.info("CRC Bad") else: log.debug("CRC OK") ...
[ "perform", "CRC", "check", "on", "raw", "serial", "data", "return", "true", "if", "valid", ".", "a", "valid", "CRC", "==", "0", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L103-L115
[ "def", "verify", "(", "data", ")", ":", "if", "len", "(", "data", ")", "==", "0", ":", "return", "False", "crc", "=", "VProCRC", ".", "get", "(", "data", ")", "if", "crc", ":", "log", ".", "info", "(", "\"CRC Bad\"", ")", "else", ":", "log", "....
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
LoopStruct._unpack_storm_date
given a packed storm date field, unpack and return 'YYYY-MM-DD' string.
weather/stations/davis.py
def _unpack_storm_date(date): ''' given a packed storm date field, unpack and return 'YYYY-MM-DD' string. ''' year = (date & 0x7f) + 2000 # 7 bits day = (date >> 7) & 0x01f # 5 bits month = (date >> 12) & 0x0f # 4 bits return "%s-%s-%s" % (year, month, day)
def _unpack_storm_date(date): ''' given a packed storm date field, unpack and return 'YYYY-MM-DD' string. ''' year = (date & 0x7f) + 2000 # 7 bits day = (date >> 7) & 0x01f # 5 bits month = (date >> 12) & 0x0f # 4 bits return "%s-%s-%s" % (year, month, day)
[ "given", "a", "packed", "storm", "date", "field", "unpack", "and", "return", "YYYY", "-", "MM", "-", "DD", "string", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L181-L188
[ "def", "_unpack_storm_date", "(", "date", ")", ":", "year", "=", "(", "date", "&", "0x7f", ")", "+", "2000", "# 7 bits", "day", "=", "(", "date", ">>", "7", ")", "&", "0x01f", "# 5 bits", "month", "=", "(", "date", ">>", "12", ")", "&", "0x0f", "...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro._use_rev_b_archive
return True if weather station returns Rev.B archives
weather/stations/davis.py
def _use_rev_b_archive(self, records, offset): ''' return True if weather station returns Rev.B archives ''' # if pre-determined, return result if type(self._ARCHIVE_REV_B) is bool: return self._ARCHIVE_REV_B # assume, B and check 'RecType' field data ...
def _use_rev_b_archive(self, records, offset): ''' return True if weather station returns Rev.B archives ''' # if pre-determined, return result if type(self._ARCHIVE_REV_B) is bool: return self._ARCHIVE_REV_B # assume, B and check 'RecType' field data ...
[ "return", "True", "if", "weather", "station", "returns", "Rev", ".", "B", "archives" ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L364-L380
[ "def", "_use_rev_b_archive", "(", "self", ",", "records", ",", "offset", ")", ":", "# if pre-determined, return result", "if", "type", "(", "self", ".", "_ARCHIVE_REV_B", ")", "is", "bool", ":", "return", "self", ".", "_ARCHIVE_REV_B", "# assume, B and check 'RecTyp...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro._wakeup
issue wakeup command to device to take out of standby mode.
weather/stations/davis.py
def _wakeup(self): ''' issue wakeup command to device to take out of standby mode. ''' log.info("send: WAKEUP") for i in xrange(3): self.port.write('\n') # wakeup device ack = self.port.read(len(self.WAKE_ACK)) # read wakeup string log_raw('r...
def _wakeup(self): ''' issue wakeup command to device to take out of standby mode. ''' log.info("send: WAKEUP") for i in xrange(3): self.port.write('\n') # wakeup device ack = self.port.read(len(self.WAKE_ACK)) # read wakeup string log_raw('r...
[ "issue", "wakeup", "command", "to", "device", "to", "take", "out", "of", "standby", "mode", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L382-L393
[ "def", "_wakeup", "(", "self", ")", ":", "log", ".", "info", "(", "\"send: WAKEUP\"", ")", "for", "i", "in", "xrange", "(", "3", ")", ":", "self", ".", "port", ".", "write", "(", "'\\n'", ")", "# wakeup device", "ack", "=", "self", ".", "port", "."...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro._cmd
write a single command, with variable number of arguments. after the command, the device must return ACK
weather/stations/davis.py
def _cmd(self, cmd, *args, **kw): ''' write a single command, with variable number of arguments. after the command, the device must return ACK ''' ok = kw.setdefault('ok', False) self._wakeup() if args: cmd = "%s %s" % (cmd, ' '.join(str(a) for a in a...
def _cmd(self, cmd, *args, **kw): ''' write a single command, with variable number of arguments. after the command, the device must return ACK ''' ok = kw.setdefault('ok', False) self._wakeup() if args: cmd = "%s %s" % (cmd, ' '.join(str(a) for a in a...
[ "write", "a", "single", "command", "with", "variable", "number", "of", "arguments", ".", "after", "the", "command", "the", "device", "must", "return", "ACK" ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L395-L418
[ "def", "_cmd", "(", "self", ",", "cmd", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "ok", "=", "kw", ".", "setdefault", "(", "'ok'", ",", "False", ")", "self", ".", "_wakeup", "(", ")", "if", "args", ":", "cmd", "=", "\"%s %s\"", "%", "(...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro._loop_cmd
reads a raw string containing data read from the device provided (in /dev/XXX) format. all reads are non-blocking.
weather/stations/davis.py
def _loop_cmd(self): ''' reads a raw string containing data read from the device provided (in /dev/XXX) format. all reads are non-blocking. ''' self._cmd('LOOP', 1) raw = self.port.read(LoopStruct.size) # read data log_raw('read', raw) return raw
def _loop_cmd(self): ''' reads a raw string containing data read from the device provided (in /dev/XXX) format. all reads are non-blocking. ''' self._cmd('LOOP', 1) raw = self.port.read(LoopStruct.size) # read data log_raw('read', raw) return raw
[ "reads", "a", "raw", "string", "containing", "data", "read", "from", "the", "device", "provided", "(", "in", "/", "dev", "/", "XXX", ")", "format", ".", "all", "reads", "are", "non", "-", "blocking", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L420-L428
[ "def", "_loop_cmd", "(", "self", ")", ":", "self", ".", "_cmd", "(", "'LOOP'", ",", "1", ")", "raw", "=", "self", ".", "port", ".", "read", "(", "LoopStruct", ".", "size", ")", "# read data", "log_raw", "(", "'read'", ",", "raw", ")", "return", "ra...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro._dmpaft_cmd
issue a command to read the archive records after a known time stamp.
weather/stations/davis.py
def _dmpaft_cmd(self, time_fields): ''' issue a command to read the archive records after a known time stamp. ''' records = [] # convert time stamp fields to buffer tbuf = struct.pack('2H', *time_fields) # 1. send 'DMPAFT' cmd self._cmd('DMPAFT') ...
def _dmpaft_cmd(self, time_fields): ''' issue a command to read the archive records after a known time stamp. ''' records = [] # convert time stamp fields to buffer tbuf = struct.pack('2H', *time_fields) # 1. send 'DMPAFT' cmd self._cmd('DMPAFT') ...
[ "issue", "a", "command", "to", "read", "the", "archive", "records", "after", "a", "known", "time", "stamp", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L430-L492
[ "def", "_dmpaft_cmd", "(", "self", ",", "time_fields", ")", ":", "records", "=", "[", "]", "# convert time stamp fields to buffer", "tbuf", "=", "struct", ".", "pack", "(", "'2H'", ",", "*", "time_fields", ")", "# 1. send 'DMPAFT' cmd", "self", ".", "_cmd", "(...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro._get_new_archive_fields
returns a dictionary of fields from the newest archive record in the device. return None when no records are new.
weather/stations/davis.py
def _get_new_archive_fields(self): ''' returns a dictionary of fields from the newest archive record in the device. return None when no records are new. ''' for i in xrange(3): records = self._dmpaft_cmd(self._archive_time) if records is not None: break ...
def _get_new_archive_fields(self): ''' returns a dictionary of fields from the newest archive record in the device. return None when no records are new. ''' for i in xrange(3): records = self._dmpaft_cmd(self._archive_time) if records is not None: break ...
[ "returns", "a", "dictionary", "of", "fields", "from", "the", "newest", "archive", "record", "in", "the", "device", ".", "return", "None", "when", "no", "records", "are", "new", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L506-L527
[ "def", "_get_new_archive_fields", "(", "self", ")", ":", "for", "i", "in", "xrange", "(", "3", ")", ":", "records", "=", "self", ".", "_dmpaft_cmd", "(", "self", ".", "_archive_time", ")", "if", "records", "is", "not", "None", ":", "break", "time", "."...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro._calc_derived_fields
calculates the derived fields (those fields that are calculated)
weather/stations/davis.py
def _calc_derived_fields(self, fields): ''' calculates the derived fields (those fields that are calculated) ''' # convenience variables for the calculations below temp = fields['TempOut'] hum = fields['HumOut'] wind = fields['WindSpeed'] wind10min = field...
def _calc_derived_fields(self, fields): ''' calculates the derived fields (those fields that are calculated) ''' # convenience variables for the calculations below temp = fields['TempOut'] hum = fields['HumOut'] wind = fields['WindSpeed'] wind10min = field...
[ "calculates", "the", "derived", "fields", "(", "those", "fields", "that", "are", "calculated", ")" ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L529-L549
[ "def", "_calc_derived_fields", "(", "self", ",", "fields", ")", ":", "# convenience variables for the calculations below", "temp", "=", "fields", "[", "'TempOut'", "]", "hum", "=", "fields", "[", "'HumOut'", "]", "wind", "=", "fields", "[", "'WindSpeed'", "]", "...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
VantagePro.parse
read and parse a set of data read from the console. after the data is parsed it is available in the fields variable.
weather/stations/davis.py
def parse(self): ''' read and parse a set of data read from the console. after the data is parsed it is available in the fields variable. ''' fields = self._get_loop_fields() fields['Archive'] = self._get_new_archive_fields() self._calc_derived_fields(fields) ...
def parse(self): ''' read and parse a set of data read from the console. after the data is parsed it is available in the fields variable. ''' fields = self._get_loop_fields() fields['Archive'] = self._get_new_archive_fields() self._calc_derived_fields(fields) ...
[ "read", "and", "parse", "a", "set", "of", "data", "read", "from", "the", "console", ".", "after", "the", "data", "is", "parsed", "it", "is", "available", "in", "the", "fields", "variable", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/davis.py#L551-L562
[ "def", "parse", "(", "self", ")", ":", "fields", "=", "self", ".", "_get_loop_fields", "(", ")", "fields", "[", "'Archive'", "]", "=", "self", ".", "_get_new_archive_fields", "(", ")", "self", ".", "_calc_derived_fields", "(", "fields", ")", "# set the field...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
Struct.unpack_from
unpacks data from 'buf' and returns a dication of named fields. the fields can be post-processed by extending the _post_unpack() method.
weather/stations/_struct.py
def unpack_from(self, buf, offset=0 ): ''' unpacks data from 'buf' and returns a dication of named fields. the fields can be post-processed by extending the _post_unpack() method. ''' data = super(Struct,self).unpack_from( buf, offset) items = dict(zip(self.fields,data)) ...
def unpack_from(self, buf, offset=0 ): ''' unpacks data from 'buf' and returns a dication of named fields. the fields can be post-processed by extending the _post_unpack() method. ''' data = super(Struct,self).unpack_from( buf, offset) items = dict(zip(self.fields,data)) ...
[ "unpacks", "data", "from", "buf", "and", "returns", "a", "dication", "of", "named", "fields", ".", "the", "fields", "can", "be", "post", "-", "processed", "by", "extending", "the", "_post_unpack", "()", "method", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/stations/_struct.py#L40-L47
[ "def", "unpack_from", "(", "self", ",", "buf", ",", "offset", "=", "0", ")", ":", "data", "=", "super", "(", "Struct", ",", "self", ")", ".", "unpack_from", "(", "buf", ",", "offset", ")", "items", "=", "dict", "(", "zip", "(", "self", ".", "fiel...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
weather_update
main execution loop. query weather data and post to online service.
scripts/weatherpub.py
def weather_update(station, pub_sites, interval): ''' main execution loop. query weather data and post to online service. ''' station.parse() # read weather data # santity check weather data if station.fields['TempOut'] > 200: raise NoSensorException( 'Out of range temperature ...
def weather_update(station, pub_sites, interval): ''' main execution loop. query weather data and post to online service. ''' station.parse() # read weather data # santity check weather data if station.fields['TempOut'] > 200: raise NoSensorException( 'Out of range temperature ...
[ "main", "execution", "loop", ".", "query", "weather", "data", "and", "post", "to", "online", "service", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/scripts/weatherpub.py#L77-L109
[ "def", "weather_update", "(", "station", ",", "pub_sites", ",", "interval", ")", ":", "station", ".", "parse", "(", ")", "# read weather data", "# santity check weather data", "if", "station", ".", "fields", "[", "'TempOut'", "]", ">", "200", ":", "raise", "No...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
init_log
setup system logging to desired verbosity.
scripts/weatherpub.py
def init_log( quiet, debug ): ''' setup system logging to desired verbosity. ''' from logging.handlers import SysLogHandler fmt = logging.Formatter( os.path.basename(sys.argv[0]) + ".%(name)s %(levelname)s - %(message)s") facility = SysLogHandler.LOG_DAEMON syslog = SysLogHandler(address='...
def init_log( quiet, debug ): ''' setup system logging to desired verbosity. ''' from logging.handlers import SysLogHandler fmt = logging.Formatter( os.path.basename(sys.argv[0]) + ".%(name)s %(levelname)s - %(message)s") facility = SysLogHandler.LOG_DAEMON syslog = SysLogHandler(address='...
[ "setup", "system", "logging", "to", "desired", "verbosity", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/scripts/weatherpub.py#L112-L129
[ "def", "init_log", "(", "quiet", ",", "debug", ")", ":", "from", "logging", ".", "handlers", "import", "SysLogHandler", "fmt", "=", "logging", ".", "Formatter", "(", "os", ".", "path", ".", "basename", "(", "sys", ".", "argv", "[", "0", "]", ")", "+"...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
get_pub_services
use values in opts data to generate instances of publication services.
scripts/weatherpub.py
def get_pub_services(opts): ''' use values in opts data to generate instances of publication services. ''' sites = [] for p_key in vars(opts).keys(): args = getattr(opts,p_key) if p_key in PUB_SERVICES and args: if isinstance(args,tuple): ps = PUB_SERVICES[p_key](*args) ...
def get_pub_services(opts): ''' use values in opts data to generate instances of publication services. ''' sites = [] for p_key in vars(opts).keys(): args = getattr(opts,p_key) if p_key in PUB_SERVICES and args: if isinstance(args,tuple): ps = PUB_SERVICES[p_key](*args) ...
[ "use", "values", "in", "opts", "data", "to", "generate", "instances", "of", "publication", "services", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/scripts/weatherpub.py#L132-L145
[ "def", "get_pub_services", "(", "opts", ")", ":", "sites", "=", "[", "]", "for", "p_key", "in", "vars", "(", "opts", ")", ".", "keys", "(", ")", ":", "args", "=", "getattr", "(", "opts", ",", "p_key", ")", "if", "p_key", "in", "PUB_SERVICES", "and"...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
get_options
read command line options to configure program behavior.
scripts/weatherpub.py
def get_options(parser): ''' read command line options to configure program behavior. ''' # station services # publication services pub_g = optparse.OptionGroup( parser, "Publication Services", '''One or more publication service must be specified to enable upload of weather data.''',...
def get_options(parser): ''' read command line options to configure program behavior. ''' # station services # publication services pub_g = optparse.OptionGroup( parser, "Publication Services", '''One or more publication service must be specified to enable upload of weather data.''',...
[ "read", "command", "line", "options", "to", "configure", "program", "behavior", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/scripts/weatherpub.py#L148-L173
[ "def", "get_options", "(", "parser", ")", ":", "# station services", "# publication services", "pub_g", "=", "optparse", ".", "OptionGroup", "(", "parser", ",", "\"Publication Services\"", ",", "'''One or more publication service must be specified to enable upload\n of we...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
WindGust.get
return gust data, if above threshold value and current time is inside reporting window period
scripts/weatherpub.py
def get( self, station, interval ): ''' return gust data, if above threshold value and current time is inside reporting window period ''' rec = station.fields['Archive'] # process new data if rec: threshold = station.fields['WindSpeed10Min'] + GUST_MPH_MIN if ...
def get( self, station, interval ): ''' return gust data, if above threshold value and current time is inside reporting window period ''' rec = station.fields['Archive'] # process new data if rec: threshold = station.fields['WindSpeed10Min'] + GUST_MPH_MIN if ...
[ "return", "gust", "data", "if", "above", "threshold", "value", "and", "current", "time", "is", "inside", "reporting", "window", "period" ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/scripts/weatherpub.py#L51-L73
[ "def", "get", "(", "self", ",", "station", ",", "interval", ")", ":", "rec", "=", "station", ".", "fields", "[", "'Archive'", "]", "# process new data", "if", "rec", ":", "threshold", "=", "station", ".", "fields", "[", "'WindSpeed10Min'", "]", "+", "GUS...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
Wunderground.set
Useful for defining weather data published to the server. Parameters not set will be reset and not sent to server. Unknown keyword args will be silently ignored, so be careful. This is necessary for publishers that support more fields than others.
weather/services/wunderground.py
def set( self, pressure='NA', dewpoint='NA', humidity='NA', tempf='NA', rainin='NA', rainday='NA', dateutc='NA', windgust='NA', windgustdir='NA', windspeed='NA', winddir='NA', clouds='NA', weather='NA', *args, **kw): ''' Useful for defining weather data published to t...
def set( self, pressure='NA', dewpoint='NA', humidity='NA', tempf='NA', rainin='NA', rainday='NA', dateutc='NA', windgust='NA', windgustdir='NA', windspeed='NA', winddir='NA', clouds='NA', weather='NA', *args, **kw): ''' Useful for defining weather data published to t...
[ "Useful", "for", "defining", "weather", "data", "published", "to", "the", "server", ".", "Parameters", "not", "set", "will", "be", "reset", "and", "not", "sent", "to", "server", ".", "Unknown", "keyword", "args", "will", "be", "silently", "ignored", "so", ...
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/services/wunderground.py#L79-L109
[ "def", "set", "(", "self", ",", "pressure", "=", "'NA'", ",", "dewpoint", "=", "'NA'", ",", "humidity", "=", "'NA'", ",", "tempf", "=", "'NA'", ",", "rainin", "=", "'NA'", ",", "rainday", "=", "'NA'", ",", "dateutc", "=", "'NA'", ",", "windgust", "...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
TextFile.set
Store keyword args to be written to output file.
weather/services/file.py
def set( self, **kw): ''' Store keyword args to be written to output file. ''' self.args = kw log.debug( self.args )
def set( self, **kw): ''' Store keyword args to be written to output file. ''' self.args = kw log.debug( self.args )
[ "Store", "keyword", "args", "to", "be", "written", "to", "output", "file", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/services/file.py#L53-L58
[ "def", "set", "(", "self", ",", "*", "*", "kw", ")", ":", "self", ".", "args", "=", "kw", "log", ".", "debug", "(", "self", ".", "args", ")" ]
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
TextFile.publish
Write output file.
weather/services/file.py
def publish(self): ''' Write output file. ''' with open( self.file_name, 'w') as fh: for k,v in self.args.iteritems(): buf = StringIO.StringIO() buf.write(k) self._append_vals(buf,v) fh.write(buf.getvalue() + '\n') buf.close()
def publish(self): ''' Write output file. ''' with open( self.file_name, 'w') as fh: for k,v in self.args.iteritems(): buf = StringIO.StringIO() buf.write(k) self._append_vals(buf,v) fh.write(buf.getvalue() + '\n') buf.close()
[ "Write", "output", "file", "." ]
cmcginty/PyWeather
python
https://github.com/cmcginty/PyWeather/blob/8c25d9cd1fa921e0a6e460d523656279cac045cb/weather/services/file.py#L73-L83
[ "def", "publish", "(", "self", ")", ":", "with", "open", "(", "self", ".", "file_name", ",", "'w'", ")", "as", "fh", ":", "for", "k", ",", "v", "in", "self", ".", "args", ".", "iteritems", "(", ")", ":", "buf", "=", "StringIO", ".", "StringIO", ...
8c25d9cd1fa921e0a6e460d523656279cac045cb
test
requires
Standalone decorator to apply requirements to routes, either function handlers or class based views:: @requires(MyRequirement()) def a_view(): pass class AView(View): decorators = [requires(MyRequirement())] :param requirements: The requirements to apply to thi...
src/flask_allows/views.py
def requires(*requirements, **opts): """ Standalone decorator to apply requirements to routes, either function handlers or class based views:: @requires(MyRequirement()) def a_view(): pass class AView(View): decorators = [requires(MyRequirement())] :par...
def requires(*requirements, **opts): """ Standalone decorator to apply requirements to routes, either function handlers or class based views:: @requires(MyRequirement()) def a_view(): pass class AView(View): decorators = [requires(MyRequirement())] :par...
[ "Standalone", "decorator", "to", "apply", "requirements", "to", "routes", "either", "function", "handlers", "or", "class", "based", "views", "::" ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/views.py#L21-L67
[ "def", "requires", "(", "*", "requirements", ",", "*", "*", "opts", ")", ":", "identity", "=", "opts", ".", "get", "(", "\"identity\"", ")", "on_fail", "=", "opts", ".", "get", "(", "\"on_fail\"", ")", "throws", "=", "opts", ".", "get", "(", "\"throw...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
guard_entire
Used to protect an entire blueprint with a set of requirements. If a route handler inside the blueprint should be exempt, then it may be decorated with the :func:`~flask_allows.views.exempt_from_requirements` decorator. This function should be registered as a before_request handler on the blueprint and...
src/flask_allows/views.py
def guard_entire(requirements, identity=None, throws=None, on_fail=None): """ Used to protect an entire blueprint with a set of requirements. If a route handler inside the blueprint should be exempt, then it may be decorated with the :func:`~flask_allows.views.exempt_from_requirements` decorator. T...
def guard_entire(requirements, identity=None, throws=None, on_fail=None): """ Used to protect an entire blueprint with a set of requirements. If a route handler inside the blueprint should be exempt, then it may be decorated with the :func:`~flask_allows.views.exempt_from_requirements` decorator. T...
[ "Used", "to", "protect", "an", "entire", "blueprint", "with", "a", "set", "of", "requirements", ".", "If", "a", "route", "handler", "inside", "the", "blueprint", "should", "be", "exempt", "then", "it", "may", "be", "decorated", "with", "the", ":", "func", ...
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/views.py#L115-L203
[ "def", "guard_entire", "(", "requirements", ",", "identity", "=", "None", ",", "throws", "=", "None", ",", "on_fail", "=", "None", ")", ":", "def", "guarder", "(", ")", ":", "if", "_should_run_requirements", "(", ")", ":", "return", "allows", ".", "run",...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
wants_request
Helper decorator for transitioning to user-only requirements, this aids in situations where the request may be marked optional and causes an incorrect flow into user-only requirements. This decorator causes the requirement to look like a user-only requirement but passes the current request context inte...
src/flask_allows/requirements.py
def wants_request(f): """ Helper decorator for transitioning to user-only requirements, this aids in situations where the request may be marked optional and causes an incorrect flow into user-only requirements. This decorator causes the requirement to look like a user-only requirement but passe...
def wants_request(f): """ Helper decorator for transitioning to user-only requirements, this aids in situations where the request may be marked optional and causes an incorrect flow into user-only requirements. This decorator causes the requirement to look like a user-only requirement but passe...
[ "Helper", "decorator", "for", "transitioning", "to", "user", "-", "only", "requirements", "this", "aids", "in", "situations", "where", "the", "request", "may", "be", "marked", "optional", "and", "causes", "an", "incorrect", "flow", "into", "user", "-", "only",...
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/requirements.py#L198-L217
[ "def", "wants_request", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "user", ")", ":", "return", "f", "(", "user", ",", "request", ")", "return", "wrapper" ]
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
ConditionalRequirement.And
Short cut helper to construct a combinator that uses :meth:`operator.and_` to reduce requirement results and stops evaluating on the first False. This is also exported at the module level as ``And``
src/flask_allows/requirements.py
def And(cls, *requirements): """ Short cut helper to construct a combinator that uses :meth:`operator.and_` to reduce requirement results and stops evaluating on the first False. This is also exported at the module level as ``And`` """ return cls(*requirements, o...
def And(cls, *requirements): """ Short cut helper to construct a combinator that uses :meth:`operator.and_` to reduce requirement results and stops evaluating on the first False. This is also exported at the module level as ``And`` """ return cls(*requirements, o...
[ "Short", "cut", "helper", "to", "construct", "a", "combinator", "that", "uses", ":", "meth", ":", "operator", ".", "and_", "to", "reduce", "requirement", "results", "and", "stops", "evaluating", "on", "the", "first", "False", "." ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/requirements.py#L95-L103
[ "def", "And", "(", "cls", ",", "*", "requirements", ")", ":", "return", "cls", "(", "*", "requirements", ",", "op", "=", "operator", ".", "and_", ",", "until", "=", "False", ")" ]
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
ConditionalRequirement.Or
Short cut helper to construct a combinator that uses :meth:`operator.or_` to reduce requirement results and stops evaluating on the first True. This is also exported at the module level as ``Or``
src/flask_allows/requirements.py
def Or(cls, *requirements): """ Short cut helper to construct a combinator that uses :meth:`operator.or_` to reduce requirement results and stops evaluating on the first True. This is also exported at the module level as ``Or`` """ return cls(*requirements, op=op...
def Or(cls, *requirements): """ Short cut helper to construct a combinator that uses :meth:`operator.or_` to reduce requirement results and stops evaluating on the first True. This is also exported at the module level as ``Or`` """ return cls(*requirements, op=op...
[ "Short", "cut", "helper", "to", "construct", "a", "combinator", "that", "uses", ":", "meth", ":", "operator", ".", "or_", "to", "reduce", "requirement", "results", "and", "stops", "evaluating", "on", "the", "first", "True", "." ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/requirements.py#L106-L114
[ "def", "Or", "(", "cls", ",", "*", "requirements", ")", ":", "return", "cls", "(", "*", "requirements", ",", "op", "=", "operator", ".", "or_", ",", "until", "=", "True", ")" ]
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
Allows.init_app
Initializes the Flask-Allows object against the provided application
src/flask_allows/allows.py
def init_app(self, app): """ Initializes the Flask-Allows object against the provided application """ if not hasattr(app, "extensions"): # pragma: no cover app.extensions = {} app.extensions["allows"] = self @app.before_request def start_context(*a, ...
def init_app(self, app): """ Initializes the Flask-Allows object against the provided application """ if not hasattr(app, "extensions"): # pragma: no cover app.extensions = {} app.extensions["allows"] = self @app.before_request def start_context(*a, ...
[ "Initializes", "the", "Flask", "-", "Allows", "object", "against", "the", "provided", "application" ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/allows.py#L41-L58
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "if", "not", "hasattr", "(", "app", ",", "\"extensions\"", ")", ":", "# pragma: no cover", "app", ".", "extensions", "=", "{", "}", "app", ".", "extensions", "[", "\"allows\"", "]", "=", "self", "@"...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
Allows.fulfill
Checks that the provided or current identity meets each requirement passed to this method. This method takes into account both additional and overridden requirements, with overridden requirements taking precedence:: allows.additional.push(Additional(Has('foo'))) allows....
src/flask_allows/allows.py
def fulfill(self, requirements, identity=None): """ Checks that the provided or current identity meets each requirement passed to this method. This method takes into account both additional and overridden requirements, with overridden requirements taking precedence:: ...
def fulfill(self, requirements, identity=None): """ Checks that the provided or current identity meets each requirement passed to this method. This method takes into account both additional and overridden requirements, with overridden requirements taking precedence:: ...
[ "Checks", "that", "the", "provided", "or", "current", "identity", "meets", "each", "requirement", "passed", "to", "this", "method", "." ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/allows.py#L124-L153
[ "def", "fulfill", "(", "self", ",", "requirements", ",", "identity", "=", "None", ")", ":", "identity", "=", "identity", "or", "self", ".", "_identity_loader", "(", ")", "if", "self", ".", "additional", ".", "current", ":", "all_requirements", "=", "chain"...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
Allows.run
Used to preform a full run of the requirements and the options given, this method will invoke on_fail and/or throw the appropriate exception type. Can be passed arguments to call on_fail with via f_args (which are passed positionally) and f_kwargs (which are passed as keyword). :param r...
src/flask_allows/allows.py
def run( self, requirements, identity=None, throws=None, on_fail=None, f_args=(), f_kwargs=ImmutableDict(), # noqa: B008 use_on_fail_return=True, ): """ Used to preform a full run of the requirements and the options given, this...
def run( self, requirements, identity=None, throws=None, on_fail=None, f_args=(), f_kwargs=ImmutableDict(), # noqa: B008 use_on_fail_return=True, ): """ Used to preform a full run of the requirements and the options given, this...
[ "Used", "to", "preform", "a", "full", "run", "of", "the", "requirements", "and", "the", "options", "given", "this", "method", "will", "invoke", "on_fail", "and", "/", "or", "throw", "the", "appropriate", "exception", "type", ".", "Can", "be", "passed", "ar...
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/allows.py#L183-L219
[ "def", "run", "(", "self", ",", "requirements", ",", "identity", "=", "None", ",", "throws", "=", "None", ",", "on_fail", "=", "None", ",", "f_args", "=", "(", ")", ",", "f_kwargs", "=", "ImmutableDict", "(", ")", ",", "# noqa: B008", "use_on_fail_return...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
OverrideManager.push
Binds an override to the current context, optionally use the current overrides in conjunction with this override If ``use_parent`` is true, a new override is created from the parent and child overrides rather than manipulating either directly.
src/flask_allows/overrides.py
def push(self, override, use_parent=False): """ Binds an override to the current context, optionally use the current overrides in conjunction with this override If ``use_parent`` is true, a new override is created from the parent and child overrides rather than manipulating eith...
def push(self, override, use_parent=False): """ Binds an override to the current context, optionally use the current overrides in conjunction with this override If ``use_parent`` is true, a new override is created from the parent and child overrides rather than manipulating eith...
[ "Binds", "an", "override", "to", "the", "current", "context", "optionally", "use", "the", "current", "overrides", "in", "conjunction", "with", "this", "override" ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/overrides.py#L141-L154
[ "def", "push", "(", "self", ",", "override", ",", "use_parent", "=", "False", ")", ":", "current", "=", "self", ".", "current", "if", "use_parent", "and", "current", ":", "override", "=", "current", "+", "override", "_override_ctx_stack", ".", "push", "(",...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
OverrideManager.pop
Pops the latest override context. If the override context was pushed by a different override manager, a ``RuntimeError`` is raised.
src/flask_allows/overrides.py
def pop(self): """ Pops the latest override context. If the override context was pushed by a different override manager, a ``RuntimeError`` is raised. """ rv = _override_ctx_stack.pop() if rv is None or rv[0] is not self: raise RuntimeError( ...
def pop(self): """ Pops the latest override context. If the override context was pushed by a different override manager, a ``RuntimeError`` is raised. """ rv = _override_ctx_stack.pop() if rv is None or rv[0] is not self: raise RuntimeError( ...
[ "Pops", "the", "latest", "override", "context", "." ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/overrides.py#L156-L167
[ "def", "pop", "(", "self", ")", ":", "rv", "=", "_override_ctx_stack", ".", "pop", "(", ")", "if", "rv", "is", "None", "or", "rv", "[", "0", "]", "is", "not", "self", ":", "raise", "RuntimeError", "(", "\"popped wrong override context ({} instead of {})\"", ...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
OverrideManager.override
Allows temporarily pushing an override context, yields the new context into the following block.
src/flask_allows/overrides.py
def override(self, override, use_parent=False): """ Allows temporarily pushing an override context, yields the new context into the following block. """ self.push(override, use_parent) yield self.current self.pop()
def override(self, override, use_parent=False): """ Allows temporarily pushing an override context, yields the new context into the following block. """ self.push(override, use_parent) yield self.current self.pop()
[ "Allows", "temporarily", "pushing", "an", "override", "context", "yields", "the", "new", "context", "into", "the", "following", "block", "." ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/overrides.py#L180-L187
[ "def", "override", "(", "self", ",", "override", ",", "use_parent", "=", "False", ")", ":", "self", ".", "push", "(", "override", ",", "use_parent", ")", "yield", "self", ".", "current", "self", ".", "pop", "(", ")" ]
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
AdditionalManager.push
Binds an additional to the current context, optionally use the current additionals in conjunction with this additional If ``use_parent`` is true, a new additional is created from the parent and child additionals rather than manipulating either directly.
src/flask_allows/additional.py
def push(self, additional, use_parent=False): """ Binds an additional to the current context, optionally use the current additionals in conjunction with this additional If ``use_parent`` is true, a new additional is created from the parent and child additionals rather than manip...
def push(self, additional, use_parent=False): """ Binds an additional to the current context, optionally use the current additionals in conjunction with this additional If ``use_parent`` is true, a new additional is created from the parent and child additionals rather than manip...
[ "Binds", "an", "additional", "to", "the", "current", "context", "optionally", "use", "the", "current", "additionals", "in", "conjunction", "with", "this", "additional" ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/additional.py#L139-L152
[ "def", "push", "(", "self", ",", "additional", ",", "use_parent", "=", "False", ")", ":", "current", "=", "self", ".", "current", "if", "use_parent", "and", "current", ":", "additional", "=", "current", "+", "additional", "_additional_ctx_stack", ".", "push"...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
AdditionalManager.pop
Pops the latest additional context. If the additional context was pushed by a different additional manager, a ``RuntimeError`` is raised.
src/flask_allows/additional.py
def pop(self): """ Pops the latest additional context. If the additional context was pushed by a different additional manager, a ``RuntimeError`` is raised. """ rv = _additional_ctx_stack.pop() if rv is None or rv[0] is not self: raise RuntimeError( ...
def pop(self): """ Pops the latest additional context. If the additional context was pushed by a different additional manager, a ``RuntimeError`` is raised. """ rv = _additional_ctx_stack.pop() if rv is None or rv[0] is not self: raise RuntimeError( ...
[ "Pops", "the", "latest", "additional", "context", "." ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/additional.py#L154-L165
[ "def", "pop", "(", "self", ")", ":", "rv", "=", "_additional_ctx_stack", ".", "pop", "(", ")", "if", "rv", "is", "None", "or", "rv", "[", "0", "]", "is", "not", "self", ":", "raise", "RuntimeError", "(", "\"popped wrong additional context ({} instead of {})\...
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
AdditionalManager.additional
Allows temporarily pushing an additional context, yields the new context into the following block.
src/flask_allows/additional.py
def additional(self, additional, use_parent=False): """ Allows temporarily pushing an additional context, yields the new context into the following block. """ self.push(additional, use_parent) yield self.current self.pop()
def additional(self, additional, use_parent=False): """ Allows temporarily pushing an additional context, yields the new context into the following block. """ self.push(additional, use_parent) yield self.current self.pop()
[ "Allows", "temporarily", "pushing", "an", "additional", "context", "yields", "the", "new", "context", "into", "the", "following", "block", "." ]
justanr/flask-allows
python
https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/additional.py#L178-L185
[ "def", "additional", "(", "self", ",", "additional", ",", "use_parent", "=", "False", ")", ":", "self", ".", "push", "(", "additional", ",", "use_parent", ")", "yield", "self", ".", "current", "self", ".", "pop", "(", ")" ]
39fa5c8692836a33646ea43b4081e7c2181ec7c4
test
unduplicate_field_names
Append a number to duplicate field names to make them unique.
src/cypher/run.py
def unduplicate_field_names(field_names): """Append a number to duplicate field names to make them unique. """ res = [] for k in field_names: if k in res: i = 1 while k + '_' + str(i) in res: i += 1 k += '_' + str(i) res.append(k) retur...
def unduplicate_field_names(field_names): """Append a number to duplicate field names to make them unique. """ res = [] for k in field_names: if k in res: i = 1 while k + '_' + str(i) in res: i += 1 k += '_' + str(i) res.append(k) retur...
[ "Append", "a", "number", "to", "duplicate", "field", "names", "to", "make", "them", "unique", "." ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L35-L45
[ "def", "unduplicate_field_names", "(", "field_names", ")", ":", "res", "=", "[", "]", "for", "k", "in", "field_names", ":", "if", "k", "in", "res", ":", "i", "=", "1", "while", "k", "+", "'_'", "+", "str", "(", "i", ")", "in", "res", ":", "i", ...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
interpret_stats
Generates the string to be shown as updates after the execution of a Cypher query :param results: ``ResultSet`` with the raw results of the execution of the Cypher query
src/cypher/run.py
def interpret_stats(results): """Generates the string to be shown as updates after the execution of a Cypher query :param results: ``ResultSet`` with the raw results of the execution of the Cypher query """ stats = results.stats contains_updates = stats.pop("contains_updates...
def interpret_stats(results): """Generates the string to be shown as updates after the execution of a Cypher query :param results: ``ResultSet`` with the raw results of the execution of the Cypher query """ stats = results.stats contains_updates = stats.pop("contains_updates...
[ "Generates", "the", "string", "to", "be", "shown", "as", "updates", "after", "the", "execution", "of", "a", "Cypher", "query" ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L450-L467
[ "def", "interpret_stats", "(", "results", ")", ":", "stats", "=", "results", ".", "stats", "contains_updates", "=", "stats", ".", "pop", "(", "\"contains_updates\"", ",", "False", ")", "if", "stats", "else", "False", "if", "not", "contains_updates", ":", "re...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
extract_params_from_query
Generates a dictionary with safe keys and values to pass onto Neo4j :param query: string with the Cypher query to execute :param user_ns: dictionary with the IPython user space
src/cypher/run.py
def extract_params_from_query(query, user_ns): """Generates a dictionary with safe keys and values to pass onto Neo4j :param query: string with the Cypher query to execute :param user_ns: dictionary with the IPython user space """ # TODO: Optmize this function params = {} for k, v in user_n...
def extract_params_from_query(query, user_ns): """Generates a dictionary with safe keys and values to pass onto Neo4j :param query: string with the Cypher query to execute :param user_ns: dictionary with the IPython user space """ # TODO: Optmize this function params = {} for k, v in user_n...
[ "Generates", "a", "dictionary", "with", "safe", "keys", "and", "values", "to", "pass", "onto", "Neo4j" ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L470-L484
[ "def", "extract_params_from_query", "(", "query", ",", "user_ns", ")", ":", "# TODO: Optmize this function", "params", "=", "{", "}", "for", "k", ",", "v", "in", "user_ns", ".", "items", "(", ")", ":", "try", ":", "json", ".", "dumps", "(", "v", ")", "...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
run
Executes a query and depending on the options of the extensions will return raw data, a ``ResultSet``, a Pandas ``DataFrame`` or a NetworkX graph. :param query: string with the Cypher query :param params: dictionary with parameters for the query (default=``None``) :param config: Configurable or Nam...
src/cypher/run.py
def run(query, params=None, config=None, conn=None, **kwargs): """Executes a query and depending on the options of the extensions will return raw data, a ``ResultSet``, a Pandas ``DataFrame`` or a NetworkX graph. :param query: string with the Cypher query :param params: dictionary with parameters f...
def run(query, params=None, config=None, conn=None, **kwargs): """Executes a query and depending on the options of the extensions will return raw data, a ``ResultSet``, a Pandas ``DataFrame`` or a NetworkX graph. :param query: string with the Cypher query :param params: dictionary with parameters f...
[ "Executes", "a", "query", "and", "depending", "on", "the", "options", "of", "the", "extensions", "will", "return", "raw", "data", "a", "ResultSet", "a", "Pandas", "DataFrame", "or", "a", "NetworkX", "graph", "." ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L487-L529
[ "def", "run", "(", "query", ",", "params", "=", "None", ",", "config", "=", "None", ",", "conn", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "if", "conn", "is", "None", ":", "conn"...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
ResultSet.get_dataframe
Returns a Pandas DataFrame instance built from the result set.
src/cypher/run.py
def get_dataframe(self): """Returns a Pandas DataFrame instance built from the result set.""" if pd is None: raise ImportError("Try installing Pandas first.") frame = pd.DataFrame(self[:], columns=(self and self.keys) or []) return frame
def get_dataframe(self): """Returns a Pandas DataFrame instance built from the result set.""" if pd is None: raise ImportError("Try installing Pandas first.") frame = pd.DataFrame(self[:], columns=(self and self.keys) or []) return frame
[ "Returns", "a", "Pandas", "DataFrame", "instance", "built", "from", "the", "result", "set", "." ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L175-L180
[ "def", "get_dataframe", "(", "self", ")", ":", "if", "pd", "is", "None", ":", "raise", "ImportError", "(", "\"Try installing Pandas first.\"", ")", "frame", "=", "pd", ".", "DataFrame", "(", "self", "[", ":", "]", ",", "columns", "=", "(", "self", "and",...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
ResultSet.get_graph
Returns a NetworkX multi-graph instance built from the result set :param directed: boolean, optional (default=`True`). Whether to create a direted or an undirected graph.
src/cypher/run.py
def get_graph(self, directed=True): """Returns a NetworkX multi-graph instance built from the result set :param directed: boolean, optional (default=`True`). Whether to create a direted or an undirected graph. """ if nx is None: raise ImportError("Try installing ...
def get_graph(self, directed=True): """Returns a NetworkX multi-graph instance built from the result set :param directed: boolean, optional (default=`True`). Whether to create a direted or an undirected graph. """ if nx is None: raise ImportError("Try installing ...
[ "Returns", "a", "NetworkX", "multi", "-", "graph", "instance", "built", "from", "the", "result", "set" ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L188-L213
[ "def", "get_graph", "(", "self", ",", "directed", "=", "True", ")", ":", "if", "nx", "is", "None", ":", "raise", "ImportError", "(", "\"Try installing NetworkX first.\"", ")", "if", "directed", ":", "graph", "=", "nx", ".", "MultiDiGraph", "(", ")", "else"...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
ResultSet.draw
Plot of a NetworkX multi-graph instance :param directed: boolean, optional (default=`True`). Whether to return a directed graph or not. :param layout: string, optional (default=`"spring"`). Layout to apply. Any of the possible NetworkX layouts will work: ``'circular_...
src/cypher/run.py
def draw(self, directed=True, layout="spring", node_label_attr=None, show_node_labels=True, edge_label_attr=None, show_edge_labels=True, node_size=1600, node_color='blue', node_alpha=0.3, node_text_size=12, edge_color='blue', edge_alpha=0.3, edge_tickness...
def draw(self, directed=True, layout="spring", node_label_attr=None, show_node_labels=True, edge_label_attr=None, show_edge_labels=True, node_size=1600, node_color='blue', node_alpha=0.3, node_text_size=12, edge_color='blue', edge_alpha=0.3, edge_tickness...
[ "Plot", "of", "a", "NetworkX", "multi", "-", "graph", "instance" ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L221-L339
[ "def", "draw", "(", "self", ",", "directed", "=", "True", ",", "layout", "=", "\"spring\"", ",", "node_label_attr", "=", "None", ",", "show_node_labels", "=", "True", ",", "edge_label_attr", "=", "None", ",", "show_edge_labels", "=", "True", ",", "node_size"...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
ResultSet.pie
Generates a pylab pie chart from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline Values (pie slice sizes) are taken from the rightmost column (numerical values required). All other columns are ...
src/cypher/run.py
def pie(self, key_word_sep=" ", title=None, **kwargs): """Generates a pylab pie chart from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline Values (pie slice sizes) are taken from the rightmost ...
def pie(self, key_word_sep=" ", title=None, **kwargs): """Generates a pylab pie chart from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline Values (pie slice sizes) are taken from the rightmost ...
[ "Generates", "a", "pylab", "pie", "chart", "from", "the", "result", "set", "." ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L341-L364
[ "def", "pie", "(", "self", ",", "key_word_sep", "=", "\" \"", ",", "title", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "plt", ":", "raise", "ImportError", "(", "\"Try installing matplotlib first.\"", ")", "self", ".", "guess_pie_columns", ...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
ResultSet.plot
Generates a pylab plot from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline The first and last columns are taken as the X and Y values. Any columns between are ignored. :param title: plot tit...
src/cypher/run.py
def plot(self, title=None, **kwargs): """Generates a pylab plot from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline The first and last columns are taken as the X and Y values. Any columns bet...
def plot(self, title=None, **kwargs): """Generates a pylab plot from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline The first and last columns are taken as the X and Y values. Any columns bet...
[ "Generates", "a", "pylab", "plot", "from", "the", "result", "set", "." ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L366-L393
[ "def", "plot", "(", "self", ",", "title", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "plt", ":", "raise", "ImportError", "(", "\"Try installing matplotlib first.\"", ")", "self", ".", "guess_plot_columns", "(", ")", "self", ".", "x", "=...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
ResultSet.bar
Generates a pylab bar plot from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline The last quantitative column is taken as the Y values; all other columns are combined to label the X axis. :para...
src/cypher/run.py
def bar(self, key_word_sep=" ", title=None, **kwargs): """Generates a pylab bar plot from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline The last quantitative column is taken as the Y values; ...
def bar(self, key_word_sep=" ", title=None, **kwargs): """Generates a pylab bar plot from the result set. ``matplotlib`` must be installed, and in an IPython Notebook, inlining must be on:: %%matplotlib inline The last quantitative column is taken as the Y values; ...
[ "Generates", "a", "pylab", "bar", "plot", "from", "the", "result", "set", "." ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L395-L422
[ "def", "bar", "(", "self", ",", "key_word_sep", "=", "\" \"", ",", "title", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "plt", ":", "raise", "ImportError", "(", "\"Try installing matplotlib first.\"", ")", "self", ".", "guess_pie_columns", ...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
ResultSet.csv
Generates results in comma-separated form. Write to ``filename`` if given. Any other parameter will be passed on to ``csv.writer``. :param filename: if given, the CSV will be written to filename. Any additional keyword arguments will be passsed through to ``csv.writer``.
src/cypher/run.py
def csv(self, filename=None, **format_params): """Generates results in comma-separated form. Write to ``filename`` if given. Any other parameter will be passed on to ``csv.writer``. :param filename: if given, the CSV will be written to filename. Any additional keyword arguments will b...
def csv(self, filename=None, **format_params): """Generates results in comma-separated form. Write to ``filename`` if given. Any other parameter will be passed on to ``csv.writer``. :param filename: if given, the CSV will be written to filename. Any additional keyword arguments will b...
[ "Generates", "results", "in", "comma", "-", "separated", "form", ".", "Write", "to", "filename", "if", "given", ".", "Any", "other", "parameter", "will", "be", "passed", "on", "to", "csv", ".", "writer", "." ]
versae/ipython-cypher
python
https://github.com/versae/ipython-cypher/blob/1e88bd8227743e70b78af42e0e713ae8803485e1/src/cypher/run.py#L424-L447
[ "def", "csv", "(", "self", ",", "filename", "=", "None", ",", "*", "*", "format_params", ")", ":", "if", "not", "self", ".", "pretty", ":", "return", "None", "# no results", "if", "filename", ":", "outfile", "=", "open", "(", "filename", ",", "'w'", ...
1e88bd8227743e70b78af42e0e713ae8803485e1
test
permission_required
Re-implementation of the permission_required decorator, honors settings. If ``DASHBOARD_REQUIRE_LOGIN`` is False, this decorator will always return ``True``, otherwise it will check for the permission as usual.
dashboard_app/decorators.py
def permission_required(perm, login_url=None, raise_exception=False): """ Re-implementation of the permission_required decorator, honors settings. If ``DASHBOARD_REQUIRE_LOGIN`` is False, this decorator will always return ``True``, otherwise it will check for the permission as usual. """ def c...
def permission_required(perm, login_url=None, raise_exception=False): """ Re-implementation of the permission_required decorator, honors settings. If ``DASHBOARD_REQUIRE_LOGIN`` is False, this decorator will always return ``True``, otherwise it will check for the permission as usual. """ def c...
[ "Re", "-", "implementation", "of", "the", "permission_required", "decorator", "honors", "settings", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/decorators.py#L11-L31
[ "def", "permission_required", "(", "perm", ",", "login_url", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "def", "check_perms", "(", "user", ")", ":", "if", "not", "getattr", "(", "settings", ",", "'DASHBOARD_REQUIRE_LOGIN'", ",", "app_settings...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
RenderWidgetMixin.get_context_data
Adds ``is_rendered`` to the context and the widget's context data. ``is_rendered`` signals that the AJAX view has been called and that we are displaying the full widget now. When ``is_rendered`` is not found in the widget template it means that we are seeing the first page load and all ...
dashboard_app/view_mixins.py
def get_context_data(self, **kwargs): """ Adds ``is_rendered`` to the context and the widget's context data. ``is_rendered`` signals that the AJAX view has been called and that we are displaying the full widget now. When ``is_rendered`` is not found in the widget template it mea...
def get_context_data(self, **kwargs): """ Adds ``is_rendered`` to the context and the widget's context data. ``is_rendered`` signals that the AJAX view has been called and that we are displaying the full widget now. When ``is_rendered`` is not found in the widget template it mea...
[ "Adds", "is_rendered", "to", "the", "context", "and", "the", "widget", "s", "context", "data", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/view_mixins.py#L44-L61
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "super", "(", "RenderWidgetMixin", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "ctx", ".", "update", "(", "{", "'is_rendered'", ":", "Tr...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetPool.get_widgets_sorted
Returns the widgets sorted by position.
dashboard_app/widget_pool.py
def get_widgets_sorted(self): """Returns the widgets sorted by position.""" result = [] for widget_name, widget in self.get_widgets().items(): result.append((widget_name, widget, widget.position)) result.sort(key=lambda x: x[2]) return result
def get_widgets_sorted(self): """Returns the widgets sorted by position.""" result = [] for widget_name, widget in self.get_widgets().items(): result.append((widget_name, widget, widget.position)) result.sort(key=lambda x: x[2]) return result
[ "Returns", "the", "widgets", "sorted", "by", "position", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_pool.py#L44-L50
[ "def", "get_widgets_sorted", "(", "self", ")", ":", "result", "=", "[", "]", "for", "widget_name", ",", "widget", "in", "self", ".", "get_widgets", "(", ")", ".", "items", "(", ")", ":", "result", ".", "append", "(", "(", "widget_name", ",", "widget", ...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetPool.get_widgets_that_need_update
Returns all widgets that need an update. This should be scheduled every minute via crontab.
dashboard_app/widget_pool.py
def get_widgets_that_need_update(self): """ Returns all widgets that need an update. This should be scheduled every minute via crontab. """ result = [] for widget_name, widget in self.get_widgets().items(): if widget.should_update(): result.a...
def get_widgets_that_need_update(self): """ Returns all widgets that need an update. This should be scheduled every minute via crontab. """ result = [] for widget_name, widget in self.get_widgets().items(): if widget.should_update(): result.a...
[ "Returns", "all", "widgets", "that", "need", "an", "update", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_pool.py#L56-L67
[ "def", "get_widgets_that_need_update", "(", "self", ")", ":", "result", "=", "[", "]", "for", "widget_name", ",", "widget", "in", "self", ".", "get_widgets", "(", ")", ".", "items", "(", ")", ":", "if", "widget", ".", "should_update", "(", ")", ":", "r...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetPool.register_widget
Registers the given widget. Widgets must inherit ``DashboardWidgetBase`` and you cannot register the same widget twice. :widget_cls: A class that inherits ``DashboardWidgetBase``.
dashboard_app/widget_pool.py
def register_widget(self, widget_cls, **widget_kwargs): """ Registers the given widget. Widgets must inherit ``DashboardWidgetBase`` and you cannot register the same widget twice. :widget_cls: A class that inherits ``DashboardWidgetBase``. """ if not issubclass...
def register_widget(self, widget_cls, **widget_kwargs): """ Registers the given widget. Widgets must inherit ``DashboardWidgetBase`` and you cannot register the same widget twice. :widget_cls: A class that inherits ``DashboardWidgetBase``. """ if not issubclass...
[ "Registers", "the", "given", "widget", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_pool.py#L69-L91
[ "def", "register_widget", "(", "self", ",", "widget_cls", ",", "*", "*", "widget_kwargs", ")", ":", "if", "not", "issubclass", "(", "widget_cls", ",", "DashboardWidgetBase", ")", ":", "raise", "ImproperlyConfigured", "(", "'DashboardWidgets must be subclasses of Dashb...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetPool.unregister_widget
Unregisters the given widget.
dashboard_app/widget_pool.py
def unregister_widget(self, widget_cls): """Unregisters the given widget.""" if widget_cls.__name__ in self.widgets: del self.widgets[widget_cls().get_name()]
def unregister_widget(self, widget_cls): """Unregisters the given widget.""" if widget_cls.__name__ in self.widgets: del self.widgets[widget_cls().get_name()]
[ "Unregisters", "the", "given", "widget", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_pool.py#L93-L96
[ "def", "unregister_widget", "(", "self", ",", "widget_cls", ")", ":", "if", "widget_cls", ".", "__name__", "in", "self", ".", "widgets", ":", "del", "self", ".", "widgets", "[", "widget_cls", "(", ")", ".", "get_name", "(", ")", "]" ]
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetBase.get_last_update
Gets or creates the last update object for this widget.
dashboard_app/widget_base.py
def get_last_update(self): """Gets or creates the last update object for this widget.""" instance, created = \ models.DashboardWidgetLastUpdate.objects.get_or_create( widget_name=self.get_name()) return instance
def get_last_update(self): """Gets or creates the last update object for this widget.""" instance, created = \ models.DashboardWidgetLastUpdate.objects.get_or_create( widget_name=self.get_name()) return instance
[ "Gets", "or", "creates", "the", "last", "update", "object", "for", "this", "widget", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_base.py#L32-L37
[ "def", "get_last_update", "(", "self", ")", ":", "instance", ",", "created", "=", "models", ".", "DashboardWidgetLastUpdate", ".", "objects", ".", "get_or_create", "(", "widget_name", "=", "self", ".", "get_name", "(", ")", ")", "return", "instance" ]
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetBase.get_setting
Returns the setting for this widget from the database. :setting_name: The name of the setting. :default: Optional default value if the setting cannot be found.
dashboard_app/widget_base.py
def get_setting(self, setting_name, default=None): """ Returns the setting for this widget from the database. :setting_name: The name of the setting. :default: Optional default value if the setting cannot be found. """ try: setting = models.DashboardWidgetSe...
def get_setting(self, setting_name, default=None): """ Returns the setting for this widget from the database. :setting_name: The name of the setting. :default: Optional default value if the setting cannot be found. """ try: setting = models.DashboardWidgetSe...
[ "Returns", "the", "setting", "for", "this", "widget", "from", "the", "database", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_base.py#L52-L66
[ "def", "get_setting", "(", "self", ",", "setting_name", ",", "default", "=", "None", ")", ":", "try", ":", "setting", "=", "models", ".", "DashboardWidgetSettings", ".", "objects", ".", "get", "(", "widget_name", "=", "self", ".", "get_name", "(", ")", "...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetBase.save_setting
Saves the setting value into the database.
dashboard_app/widget_base.py
def save_setting(self, setting_name, value): """Saves the setting value into the database.""" setting = self.get_setting(setting_name) if setting is None: setting = models.DashboardWidgetSettings.objects.create( widget_name=self.get_name(), setting_nam...
def save_setting(self, setting_name, value): """Saves the setting value into the database.""" setting = self.get_setting(setting_name) if setting is None: setting = models.DashboardWidgetSettings.objects.create( widget_name=self.get_name(), setting_nam...
[ "Saves", "the", "setting", "value", "into", "the", "database", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_base.py#L77-L87
[ "def", "save_setting", "(", "self", ",", "setting_name", ",", "value", ")", ":", "setting", "=", "self", ".", "get_setting", "(", "setting_name", ")", "if", "setting", "is", "None", ":", "setting", "=", "models", ".", "DashboardWidgetSettings", ".", "objects...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
DashboardWidgetBase.should_update
Checks if an update is needed. Checks against ``self.update_interval`` and this widgets ``DashboardWidgetLastUpdate`` instance if an update is overdue. This should be called by ``DashboardWidgetPool.get_widgets_that_need_update()``, which in turn should be called by an admin co...
dashboard_app/widget_base.py
def should_update(self): """ Checks if an update is needed. Checks against ``self.update_interval`` and this widgets ``DashboardWidgetLastUpdate`` instance if an update is overdue. This should be called by ``DashboardWidgetPool.get_widgets_that_need_update()``, which in...
def should_update(self): """ Checks if an update is needed. Checks against ``self.update_interval`` and this widgets ``DashboardWidgetLastUpdate`` instance if an update is overdue. This should be called by ``DashboardWidgetPool.get_widgets_that_need_update()``, which in...
[ "Checks", "if", "an", "update", "is", "needed", "." ]
bitlabstudio/django-dashboard-app
python
https://github.com/bitlabstudio/django-dashboard-app/blob/ed98f2bca91a4ced36d0dd1aa1baee78e989cf64/dashboard_app/widget_base.py#L94-L111
[ "def", "should_update", "(", "self", ")", ":", "last_update", "=", "self", ".", "get_last_update", "(", ")", "time_since", "=", "now", "(", ")", "-", "last_update", ".", "last_update", "if", "time_since", ".", "seconds", "<", "self", ".", "update_interval", ...
ed98f2bca91a4ced36d0dd1aa1baee78e989cf64
test
Pyzomato.getCityDetails
:param q: query by city name :param lat: latitude :param lon: longitude :param city_ids: comma separated city_id values :param count: number of max results to display Find the Zomato ID and other details for a city . You can obtain the Zomato City ID in one of the following ways...
pyzomato/pyzomato.py
def getCityDetails(self, **kwargs): """ :param q: query by city name :param lat: latitude :param lon: longitude :param city_ids: comma separated city_id values :param count: number of max results to display Find the Zomato ID and other details for a city . You ca...
def getCityDetails(self, **kwargs): """ :param q: query by city name :param lat: latitude :param lon: longitude :param city_ids: comma separated city_id values :param count: number of max results to display Find the Zomato ID and other details for a city . You ca...
[ ":", "param", "q", ":", "query", "by", "city", "name", ":", "param", "lat", ":", "latitude", ":", "param", "lon", ":", "longitude", ":", "param", "city_ids", ":", "comma", "separated", "city_id", "values", ":", "param", "count", ":", "number", "of", "m...
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L16-L35
[ "def", "getCityDetails", "(", "self", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "}", "available_keys", "=", "[", "\"q\"", ",", "\"lat\"", ",", "\"lon\"", ",", "\"city_ids\"", ",", "\"count\"", "]", "for", "key", "in", "available_keys", ":", ...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getCollectionsViaCityId
:param city_id: id of the city for which collections are needed :param lat: latitude :param lon: longitude :param count: number of max results to display Returns Zomato Restaurant Collections in a City. The location/City input can be provided in the following ways - Using Zomato...
pyzomato/pyzomato.py
def getCollectionsViaCityId(self, city_id, **kwargs): """ :param city_id: id of the city for which collections are needed :param lat: latitude :param lon: longitude :param count: number of max results to display Returns Zomato Restaurant Collections in a City. The locatio...
def getCollectionsViaCityId(self, city_id, **kwargs): """ :param city_id: id of the city for which collections are needed :param lat: latitude :param lon: longitude :param count: number of max results to display Returns Zomato Restaurant Collections in a City. The locatio...
[ ":", "param", "city_id", ":", "id", "of", "the", "city", "for", "which", "collections", "are", "needed", ":", "param", "lat", ":", "latitude", ":", "param", "lon", ":", "longitude", ":", "param", "count", ":", "number", "of", "max", "results", "to", "d...
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L37-L55
[ "def", "getCollectionsViaCityId", "(", "self", ",", "city_id", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"city_id\"", ":", "city_id", "}", "optional_params", "=", "[", "\"lat\"", ",", "\"lon\"", ",", "\"count\"", "]", "for", "key", "in", "...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getEstablishments
:param city_id: id of the city for which collections are needed :param lat: latitude :param lon: longitude Get a list of restaurant types in a city. The location/City input can be provided in the following ways - Using Zomato City ID - Using coordinates of any location within a c...
pyzomato/pyzomato.py
def getEstablishments(self, city_id, **kwargs): """ :param city_id: id of the city for which collections are needed :param lat: latitude :param lon: longitude Get a list of restaurant types in a city. The location/City input can be provided in the following ways - Using Z...
def getEstablishments(self, city_id, **kwargs): """ :param city_id: id of the city for which collections are needed :param lat: latitude :param lon: longitude Get a list of restaurant types in a city. The location/City input can be provided in the following ways - Using Z...
[ ":", "param", "city_id", ":", "id", "of", "the", "city", "for", "which", "collections", "are", "needed", ":", "param", "lat", ":", "latitude", ":", "param", "lon", ":", "longitude", "Get", "a", "list", "of", "restaurant", "types", "in", "a", "city", "....
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L79-L97
[ "def", "getEstablishments", "(", "self", ",", "city_id", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"city_id\"", ":", "city_id", "}", "optional_params", "=", "[", "\"lat\"", ",", "\"lon\"", "]", "for", "key", "in", "optional_params", ":", "...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getByGeocode
:param lat: latitude :param lon: longitude Get Foodie and Nightlife Index, list of popular cuisines and nearby restaurants around the given coordinates
pyzomato/pyzomato.py
def getByGeocode(self, lat, lon): """ :param lat: latitude :param lon: longitude Get Foodie and Nightlife Index, list of popular cuisines and nearby restaurants around the given coordinates """ params = {"lat": lat, "lon": lon} response = self.api.get("/geocode", ...
def getByGeocode(self, lat, lon): """ :param lat: latitude :param lon: longitude Get Foodie and Nightlife Index, list of popular cuisines and nearby restaurants around the given coordinates """ params = {"lat": lat, "lon": lon} response = self.api.get("/geocode", ...
[ ":", "param", "lat", ":", "latitude", ":", "param", "lon", ":", "longitude", "Get", "Foodie", "and", "Nightlife", "Index", "list", "of", "popular", "cuisines", "and", "nearby", "restaurants", "around", "the", "given", "coordinates" ]
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L99-L107
[ "def", "getByGeocode", "(", "self", ",", "lat", ",", "lon", ")", ":", "params", "=", "{", "\"lat\"", ":", "lat", ",", "\"lon\"", ":", "lon", "}", "response", "=", "self", ".", "api", ".", "get", "(", "\"/geocode\"", ",", "params", ")", "return", "r...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getLocationDetails
:param entity_id: location id obtained from locations api :param entity_type: location type obtained from locations api :return: Get Foodie Index, Nightlife Index, Top Cuisines and Best rated restaurants in a given location
pyzomato/pyzomato.py
def getLocationDetails(self, entity_id, entity_type): """ :param entity_id: location id obtained from locations api :param entity_type: location type obtained from locations api :return: Get Foodie Index, Nightlife Index, Top Cuisines and Best rated restaurants in a given locatio...
def getLocationDetails(self, entity_id, entity_type): """ :param entity_id: location id obtained from locations api :param entity_type: location type obtained from locations api :return: Get Foodie Index, Nightlife Index, Top Cuisines and Best rated restaurants in a given locatio...
[ ":", "param", "entity_id", ":", "location", "id", "obtained", "from", "locations", "api", ":", "param", "entity_type", ":", "location", "type", "obtained", "from", "locations", "api", ":", "return", ":", "Get", "Foodie", "Index", "Nightlife", "Index", "Top", ...
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L109-L118
[ "def", "getLocationDetails", "(", "self", ",", "entity_id", ",", "entity_type", ")", ":", "params", "=", "{", "\"entity_id\"", ":", "entity_id", ",", "\"entity_type\"", ":", "entity_type", "}", "location_details", "=", "self", ".", "api", ".", "get", "(", "\...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getLocations
:param query: suggestion for location name :param lat: latitude :param lon: longitude :param count: number of max results to display :return: json response Search for Zomato locations by keyword. Provide coordinates to get better search results
pyzomato/pyzomato.py
def getLocations(self, query, **kwargs): """ :param query: suggestion for location name :param lat: latitude :param lon: longitude :param count: number of max results to display :return: json response Search for Zomato locations by keyword. Provide coordinates to ...
def getLocations(self, query, **kwargs): """ :param query: suggestion for location name :param lat: latitude :param lon: longitude :param count: number of max results to display :return: json response Search for Zomato locations by keyword. Provide coordinates to ...
[ ":", "param", "query", ":", "suggestion", "for", "location", "name", ":", "param", "lat", ":", "latitude", ":", "param", "lon", ":", "longitude", ":", "param", "count", ":", "number", "of", "max", "results", "to", "display", ":", "return", ":", "json", ...
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L120-L136
[ "def", "getLocations", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"query\"", ":", "query", "}", "optional_params", "=", "[", "\"lat\"", ",", "\"lon\"", ",", "\"count\"", "]", "for", "key", "in", "optional_params",...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getDailyMenu
:param restaurant_id: id of restaurant whose details are requested :return: json response Get daily menu using Zomato restaurant ID.
pyzomato/pyzomato.py
def getDailyMenu(self, restaurant_id): """ :param restaurant_id: id of restaurant whose details are requested :return: json response Get daily menu using Zomato restaurant ID. """ params = {"res_id": restaurant_id} daily_menu = self.api.get("/dailymenu", params) ...
def getDailyMenu(self, restaurant_id): """ :param restaurant_id: id of restaurant whose details are requested :return: json response Get daily menu using Zomato restaurant ID. """ params = {"res_id": restaurant_id} daily_menu = self.api.get("/dailymenu", params) ...
[ ":", "param", "restaurant_id", ":", "id", "of", "restaurant", "whose", "details", "are", "requested", ":", "return", ":", "json", "response", "Get", "daily", "menu", "using", "Zomato", "restaurant", "ID", "." ]
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L138-L146
[ "def", "getDailyMenu", "(", "self", ",", "restaurant_id", ")", ":", "params", "=", "{", "\"res_id\"", ":", "restaurant_id", "}", "daily_menu", "=", "self", ".", "api", ".", "get", "(", "\"/dailymenu\"", ",", "params", ")", "return", "daily_menu" ]
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getRestaurantDetails
:param restaurant_id: id of restaurant whose details are requested :return: json response Get detailed restaurant information using Zomato restaurant ID. Partner Access is required to access photos and reviews.
pyzomato/pyzomato.py
def getRestaurantDetails(self, restaurant_id): """ :param restaurant_id: id of restaurant whose details are requested :return: json response Get detailed restaurant information using Zomato restaurant ID. Partner Access is required to access photos and reviews. """ ...
def getRestaurantDetails(self, restaurant_id): """ :param restaurant_id: id of restaurant whose details are requested :return: json response Get detailed restaurant information using Zomato restaurant ID. Partner Access is required to access photos and reviews. """ ...
[ ":", "param", "restaurant_id", ":", "id", "of", "restaurant", "whose", "details", "are", "requested", ":", "return", ":", "json", "response", "Get", "detailed", "restaurant", "information", "using", "Zomato", "restaurant", "ID", ".", "Partner", "Access", "is", ...
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L148-L157
[ "def", "getRestaurantDetails", "(", "self", ",", "restaurant_id", ")", ":", "params", "=", "{", "\"res_id\"", ":", "restaurant_id", "}", "restaurant_details", "=", "self", ".", "api", ".", "get", "(", "\"/restaurant\"", ",", "params", ")", "return", "restauran...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.getRestaurantReviews
:param restaurant_id: id of restaurant whose details are requested :param start: fetch results after this offset :param count: max number of results to retrieve :return: json response Get restaurant reviews using the Zomato restaurant ID
pyzomato/pyzomato.py
def getRestaurantReviews(self, restaurant_id, **kwargs): """ :param restaurant_id: id of restaurant whose details are requested :param start: fetch results after this offset :param count: max number of results to retrieve :return: json response Get restaurant reviews usin...
def getRestaurantReviews(self, restaurant_id, **kwargs): """ :param restaurant_id: id of restaurant whose details are requested :param start: fetch results after this offset :param count: max number of results to retrieve :return: json response Get restaurant reviews usin...
[ ":", "param", "restaurant_id", ":", "id", "of", "restaurant", "whose", "details", "are", "requested", ":", "param", "start", ":", "fetch", "results", "after", "this", "offset", ":", "param", "count", ":", "max", "number", "of", "results", "to", "retrieve", ...
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L159-L174
[ "def", "getRestaurantReviews", "(", "self", ",", "restaurant_id", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"res_id\"", ":", "restaurant_id", "}", "optional_params", "=", "[", "\"start\"", ",", "\"count\"", "]", "for", "key", "in", "optional_p...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
Pyzomato.search
:param entity_id: location id :param entity_type: location type (city, subzone, zone, lanmark, metro , group) :param q: search keyword :param start: fetch results after offset :param count: max number of results to display :param lat: latitude :param lon: longitude ...
pyzomato/pyzomato.py
def search(self, **kwargs): """ :param entity_id: location id :param entity_type: location type (city, subzone, zone, lanmark, metro , group) :param q: search keyword :param start: fetch results after offset :param count: max number of results to display :param la...
def search(self, **kwargs): """ :param entity_id: location id :param entity_type: location type (city, subzone, zone, lanmark, metro , group) :param q: search keyword :param start: fetch results after offset :param count: max number of results to display :param la...
[ ":", "param", "entity_id", ":", "location", "id", ":", "param", "entity_type", ":", "location", "type", "(", "city", "subzone", "zone", "lanmark", "metro", "group", ")", ":", "param", "q", ":", "search", "keyword", ":", "param", "start", ":", "fetch", "r...
fatihsucu/pyzomato
python
https://github.com/fatihsucu/pyzomato/blob/91c805bac8a49c808d497b7b0b6222a48f2d1324/pyzomato/pyzomato.py#L176-L217
[ "def", "search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "}", "available_params", "=", "[", "\"entity_id\"", ",", "\"entity_type\"", ",", "\"q\"", ",", "\"start\"", ",", "\"count\"", ",", "\"lat\"", ",", "\"lon\"", ",", "\"rad...
91c805bac8a49c808d497b7b0b6222a48f2d1324
test
ConstructSpark.array
Create a spark bolt array from a local array. Parameters ---------- a : array-like An array, any object exposing the array interface, an object whose __array__ method returns an array, or any (nested) sequence. context : SparkContext A co...
bolt/spark/construct.py
def array(a, context=None, axis=(0,), dtype=None, npartitions=None): """ Create a spark bolt array from a local array. Parameters ---------- a : array-like An array, any object exposing the array interface, an object whose __array__ method returns an arra...
def array(a, context=None, axis=(0,), dtype=None, npartitions=None): """ Create a spark bolt array from a local array. Parameters ---------- a : array-like An array, any object exposing the array interface, an object whose __array__ method returns an arra...
[ "Create", "a", "spark", "bolt", "array", "from", "a", "local", "array", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/construct.py#L13-L70
[ "def", "array", "(", "a", ",", "context", "=", "None", ",", "axis", "=", "(", "0", ",", ")", ",", "dtype", "=", "None", ",", "npartitions", "=", "None", ")", ":", "if", "dtype", "is", "None", ":", "arry", "=", "asarray", "(", "a", ")", "dtype",...
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructSpark.ones
Create a spark bolt array of ones. Parameters ---------- shape : tuple The desired shape of the array. context : SparkContext A context running Spark. (see pyspark) axis : tuple, optional, default=(0,) Which axes to distribute the array alon...
bolt/spark/construct.py
def ones(shape, context=None, axis=(0,), dtype=float64, npartitions=None): """ Create a spark bolt array of ones. Parameters ---------- shape : tuple The desired shape of the array. context : SparkContext A context running Spark. (see pyspark) ...
def ones(shape, context=None, axis=(0,), dtype=float64, npartitions=None): """ Create a spark bolt array of ones. Parameters ---------- shape : tuple The desired shape of the array. context : SparkContext A context running Spark. (see pyspark) ...
[ "Create", "a", "spark", "bolt", "array", "of", "ones", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/construct.py#L73-L102
[ "def", "ones", "(", "shape", ",", "context", "=", "None", ",", "axis", "=", "(", "0", ",", ")", ",", "dtype", "=", "float64", ",", "npartitions", "=", "None", ")", ":", "from", "numpy", "import", "ones", "return", "ConstructSpark", ".", "_wrap", "(",...
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructSpark.concatenate
Join two bolt arrays together, at least one of which is in spark. Parameters ---------- arrays : tuple A pair of arrays. At least one must be a spark array, the other can be a local bolt array, a local numpy array, or an array-like. axis : int, optio...
bolt/spark/construct.py
def concatenate(arrays, axis=0): """ Join two bolt arrays together, at least one of which is in spark. Parameters ---------- arrays : tuple A pair of arrays. At least one must be a spark array, the other can be a local bolt array, a local numpy array, ...
def concatenate(arrays, axis=0): """ Join two bolt arrays together, at least one of which is in spark. Parameters ---------- arrays : tuple A pair of arrays. At least one must be a spark array, the other can be a local bolt array, a local numpy array, ...
[ "Join", "two", "bolt", "arrays", "together", "at", "least", "one", "of", "which", "is", "in", "spark", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/construct.py#L137-L167
[ "def", "concatenate", "(", "arrays", ",", "axis", "=", "0", ")", ":", "if", "not", "isinstance", "(", "arrays", ",", "tuple", ")", ":", "raise", "ValueError", "(", "\"data type not understood\"", ")", "if", "not", "len", "(", "arrays", ")", "==", "2", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructSpark._argcheck
Check that arguments are consistent with spark array construction. Conditions are: (1) a positional argument is a SparkContext (2) keyword arg 'context' is a SparkContext (3) an argument is a BoltArraySpark, or (4) an argument is a nested list containing a BoltArraySpark
bolt/spark/construct.py
def _argcheck(*args, **kwargs): """ Check that arguments are consistent with spark array construction. Conditions are: (1) a positional argument is a SparkContext (2) keyword arg 'context' is a SparkContext (3) an argument is a BoltArraySpark, or (4) an argument ...
def _argcheck(*args, **kwargs): """ Check that arguments are consistent with spark array construction. Conditions are: (1) a positional argument is a SparkContext (2) keyword arg 'context' is a SparkContext (3) an argument is a BoltArraySpark, or (4) an argument ...
[ "Check", "that", "arguments", "are", "consistent", "with", "spark", "array", "construction", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/construct.py#L170-L190
[ "def", "_argcheck", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "from", "pyspark", "import", "SparkContext", "except", "ImportError", ":", "return", "False", "cond1", "=", "any", "(", "[", "isinstance", "(", "arg", ",", "SparkContext...
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructSpark._format_axes
Format target axes given an array shape
bolt/spark/construct.py
def _format_axes(axes, shape): """ Format target axes given an array shape """ if isinstance(axes, int): axes = (axes,) elif isinstance(axes, list) or hasattr(axes, '__iter__'): axes = tuple(axes) if not isinstance(axes, tuple): raise V...
def _format_axes(axes, shape): """ Format target axes given an array shape """ if isinstance(axes, int): axes = (axes,) elif isinstance(axes, list) or hasattr(axes, '__iter__'): axes = tuple(axes) if not isinstance(axes, tuple): raise V...
[ "Format", "target", "axes", "given", "an", "array", "shape" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/construct.py#L193-L205
[ "def", "_format_axes", "(", "axes", ",", "shape", ")", ":", "if", "isinstance", "(", "axes", ",", "int", ")", ":", "axes", "=", "(", "axes", ",", ")", "elif", "isinstance", "(", "axes", ",", "list", ")", "or", "hasattr", "(", "axes", ",", "'__iter_...
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructSpark._wrap
Wrap an existing numpy constructor in a parallelized construction
bolt/spark/construct.py
def _wrap(func, shape, context=None, axis=(0,), dtype=None, npartitions=None): """ Wrap an existing numpy constructor in a parallelized construction """ if isinstance(shape, int): shape = (shape,) key_shape, value_shape = get_kv_shape(shape, ConstructSpark._format_axe...
def _wrap(func, shape, context=None, axis=(0,), dtype=None, npartitions=None): """ Wrap an existing numpy constructor in a parallelized construction """ if isinstance(shape, int): shape = (shape,) key_shape, value_shape = get_kv_shape(shape, ConstructSpark._format_axe...
[ "Wrap", "an", "existing", "numpy", "constructor", "in", "a", "parallelized", "construction" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/construct.py#L208-L222
[ "def", "_wrap", "(", "func", ",", "shape", ",", "context", "=", "None", ",", "axis", "=", "(", "0", ",", ")", ",", "dtype", "=", "None", ",", "npartitions", "=", "None", ")", ":", "if", "isinstance", "(", "shape", ",", "int", ")", ":", "shape", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArrayLocal._align
Align local bolt array so that axes for iteration are in the keys. This operation is applied before most functional operators. It ensures that the specified axes are valid, and might transpose/reshape the underlying array so that the functional operators can be applied over the correct ...
bolt/local/array.py
def _align(self, axes, key_shape=None): """ Align local bolt array so that axes for iteration are in the keys. This operation is applied before most functional operators. It ensures that the specified axes are valid, and might transpose/reshape the underlying array so that the f...
def _align(self, axes, key_shape=None): """ Align local bolt array so that axes for iteration are in the keys. This operation is applied before most functional operators. It ensures that the specified axes are valid, and might transpose/reshape the underlying array so that the f...
[ "Align", "local", "bolt", "array", "so", "that", "axes", "for", "iteration", "are", "in", "the", "keys", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/array.py#L30-L64
[ "def", "_align", "(", "self", ",", "axes", ",", "key_shape", "=", "None", ")", ":", "# ensure that the key axes are valid for an ndarray of this shape", "inshape", "(", "self", ".", "shape", ",", "axes", ")", "# compute the set of dimensions/axes that will be used to reshap...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArrayLocal.filter
Filter array along an axis. Applies a function which should evaluate to boolean, along a single axis or multiple axes. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape. Parameters ---------- func : func...
bolt/local/array.py
def filter(self, func, axis=(0,)): """ Filter array along an axis. Applies a function which should evaluate to boolean, along a single axis or multiple axes. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape. ...
def filter(self, func, axis=(0,)): """ Filter array along an axis. Applies a function which should evaluate to boolean, along a single axis or multiple axes. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape. ...
[ "Filter", "array", "along", "an", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/array.py#L66-L92
[ "def", "filter", "(", "self", ",", "func", ",", "axis", "=", "(", "0", ",", ")", ")", ":", "axes", "=", "sorted", "(", "tupleize", "(", "axis", ")", ")", "reshaped", "=", "self", ".", "_align", "(", "axes", ")", "filtered", "=", "asarray", "(", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArrayLocal.map
Apply a function across an axis. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape. Parameters ---------- func : function Function of a single array to apply axis : tuple or int, optional, default=(...
bolt/local/array.py
def map(self, func, axis=(0,)): """ Apply a function across an axis. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape. Parameters ---------- func : function Function of a single array to app...
def map(self, func, axis=(0,)): """ Apply a function across an axis. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape. Parameters ---------- func : function Function of a single array to app...
[ "Apply", "a", "function", "across", "an", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/array.py#L94-L124
[ "def", "map", "(", "self", ",", "func", ",", "axis", "=", "(", "0", ",", ")", ")", ":", "axes", "=", "sorted", "(", "tupleize", "(", "axis", ")", ")", "key_shape", "=", "[", "self", ".", "shape", "[", "axis", "]", "for", "axis", "in", "axes", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArrayLocal.reduce
Reduce an array along an axis. Applies an associative/commutative function of two arguments cumulatively to all arrays along an axis. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/reshape. Parameters ---------- ...
bolt/local/array.py
def reduce(self, func, axis=0): """ Reduce an array along an axis. Applies an associative/commutative function of two arguments cumulatively to all arrays along an axis. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/...
def reduce(self, func, axis=0): """ Reduce an array along an axis. Applies an associative/commutative function of two arguments cumulatively to all arrays along an axis. Array will be aligned so that the desired set of axes are in the keys, which may require a transpose/...
[ "Reduce", "an", "array", "along", "an", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/array.py#L126-L164
[ "def", "reduce", "(", "self", ",", "func", ",", "axis", "=", "0", ")", ":", "axes", "=", "sorted", "(", "tupleize", "(", "axis", ")", ")", "# if the function is a ufunc, it can automatically handle reducing over multiple axes", "if", "isinstance", "(", "func", ","...
9cd7104aa085498da3097b72696184b9d3651c51