repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.choose_parent_view
def choose_parent_view(self, request): """ Instantiates a class-based view to provide a view that allows a parent page to be chosen for a new object, where the assigned model extends Wagtail's Page model, and there is more than one potential parent for new instances. The view cla...
python
def choose_parent_view(self, request): """ Instantiates a class-based view to provide a view that allows a parent page to be chosen for a new object, where the assigned model extends Wagtail's Page model, and there is more than one potential parent for new instances. The view cla...
[ "def", "choose_parent_view", "(", "self", ",", "request", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", "}", "view_class", "=", "self", ".", "choose_parent_view_class", "return", "view_class", ".", "as_view", "(", "*", "*", "kwargs", ")", "(", ...
Instantiates a class-based view to provide a view that allows a parent page to be chosen for a new object, where the assigned model extends Wagtail's Page model, and there is more than one potential parent for new instances. The view class used can be overridden by changing the 'choose_p...
[ "Instantiates", "a", "class", "-", "based", "view", "to", "provide", "a", "view", "that", "allows", "a", "parent", "page", "to", "be", "chosen", "for", "a", "new", "object", "where", "the", "assigned", "model", "extends", "Wagtail", "s", "Page", "model", ...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L342-L352
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.edit_view
def edit_view(self, request, object_id): """ Instantiates a class-based view to provide 'edit' functionality for the assigned model, or redirect to Wagtail's edit view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'edit_view_class' a...
python
def edit_view(self, request, object_id): """ Instantiates a class-based view to provide 'edit' functionality for the assigned model, or redirect to Wagtail's edit view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'edit_view_class' a...
[ "def", "edit_view", "(", "self", ",", "request", ",", "object_id", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", ",", "'object_id'", ":", "object_id", "}", "view_class", "=", "self", ".", "edit_view_class", "return", "view_class", ".", "as_view...
Instantiates a class-based view to provide 'edit' functionality for the assigned model, or redirect to Wagtail's edit view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'edit_view_class' attribute.
[ "Instantiates", "a", "class", "-", "based", "view", "to", "provide", "edit", "functionality", "for", "the", "assigned", "model", "or", "redirect", "to", "Wagtail", "s", "edit", "view", "if", "the", "assigned", "model", "extends", "Page", ".", "The", "view", ...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L354-L363
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.confirm_delete_view
def confirm_delete_view(self, request, object_id): """ Instantiates a class-based view to provide 'delete confirmation' functionality for the assigned model, or redirect to Wagtail's delete confirmation view if the assigned model extends 'Page'. The view class used can be overrid...
python
def confirm_delete_view(self, request, object_id): """ Instantiates a class-based view to provide 'delete confirmation' functionality for the assigned model, or redirect to Wagtail's delete confirmation view if the assigned model extends 'Page'. The view class used can be overrid...
[ "def", "confirm_delete_view", "(", "self", ",", "request", ",", "object_id", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", ",", "'object_id'", ":", "object_id", "}", "view_class", "=", "self", ".", "confirm_delete_view_class", "return", "view_class...
Instantiates a class-based view to provide 'delete confirmation' functionality for the assigned model, or redirect to Wagtail's delete confirmation view if the assigned model extends 'Page'. The view class used can be overridden by changing the 'confirm_delete_view_class' attribute.
[ "Instantiates", "a", "class", "-", "based", "view", "to", "provide", "delete", "confirmation", "functionality", "for", "the", "assigned", "model", "or", "redirect", "to", "Wagtail", "s", "delete", "confirmation", "view", "if", "the", "assigned", "model", "extend...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L365-L375
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.unpublish_view
def unpublish_view(self, request, object_id): """ Instantiates a class-based view that redirects to Wagtail's 'unpublish' view for models that extend 'Page' (if the user has sufficient permissions). We do this via our own view so that we can reliably control redirection of the us...
python
def unpublish_view(self, request, object_id): """ Instantiates a class-based view that redirects to Wagtail's 'unpublish' view for models that extend 'Page' (if the user has sufficient permissions). We do this via our own view so that we can reliably control redirection of the us...
[ "def", "unpublish_view", "(", "self", ",", "request", ",", "object_id", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", ",", "'object_id'", ":", "object_id", "}", "view_class", "=", "self", ".", "unpublish_view_class", "return", "view_class", ".", ...
Instantiates a class-based view that redirects to Wagtail's 'unpublish' view for models that extend 'Page' (if the user has sufficient permissions). We do this via our own view so that we can reliably control redirection of the user back to the index_view once the action is completed. Th...
[ "Instantiates", "a", "class", "-", "based", "view", "that", "redirects", "to", "Wagtail", "s", "unpublish", "view", "for", "models", "that", "extend", "Page", "(", "if", "the", "user", "has", "sufficient", "permissions", ")", ".", "We", "do", "this", "via"...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L377-L388
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.copy_view
def copy_view(self, request, object_id): """ Instantiates a class-based view that redirects to Wagtail's 'copy' view for models that extend 'Page' (if the user has sufficient permissions). We do this via our own view so that we can reliably control redirection of the user back to...
python
def copy_view(self, request, object_id): """ Instantiates a class-based view that redirects to Wagtail's 'copy' view for models that extend 'Page' (if the user has sufficient permissions). We do this via our own view so that we can reliably control redirection of the user back to...
[ "def", "copy_view", "(", "self", ",", "request", ",", "object_id", ")", ":", "kwargs", "=", "{", "'model_admin'", ":", "self", ",", "'object_id'", ":", "object_id", "}", "view_class", "=", "self", ".", "copy_view_class", "return", "view_class", ".", "as_view...
Instantiates a class-based view that redirects to Wagtail's 'copy' view for models that extend 'Page' (if the user has sufficient permissions). We do this via our own view so that we can reliably control redirection of the user back to the index_view once the action is completed. The vie...
[ "Instantiates", "a", "class", "-", "based", "view", "that", "redirects", "to", "Wagtail", "s", "copy", "view", "for", "models", "that", "extend", "Page", "(", "if", "the", "user", "has", "sufficient", "permissions", ")", ".", "We", "do", "this", "via", "...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L390-L401
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.get_templates
def get_templates(self, action='index'): """ Utility function that provides a list of templates to try for a given view, when the template isn't overridden by one of the template attributes on the class. """ app = self.opts.app_label model_name = self.opts.model_n...
python
def get_templates(self, action='index'): """ Utility function that provides a list of templates to try for a given view, when the template isn't overridden by one of the template attributes on the class. """ app = self.opts.app_label model_name = self.opts.model_n...
[ "def", "get_templates", "(", "self", ",", "action", "=", "'index'", ")", ":", "app", "=", "self", ".", "opts", ".", "app_label", "model_name", "=", "self", ".", "opts", ".", "model_name", "return", "[", "'wagtailmodeladmin/%s/%s/%s.html'", "%", "(", "app", ...
Utility function that provides a list of templates to try for a given view, when the template isn't overridden by one of the template attributes on the class.
[ "Utility", "function", "that", "provides", "a", "list", "of", "templates", "to", "try", "for", "a", "given", "view", "when", "the", "template", "isn", "t", "overridden", "by", "one", "of", "the", "template", "attributes", "on", "the", "class", "." ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L403-L415
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.get_permissions_for_registration
def get_permissions_for_registration(self): """ Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet """ from wagta...
python
def get_permissions_for_registration(self): """ Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet """ from wagta...
[ "def", "get_permissions_for_registration", "(", "self", ")", ":", "from", "wagtail", ".", "wagtailsnippets", ".", "models", "import", "SNIPPET_MODELS", "if", "not", "self", ".", "is_pagemodel", "and", "self", ".", "model", "not", "in", "SNIPPET_MODELS", ":", "re...
Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet
[ "Utilised", "by", "Wagtail", "s", "register_permissions", "hook", "to", "allow", "permissions", "for", "a", "model", "to", "be", "assigned", "to", "groups", "in", "settings", ".", "This", "is", "only", "required", "if", "the", "model", "isn", "t", "a", "Pa...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L481-L490
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdmin.get_admin_urls_for_registration
def get_admin_urls_for_registration(self): """ Utilised by Wagtail's 'register_admin_urls' hook to register urls for our the views that class offers. """ urls = ( url(get_url_pattern(self.opts), self.index_view, name=get_url_name(self.opts)), ...
python
def get_admin_urls_for_registration(self): """ Utilised by Wagtail's 'register_admin_urls' hook to register urls for our the views that class offers. """ urls = ( url(get_url_pattern(self.opts), self.index_view, name=get_url_name(self.opts)), ...
[ "def", "get_admin_urls_for_registration", "(", "self", ")", ":", "urls", "=", "(", "url", "(", "get_url_pattern", "(", "self", ".", "opts", ")", ",", "self", ".", "index_view", ",", "name", "=", "get_url_name", "(", "self", ".", "opts", ")", ")", ",", ...
Utilised by Wagtail's 'register_admin_urls' hook to register urls for our the views that class offers.
[ "Utilised", "by", "Wagtail", "s", "register_admin_urls", "hook", "to", "register", "urls", "for", "our", "the", "views", "that", "class", "offers", "." ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L492-L533
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdminGroup.get_menu_item
def get_menu_item(self): """ Utilised by Wagtail's 'register_menu_item' hook to create a menu for this group with a SubMenu linking to listing pages for any associated ModelAdmin instances """ if self.modeladmin_instances: submenu = SubMenu(self.get_submenu_it...
python
def get_menu_item(self): """ Utilised by Wagtail's 'register_menu_item' hook to create a menu for this group with a SubMenu linking to listing pages for any associated ModelAdmin instances """ if self.modeladmin_instances: submenu = SubMenu(self.get_submenu_it...
[ "def", "get_menu_item", "(", "self", ")", ":", "if", "self", ".", "modeladmin_instances", ":", "submenu", "=", "SubMenu", "(", "self", ".", "get_submenu_items", "(", ")", ")", "return", "GroupMenuItem", "(", "self", ",", "self", ".", "get_menu_order", "(", ...
Utilised by Wagtail's 'register_menu_item' hook to create a menu for this group with a SubMenu linking to listing pages for any associated ModelAdmin instances
[ "Utilised", "by", "Wagtail", "s", "register_menu_item", "hook", "to", "create", "a", "menu", "for", "this", "group", "with", "a", "SubMenu", "linking", "to", "listing", "pages", "for", "any", "associated", "ModelAdmin", "instances" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L579-L587
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdminGroup.get_permissions_for_registration
def get_permissions_for_registration(self): """ Utilised by Wagtail's 'register_permissions' hook to allow permissions for a all models grouped by this class to be assigned to Groups in settings. """ qs = Permission.objects.none() for instance in self.modeladmin_i...
python
def get_permissions_for_registration(self): """ Utilised by Wagtail's 'register_permissions' hook to allow permissions for a all models grouped by this class to be assigned to Groups in settings. """ qs = Permission.objects.none() for instance in self.modeladmin_i...
[ "def", "get_permissions_for_registration", "(", "self", ")", ":", "qs", "=", "Permission", ".", "objects", ".", "none", "(", ")", "for", "instance", "in", "self", ".", "modeladmin_instances", ":", "qs", "=", "qs", "|", "instance", ".", "get_permissions_for_reg...
Utilised by Wagtail's 'register_permissions' hook to allow permissions for a all models grouped by this class to be assigned to Groups in settings.
[ "Utilised", "by", "Wagtail", "s", "register_permissions", "hook", "to", "allow", "permissions", "for", "a", "all", "models", "grouped", "by", "this", "class", "to", "be", "assigned", "to", "Groups", "in", "settings", "." ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L589-L598
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/options.py
ModelAdminGroup.get_admin_urls_for_registration
def get_admin_urls_for_registration(self): """ Utilised by Wagtail's 'register_admin_urls' hook to register urls for used by any associated ModelAdmin instances """ urls = [] for instance in self.modeladmin_instances: urls.extend(instance.get_admin_urls_for_re...
python
def get_admin_urls_for_registration(self): """ Utilised by Wagtail's 'register_admin_urls' hook to register urls for used by any associated ModelAdmin instances """ urls = [] for instance in self.modeladmin_instances: urls.extend(instance.get_admin_urls_for_re...
[ "def", "get_admin_urls_for_registration", "(", "self", ")", ":", "urls", "=", "[", "]", "for", "instance", "in", "self", ".", "modeladmin_instances", ":", "urls", ".", "extend", "(", "instance", ".", "get_admin_urls_for_registration", "(", ")", ")", "return", ...
Utilised by Wagtail's 'register_admin_urls' hook to register urls for used by any associated ModelAdmin instances
[ "Utilised", "by", "Wagtail", "s", "register_admin_urls", "hook", "to", "register", "urls", "for", "used", "by", "any", "associated", "ModelAdmin", "instances" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/options.py#L600-L608
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/menus.py
GroupMenuItem.is_shown
def is_shown(self, request): """ If there aren't any visible items in the submenu, don't bother to show this menu item """ for menuitem in self.menu._registered_menu_items: if menuitem.is_shown(request): return True return False
python
def is_shown(self, request): """ If there aren't any visible items in the submenu, don't bother to show this menu item """ for menuitem in self.menu._registered_menu_items: if menuitem.is_shown(request): return True return False
[ "def", "is_shown", "(", "self", ",", "request", ")", ":", "for", "menuitem", "in", "self", ".", "menu", ".", "_registered_menu_items", ":", "if", "menuitem", ".", "is_shown", "(", "request", ")", ":", "return", "True", "return", "False" ]
If there aren't any visible items in the submenu, don't bother to show this menu item
[ "If", "there", "aren", "t", "any", "visible", "items", "in", "the", "submenu", "don", "t", "bother", "to", "show", "this", "menu", "item" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/menus.py#L34-L42
train
spacetelescope/acstools
acstools/acscteforwardmodel.py
run
def run(configobj=None): """ TEAL interface for the `acscteforwardmodel` function. """ acscteforwardmodel(configobj['input'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], ...
python
def run(configobj=None): """ TEAL interface for the `acscteforwardmodel` function. """ acscteforwardmodel(configobj['input'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], ...
[ "def", "run", "(", "configobj", "=", "None", ")", ":", "acscteforwardmodel", "(", "configobj", "[", "'input'", "]", ",", "exec_path", "=", "configobj", "[", "'exec_path'", "]", ",", "time_stamps", "=", "configobj", "[", "'time_stamps'", "]", ",", "verbose", ...
TEAL interface for the `acscteforwardmodel` function.
[ "TEAL", "interface", "for", "the", "acscteforwardmodel", "function", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acscteforwardmodel.py#L127-L138
train
spacetelescope/acstools
acstools/acsccd.py
run
def run(configobj=None): """ TEAL interface for the `acsccd` function. """ acsccd(configobj['input'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], quiet=configobj['quiet'] #, #dqicorr=config...
python
def run(configobj=None): """ TEAL interface for the `acsccd` function. """ acsccd(configobj['input'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], quiet=configobj['quiet'] #, #dqicorr=config...
[ "def", "run", "(", "configobj", "=", "None", ")", ":", "acsccd", "(", "configobj", "[", "'input'", "]", ",", "exec_path", "=", "configobj", "[", "'exec_path'", "]", ",", "time_stamps", "=", "configobj", "[", "'time_stamps'", "]", ",", "verbose", "=", "co...
TEAL interface for the `acsccd` function.
[ "TEAL", "interface", "for", "the", "acsccd", "function", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acsccd.py#L134-L148
train
spacetelescope/acstools
acstools/acs_destripe_plus.py
destripe_plus
def destripe_plus(inputfile, suffix='strp', stat='pmode1', maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, scimask1=None, scimask2=None, dqbits=None, rpt_clean=0, atol=0.01, cte_correct=True, clobber=False, verbose=True): r"""Cali...
python
def destripe_plus(inputfile, suffix='strp', stat='pmode1', maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, scimask1=None, scimask2=None, dqbits=None, rpt_clean=0, atol=0.01, cte_correct=True, clobber=False, verbose=True): r"""Cali...
[ "def", "destripe_plus", "(", "inputfile", ",", "suffix", "=", "'strp'", ",", "stat", "=", "'pmode1'", ",", "maxiter", "=", "15", ",", "sigrej", "=", "2.0", ",", "lower", "=", "None", ",", "upper", "=", "None", ",", "binwidth", "=", "0.3", ",", "scima...
r"""Calibrate post-SM4 ACS/WFC exposure(s) and use standalone :ref:`acsdestripe`. This takes a RAW image and generates a FLT file containing its calibrated and destriped counterpart. If CTE correction is performed, FLC will also be present. Parameters ---------- inputfile : str or list of ...
[ "r", "Calibrate", "post", "-", "SM4", "ACS", "/", "WFC", "exposure", "(", "s", ")", "and", "use", "standalone", ":", "ref", ":", "acsdestripe", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe_plus.py#L111-L498
train
spacetelescope/acstools
acstools/acs_destripe_plus.py
run
def run(configobj=None): """TEAL interface for :func:`destripe_plus`.""" destripe_plus( configobj['input'], suffix=configobj['suffix'], stat=configobj['stat'], maxiter=configobj['maxiter'], sigrej=configobj['sigrej'], lower=configobj['lower'], upper=config...
python
def run(configobj=None): """TEAL interface for :func:`destripe_plus`.""" destripe_plus( configobj['input'], suffix=configobj['suffix'], stat=configobj['stat'], maxiter=configobj['maxiter'], sigrej=configobj['sigrej'], lower=configobj['lower'], upper=config...
[ "def", "run", "(", "configobj", "=", "None", ")", ":", "destripe_plus", "(", "configobj", "[", "'input'", "]", ",", "suffix", "=", "configobj", "[", "'suffix'", "]", ",", "stat", "=", "configobj", "[", "'stat'", "]", ",", "maxiter", "=", "configobj", "...
TEAL interface for :func:`destripe_plus`.
[ "TEAL", "interface", "for", ":", "func", ":", "destripe_plus", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe_plus.py#L537-L555
train
spacetelescope/acstools
acstools/acs_destripe_plus.py
main
def main(): """Command line driver.""" import argparse # Parse input parameters parser = argparse.ArgumentParser( prog=__taskname__, description=( 'Run CALACS and standalone acs_destripe script on given post-SM4 ' 'ACS/WFC RAW full-frame or supported subarray ima...
python
def main(): """Command line driver.""" import argparse # Parse input parameters parser = argparse.ArgumentParser( prog=__taskname__, description=( 'Run CALACS and standalone acs_destripe script on given post-SM4 ' 'ACS/WFC RAW full-frame or supported subarray ima...
[ "def", "main", "(", ")", ":", "import", "argparse", "# Parse input parameters", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "__taskname__", ",", "description", "=", "(", "'Run CALACS and standalone acs_destripe script on given post-SM4 '", "'ACS/WF...
Command line driver.
[ "Command", "line", "driver", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe_plus.py#L562-L636
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
IndexView.get_search_results
def get_search_results(self, request, queryset, search_term): """ Returns a tuple containing a queryset to implement the search, and a boolean indicating if the results may contain duplicates. """ # Apply keyword searches. def construct_search(field_name): if ...
python
def get_search_results(self, request, queryset, search_term): """ Returns a tuple containing a queryset to implement the search, and a boolean indicating if the results may contain duplicates. """ # Apply keyword searches. def construct_search(field_name): if ...
[ "def", "get_search_results", "(", "self", ",", "request", ",", "queryset", ",", "search_term", ")", ":", "# Apply keyword searches.", "def", "construct_search", "(", "field_name", ")", ":", "if", "field_name", ".", "startswith", "(", "'^'", ")", ":", "return", ...
Returns a tuple containing a queryset to implement the search, and a boolean indicating if the results may contain duplicates.
[ "Returns", "a", "tuple", "containing", "a", "queryset", "to", "implement", "the", "search", "and", "a", "boolean", "indicating", "if", "the", "results", "may", "contain", "duplicates", "." ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L297-L327
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
IndexView.get_filters_params
def get_filters_params(self, params=None): """ Returns all params except IGNORED_PARAMS """ if not params: params = self.params lookup_params = params.copy() # a dictionary of the query string # Remove all the parameters that are globally and systematically ...
python
def get_filters_params(self, params=None): """ Returns all params except IGNORED_PARAMS """ if not params: params = self.params lookup_params = params.copy() # a dictionary of the query string # Remove all the parameters that are globally and systematically ...
[ "def", "get_filters_params", "(", "self", ",", "params", "=", "None", ")", ":", "if", "not", "params", ":", "params", "=", "self", ".", "params", "lookup_params", "=", "params", ".", "copy", "(", ")", "# a dictionary of the query string", "# Remove all the param...
Returns all params except IGNORED_PARAMS
[ "Returns", "all", "params", "except", "IGNORED_PARAMS" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L377-L389
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
IndexView.get_ordering_field
def get_ordering_field(self, field_name): """ Returns the proper model field name corresponding to the given field_name to use for ordering. field_name may either be the name of a proper model field or the name of a method (on the admin or model) or a callable with the 'admin_ord...
python
def get_ordering_field(self, field_name): """ Returns the proper model field name corresponding to the given field_name to use for ordering. field_name may either be the name of a proper model field or the name of a method (on the admin or model) or a callable with the 'admin_ord...
[ "def", "get_ordering_field", "(", "self", ",", "field_name", ")", ":", "try", ":", "field", "=", "self", ".", "opts", ".", "get_field", "(", "field_name", ")", "return", "field", ".", "name", "except", "FieldDoesNotExist", ":", "# See whether field_name is a nam...
Returns the proper model field name corresponding to the given field_name to use for ordering. field_name may either be the name of a proper model field or the name of a method (on the admin or model) or a callable with the 'admin_order_field' attribute. Returns None if no proper model f...
[ "Returns", "the", "proper", "model", "field", "name", "corresponding", "to", "the", "given", "field_name", "to", "use", "for", "ordering", ".", "field_name", "may", "either", "be", "the", "name", "of", "a", "proper", "model", "field", "or", "the", "name", ...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L494-L514
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
IndexView.get_ordering
def get_ordering(self, request, queryset): """ Returns the list of ordering fields for the change list. First we check the get_ordering() method in model admin, then we check the object's default ordering. Then, any manually-specified ordering from the query string overrides anyt...
python
def get_ordering(self, request, queryset): """ Returns the list of ordering fields for the change list. First we check the get_ordering() method in model admin, then we check the object's default ordering. Then, any manually-specified ordering from the query string overrides anyt...
[ "def", "get_ordering", "(", "self", ",", "request", ",", "queryset", ")", ":", "params", "=", "self", ".", "params", "ordering", "=", "list", "(", "self", ".", "get_default_ordering", "(", "request", ")", ")", "if", "ORDER_VAR", "in", "params", ":", "# C...
Returns the list of ordering fields for the change list. First we check the get_ordering() method in model admin, then we check the object's default ordering. Then, any manually-specified ordering from the query string overrides anything. Finally, a deterministic order is guaranteed by e...
[ "Returns", "the", "list", "of", "ordering", "fields", "for", "the", "change", "list", ".", "First", "we", "check", "the", "get_ordering", "()", "method", "in", "model", "admin", "then", "we", "check", "the", "object", "s", "default", "ordering", ".", "Then...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L516-L558
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
IndexView.get_ordering_field_columns
def get_ordering_field_columns(self): """ Returns an OrderedDict of ordering field column numbers and asc/desc """ # We must cope with more than one column having the same underlying # sort field, so we base things on column numbers. ordering = self._get_default_ordering...
python
def get_ordering_field_columns(self): """ Returns an OrderedDict of ordering field column numbers and asc/desc """ # We must cope with more than one column having the same underlying # sort field, so we base things on column numbers. ordering = self._get_default_ordering...
[ "def", "get_ordering_field_columns", "(", "self", ")", ":", "# We must cope with more than one column having the same underlying", "# sort field, so we base things on column numbers.", "ordering", "=", "self", ".", "_get_default_ordering", "(", ")", "ordering_fields", "=", "Ordered...
Returns an OrderedDict of ordering field column numbers and asc/desc
[ "Returns", "an", "OrderedDict", "of", "ordering", "field", "column", "numbers", "and", "asc", "/", "desc" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L560-L591
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
InspectView.get_field_label
def get_field_label(self, field_name, field=None): """ Return a label to display for a field """ label = None if field is not None: label = getattr(field, 'verbose_name', None) if label is None: label = getattr(field, 'name', None) if label is None...
python
def get_field_label(self, field_name, field=None): """ Return a label to display for a field """ label = None if field is not None: label = getattr(field, 'verbose_name', None) if label is None: label = getattr(field, 'name', None) if label is None...
[ "def", "get_field_label", "(", "self", ",", "field_name", ",", "field", "=", "None", ")", ":", "label", "=", "None", "if", "field", "is", "not", "None", ":", "label", "=", "getattr", "(", "field", ",", "'verbose_name'", ",", "None", ")", "if", "label",...
Return a label to display for a field
[ "Return", "a", "label", "to", "display", "for", "a", "field" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L732-L741
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
InspectView.get_field_display_value
def get_field_display_value(self, field_name, field=None): """ Return a display value for a field """ """ Firstly, check for a 'get_fieldname_display' property/method on the model, and return the value of that, if present. """ val_funct = getattr(self.instance, 'get_%s_d...
python
def get_field_display_value(self, field_name, field=None): """ Return a display value for a field """ """ Firstly, check for a 'get_fieldname_display' property/method on the model, and return the value of that, if present. """ val_funct = getattr(self.instance, 'get_%s_d...
[ "def", "get_field_display_value", "(", "self", ",", "field_name", ",", "field", "=", "None", ")", ":", "\"\"\"\n Firstly, check for a 'get_fieldname_display' property/method on\n the model, and return the value of that, if present.\n \"\"\"", "val_funct", "=", "get...
Return a display value for a field
[ "Return", "a", "display", "value", "for", "a", "field" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L743-L784
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
InspectView.get_image_field_display
def get_image_field_display(self, field_name, field): """ Render an image """ image = getattr(self.instance, field_name) if image: fltr, _ = Filter.objects.get_or_create(spec='max-400x400') rendition = image.get_rendition(fltr) return rendition.img_tag ...
python
def get_image_field_display(self, field_name, field): """ Render an image """ image = getattr(self.instance, field_name) if image: fltr, _ = Filter.objects.get_or_create(spec='max-400x400') rendition = image.get_rendition(fltr) return rendition.img_tag ...
[ "def", "get_image_field_display", "(", "self", ",", "field_name", ",", "field", ")", ":", "image", "=", "getattr", "(", "self", ".", "instance", ",", "field_name", ")", "if", "image", ":", "fltr", ",", "_", "=", "Filter", ".", "objects", ".", "get_or_cre...
Render an image
[ "Render", "an", "image" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L786-L793
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
InspectView.get_document_field_display
def get_document_field_display(self, field_name, field): """ Render a link to a document """ document = getattr(self.instance, field_name) if document: return mark_safe( '<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % ( document.url, ...
python
def get_document_field_display(self, field_name, field): """ Render a link to a document """ document = getattr(self.instance, field_name) if document: return mark_safe( '<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % ( document.url, ...
[ "def", "get_document_field_display", "(", "self", ",", "field_name", ",", "field", ")", ":", "document", "=", "getattr", "(", "self", ".", "instance", ",", "field_name", ")", "if", "document", ":", "return", "mark_safe", "(", "'<a href=\"%s\">%s <span class=\"meta...
Render a link to a document
[ "Render", "a", "link", "to", "a", "document" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L795-L807
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
InspectView.get_dict_for_field
def get_dict_for_field(self, field_name): """ Return a dictionary containing `label` and `value` values to display for a field. """ try: field = self.model._meta.get_field(field_name) except FieldDoesNotExist: field = None return { ...
python
def get_dict_for_field(self, field_name): """ Return a dictionary containing `label` and `value` values to display for a field. """ try: field = self.model._meta.get_field(field_name) except FieldDoesNotExist: field = None return { ...
[ "def", "get_dict_for_field", "(", "self", ",", "field_name", ")", ":", "try", ":", "field", "=", "self", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "field", "=", "None", "return", "{", "'label'...
Return a dictionary containing `label` and `value` values to display for a field.
[ "Return", "a", "dictionary", "containing", "label", "and", "value", "values", "to", "display", "for", "a", "field", "." ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L809-L821
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/views.py
InspectView.get_fields_dict
def get_fields_dict(self): """ Return a list of `label`/`value` dictionaries to represent the fiels named by the model_admin class's `get_inspect_view_fields` method """ fields = [] for field_name in self.model_admin.get_inspect_view_fields(): fields.append(se...
python
def get_fields_dict(self): """ Return a list of `label`/`value` dictionaries to represent the fiels named by the model_admin class's `get_inspect_view_fields` method """ fields = [] for field_name in self.model_admin.get_inspect_view_fields(): fields.append(se...
[ "def", "get_fields_dict", "(", "self", ")", ":", "fields", "=", "[", "]", "for", "field_name", "in", "self", ".", "model_admin", ".", "get_inspect_view_fields", "(", ")", ":", "fields", ".", "append", "(", "self", ".", "get_dict_for_field", "(", "field_name"...
Return a list of `label`/`value` dictionaries to represent the fiels named by the model_admin class's `get_inspect_view_fields` method
[ "Return", "a", "list", "of", "label", "/", "value", "dictionaries", "to", "represent", "the", "fiels", "named", "by", "the", "model_admin", "class", "s", "get_inspect_view_fields", "method" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L823-L831
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py
items_for_result
def items_for_result(view, result): """ Generates the actual list of data. """ model_admin = view.model_admin for field_name in view.list_display: empty_value_display = model_admin.get_empty_value_display() row_classes = ['field-%s' % field_name] try: f, attr, val...
python
def items_for_result(view, result): """ Generates the actual list of data. """ model_admin = view.model_admin for field_name in view.list_display: empty_value_display = model_admin.get_empty_value_display() row_classes = ['field-%s' % field_name] try: f, attr, val...
[ "def", "items_for_result", "(", "view", ",", "result", ")", ":", "model_admin", "=", "view", ".", "model_admin", "for", "field_name", "in", "view", ".", "list_display", ":", "empty_value_display", "=", "model_admin", ".", "get_empty_value_display", "(", ")", "ro...
Generates the actual list of data.
[ "Generates", "the", "actual", "list", "of", "data", "." ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py#L26-L78
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py
result_list
def result_list(context): """ Displays the headers and data list together """ view = context['view'] object_list = context['object_list'] headers = list(result_headers(view)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields +...
python
def result_list(context): """ Displays the headers and data list together """ view = context['view'] object_list = context['object_list'] headers = list(result_headers(view)) num_sorted_fields = 0 for h in headers: if h['sortable'] and h['sorted']: num_sorted_fields +...
[ "def", "result_list", "(", "context", ")", ":", "view", "=", "context", "[", "'view'", "]", "object_list", "=", "context", "[", "'object_list'", "]", "headers", "=", "list", "(", "result_headers", "(", "view", ")", ")", "num_sorted_fields", "=", "0", "for"...
Displays the headers and data list together
[ "Displays", "the", "headers", "and", "data", "list", "together" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py#L88-L103
train
spacetelescope/acstools
acstools/acssum.py
run
def run(configobj=None): """ TEAL interface for the `acssum` function. """ acssum(configobj['input'], configobj['output'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], quiet=configobj['quiet'...
python
def run(configobj=None): """ TEAL interface for the `acssum` function. """ acssum(configobj['input'], configobj['output'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], quiet=configobj['quiet'...
[ "def", "run", "(", "configobj", "=", "None", ")", ":", "acssum", "(", "configobj", "[", "'input'", "]", ",", "configobj", "[", "'output'", "]", ",", "exec_path", "=", "configobj", "[", "'exec_path'", "]", ",", "time_stamps", "=", "configobj", "[", "'time...
TEAL interface for the `acssum` function.
[ "TEAL", "interface", "for", "the", "acssum", "function", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acssum.py#L111-L122
train
spacetelescope/acstools
acstools/satdet.py
_detsat_one
def _detsat_one(filename, ext, sigma=2.0, low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200, line_gap=75, percentile=(4.5, 93.0), buf=200, plot=False, verbose=False): """Called by :func:`detsat`.""" if verbose: t_beg = time.time() fname = '{0}[{1}]'.format(fi...
python
def _detsat_one(filename, ext, sigma=2.0, low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200, line_gap=75, percentile=(4.5, 93.0), buf=200, plot=False, verbose=False): """Called by :func:`detsat`.""" if verbose: t_beg = time.time() fname = '{0}[{1}]'.format(fi...
[ "def", "_detsat_one", "(", "filename", ",", "ext", ",", "sigma", "=", "2.0", ",", "low_thresh", "=", "0.1", ",", "h_thresh", "=", "0.5", ",", "small_edge", "=", "60", ",", "line_len", "=", "200", ",", "line_gap", "=", "75", ",", "percentile", "=", "(...
Called by :func:`detsat`.
[ "Called", "by", ":", "func", ":", "detsat", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L180-L444
train
spacetelescope/acstools
acstools/satdet.py
_get_valid_indices
def _get_valid_indices(shape, ix0, ix1, iy0, iy1): """Give array shape and desired indices, return indices that are correctly bounded by the shape.""" ymax, xmax = shape if ix0 < 0: ix0 = 0 if ix1 > xmax: ix1 = xmax if iy0 < 0: iy0 = 0 if iy1 > ymax: iy1 = ym...
python
def _get_valid_indices(shape, ix0, ix1, iy0, iy1): """Give array shape and desired indices, return indices that are correctly bounded by the shape.""" ymax, xmax = shape if ix0 < 0: ix0 = 0 if ix1 > xmax: ix1 = xmax if iy0 < 0: iy0 = 0 if iy1 > ymax: iy1 = ym...
[ "def", "_get_valid_indices", "(", "shape", ",", "ix0", ",", "ix1", ",", "iy0", ",", "iy1", ")", ":", "ymax", ",", "xmax", "=", "shape", "if", "ix0", "<", "0", ":", "ix0", "=", "0", "if", "ix1", ">", "xmax", ":", "ix1", "=", "xmax", "if", "iy0",...
Give array shape and desired indices, return indices that are correctly bounded by the shape.
[ "Give", "array", "shape", "and", "desired", "indices", "return", "indices", "that", "are", "correctly", "bounded", "by", "the", "shape", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L447-L465
train
spacetelescope/acstools
acstools/satdet.py
_rotate_point
def _rotate_point(point, angle, ishape, rshape, reverse=False): """Transform a point from original image coordinates to rotated image coordinates and back. It assumes the rotation point is the center of an image. This works on a simple rotation transformation:: newx = (startx) * np.cos(angle) ...
python
def _rotate_point(point, angle, ishape, rshape, reverse=False): """Transform a point from original image coordinates to rotated image coordinates and back. It assumes the rotation point is the center of an image. This works on a simple rotation transformation:: newx = (startx) * np.cos(angle) ...
[ "def", "_rotate_point", "(", "point", ",", "angle", ",", "ishape", ",", "rshape", ",", "reverse", "=", "False", ")", ":", "# unpack the image and rotated images shapes", "if", "reverse", ":", "angle", "=", "(", "angle", "*", "-", "1", ")", "temp", "=", "i...
Transform a point from original image coordinates to rotated image coordinates and back. It assumes the rotation point is the center of an image. This works on a simple rotation transformation:: newx = (startx) * np.cos(angle) - (starty) * np.sin(angle) newy = (startx) * np.sin(angle) + (s...
[ "Transform", "a", "point", "from", "original", "image", "coordinates", "to", "rotated", "image", "coordinates", "and", "back", ".", "It", "assumes", "the", "rotation", "point", "is", "the", "center", "of", "an", "image", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L468-L532
train
spacetelescope/acstools
acstools/satdet.py
make_mask
def make_mask(filename, ext, trail_coords, sublen=75, subwidth=200, order=3, sigma=4, pad=10, plot=False, verbose=False): """Create DQ mask for an image for a given satellite trail. This mask can be added to existing DQ data using :func:`update_dq`. .. note:: Unlike :func:`detsat`, m...
python
def make_mask(filename, ext, trail_coords, sublen=75, subwidth=200, order=3, sigma=4, pad=10, plot=False, verbose=False): """Create DQ mask for an image for a given satellite trail. This mask can be added to existing DQ data using :func:`update_dq`. .. note:: Unlike :func:`detsat`, m...
[ "def", "make_mask", "(", "filename", ",", "ext", ",", "trail_coords", ",", "sublen", "=", "75", ",", "subwidth", "=", "200", ",", "order", "=", "3", ",", "sigma", "=", "4", ",", "pad", "=", "10", ",", "plot", "=", "False", ",", "verbose", "=", "F...
Create DQ mask for an image for a given satellite trail. This mask can be added to existing DQ data using :func:`update_dq`. .. note:: Unlike :func:`detsat`, multiprocessing is not available for this function. Parameters ---------- filename : str FITS image filename. ...
[ "Create", "DQ", "mask", "for", "an", "image", "for", "a", "given", "satellite", "trail", ".", "This", "mask", "can", "be", "added", "to", "existing", "DQ", "data", "using", ":", "func", ":", "update_dq", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L535-L874
train
spacetelescope/acstools
acstools/satdet.py
update_dq
def update_dq(filename, ext, mask, dqval=16384, verbose=True): """Update the given image and DQ extension with the given satellite trails mask and flag. Parameters ---------- filename : str FITS image filename to update. ext : int, str, or tuple DQ extension, as accepted by ``a...
python
def update_dq(filename, ext, mask, dqval=16384, verbose=True): """Update the given image and DQ extension with the given satellite trails mask and flag. Parameters ---------- filename : str FITS image filename to update. ext : int, str, or tuple DQ extension, as accepted by ``a...
[ "def", "update_dq", "(", "filename", ",", "ext", ",", "mask", ",", "dqval", "=", "16384", ",", "verbose", "=", "True", ")", ":", "with", "fits", ".", "open", "(", "filename", ",", "mode", "=", "'update'", ")", "as", "pf", ":", "dqarr", "=", "pf", ...
Update the given image and DQ extension with the given satellite trails mask and flag. Parameters ---------- filename : str FITS image filename to update. ext : int, str, or tuple DQ extension, as accepted by ``astropy.io.fits``, to update. mask : ndarray Boolean mask,...
[ "Update", "the", "given", "image", "and", "DQ", "extension", "with", "the", "given", "satellite", "trails", "mask", "and", "flag", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L877-L927
train
spacetelescope/acstools
acstools/satdet.py
_satdet_worker
def _satdet_worker(work_queue, done_queue, sigma=2.0, low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200, line_gap=75, percentile=(4.5, 93.0), buf=200): """Multiprocessing worker.""" for fil, chip in iter(work_queue.get, 'STOP'): try: result = _de...
python
def _satdet_worker(work_queue, done_queue, sigma=2.0, low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200, line_gap=75, percentile=(4.5, 93.0), buf=200): """Multiprocessing worker.""" for fil, chip in iter(work_queue.get, 'STOP'): try: result = _de...
[ "def", "_satdet_worker", "(", "work_queue", ",", "done_queue", ",", "sigma", "=", "2.0", ",", "low_thresh", "=", "0.1", ",", "h_thresh", "=", "0.5", ",", "small_edge", "=", "60", ",", "line_len", "=", "200", ",", "line_gap", "=", "75", ",", "percentile",...
Multiprocessing worker.
[ "Multiprocessing", "worker", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L934-L952
train
spacetelescope/acstools
acstools/satdet.py
detsat
def detsat(searchpattern, chips=[1, 4], n_processes=4, sigma=2.0, low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200, line_gap=75, percentile=(4.5, 93.0), buf=200, plot=False, verbose=True): """Find satellite trails in the given images and extensions. The trails are calcu...
python
def detsat(searchpattern, chips=[1, 4], n_processes=4, sigma=2.0, low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200, line_gap=75, percentile=(4.5, 93.0), buf=200, plot=False, verbose=True): """Find satellite trails in the given images and extensions. The trails are calcu...
[ "def", "detsat", "(", "searchpattern", ",", "chips", "=", "[", "1", ",", "4", "]", ",", "n_processes", "=", "4", ",", "sigma", "=", "2.0", ",", "low_thresh", "=", "0.1", ",", "h_thresh", "=", "0.5", ",", "small_edge", "=", "60", ",", "line_len", "=...
Find satellite trails in the given images and extensions. The trails are calculated using Probabilistic Hough Transform. .. note:: The trail endpoints found here are crude approximations. Use :func:`make_mask` to create the actual DQ mask for the trail(s) of interest. Parameters ...
[ "Find", "satellite", "trails", "in", "the", "given", "images", "and", "extensions", ".", "The", "trails", "are", "calculated", "using", "Probabilistic", "Hough", "Transform", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L955-L1149
train
seanpar203/event-bus
event_bus/bus.py
EventBus.on
def on(self, event: str) -> Callable: """ Decorator for subscribing a function to a specific event. :param event: Name of the event to subscribe to. :type event: str :return: The outer function. :rtype: Callable """ def outer(func): self.add_event(f...
python
def on(self, event: str) -> Callable: """ Decorator for subscribing a function to a specific event. :param event: Name of the event to subscribe to. :type event: str :return: The outer function. :rtype: Callable """ def outer(func): self.add_event(f...
[ "def", "on", "(", "self", ",", "event", ":", "str", ")", "->", "Callable", ":", "def", "outer", "(", "func", ")", ":", "self", ".", "add_event", "(", "func", ",", "event", ")", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ...
Decorator for subscribing a function to a specific event. :param event: Name of the event to subscribe to. :type event: str :return: The outer function. :rtype: Callable
[ "Decorator", "for", "subscribing", "a", "function", "to", "a", "specific", "event", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L73-L92
train
seanpar203/event-bus
event_bus/bus.py
EventBus.add_event
def add_event(self, func: Callable, event: str) -> None: """ Adds a function to a event. :param func: The function to call when event is emitted :type func: Callable :param event: Name of the event. :type event: str """ self._events[event].add(func)
python
def add_event(self, func: Callable, event: str) -> None: """ Adds a function to a event. :param func: The function to call when event is emitted :type func: Callable :param event: Name of the event. :type event: str """ self._events[event].add(func)
[ "def", "add_event", "(", "self", ",", "func", ":", "Callable", ",", "event", ":", "str", ")", "->", "None", ":", "self", ".", "_events", "[", "event", "]", ".", "add", "(", "func", ")" ]
Adds a function to a event. :param func: The function to call when event is emitted :type func: Callable :param event: Name of the event. :type event: str
[ "Adds", "a", "function", "to", "a", "event", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L94-L103
train
seanpar203/event-bus
event_bus/bus.py
EventBus.emit
def emit(self, event: str, *args, **kwargs) -> None: """ Emit an event and run the subscribed functions. :param event: Name of the event. :type event: str .. notes: Passing in threads=True as a kwarg allows to run emitted events as separate threads. This can sig...
python
def emit(self, event: str, *args, **kwargs) -> None: """ Emit an event and run the subscribed functions. :param event: Name of the event. :type event: str .. notes: Passing in threads=True as a kwarg allows to run emitted events as separate threads. This can sig...
[ "def", "emit", "(", "self", ",", "event", ":", "str", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "None", ":", "threads", "=", "kwargs", ".", "pop", "(", "'threads'", ",", "None", ")", "if", "threads", ":", "events", "=", "[", "Thread",...
Emit an event and run the subscribed functions. :param event: Name of the event. :type event: str .. notes: Passing in threads=True as a kwarg allows to run emitted events as separate threads. This can significantly speed up code execution depending on the c...
[ "Emit", "an", "event", "and", "run", "the", "subscribed", "functions", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L105-L130
train
seanpar203/event-bus
event_bus/bus.py
EventBus.emit_only
def emit_only(self, event: str, func_names: Union[str, List[str]], *args, **kwargs) -> None: """ Specifically only emits certain subscribed events. :param event: Name of the event. :type event: str :param func_names: Function(s) to emit. :type func_names: Unio...
python
def emit_only(self, event: str, func_names: Union[str, List[str]], *args, **kwargs) -> None: """ Specifically only emits certain subscribed events. :param event: Name of the event. :type event: str :param func_names: Function(s) to emit. :type func_names: Unio...
[ "def", "emit_only", "(", "self", ",", "event", ":", "str", ",", "func_names", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "isinstance", "(", "func_names", "...
Specifically only emits certain subscribed events. :param event: Name of the event. :type event: str :param func_names: Function(s) to emit. :type func_names: Union[ str | List[str] ]
[ "Specifically", "only", "emits", "certain", "subscribed", "events", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L132-L147
train
seanpar203/event-bus
event_bus/bus.py
EventBus.emit_after
def emit_after(self, event: str) -> Callable: """ Decorator that emits events after the function is completed. :param event: Name of the event. :type event: str :return: Callable .. note: This plainly just calls functions without passing params into the ...
python
def emit_after(self, event: str) -> Callable: """ Decorator that emits events after the function is completed. :param event: Name of the event. :type event: str :return: Callable .. note: This plainly just calls functions without passing params into the ...
[ "def", "emit_after", "(", "self", ",", "event", ":", "str", ")", "->", "Callable", ":", "def", "outer", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "returned", "=",...
Decorator that emits events after the function is completed. :param event: Name of the event. :type event: str :return: Callable .. note: This plainly just calls functions without passing params into the subscribed callables. This is great if you want to do som...
[ "Decorator", "that", "emits", "events", "after", "the", "function", "is", "completed", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L149-L173
train
seanpar203/event-bus
event_bus/bus.py
EventBus.remove_event
def remove_event(self, func_name: str, event: str) -> None: """ Removes a subscribed function from a specific event. :param func_name: The name of the function to be removed. :type func_name: str :param event: The name of the event. :type event: str :raise EventDoesntE...
python
def remove_event(self, func_name: str, event: str) -> None: """ Removes a subscribed function from a specific event. :param func_name: The name of the function to be removed. :type func_name: str :param event: The name of the event. :type event: str :raise EventDoesntE...
[ "def", "remove_event", "(", "self", ",", "func_name", ":", "str", ",", "event", ":", "str", ")", "->", "None", ":", "event_funcs_copy", "=", "self", ".", "_events", "[", "event", "]", ".", "copy", "(", ")", "for", "func", "in", "self", ".", "_event_f...
Removes a subscribed function from a specific event. :param func_name: The name of the function to be removed. :type func_name: str :param event: The name of the event. :type event: str :raise EventDoesntExist if there func_name doesn't exist in event.
[ "Removes", "a", "subscribed", "function", "from", "a", "specific", "event", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L175-L196
train
seanpar203/event-bus
event_bus/bus.py
EventBus._event_funcs
def _event_funcs(self, event: str) -> Iterable[Callable]: """ Returns an Iterable of the functions subscribed to a event. :param event: Name of the event. :type event: str :return: A iterable to do things with. :rtype: Iterable """ for func in self._events[event...
python
def _event_funcs(self, event: str) -> Iterable[Callable]: """ Returns an Iterable of the functions subscribed to a event. :param event: Name of the event. :type event: str :return: A iterable to do things with. :rtype: Iterable """ for func in self._events[event...
[ "def", "_event_funcs", "(", "self", ",", "event", ":", "str", ")", "->", "Iterable", "[", "Callable", "]", ":", "for", "func", "in", "self", ".", "_events", "[", "event", "]", ":", "yield", "func" ]
Returns an Iterable of the functions subscribed to a event. :param event: Name of the event. :type event: str :return: A iterable to do things with. :rtype: Iterable
[ "Returns", "an", "Iterable", "of", "the", "functions", "subscribed", "to", "a", "event", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L202-L212
train
seanpar203/event-bus
event_bus/bus.py
EventBus._event_func_names
def _event_func_names(self, event: str) -> List[str]: """ Returns string name of each function subscribed to an event. :param event: Name of the event. :type event: str :return: Names of functions subscribed to a specific event. :rtype: list """ return [func.__n...
python
def _event_func_names(self, event: str) -> List[str]: """ Returns string name of each function subscribed to an event. :param event: Name of the event. :type event: str :return: Names of functions subscribed to a specific event. :rtype: list """ return [func.__n...
[ "def", "_event_func_names", "(", "self", ",", "event", ":", "str", ")", "->", "List", "[", "str", "]", ":", "return", "[", "func", ".", "__name__", "for", "func", "in", "self", ".", "_events", "[", "event", "]", "]" ]
Returns string name of each function subscribed to an event. :param event: Name of the event. :type event: str :return: Names of functions subscribed to a specific event. :rtype: list
[ "Returns", "string", "name", "of", "each", "function", "subscribed", "to", "an", "event", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L214-L223
train
seanpar203/event-bus
event_bus/bus.py
EventBus._subscribed_event_count
def _subscribed_event_count(self) -> int: """ Returns the total amount of subscribed events. :return: Integer amount events. :rtype: int """ event_counter = Counter() # type: Dict[Any, int] for key, values in self._events.items(): event_counter[key] = len(v...
python
def _subscribed_event_count(self) -> int: """ Returns the total amount of subscribed events. :return: Integer amount events. :rtype: int """ event_counter = Counter() # type: Dict[Any, int] for key, values in self._events.items(): event_counter[key] = len(v...
[ "def", "_subscribed_event_count", "(", "self", ")", "->", "int", ":", "event_counter", "=", "Counter", "(", ")", "# type: Dict[Any, int]", "for", "key", ",", "values", "in", "self", ".", "_events", ".", "items", "(", ")", ":", "event_counter", "[", "key", ...
Returns the total amount of subscribed events. :return: Integer amount events. :rtype: int
[ "Returns", "the", "total", "amount", "of", "subscribed", "events", "." ]
60319b9eb4e38c348e80f3ec625312eda75da765
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L225-L236
train
spacetelescope/acstools
acstools/acs_destripe.py
clean
def clean(input, suffix, stat="pmode1", maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, mask1=None, mask2=None, dqbits=None, rpt_clean=0, atol=0.01, clobber=False, verbose=True): r"""Remove horizontal stripes from ACS WFC post-SM4 data. Parameters ---------- ...
python
def clean(input, suffix, stat="pmode1", maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, mask1=None, mask2=None, dqbits=None, rpt_clean=0, atol=0.01, clobber=False, verbose=True): r"""Remove horizontal stripes from ACS WFC post-SM4 data. Parameters ---------- ...
[ "def", "clean", "(", "input", ",", "suffix", ",", "stat", "=", "\"pmode1\"", ",", "maxiter", "=", "15", ",", "sigrej", "=", "2.0", ",", "lower", "=", "None", ",", "upper", "=", "None", ",", "binwidth", "=", "0.3", ",", "mask1", "=", "None", ",", ...
r"""Remove horizontal stripes from ACS WFC post-SM4 data. Parameters ---------- input : str or list of str Input filenames in one of these formats: * a Python list of filenames * a partial filename with wildcards ('\*flt.fits') * filename of an ASN table ('j1234...
[ "r", "Remove", "horizontal", "stripes", "from", "ACS", "WFC", "post", "-", "SM4", "data", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L222-L463
train
spacetelescope/acstools
acstools/acs_destripe.py
perform_correction
def perform_correction(image, output, stat="pmode1", maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, mask=None, dqbits=None, rpt_clean=0, atol=0.01, clobber=False, verbose=True): """ Clean each input image. Parameters --...
python
def perform_correction(image, output, stat="pmode1", maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, mask=None, dqbits=None, rpt_clean=0, atol=0.01, clobber=False, verbose=True): """ Clean each input image. Parameters --...
[ "def", "perform_correction", "(", "image", ",", "output", ",", "stat", "=", "\"pmode1\"", ",", "maxiter", "=", "15", ",", "sigrej", "=", "2.0", ",", "lower", "=", "None", ",", "upper", "=", "None", ",", "binwidth", "=", "0.3", ",", "mask", "=", "None...
Clean each input image. Parameters ---------- image : str Input image name. output : str Output image name. mask : `numpy.ndarray` Mask array. maxiter, sigrej, clobber See :func:`clean`. dqbits : int, str, or None Data quality bits to be considere...
[ "Clean", "each", "input", "image", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L466-L547
train
spacetelescope/acstools
acstools/acs_destripe.py
clean_streak
def clean_streak(image, stat="pmode1", maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, mask=None, rpt_clean=0, atol=0.01, verbose=True): """ Apply destriping algorithm to input array. Parameters ---------- image : `StripeArray` object Arrays a...
python
def clean_streak(image, stat="pmode1", maxiter=15, sigrej=2.0, lower=None, upper=None, binwidth=0.3, mask=None, rpt_clean=0, atol=0.01, verbose=True): """ Apply destriping algorithm to input array. Parameters ---------- image : `StripeArray` object Arrays a...
[ "def", "clean_streak", "(", "image", ",", "stat", "=", "\"pmode1\"", ",", "maxiter", "=", "15", ",", "sigrej", "=", "2.0", ",", "lower", "=", "None", ",", "upper", "=", "None", ",", "binwidth", "=", "0.3", ",", "mask", "=", "None", ",", "rpt_clean", ...
Apply destriping algorithm to input array. Parameters ---------- image : `StripeArray` object Arrays are modifed in-place. stat : str Statistics for background computations (see :py:func:`clean` for more details) mask : `numpy.ndarray` Mask array. Pixels with zero ...
[ "Apply", "destriping", "algorithm", "to", "input", "array", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L583-L890
train
spacetelescope/acstools
acstools/acs_destripe.py
djs_iterstat
def djs_iterstat(InputArr, MaxIter=10, SigRej=3.0, Max=None, Min=None, Mask=None, lineno=None): """ Iterative sigma-clipping. Parameters ---------- InputArr : `numpy.ndarray` Input image array. MaxIter, SigRej : see `clean` Max, Min : float Max and min val...
python
def djs_iterstat(InputArr, MaxIter=10, SigRej=3.0, Max=None, Min=None, Mask=None, lineno=None): """ Iterative sigma-clipping. Parameters ---------- InputArr : `numpy.ndarray` Input image array. MaxIter, SigRej : see `clean` Max, Min : float Max and min val...
[ "def", "djs_iterstat", "(", "InputArr", ",", "MaxIter", "=", "10", ",", "SigRej", "=", "3.0", ",", "Max", "=", "None", ",", "Min", "=", "None", ",", "Mask", "=", "None", ",", "lineno", "=", "None", ")", ":", "NGood", "=", "InputArr", ".", "size", ...
Iterative sigma-clipping. Parameters ---------- InputArr : `numpy.ndarray` Input image array. MaxIter, SigRej : see `clean` Max, Min : float Max and min values for clipping. Mask : `numpy.ndarray` Mask array to indicate pixels to reject, in addition to clipping. ...
[ "Iterative", "sigma", "-", "clipping", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L899-L1010
train
spacetelescope/acstools
acstools/acs_destripe.py
run
def run(configobj=None): """TEAL interface for the `clean` function.""" clean(configobj['input'], suffix=configobj['suffix'], stat=configobj['stat'], maxiter=configobj['maxiter'], sigrej=configobj['sigrej'], lower=configobj['lower'], upper=configobj['u...
python
def run(configobj=None): """TEAL interface for the `clean` function.""" clean(configobj['input'], suffix=configobj['suffix'], stat=configobj['stat'], maxiter=configobj['maxiter'], sigrej=configobj['sigrej'], lower=configobj['lower'], upper=configobj['u...
[ "def", "run", "(", "configobj", "=", "None", ")", ":", "clean", "(", "configobj", "[", "'input'", "]", ",", "suffix", "=", "configobj", "[", "'suffix'", "]", ",", "stat", "=", "configobj", "[", "'stat'", "]", ",", "maxiter", "=", "configobj", "[", "'...
TEAL interface for the `clean` function.
[ "TEAL", "interface", "for", "the", "clean", "function", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L1022-L1039
train
spacetelescope/acstools
acstools/acs_destripe.py
main
def main(): """Command line driver.""" import argparse parser = argparse.ArgumentParser( prog=__taskname__, description='Remove horizontal stripes from ACS WFC post-SM4 data.') parser.add_argument( 'arg0', metavar='input', type=str, help='Input file') parser.add_argument( ...
python
def main(): """Command line driver.""" import argparse parser = argparse.ArgumentParser( prog=__taskname__, description='Remove horizontal stripes from ACS WFC post-SM4 data.') parser.add_argument( 'arg0', metavar='input', type=str, help='Input file') parser.add_argument( ...
[ "def", "main", "(", ")", ":", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "__taskname__", ",", "description", "=", "'Remove horizontal stripes from ACS WFC post-SM4 data.'", ")", "parser", ".", "add_argument", "(", "'arg...
Command line driver.
[ "Command", "line", "driver", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L1046-L1111
train
spacetelescope/acstools
acstools/acs_destripe.py
StripeArray.configure_arrays
def configure_arrays(self): """Get the SCI and ERR data.""" self.science = self.hdulist['sci', 1].data self.err = self.hdulist['err', 1].data self.dq = self.hdulist['dq', 1].data if (self.ampstring == 'ABCD'): self.science = np.concatenate( (self.scien...
python
def configure_arrays(self): """Get the SCI and ERR data.""" self.science = self.hdulist['sci', 1].data self.err = self.hdulist['err', 1].data self.dq = self.hdulist['dq', 1].data if (self.ampstring == 'ABCD'): self.science = np.concatenate( (self.scien...
[ "def", "configure_arrays", "(", "self", ")", ":", "self", ".", "science", "=", "self", ".", "hdulist", "[", "'sci'", ",", "1", "]", ".", "data", "self", ".", "err", "=", "self", ".", "hdulist", "[", "'err'", ",", "1", "]", ".", "data", "self", "....
Get the SCI and ERR data.
[ "Get", "the", "SCI", "and", "ERR", "data", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L99-L113
train
spacetelescope/acstools
acstools/acs_destripe.py
StripeArray.ingest_flatfield
def ingest_flatfield(self): """Process flatfield.""" self.invflat = extract_flatfield( self.hdulist[0].header, self.hdulist[1]) # If BIAS or DARK, set flatfield to unity if self.invflat is None: self.invflat = np.ones_like(self.science) return ...
python
def ingest_flatfield(self): """Process flatfield.""" self.invflat = extract_flatfield( self.hdulist[0].header, self.hdulist[1]) # If BIAS or DARK, set flatfield to unity if self.invflat is None: self.invflat = np.ones_like(self.science) return ...
[ "def", "ingest_flatfield", "(", "self", ")", ":", "self", ".", "invflat", "=", "extract_flatfield", "(", "self", ".", "hdulist", "[", "0", "]", ".", "header", ",", "self", ".", "hdulist", "[", "1", "]", ")", "# If BIAS or DARK, set flatfield to unity", "if",...
Process flatfield.
[ "Process", "flatfield", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L115-L129
train
spacetelescope/acstools
acstools/acs_destripe.py
StripeArray.ingest_flash
def ingest_flash(self): """Process post-flash.""" self.flash = extract_flash(self.hdulist[0].header, self.hdulist[1]) # Set post-flash to zeros if self.flash is None: self.flash = np.zeros_like(self.science) return # Apply the flash subtraction if neces...
python
def ingest_flash(self): """Process post-flash.""" self.flash = extract_flash(self.hdulist[0].header, self.hdulist[1]) # Set post-flash to zeros if self.flash is None: self.flash = np.zeros_like(self.science) return # Apply the flash subtraction if neces...
[ "def", "ingest_flash", "(", "self", ")", ":", "self", ".", "flash", "=", "extract_flash", "(", "self", ".", "hdulist", "[", "0", "]", ".", "header", ",", "self", ".", "hdulist", "[", "1", "]", ")", "# Set post-flash to zeros", "if", "self", ".", "flash...
Process post-flash.
[ "Process", "post", "-", "flash", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L131-L144
train
spacetelescope/acstools
acstools/acs_destripe.py
StripeArray.ingest_dark
def ingest_dark(self): """Process dark.""" self.dark = extract_dark(self.hdulist[0].header, self.hdulist[1]) # If BIAS or DARK, set dark to zeros if self.dark is None: self.dark = np.zeros_like(self.science) return # Apply the dark subtraction if necess...
python
def ingest_dark(self): """Process dark.""" self.dark = extract_dark(self.hdulist[0].header, self.hdulist[1]) # If BIAS or DARK, set dark to zeros if self.dark is None: self.dark = np.zeros_like(self.science) return # Apply the dark subtraction if necess...
[ "def", "ingest_dark", "(", "self", ")", ":", "self", ".", "dark", "=", "extract_dark", "(", "self", ".", "hdulist", "[", "0", "]", ".", "header", ",", "self", ".", "hdulist", "[", "1", "]", ")", "# If BIAS or DARK, set dark to zeros", "if", "self", ".", ...
Process dark.
[ "Process", "dark", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L146-L159
train
spacetelescope/acstools
acstools/acs_destripe.py
StripeArray.write_corrected
def write_corrected(self, output, clobber=False): """Write out the destriped data.""" # un-apply the flatfield if necessary if self.flatcorr != 'COMPLETE': self.science = self.science / self.invflat self.err = self.err / self.invflat # un-apply the post-flash if...
python
def write_corrected(self, output, clobber=False): """Write out the destriped data.""" # un-apply the flatfield if necessary if self.flatcorr != 'COMPLETE': self.science = self.science / self.invflat self.err = self.err / self.invflat # un-apply the post-flash if...
[ "def", "write_corrected", "(", "self", ",", "output", ",", "clobber", "=", "False", ")", ":", "# un-apply the flatfield if necessary", "if", "self", ".", "flatcorr", "!=", "'COMPLETE'", ":", "self", ".", "science", "=", "self", ".", "science", "/", "self", "...
Write out the destriped data.
[ "Write", "out", "the", "destriped", "data", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L161-L191
train
spacetelescope/acstools
acstools/calacs.py
calacs
def calacs(input_file, exec_path=None, time_stamps=False, temp_files=False, verbose=False, debug=False, quiet=False, single_core=False, exe_args=None): """ Run the calacs.e executable as from the shell. By default this will run the calacs given by 'calacs.e'. Parameters -----...
python
def calacs(input_file, exec_path=None, time_stamps=False, temp_files=False, verbose=False, debug=False, quiet=False, single_core=False, exe_args=None): """ Run the calacs.e executable as from the shell. By default this will run the calacs given by 'calacs.e'. Parameters -----...
[ "def", "calacs", "(", "input_file", ",", "exec_path", "=", "None", ",", "time_stamps", "=", "False", ",", "temp_files", "=", "False", ",", "verbose", "=", "False", ",", "debug", "=", "False", ",", "quiet", "=", "False", ",", "single_core", "=", "False", ...
Run the calacs.e executable as from the shell. By default this will run the calacs given by 'calacs.e'. Parameters ---------- input_file : str Name of input file. exec_path : str, optional The complete path to a calacs executable. time_stamps : bool, optional Set to T...
[ "Run", "the", "calacs", ".", "e", "executable", "as", "from", "the", "shell", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/calacs.py#L28-L104
train
spacetelescope/acstools
acstools/calacs.py
run
def run(configobj=None): """ TEAL interface for the `calacs` function. """ calacs(configobj['input_file'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], temp_files=configobj['temp_files'], verbose=configobj['verbose'], deb...
python
def run(configobj=None): """ TEAL interface for the `calacs` function. """ calacs(configobj['input_file'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], temp_files=configobj['temp_files'], verbose=configobj['verbose'], deb...
[ "def", "run", "(", "configobj", "=", "None", ")", ":", "calacs", "(", "configobj", "[", "'input_file'", "]", ",", "exec_path", "=", "configobj", "[", "'exec_path'", "]", ",", "time_stamps", "=", "configobj", "[", "'time_stamps'", "]", ",", "temp_files", "=...
TEAL interface for the `calacs` function.
[ "TEAL", "interface", "for", "the", "calacs", "function", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/calacs.py#L115-L128
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/helpers.py
PermissionHelper.has_any_permissions
def has_any_permissions(self, user): """ Return a boolean to indicate whether the supplied user has any permissions at all on the associated model """ for perm in self.get_all_model_permissions(): if self.has_specific_permission(user, perm.codename): r...
python
def has_any_permissions(self, user): """ Return a boolean to indicate whether the supplied user has any permissions at all on the associated model """ for perm in self.get_all_model_permissions(): if self.has_specific_permission(user, perm.codename): r...
[ "def", "has_any_permissions", "(", "self", ",", "user", ")", ":", "for", "perm", "in", "self", ".", "get_all_model_permissions", "(", ")", ":", "if", "self", ".", "has_specific_permission", "(", "user", ",", "perm", ".", "codename", ")", ":", "return", "Tr...
Return a boolean to indicate whether the supplied user has any permissions at all on the associated model
[ "Return", "a", "boolean", "to", "indicate", "whether", "the", "supplied", "user", "has", "any", "permissions", "at", "all", "on", "the", "associated", "model" ]
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/helpers.py#L31-L39
train
rkhleics/wagtailmodeladmin
wagtailmodeladmin/helpers.py
PagePermissionHelper.get_valid_parent_pages
def get_valid_parent_pages(self, user): """ Identifies possible parent pages for the current user by first looking at allowed_parent_page_models() on self.model to limit options to the correct type of page, then checking permissions on those individual pages to make sure we have ...
python
def get_valid_parent_pages(self, user): """ Identifies possible parent pages for the current user by first looking at allowed_parent_page_models() on self.model to limit options to the correct type of page, then checking permissions on those individual pages to make sure we have ...
[ "def", "get_valid_parent_pages", "(", "self", ",", "user", ")", ":", "# Start with empty qs", "parents_qs", "=", "Page", ".", "objects", ".", "none", "(", ")", "# Add pages of the correct type", "for", "pt", "in", "self", ".", "model", ".", "allowed_parent_page_mo...
Identifies possible parent pages for the current user by first looking at allowed_parent_page_models() on self.model to limit options to the correct type of page, then checking permissions on those individual pages to make sure we have permission to add a subpage to it.
[ "Identifies", "possible", "parent", "pages", "for", "the", "current", "user", "by", "first", "looking", "at", "allowed_parent_page_models", "()", "on", "self", ".", "model", "to", "limit", "options", "to", "the", "correct", "type", "of", "page", "then", "check...
7fddc853bab2ff3868b8c7a03329308c55f16358
https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/helpers.py#L108-L128
train
spacetelescope/acstools
acstools/acsrej.py
acsrej
def acsrej(input, output, exec_path='', time_stamps=False, verbose=False, shadcorr=False, crrejtab='', crmask=False, scalense=None, initgues='', skysub='', crsigmas='', crradius=None, crthresh=None, badinpdq=None, newbias=False, readnoise_only=False, exe_args=None): r""" Run the...
python
def acsrej(input, output, exec_path='', time_stamps=False, verbose=False, shadcorr=False, crrejtab='', crmask=False, scalense=None, initgues='', skysub='', crsigmas='', crradius=None, crthresh=None, badinpdq=None, newbias=False, readnoise_only=False, exe_args=None): r""" Run the...
[ "def", "acsrej", "(", "input", ",", "output", ",", "exec_path", "=", "''", ",", "time_stamps", "=", "False", ",", "verbose", "=", "False", ",", "shadcorr", "=", "False", ",", "crrejtab", "=", "''", ",", "crmask", "=", "False", ",", "scalense", "=", "...
r""" Run the acsrej.e executable as from the shell. Parameters ---------- input : str or list of str Input filenames in one of these formats: * a Python list of filenames * a partial filename with wildcards ('\*flt.fits') * filename of an ASN table ('j123456...
[ "r", "Run", "the", "acsrej", ".", "e", "executable", "as", "from", "the", "shell", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acsrej.py#L38-L198
train
spacetelescope/acstools
acstools/acsrej.py
run
def run(configobj=None): """ TEAL interface for the `acsrej` function. """ acsrej(configobj['input'], configobj['output'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], shadcorr=configobj['sha...
python
def run(configobj=None): """ TEAL interface for the `acsrej` function. """ acsrej(configobj['input'], configobj['output'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], shadcorr=configobj['sha...
[ "def", "run", "(", "configobj", "=", "None", ")", ":", "acsrej", "(", "configobj", "[", "'input'", "]", ",", "configobj", "[", "'output'", "]", ",", "exec_path", "=", "configobj", "[", "'exec_path'", "]", ",", "time_stamps", "=", "configobj", "[", "'time...
TEAL interface for the `acsrej` function.
[ "TEAL", "interface", "for", "the", "acsrej", "function", "." ]
bbf8dd080cefcbf88529ec87c420f9e1b8002554
https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acsrej.py#L209-L229
train
google/python-atfork
atfork/__init__.py
monkeypatch_os_fork_functions
def monkeypatch_os_fork_functions(): """ Replace os.fork* with wrappers that use ForkSafeLock to acquire all locks before forking and release them afterwards. """ builtin_function = type(''.join) if hasattr(os, 'fork') and isinstance(os.fork, builtin_function): global _orig_os_fork ...
python
def monkeypatch_os_fork_functions(): """ Replace os.fork* with wrappers that use ForkSafeLock to acquire all locks before forking and release them afterwards. """ builtin_function = type(''.join) if hasattr(os, 'fork') and isinstance(os.fork, builtin_function): global _orig_os_fork ...
[ "def", "monkeypatch_os_fork_functions", "(", ")", ":", "builtin_function", "=", "type", "(", "''", ".", "join", ")", "if", "hasattr", "(", "os", ",", "'fork'", ")", "and", "isinstance", "(", "os", ".", "fork", ",", "builtin_function", ")", ":", "global", ...
Replace os.fork* with wrappers that use ForkSafeLock to acquire all locks before forking and release them afterwards.
[ "Replace", "os", ".", "fork", "*", "with", "wrappers", "that", "use", "ForkSafeLock", "to", "acquire", "all", "locks", "before", "forking", "and", "release", "them", "afterwards", "." ]
0ba186bd3a75f823c720e711b39d73441da67ea4
https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L58-L71
train
google/python-atfork
atfork/__init__.py
atfork
def atfork(prepare=None, parent=None, child=None): """A Python work-a-like of pthread_atfork. Any time a fork() is called from Python, all 'prepare' callables will be called in the order they were registered using this function. After the fork (successful or not), all 'parent' callables will be ca...
python
def atfork(prepare=None, parent=None, child=None): """A Python work-a-like of pthread_atfork. Any time a fork() is called from Python, all 'prepare' callables will be called in the order they were registered using this function. After the fork (successful or not), all 'parent' callables will be ca...
[ "def", "atfork", "(", "prepare", "=", "None", ",", "parent", "=", "None", ",", "child", "=", "None", ")", ":", "assert", "not", "prepare", "or", "callable", "(", "prepare", ")", "assert", "not", "parent", "or", "callable", "(", "parent", ")", "assert",...
A Python work-a-like of pthread_atfork. Any time a fork() is called from Python, all 'prepare' callables will be called in the order they were registered using this function. After the fork (successful or not), all 'parent' callables will be called in the parent process. If the fork succeeded, al...
[ "A", "Python", "work", "-", "a", "-", "like", "of", "pthread_atfork", ".", "Any", "time", "a", "fork", "()", "is", "called", "from", "Python", "all", "prepare", "callables", "will", "be", "called", "in", "the", "order", "they", "were", "registered", "usi...
0ba186bd3a75f823c720e711b39d73441da67ea4
https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L82-L108
train
google/python-atfork
atfork/__init__.py
_call_atfork_list
def _call_atfork_list(call_list): """ Given a list of callables in call_list, call them all in order and save and return a list of sys.exc_info() tuples for each exception raised. """ exception_list = [] for func in call_list: try: func() except: exception...
python
def _call_atfork_list(call_list): """ Given a list of callables in call_list, call them all in order and save and return a list of sys.exc_info() tuples for each exception raised. """ exception_list = [] for func in call_list: try: func() except: exception...
[ "def", "_call_atfork_list", "(", "call_list", ")", ":", "exception_list", "=", "[", "]", "for", "func", "in", "call_list", ":", "try", ":", "func", "(", ")", "except", ":", "exception_list", ".", "append", "(", "sys", ".", "exc_info", "(", ")", ")", "r...
Given a list of callables in call_list, call them all in order and save and return a list of sys.exc_info() tuples for each exception raised.
[ "Given", "a", "list", "of", "callables", "in", "call_list", "call", "them", "all", "in", "order", "and", "save", "and", "return", "a", "list", "of", "sys", ".", "exc_info", "()", "tuples", "for", "each", "exception", "raised", "." ]
0ba186bd3a75f823c720e711b39d73441da67ea4
https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L111-L122
train
google/python-atfork
atfork/__init__.py
parent_after_fork_release
def parent_after_fork_release(): """ Call all parent after fork callables, release the lock and print all prepare and parent callback exceptions. """ prepare_exceptions = list(_prepare_call_exceptions) del _prepare_call_exceptions[:] exceptions = _call_atfork_list(_parent_call_list) _for...
python
def parent_after_fork_release(): """ Call all parent after fork callables, release the lock and print all prepare and parent callback exceptions. """ prepare_exceptions = list(_prepare_call_exceptions) del _prepare_call_exceptions[:] exceptions = _call_atfork_list(_parent_call_list) _for...
[ "def", "parent_after_fork_release", "(", ")", ":", "prepare_exceptions", "=", "list", "(", "_prepare_call_exceptions", ")", "del", "_prepare_call_exceptions", "[", ":", "]", "exceptions", "=", "_call_atfork_list", "(", "_parent_call_list", ")", "_fork_lock", ".", "rel...
Call all parent after fork callables, release the lock and print all prepare and parent callback exceptions.
[ "Call", "all", "parent", "after", "fork", "callables", "release", "the", "lock", "and", "print", "all", "prepare", "and", "parent", "callback", "exceptions", "." ]
0ba186bd3a75f823c720e711b39d73441da67ea4
https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L131-L141
train
google/python-atfork
atfork/__init__.py
_print_exception_list
def _print_exception_list(exceptions, message, output_file=None): """ Given a list of sys.exc_info tuples, print them all using the traceback module preceeded by a message and separated by a blank line. """ output_file = output_file or sys.stderr message = 'Exception %s:\n' % message for exc...
python
def _print_exception_list(exceptions, message, output_file=None): """ Given a list of sys.exc_info tuples, print them all using the traceback module preceeded by a message and separated by a blank line. """ output_file = output_file or sys.stderr message = 'Exception %s:\n' % message for exc...
[ "def", "_print_exception_list", "(", "exceptions", ",", "message", ",", "output_file", "=", "None", ")", ":", "output_file", "=", "output_file", "or", "sys", ".", "stderr", "message", "=", "'Exception %s:\\n'", "%", "message", "for", "exc_type", ",", "exc_value"...
Given a list of sys.exc_info tuples, print them all using the traceback module preceeded by a message and separated by a blank line.
[ "Given", "a", "list", "of", "sys", ".", "exc_info", "tuples", "print", "them", "all", "using", "the", "traceback", "module", "preceeded", "by", "a", "message", "and", "separated", "by", "a", "blank", "line", "." ]
0ba186bd3a75f823c720e711b39d73441da67ea4
https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L155-L166
train
google/python-atfork
atfork/__init__.py
os_forkpty_wrapper
def os_forkpty_wrapper(): """Wraps os.forkpty() to run atfork handlers.""" pid = None prepare_to_fork_acquire() try: pid, fd = _orig_os_forkpty() finally: if pid == 0: child_after_fork_release() else: parent_after_fork_release() return pid, fd
python
def os_forkpty_wrapper(): """Wraps os.forkpty() to run atfork handlers.""" pid = None prepare_to_fork_acquire() try: pid, fd = _orig_os_forkpty() finally: if pid == 0: child_after_fork_release() else: parent_after_fork_release() return pid, fd
[ "def", "os_forkpty_wrapper", "(", ")", ":", "pid", "=", "None", "prepare_to_fork_acquire", "(", ")", "try", ":", "pid", ",", "fd", "=", "_orig_os_forkpty", "(", ")", "finally", ":", "if", "pid", "==", "0", ":", "child_after_fork_release", "(", ")", "else",...
Wraps os.forkpty() to run atfork handlers.
[ "Wraps", "os", ".", "forkpty", "()", "to", "run", "atfork", "handlers", "." ]
0ba186bd3a75f823c720e711b39d73441da67ea4
https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L185-L196
train
ekampf/pymaybe
pymaybe/__init__.py
maybe
def maybe(value): """Wraps an object with a Maybe instance. >>> maybe("I'm a value") Something("I'm a value") >>> maybe(None); Nothing Testing for value: >>> maybe("I'm a value").is_some() True >>> maybe("I'm a value").is_none() False >>> may...
python
def maybe(value): """Wraps an object with a Maybe instance. >>> maybe("I'm a value") Something("I'm a value") >>> maybe(None); Nothing Testing for value: >>> maybe("I'm a value").is_some() True >>> maybe("I'm a value").is_none() False >>> may...
[ "def", "maybe", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "Maybe", ")", ":", "return", "value", "if", "value", "is", "not", "None", ":", "return", "Something", "(", "value", ")", "return", "Nothing", "(", ")" ]
Wraps an object with a Maybe instance. >>> maybe("I'm a value") Something("I'm a value") >>> maybe(None); Nothing Testing for value: >>> maybe("I'm a value").is_some() True >>> maybe("I'm a value").is_none() False >>> maybe(None).is_some() ...
[ "Wraps", "an", "object", "with", "a", "Maybe", "instance", "." ]
f755600f5478b6b595e2100417b39a7bc3de2c6f
https://github.com/ekampf/pymaybe/blob/f755600f5478b6b595e2100417b39a7bc3de2c6f/pymaybe/__init__.py#L472-L575
train
ianepperson/telnetsrvlib
telnetsrv/evtlet.py
TelnetHandler.setup
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a greenlet to handle socket input self.greenlet_ic = eventlet.spawn(self.inputcooker) # Note that inputcooker exits on EOF # Sleep for 0.5 second to allow options negotiation ...
python
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a greenlet to handle socket input self.greenlet_ic = eventlet.spawn(self.inputcooker) # Note that inputcooker exits on EOF # Sleep for 0.5 second to allow options negotiation ...
[ "def", "setup", "(", "self", ")", ":", "TelnetHandlerBase", ".", "setup", "(", "self", ")", "# Spawn a greenlet to handle socket input", "self", ".", "greenlet_ic", "=", "eventlet", ".", "spawn", "(", "self", ".", "inputcooker", ")", "# Note that inputcooker exits o...
Called after instantiation
[ "Called", "after", "instantiation" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/evtlet.py#L16-L24
train
ianepperson/telnetsrvlib
telnetsrv/evtlet.py
TelnetHandler.inputcooker_store_queue
def inputcooker_store_queue(self, char): """Put the cooked data in the input queue (no locking needed)""" if type(char) in [type(()), type([]), type("")]: for v in char: self.cookedq.put(v) else: self.cookedq.put(char)
python
def inputcooker_store_queue(self, char): """Put the cooked data in the input queue (no locking needed)""" if type(char) in [type(()), type([]), type("")]: for v in char: self.cookedq.put(v) else: self.cookedq.put(char)
[ "def", "inputcooker_store_queue", "(", "self", ",", "char", ")", ":", "if", "type", "(", "char", ")", "in", "[", "type", "(", "(", ")", ")", ",", "type", "(", "[", "]", ")", ",", "type", "(", "\"\"", ")", "]", ":", "for", "v", "in", "char", "...
Put the cooked data in the input queue (no locking needed)
[ "Put", "the", "cooked", "data", "in", "the", "input", "queue", "(", "no", "locking", "needed", ")" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/evtlet.py#L51-L57
train
ianepperson/telnetsrvlib
telnetsrv/paramiko_ssh.py
SSHHandler.setup
def setup(self): '''Setup the connection.''' log.debug( 'New request from address %s, port %d', self.client_address ) try: self.transport.load_server_moduli() except: log.exception( '(Failed to load moduli -- gex will be unsupported.)' ) rais...
python
def setup(self): '''Setup the connection.''' log.debug( 'New request from address %s, port %d', self.client_address ) try: self.transport.load_server_moduli() except: log.exception( '(Failed to load moduli -- gex will be unsupported.)' ) rais...
[ "def", "setup", "(", "self", ")", ":", "log", ".", "debug", "(", "'New request from address %s, port %d'", ",", "self", ".", "client_address", ")", "try", ":", "self", ".", "transport", ".", "load_server_moduli", "(", ")", "except", ":", "log", ".", "excepti...
Setup the connection.
[ "Setup", "the", "connection", "." ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L71-L108
train
ianepperson/telnetsrvlib
telnetsrv/paramiko_ssh.py
SSHHandler.streamserver_handle
def streamserver_handle(cls, socket, address): '''Translate this class for use in a StreamServer''' request = cls.dummy_request() request._sock = socket server = None cls(request, address, server)
python
def streamserver_handle(cls, socket, address): '''Translate this class for use in a StreamServer''' request = cls.dummy_request() request._sock = socket server = None cls(request, address, server)
[ "def", "streamserver_handle", "(", "cls", ",", "socket", ",", "address", ")", ":", "request", "=", "cls", ".", "dummy_request", "(", ")", "request", ".", "_sock", "=", "socket", "server", "=", "None", "cls", "(", "request", ",", "address", ",", "server",...
Translate this class for use in a StreamServer
[ "Translate", "this", "class", "for", "use", "in", "a", "StreamServer" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L118-L123
train
ianepperson/telnetsrvlib
telnetsrv/paramiko_ssh.py
SSHHandler.check_channel_shell_request
def check_channel_shell_request(self, channel): '''Request to start a shell on the given channel''' try: self.channels[channel].start() except KeyError: log.error('Requested to start a channel (%r) that was not previously set up.', channel) return False ...
python
def check_channel_shell_request(self, channel): '''Request to start a shell on the given channel''' try: self.channels[channel].start() except KeyError: log.error('Requested to start a channel (%r) that was not previously set up.', channel) return False ...
[ "def", "check_channel_shell_request", "(", "self", ",", "channel", ")", ":", "try", ":", "self", ".", "channels", "[", "channel", "]", ".", "start", "(", ")", "except", "KeyError", ":", "log", ".", "error", "(", "'Requested to start a channel (%r) that was not p...
Request to start a shell on the given channel
[ "Request", "to", "start", "a", "shell", "on", "the", "given", "channel" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L200-L208
train
ianepperson/telnetsrvlib
telnetsrv/paramiko_ssh.py
SSHHandler.check_channel_pty_request
def check_channel_pty_request(self, channel, term, width, height, pixelwidth, pixelheight, modes): '''Request to allocate a PTY terminal.''' #self.sshterm = term #print "term: %r, modes: %r" % (term, modes) log.debug('PTY requested. Setting up %r.', sel...
python
def check_channel_pty_request(self, channel, term, width, height, pixelwidth, pixelheight, modes): '''Request to allocate a PTY terminal.''' #self.sshterm = term #print "term: %r, modes: %r" % (term, modes) log.debug('PTY requested. Setting up %r.', sel...
[ "def", "check_channel_pty_request", "(", "self", ",", "channel", ",", "term", ",", "width", ",", "height", ",", "pixelwidth", ",", "pixelheight", ",", "modes", ")", ":", "#self.sshterm = term", "#print \"term: %r, modes: %r\" % (term, modes)", "log", ".", "debug", "...
Request to allocate a PTY terminal.
[ "Request", "to", "allocate", "a", "PTY", "terminal", "." ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L210-L219
train
deeplearning4j/pydl4j
pydl4j/downloader.py
download
def download(url, file_name): r = requests.get(url, stream=True) file_size = int(r.headers['Content-length']) ''' if py3: file_size = int(u.getheader("Content-Length")[0]) else: file_size = int(u.info().getheaders("Content-Length")[0]) ''' file_exists = False if...
python
def download(url, file_name): r = requests.get(url, stream=True) file_size = int(r.headers['Content-length']) ''' if py3: file_size = int(u.getheader("Content-Length")[0]) else: file_size = int(u.info().getheaders("Content-Length")[0]) ''' file_exists = False if...
[ "def", "download", "(", "url", ",", "file_name", ")", ":", "r", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "file_size", "=", "int", "(", "r", ".", "headers", "[", "'Content-length'", "]", ")", "file_exists", "=", "False...
if py3: file_size = int(u.getheader("Content-Length")[0]) else: file_size = int(u.info().getheaders("Content-Length")[0])
[ "if", "py3", ":", "file_size", "=", "int", "(", "u", ".", "getheader", "(", "Content", "-", "Length", ")", "[", "0", "]", ")", "else", ":", "file_size", "=", "int", "(", "u", ".", "info", "()", ".", "getheaders", "(", "Content", "-", "Length", ")...
63f8a1cae2afb4b08dbfe28ef8e08de741f0d3cd
https://github.com/deeplearning4j/pydl4j/blob/63f8a1cae2afb4b08dbfe28ef8e08de741f0d3cd/pydl4j/downloader.py#L23-L82
train
hbldh/pybankid
bankid/jsonclient.py
BankIDJSONClient.authenticate
def authenticate( self, end_user_ip, personal_number=None, requirement=None, **kwargs ): """Request an authentication order. The :py:meth:`collect` method is used to query the status of the order. Note that personal number is not needed when authentication is to be done on t...
python
def authenticate( self, end_user_ip, personal_number=None, requirement=None, **kwargs ): """Request an authentication order. The :py:meth:`collect` method is used to query the status of the order. Note that personal number is not needed when authentication is to be done on t...
[ "def", "authenticate", "(", "self", ",", "end_user_ip", ",", "personal_number", "=", "None", ",", "requirement", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"endUserIp\"", ":", "end_user_ip", "}", "if", "personal_number", ":", "data...
Request an authentication order. The :py:meth:`collect` method is used to query the status of the order. Note that personal number is not needed when authentication is to be done on the same device, provided that the returned ``autoStartToken`` is used to open the BankID Client. ...
[ "Request", "an", "authentication", "order", ".", "The", ":", "py", ":", "meth", ":", "collect", "method", "is", "used", "to", "query", "the", "status", "of", "the", "order", "." ]
1405f66e41f912cdda15e20aea08cdfa6b60480a
https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L79-L126
train
hbldh/pybankid
bankid/jsonclient.py
BankIDJSONClient.sign
def sign( self, end_user_ip, user_visible_data, personal_number=None, requirement=None, user_non_visible_data=None, **kwargs ): """Request an signing order. The :py:meth:`collect` method is used to query the status of the order. Note t...
python
def sign( self, end_user_ip, user_visible_data, personal_number=None, requirement=None, user_non_visible_data=None, **kwargs ): """Request an signing order. The :py:meth:`collect` method is used to query the status of the order. Note t...
[ "def", "sign", "(", "self", ",", "end_user_ip", ",", "user_visible_data", ",", "personal_number", "=", "None", ",", "requirement", "=", "None", ",", "user_non_visible_data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"endUserIp\"", ...
Request an signing order. The :py:meth:`collect` method is used to query the status of the order. Note that personal number is not needed when signing is to be done on the same device, provided that the returned ``autoStartToken`` is used to open the BankID Client. Example data...
[ "Request", "an", "signing", "order", ".", "The", ":", "py", ":", "meth", ":", "collect", "method", "is", "used", "to", "query", "the", "status", "of", "the", "order", "." ]
1405f66e41f912cdda15e20aea08cdfa6b60480a
https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L128-L190
train
hbldh/pybankid
bankid/jsonclient.py
BankIDJSONClient.collect
def collect(self, order_ref): """Collects the result of a sign or auth order using the ``orderRef`` as reference. RP should keep on calling collect every two seconds as long as status indicates pending. RP must abort if status indicates failed. The user identity is returned when...
python
def collect(self, order_ref): """Collects the result of a sign or auth order using the ``orderRef`` as reference. RP should keep on calling collect every two seconds as long as status indicates pending. RP must abort if status indicates failed. The user identity is returned when...
[ "def", "collect", "(", "self", ",", "order_ref", ")", ":", "response", "=", "self", ".", "client", ".", "post", "(", "self", ".", "_collect_endpoint", ",", "json", "=", "{", "\"orderRef\"", ":", "order_ref", "}", ")", "if", "response", ".", "status_code"...
Collects the result of a sign or auth order using the ``orderRef`` as reference. RP should keep on calling collect every two seconds as long as status indicates pending. RP must abort if status indicates failed. The user identity is returned when complete. Example collect resul...
[ "Collects", "the", "result", "of", "a", "sign", "or", "auth", "order", "using", "the", "orderRef", "as", "reference", "." ]
1405f66e41f912cdda15e20aea08cdfa6b60480a
https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L192-L267
train
hbldh/pybankid
bankid/jsonclient.py
BankIDJSONClient.cancel
def cancel(self, order_ref): """Cancels an ongoing sign or auth order. This is typically used if the user cancels the order in your service or app. :param order_ref: The UUID string specifying which order to cancel. :type order_ref: str :return: Boolean regarding succes...
python
def cancel(self, order_ref): """Cancels an ongoing sign or auth order. This is typically used if the user cancels the order in your service or app. :param order_ref: The UUID string specifying which order to cancel. :type order_ref: str :return: Boolean regarding succes...
[ "def", "cancel", "(", "self", ",", "order_ref", ")", ":", "response", "=", "self", ".", "client", ".", "post", "(", "self", ".", "_cancel_endpoint", ",", "json", "=", "{", "\"orderRef\"", ":", "order_ref", "}", ")", "if", "response", ".", "status_code", ...
Cancels an ongoing sign or auth order. This is typically used if the user cancels the order in your service or app. :param order_ref: The UUID string specifying which order to cancel. :type order_ref: str :return: Boolean regarding success of cancellation. :rtype: bool ...
[ "Cancels", "an", "ongoing", "sign", "or", "auth", "order", "." ]
1405f66e41f912cdda15e20aea08cdfa6b60480a
https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L269-L288
train
ianepperson/telnetsrvlib
telnetsrv/threaded.py
TelnetHandler.setup
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a thread to handle socket input self.thread_ic = threading.Thread(target=self.inputcooker) self.thread_ic.setDaemon(True) self.thread_ic.start() # Note that inputcooker exits o...
python
def setup(self): '''Called after instantiation''' TelnetHandlerBase.setup(self) # Spawn a thread to handle socket input self.thread_ic = threading.Thread(target=self.inputcooker) self.thread_ic.setDaemon(True) self.thread_ic.start() # Note that inputcooker exits o...
[ "def", "setup", "(", "self", ")", ":", "TelnetHandlerBase", ".", "setup", "(", "self", ")", "# Spawn a thread to handle socket input", "self", ".", "thread_ic", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "inputcooker", ")", "self", ".", ...
Called after instantiation
[ "Called", "after", "instantiation" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L23-L33
train
ianepperson/telnetsrvlib
telnetsrv/threaded.py
TelnetHandler.getc
def getc(self, block=True): """Return one character from the input queue""" if not block: if not len(self.cookedq): return '' while not len(self.cookedq): time.sleep(0.05) self.IQUEUELOCK.acquire() ret = self.cookedq[0] self.cookedq...
python
def getc(self, block=True): """Return one character from the input queue""" if not block: if not len(self.cookedq): return '' while not len(self.cookedq): time.sleep(0.05) self.IQUEUELOCK.acquire() ret = self.cookedq[0] self.cookedq...
[ "def", "getc", "(", "self", ",", "block", "=", "True", ")", ":", "if", "not", "block", ":", "if", "not", "len", "(", "self", ".", "cookedq", ")", ":", "return", "''", "while", "not", "len", "(", "self", ".", "cookedq", ")", ":", "time", ".", "s...
Return one character from the input queue
[ "Return", "one", "character", "from", "the", "input", "queue" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L44-L55
train
ianepperson/telnetsrvlib
telnetsrv/threaded.py
TelnetHandler.inputcooker_store_queue
def inputcooker_store_queue(self, char): """Put the cooked data in the input queue (with locking)""" self.IQUEUELOCK.acquire() if type(char) in [type(()), type([]), type("")]: for v in char: self.cookedq.append(v) else: self.cookedq.append(char) ...
python
def inputcooker_store_queue(self, char): """Put the cooked data in the input queue (with locking)""" self.IQUEUELOCK.acquire() if type(char) in [type(()), type([]), type("")]: for v in char: self.cookedq.append(v) else: self.cookedq.append(char) ...
[ "def", "inputcooker_store_queue", "(", "self", ",", "char", ")", ":", "self", ".", "IQUEUELOCK", ".", "acquire", "(", ")", "if", "type", "(", "char", ")", "in", "[", "type", "(", "(", ")", ")", ",", "type", "(", "[", "]", ")", ",", "type", "(", ...
Put the cooked data in the input queue (with locking)
[ "Put", "the", "cooked", "data", "in", "the", "input", "queue", "(", "with", "locking", ")" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L61-L69
train
ianepperson/telnetsrvlib
telnetsrv/threaded.py
TelnetHandler.writemessage
def writemessage(self, text): """Put data in output queue, rebuild the prompt and entered data""" # Need to grab the input queue lock to ensure the entered data doesn't change # before we're done rebuilding it. # Note that writemessage will eventually call writecooked self.IQUEUE...
python
def writemessage(self, text): """Put data in output queue, rebuild the prompt and entered data""" # Need to grab the input queue lock to ensure the entered data doesn't change # before we're done rebuilding it. # Note that writemessage will eventually call writecooked self.IQUEUE...
[ "def", "writemessage", "(", "self", ",", "text", ")", ":", "# Need to grab the input queue lock to ensure the entered data doesn't change", "# before we're done rebuilding it.", "# Note that writemessage will eventually call writecooked", "self", ".", "IQUEUELOCK", ".", "acquire", "(...
Put data in output queue, rebuild the prompt and entered data
[ "Put", "data", "in", "output", "queue", "rebuild", "the", "prompt", "and", "entered", "data" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L74-L81
train
ianepperson/telnetsrvlib
telnetsrv/threaded.py
TelnetHandler.writecooked
def writecooked(self, text): """Put data directly into the output queue""" # Ensure this is the only thread writing self.OQUEUELOCK.acquire() TelnetHandlerBase.writecooked(self, text) self.OQUEUELOCK.release()
python
def writecooked(self, text): """Put data directly into the output queue""" # Ensure this is the only thread writing self.OQUEUELOCK.acquire() TelnetHandlerBase.writecooked(self, text) self.OQUEUELOCK.release()
[ "def", "writecooked", "(", "self", ",", "text", ")", ":", "# Ensure this is the only thread writing", "self", ".", "OQUEUELOCK", ".", "acquire", "(", ")", "TelnetHandlerBase", ".", "writecooked", "(", "self", ",", "text", ")", "self", ".", "OQUEUELOCK", ".", "...
Put data directly into the output queue
[ "Put", "data", "directly", "into", "the", "output", "queue" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L83-L88
train
hbldh/pybankid
bankid/certutils.py
split_certificate
def split_certificate(certificate_path, destination_folder, password=None): """Splits a PKCS12 certificate into Base64-encoded DER certificate and key. This method splits a potentially password-protected `PKCS12 <https://en.wikipedia.org/wiki/PKCS_12>`_ certificate (format ``.p12`` or ``.pfx``) into on...
python
def split_certificate(certificate_path, destination_folder, password=None): """Splits a PKCS12 certificate into Base64-encoded DER certificate and key. This method splits a potentially password-protected `PKCS12 <https://en.wikipedia.org/wiki/PKCS_12>`_ certificate (format ``.p12`` or ``.pfx``) into on...
[ "def", "split_certificate", "(", "certificate_path", ",", "destination_folder", ",", "password", "=", "None", ")", ":", "try", ":", "# Attempt Linux and Darwin call first.", "p", "=", "subprocess", ".", "Popen", "(", "[", "\"openssl\"", ",", "\"version\"", "]", ",...
Splits a PKCS12 certificate into Base64-encoded DER certificate and key. This method splits a potentially password-protected `PKCS12 <https://en.wikipedia.org/wiki/PKCS_12>`_ certificate (format ``.p12`` or ``.pfx``) into one certificate and one key part, both in `pem <https://en.wikipedia.org/wiki/X.5...
[ "Splits", "a", "PKCS12", "certificate", "into", "Base64", "-", "encoded", "DER", "certificate", "and", "key", "." ]
1405f66e41f912cdda15e20aea08cdfa6b60480a
https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/certutils.py#L62-L152
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
InputBashLike.process_delimiter
def process_delimiter(self, char): '''Process chars while not in a part''' if char in self.whitespace: return if char in self.quote_chars: # Store the quote type (' or ") and switch to quote processing. self.inquote = char self.process_char = self....
python
def process_delimiter(self, char): '''Process chars while not in a part''' if char in self.whitespace: return if char in self.quote_chars: # Store the quote type (' or ") and switch to quote processing. self.inquote = char self.process_char = self....
[ "def", "process_delimiter", "(", "self", ",", "char", ")", ":", "if", "char", "in", "self", ".", "whitespace", ":", "return", "if", "char", "in", "self", ".", "quote_chars", ":", "# Store the quote type (' or \") and switch to quote processing.", "self", ".", "inq...
Process chars while not in a part
[ "Process", "chars", "while", "not", "in", "a", "part" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L287-L301
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
InputBashLike.process_part
def process_part(self, char): '''Process chars while in a part''' if char in self.whitespace or char == self.eol_char: # End of the part. self.parts.append( ''.join(self.part) ) self.part = [] # Switch back to processing a delimiter. self.proce...
python
def process_part(self, char): '''Process chars while in a part''' if char in self.whitespace or char == self.eol_char: # End of the part. self.parts.append( ''.join(self.part) ) self.part = [] # Switch back to processing a delimiter. self.proce...
[ "def", "process_part", "(", "self", ",", "char", ")", ":", "if", "char", "in", "self", ".", "whitespace", "or", "char", "==", "self", ".", "eol_char", ":", "# End of the part.", "self", ".", "parts", ".", "append", "(", "''", ".", "join", "(", "self", ...
Process chars while in a part
[ "Process", "chars", "while", "in", "a", "part" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L303-L319
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
InputBashLike.process_quote
def process_quote(self, char): '''Process character while in a quote''' if char == self.inquote: # Quote is finished, switch to part processing. self.process_char = self.process_part return try: self.part.append(char) except: se...
python
def process_quote(self, char): '''Process character while in a quote''' if char == self.inquote: # Quote is finished, switch to part processing. self.process_char = self.process_part return try: self.part.append(char) except: se...
[ "def", "process_quote", "(", "self", ",", "char", ")", ":", "if", "char", "==", "self", ".", "inquote", ":", "# Quote is finished, switch to part processing.", "self", ".", "process_char", "=", "self", ".", "process_part", "return", "try", ":", "self", ".", "p...
Process character while in a quote
[ "Process", "character", "while", "in", "a", "quote" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L321-L330
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
InputBashLike.process_escape
def process_escape(self, char): '''Handle the char after the escape char''' # Always only run once, switch back to the last processor. self.process_char = self.last_process_char if self.part == [] and char in self.whitespace: # Special case where \ is by itself and not at the...
python
def process_escape(self, char): '''Handle the char after the escape char''' # Always only run once, switch back to the last processor. self.process_char = self.last_process_char if self.part == [] and char in self.whitespace: # Special case where \ is by itself and not at the...
[ "def", "process_escape", "(", "self", ",", "char", ")", ":", "# Always only run once, switch back to the last processor.", "self", ".", "process_char", "=", "self", ".", "last_process_char", "if", "self", ".", "part", "==", "[", "]", "and", "char", "in", "self", ...
Handle the char after the escape char
[ "Handle", "the", "char", "after", "the", "escape", "char" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L332-L344
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
InputBashLike.process
def process(self, line): '''Step through the line and process each character''' self.raw = self.raw + line try: if not line[-1] == self.eol_char: # Should always be here, but add it just in case. line = line + self.eol_char except IndexError: ...
python
def process(self, line): '''Step through the line and process each character''' self.raw = self.raw + line try: if not line[-1] == self.eol_char: # Should always be here, but add it just in case. line = line + self.eol_char except IndexError: ...
[ "def", "process", "(", "self", ",", "line", ")", ":", "self", ".", "raw", "=", "self", ".", "raw", "+", "line", "try", ":", "if", "not", "line", "[", "-", "1", "]", "==", "self", ".", "eol_char", ":", "# Should always be here, but add it just in case.", ...
Step through the line and process each character
[ "Step", "through", "the", "line", "and", "process", "each", "character" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L347-L367
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
TelnetHandlerBase.streamserver_handle
def streamserver_handle(cls, sock, address): '''Translate this class for use in a StreamServer''' request = cls.false_request() request._sock = sock server = None log.debug("Accepted connection, starting telnet session.") try: cls(request, address, server) ...
python
def streamserver_handle(cls, sock, address): '''Translate this class for use in a StreamServer''' request = cls.false_request() request._sock = sock server = None log.debug("Accepted connection, starting telnet session.") try: cls(request, address, server) ...
[ "def", "streamserver_handle", "(", "cls", ",", "sock", ",", "address", ")", ":", "request", "=", "cls", ".", "false_request", "(", ")", "request", ".", "_sock", "=", "sock", "server", "=", "None", "log", ".", "debug", "(", "\"Accepted connection, starting te...
Translate this class for use in a StreamServer
[ "Translate", "this", "class", "for", "use", "in", "a", "StreamServer" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L491-L500
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
TelnetHandlerBase.setterm
def setterm(self, term): "Set the curses structures for this terminal" log.debug("Setting termtype to %s" % (term, )) curses.setupterm(term) # This will raise if the termtype is not supported self.TERM = term self.ESCSEQ = {} for k in self.KEYS.keys(): str = c...
python
def setterm(self, term): "Set the curses structures for this terminal" log.debug("Setting termtype to %s" % (term, )) curses.setupterm(term) # This will raise if the termtype is not supported self.TERM = term self.ESCSEQ = {} for k in self.KEYS.keys(): str = c...
[ "def", "setterm", "(", "self", ",", "term", ")", ":", "log", ".", "debug", "(", "\"Setting termtype to %s\"", "%", "(", "term", ",", ")", ")", "curses", ".", "setupterm", "(", "term", ")", "# This will raise if the termtype is not supported", "self", ".", "TER...
Set the curses structures for this terminal
[ "Set", "the", "curses", "structures", "for", "this", "terminal" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L502-L518
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
TelnetHandlerBase.setup
def setup(self): "Connect incoming connection to a telnet session" try: self.TERM = self.request.term except: pass self.setterm(self.TERM) self.sock = self.request._sock for k in self.DOACK.keys(): self.sendcommand(self.DOACK[k], k) ...
python
def setup(self): "Connect incoming connection to a telnet session" try: self.TERM = self.request.term except: pass self.setterm(self.TERM) self.sock = self.request._sock for k in self.DOACK.keys(): self.sendcommand(self.DOACK[k], k) ...
[ "def", "setup", "(", "self", ")", ":", "try", ":", "self", ".", "TERM", "=", "self", ".", "request", ".", "term", "except", ":", "pass", "self", ".", "setterm", "(", "self", ".", "TERM", ")", "self", ".", "sock", "=", "self", ".", "request", ".",...
Connect incoming connection to a telnet session
[ "Connect", "incoming", "connection", "to", "a", "telnet", "session" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L520-L531
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
TelnetHandlerBase.finish
def finish(self): "End this session" log.debug("Session disconnected.") try: self.sock.shutdown(socket.SHUT_RDWR) except: pass self.session_end()
python
def finish(self): "End this session" log.debug("Session disconnected.") try: self.sock.shutdown(socket.SHUT_RDWR) except: pass self.session_end()
[ "def", "finish", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Session disconnected.\"", ")", "try", ":", "self", ".", "sock", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "except", ":", "pass", "self", ".", "session_end", "(", ")" ]
End this session
[ "End", "this", "session" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L534-L540
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
TelnetHandlerBase.options_handler
def options_handler(self, sock, cmd, opt): "Negotiate options" if cmd == NOP: self.sendcommand(NOP) elif cmd == WILL or cmd == WONT: if self.WILLACK.has_key(opt): self.sendcommand(self.WILLACK[opt], opt) else: self.sendcommand(D...
python
def options_handler(self, sock, cmd, opt): "Negotiate options" if cmd == NOP: self.sendcommand(NOP) elif cmd == WILL or cmd == WONT: if self.WILLACK.has_key(opt): self.sendcommand(self.WILLACK[opt], opt) else: self.sendcommand(D...
[ "def", "options_handler", "(", "self", ",", "sock", ",", "cmd", ",", "opt", ")", ":", "if", "cmd", "==", "NOP", ":", "self", ".", "sendcommand", "(", "NOP", ")", "elif", "cmd", "==", "WILL", "or", "cmd", "==", "WONT", ":", "if", "self", ".", "WIL...
Negotiate options
[ "Negotiate", "options" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L550-L580
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
TelnetHandlerBase.sendcommand
def sendcommand(self, cmd, opt=None): "Send a telnet command (IAC)" if cmd in [DO, DONT]: if not self.DOOPTS.has_key(opt): self.DOOPTS[opt] = None if (((cmd == DO) and (self.DOOPTS[opt] != True)) or ((cmd == DONT) and (self.DOOPTS[opt] != False))): ...
python
def sendcommand(self, cmd, opt=None): "Send a telnet command (IAC)" if cmd in [DO, DONT]: if not self.DOOPTS.has_key(opt): self.DOOPTS[opt] = None if (((cmd == DO) and (self.DOOPTS[opt] != True)) or ((cmd == DONT) and (self.DOOPTS[opt] != False))): ...
[ "def", "sendcommand", "(", "self", ",", "cmd", ",", "opt", "=", "None", ")", ":", "if", "cmd", "in", "[", "DO", ",", "DONT", "]", ":", "if", "not", "self", ".", "DOOPTS", ".", "has_key", "(", "opt", ")", ":", "self", ".", "DOOPTS", "[", "opt", ...
Send a telnet command (IAC)
[ "Send", "a", "telnet", "command", "(", "IAC", ")" ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L582-L599
train
ianepperson/telnetsrvlib
telnetsrv/telnetsrvlib.py
TelnetHandlerBase._readline_echo
def _readline_echo(self, char, echo): """Echo a recieved character, move cursor etc...""" if self._readline_do_echo(echo): self.write(char)
python
def _readline_echo(self, char, echo): """Echo a recieved character, move cursor etc...""" if self._readline_do_echo(echo): self.write(char)
[ "def", "_readline_echo", "(", "self", ",", "char", ",", "echo", ")", ":", "if", "self", ".", "_readline_do_echo", "(", "echo", ")", ":", "self", ".", "write", "(", "char", ")" ]
Echo a recieved character, move cursor etc...
[ "Echo", "a", "recieved", "character", "move", "cursor", "etc", "..." ]
fac52a4a333c2d373d53d295a76a0bbd71e5d682
https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L619-L622
train