repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
wickerwaka/russound_rio
russound_rio/rio.py
Russound.get_cached_source_variable
def get_cached_source_variable(self, source_id, variable, default=None): """ Get the cached value of a source variable. If the variable is not cached return the default value. """ source_id = int(source_id) try: return self._retrieve_cached_source_variable( ...
python
def get_cached_source_variable(self, source_id, variable, default=None): """ Get the cached value of a source variable. If the variable is not cached return the default value. """ source_id = int(source_id) try: return self._retrieve_cached_source_variable( ...
[ "def", "get_cached_source_variable", "(", "self", ",", "source_id", ",", "variable", ",", "default", "=", "None", ")", ":", "source_id", "=", "int", "(", "source_id", ")", "try", ":", "return", "self", ".", "_retrieve_cached_source_variable", "(", "source_id", ...
Get the cached value of a source variable. If the variable is not cached return the default value.
[ "Get", "the", "cached", "value", "of", "a", "source", "variable", ".", "If", "the", "variable", "is", "not", "cached", "return", "the", "default", "value", "." ]
train
https://github.com/wickerwaka/russound_rio/blob/e331985fd1544abec6a1da3637090550d6f93f76/russound_rio/rio.py#L360-L369
wickerwaka/russound_rio
russound_rio/rio.py
Russound.watch_source
def watch_source(self, source_id): """ Add a souce to the watchlist. """ source_id = int(source_id) r = yield from self._send_cmd( "WATCH S[%d] ON" % (source_id, )) self._watched_source.add(source_id) return r
python
def watch_source(self, source_id): """ Add a souce to the watchlist. """ source_id = int(source_id) r = yield from self._send_cmd( "WATCH S[%d] ON" % (source_id, )) self._watched_source.add(source_id) return r
[ "def", "watch_source", "(", "self", ",", "source_id", ")", ":", "source_id", "=", "int", "(", "source_id", ")", "r", "=", "yield", "from", "self", ".", "_send_cmd", "(", "\"WATCH S[%d] ON\"", "%", "(", "source_id", ",", ")", ")", "self", ".", "_watched_s...
Add a souce to the watchlist.
[ "Add", "a", "souce", "to", "the", "watchlist", "." ]
train
https://github.com/wickerwaka/russound_rio/blob/e331985fd1544abec6a1da3637090550d6f93f76/russound_rio/rio.py#L372-L378
wickerwaka/russound_rio
russound_rio/rio.py
Russound.unwatch_source
def unwatch_source(self, source_id): """ Remove a souce from the watchlist. """ source_id = int(source_id) self._watched_sources.remove(source_id) return (yield from self._send_cmd("WATCH S[%d] OFF" % ( source_id, )))
python
def unwatch_source(self, source_id): """ Remove a souce from the watchlist. """ source_id = int(source_id) self._watched_sources.remove(source_id) return (yield from self._send_cmd("WATCH S[%d] OFF" % ( source_id, )))
[ "def", "unwatch_source", "(", "self", ",", "source_id", ")", ":", "source_id", "=", "int", "(", "source_id", ")", "self", ".", "_watched_sources", ".", "remove", "(", "source_id", ")", "return", "(", "yield", "from", "self", ".", "_send_cmd", "(", "\"WATCH...
Remove a souce from the watchlist.
[ "Remove", "a", "souce", "from", "the", "watchlist", "." ]
train
https://github.com/wickerwaka/russound_rio/blob/e331985fd1544abec6a1da3637090550d6f93f76/russound_rio/rio.py#L381-L387
wickerwaka/russound_rio
russound_rio/rio.py
Russound.enumerate_sources
def enumerate_sources(self): """ Return a list of (source_id, source_name) tuples """ sources = [] for source_id in range(1, 17): try: name = yield from self.get_source_variable(source_id, 'name') if name: sources.append((source_id,...
python
def enumerate_sources(self): """ Return a list of (source_id, source_name) tuples """ sources = [] for source_id in range(1, 17): try: name = yield from self.get_source_variable(source_id, 'name') if name: sources.append((source_id,...
[ "def", "enumerate_sources", "(", "self", ")", ":", "sources", "=", "[", "]", "for", "source_id", "in", "range", "(", "1", ",", "17", ")", ":", "try", ":", "name", "=", "yield", "from", "self", ".", "get_source_variable", "(", "source_id", ",", "'name'"...
Return a list of (source_id, source_name) tuples
[ "Return", "a", "list", "of", "(", "source_id", "source_name", ")", "tuples" ]
train
https://github.com/wickerwaka/russound_rio/blob/e331985fd1544abec6a1da3637090550d6f93f76/russound_rio/rio.py#L390-L400
tgs/nptime
nptime.py
nptime.from_time
def from_time(cls, other): """Construct an :class:`nptime` object from a :class:`datetime.time` .. note:: This *ignores* the :class:`datetime.tzinfo` that may be part of the ``time`` object. """ return cls(other.hour, other.minute, other.second, other.microsecond...
python
def from_time(cls, other): """Construct an :class:`nptime` object from a :class:`datetime.time` .. note:: This *ignores* the :class:`datetime.tzinfo` that may be part of the ``time`` object. """ return cls(other.hour, other.minute, other.second, other.microsecond...
[ "def", "from_time", "(", "cls", ",", "other", ")", ":", "return", "cls", "(", "other", ".", "hour", ",", "other", ".", "minute", ",", "other", ".", "second", ",", "other", ".", "microsecond", ")" ]
Construct an :class:`nptime` object from a :class:`datetime.time` .. note:: This *ignores* the :class:`datetime.tzinfo` that may be part of the ``time`` object.
[ "Construct", "an", ":", "class", ":", "nptime", "object", "from", "a", ":", "class", ":", "datetime", ".", "time" ]
train
https://github.com/tgs/nptime/blob/bf0e84d2a4e1a8fd292189342a28173bc289dff5/nptime.py#L92-L99
tgs/nptime
nptime.py
nptime.to_timedelta
def to_timedelta(self): """Construct a :class:`timedelta` object from an :class:`nptime`. The timedelta gives the number of seconds (and microseconds) since midnight.""" return timedelta(hours=self.hour, minutes=self.minute, seconds=self.second, microseconds=self.microse...
python
def to_timedelta(self): """Construct a :class:`timedelta` object from an :class:`nptime`. The timedelta gives the number of seconds (and microseconds) since midnight.""" return timedelta(hours=self.hour, minutes=self.minute, seconds=self.second, microseconds=self.microse...
[ "def", "to_timedelta", "(", "self", ")", ":", "return", "timedelta", "(", "hours", "=", "self", ".", "hour", ",", "minutes", "=", "self", ".", "minute", ",", "seconds", "=", "self", ".", "second", ",", "microseconds", "=", "self", ".", "microsecond", "...
Construct a :class:`timedelta` object from an :class:`nptime`. The timedelta gives the number of seconds (and microseconds) since midnight.
[ "Construct", "a", ":", "class", ":", "timedelta", "object", "from", "an", ":", "class", ":", "nptime", ".", "The", "timedelta", "gives", "the", "number", "of", "seconds", "(", "and", "microseconds", ")", "since", "midnight", "." ]
train
https://github.com/tgs/nptime/blob/bf0e84d2a4e1a8fd292189342a28173bc289dff5/nptime.py#L108-L113
ox-it/django-conneg
django_conneg/views.py
BaseContentNegotiatedView.set_renderers
def set_renderers(self, request=None, context=None, template_name=None, early=False): """ Makes sure that the renderers attribute on the request is up to date. renderers_for_view keeps track of the view that is attempting to render the request, so that if the request has been del...
python
def set_renderers(self, request=None, context=None, template_name=None, early=False): """ Makes sure that the renderers attribute on the request is up to date. renderers_for_view keeps track of the view that is attempting to render the request, so that if the request has been del...
[ "def", "set_renderers", "(", "self", ",", "request", "=", "None", ",", "context", "=", "None", ",", "template_name", "=", "None", ",", "early", "=", "False", ")", ":", "request", ",", "context", ",", "template_name", "=", "self", ".", "get_render_params", ...
Makes sure that the renderers attribute on the request is up to date. renderers_for_view keeps track of the view that is attempting to render the request, so that if the request has been delegated to another view we know to recalculate the applicable renderers. When called multiple times...
[ "Makes", "sure", "that", "the", "renderers", "attribute", "on", "the", "request", "is", "up", "to", "date", ".", "renderers_for_view", "keeps", "track", "of", "the", "view", "that", "is", "attempting", "to", "render", "the", "request", "so", "that", "if", ...
train
https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/views.py#L80-L108
ox-it/django-conneg
django_conneg/views.py
BaseContentNegotiatedView.render
def render(self, request=None, context=None, template_name=None): """ Returns a HttpResponse of the right media type as specified by the request. context can contain status_code and additional_headers members, to set the HTTP status code and headers of the request, respe...
python
def render(self, request=None, context=None, template_name=None): """ Returns a HttpResponse of the right media type as specified by the request. context can contain status_code and additional_headers members, to set the HTTP status code and headers of the request, respe...
[ "def", "render", "(", "self", ",", "request", "=", "None", ",", "context", "=", "None", ",", "template_name", "=", "None", ")", ":", "request", ",", "context", ",", "template_name", "=", "self", ".", "get_render_params", "(", "request", ",", "context", "...
Returns a HttpResponse of the right media type as specified by the request. context can contain status_code and additional_headers members, to set the HTTP status code and headers of the request, respectively. template_name should lack a file-type suffix (e.g. '.html', as ...
[ "Returns", "a", "HttpResponse", "of", "the", "right", "media", "type", "as", "specified", "by", "the", "request", ".", "context", "can", "contain", "status_code", "and", "additional_headers", "members", "to", "set", "the", "HTTP", "status", "code", "and", "hea...
train
https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/views.py#L117-L151
ox-it/django-conneg
django_conneg/views.py
BaseContentNegotiatedView.join_template_name
def join_template_name(self, template_name, extension): """ Appends an extension to a template_name or list of template_names. """ if template_name is None: return None if isinstance(template_name, (list, tuple)): return tuple('.'.join([n, extension]) for ...
python
def join_template_name(self, template_name, extension): """ Appends an extension to a template_name or list of template_names. """ if template_name is None: return None if isinstance(template_name, (list, tuple)): return tuple('.'.join([n, extension]) for ...
[ "def", "join_template_name", "(", "self", ",", "template_name", ",", "extension", ")", ":", "if", "template_name", "is", "None", ":", "return", "None", "if", "isinstance", "(", "template_name", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "tupl...
Appends an extension to a template_name or list of template_names.
[ "Appends", "an", "extension", "to", "a", "template_name", "or", "list", "of", "template_names", "." ]
train
https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/views.py#L203-L213
Parsl/libsubmit
libsubmit/providers/azure/azure.py
AzureProvider.submit
def submit(self, command='sleep 1', blocksize=1, job_name="parsl.auto"): """Submit command to an Azure instance. Submit returns an ID that corresponds to the task that was just submitted. Parameters ---------- command : str Command to be invoked on the remote side. ...
python
def submit(self, command='sleep 1', blocksize=1, job_name="parsl.auto"): """Submit command to an Azure instance. Submit returns an ID that corresponds to the task that was just submitted. Parameters ---------- command : str Command to be invoked on the remote side. ...
[ "def", "submit", "(", "self", ",", "command", "=", "'sleep 1'", ",", "blocksize", "=", "1", ",", "job_name", "=", "\"parsl.auto\"", ")", ":", "job_name", "=", "\"parsl.auto.{0}\"", ".", "format", "(", "time", ".", "time", "(", ")", ")", "[", "instance", ...
Submit command to an Azure instance. Submit returns an ID that corresponds to the task that was just submitted. Parameters ---------- command : str Command to be invoked on the remote side. blocksize : int Number of blocks requested. job_name : s...
[ "Submit", "command", "to", "an", "Azure", "instance", "." ]
train
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/providers/azure/azure.py#L112-L146
Parsl/libsubmit
libsubmit/providers/azure/azure.py
AzureProvider.status
def status(self, job_ids): """Get the status of a list of jobs identified by their ids. Parameters ---------- job_ids : list of str Identifiers for the jobs. Returns ------- list of int Status codes for each requested job. """ ...
python
def status(self, job_ids): """Get the status of a list of jobs identified by their ids. Parameters ---------- job_ids : list of str Identifiers for the jobs. Returns ------- list of int Status codes for each requested job. """ ...
[ "def", "status", "(", "self", ",", "job_ids", ")", ":", "states", "=", "[", "]", "statuses", "=", "self", ".", "deployer", ".", "get_vm_status", "(", "[", "self", ".", "resources", ".", "get", "(", "job_id", ")", "for", "job_id", "in", "job_ids", "]"...
Get the status of a list of jobs identified by their ids. Parameters ---------- job_ids : list of str Identifiers for the jobs. Returns ------- list of int Status codes for each requested job.
[ "Get", "the", "status", "of", "a", "list", "of", "jobs", "identified", "by", "their", "ids", "." ]
train
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/providers/azure/azure.py#L148-L165
Parsl/libsubmit
libsubmit/providers/azure/azure.py
AzureProvider.cancel
def cancel(self, job_ids): """Cancel jobs specified by a list of job ids. Parameters ---------- list of str List of identifiers of jobs which should be canceled. Returns ------- list of bool For each entry, True if the cancel operation is...
python
def cancel(self, job_ids): """Cancel jobs specified by a list of job ids. Parameters ---------- list of str List of identifiers of jobs which should be canceled. Returns ------- list of bool For each entry, True if the cancel operation is...
[ "def", "cancel", "(", "self", ",", "job_ids", ")", ":", "for", "job_id", "in", "job_ids", ":", "try", ":", "self", ".", "deployer", ".", "destroy", "(", "self", ".", "resources", ".", "get", "(", "job_id", ")", ")", "return", "True", "except", "e", ...
Cancel jobs specified by a list of job ids. Parameters ---------- list of str List of identifiers of jobs which should be canceled. Returns ------- list of bool For each entry, True if the cancel operation is successful, otherwise False.
[ "Cancel", "jobs", "specified", "by", "a", "list", "of", "job", "ids", "." ]
train
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/providers/azure/azure.py#L167-L187
bitlabstudio/django-generic-positions
generic_positions/models.py
save_positions
def save_positions(post_data, queryset=None): """ Function to update a queryset of position objects with a post data dict. :post_data: Typical post data dictionary like ``request.POST``, which contains the keys of the position inputs. :queryset: Queryset of the model ``ObjectPosition``. """ ...
python
def save_positions(post_data, queryset=None): """ Function to update a queryset of position objects with a post data dict. :post_data: Typical post data dictionary like ``request.POST``, which contains the keys of the position inputs. :queryset: Queryset of the model ``ObjectPosition``. """ ...
[ "def", "save_positions", "(", "post_data", ",", "queryset", "=", "None", ")", ":", "if", "not", "queryset", ":", "queryset", "=", "ObjectPosition", ".", "objects", ".", "all", "(", ")", "for", "key", "in", "post_data", ":", "if", "key", ".", "startswith"...
Function to update a queryset of position objects with a post data dict. :post_data: Typical post data dictionary like ``request.POST``, which contains the keys of the position inputs. :queryset: Queryset of the model ``ObjectPosition``.
[ "Function", "to", "update", "a", "queryset", "of", "position", "objects", "with", "a", "post", "data", "dict", "." ]
train
https://github.com/bitlabstudio/django-generic-positions/blob/75cac9b004fcb8e27ce167980489ffcabd49d723/generic_positions/models.py#L33-L50
bitlabstudio/django-generic-positions
generic_positions/templatetags/position_tags.py
order_by_position
def order_by_position(qs, reverse=False): """Template filter to return a position-ordered queryset.""" if qs: # ATTENTION: Django creates an invalid sql statement if two related # models have both generic positions, so we cannot use # qs.oder_by('generic_position__position') posi...
python
def order_by_position(qs, reverse=False): """Template filter to return a position-ordered queryset.""" if qs: # ATTENTION: Django creates an invalid sql statement if two related # models have both generic positions, so we cannot use # qs.oder_by('generic_position__position') posi...
[ "def", "order_by_position", "(", "qs", ",", "reverse", "=", "False", ")", ":", "if", "qs", ":", "# ATTENTION: Django creates an invalid sql statement if two related", "# models have both generic positions, so we cannot use", "# qs.oder_by('generic_position__position')", "position", ...
Template filter to return a position-ordered queryset.
[ "Template", "filter", "to", "return", "a", "position", "-", "ordered", "queryset", "." ]
train
https://github.com/bitlabstudio/django-generic-positions/blob/75cac9b004fcb8e27ce167980489ffcabd49d723/generic_positions/templatetags/position_tags.py#L13-L32
bitlabstudio/django-generic-positions
generic_positions/templatetags/position_tags.py
position_input
def position_input(obj, visible=False): """Template tag to return an input field for the position of the object.""" if not obj.generic_position.all(): ObjectPosition.objects.create(content_object=obj) return {'obj': obj, 'visible': visible, 'object_position': obj.generic_position.all()[0...
python
def position_input(obj, visible=False): """Template tag to return an input field for the position of the object.""" if not obj.generic_position.all(): ObjectPosition.objects.create(content_object=obj) return {'obj': obj, 'visible': visible, 'object_position': obj.generic_position.all()[0...
[ "def", "position_input", "(", "obj", ",", "visible", "=", "False", ")", ":", "if", "not", "obj", ".", "generic_position", ".", "all", "(", ")", ":", "ObjectPosition", ".", "objects", ".", "create", "(", "content_object", "=", "obj", ")", "return", "{", ...
Template tag to return an input field for the position of the object.
[ "Template", "tag", "to", "return", "an", "input", "field", "for", "the", "position", "of", "the", "object", "." ]
train
https://github.com/bitlabstudio/django-generic-positions/blob/75cac9b004fcb8e27ce167980489ffcabd49d723/generic_positions/templatetags/position_tags.py#L36-L41
bitlabstudio/django-generic-positions
generic_positions/templatetags/position_tags.py
position_result_list
def position_result_list(change_list): """ Returns a template which iters through the models and appends a new position column. """ result = result_list(change_list) # Remove sortable attributes for x in range(0, len(result['result_headers'])): result['result_headers'][x]['sorted'] ...
python
def position_result_list(change_list): """ Returns a template which iters through the models and appends a new position column. """ result = result_list(change_list) # Remove sortable attributes for x in range(0, len(result['result_headers'])): result['result_headers'][x]['sorted'] ...
[ "def", "position_result_list", "(", "change_list", ")", ":", "result", "=", "result_list", "(", "change_list", ")", "# Remove sortable attributes", "for", "x", "in", "range", "(", "0", ",", "len", "(", "result", "[", "'result_headers'", "]", ")", ")", ":", "...
Returns a template which iters through the models and appends a new position column.
[ "Returns", "a", "template", "which", "iters", "through", "the", "models", "and", "appends", "a", "new", "position", "column", "." ]
train
https://github.com/bitlabstudio/django-generic-positions/blob/75cac9b004fcb8e27ce167980489ffcabd49d723/generic_positions/templatetags/position_tags.py#L45-L86
dhepper/django-model-path-converter
model_path_converter/__init__.py
register_model_converter
def register_model_converter(model, name=None, field='pk', base=IntConverter, queryset=None): """ Registers a custom path converter for a model. :param model: a Django model :param str name: name to register the converter as :param str field: name of the lookup field :param base: base path conv...
python
def register_model_converter(model, name=None, field='pk', base=IntConverter, queryset=None): """ Registers a custom path converter for a model. :param model: a Django model :param str name: name to register the converter as :param str field: name of the lookup field :param base: base path conv...
[ "def", "register_model_converter", "(", "model", ",", "name", "=", "None", ",", "field", "=", "'pk'", ",", "base", "=", "IntConverter", ",", "queryset", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "camel_to_snake", "(", "model", ...
Registers a custom path converter for a model. :param model: a Django model :param str name: name to register the converter as :param str field: name of the lookup field :param base: base path converter, either by name or as class (optional, defaults to `django.urls.converter.IntConver...
[ "Registers", "a", "custom", "path", "converter", "for", "a", "model", "." ]
train
https://github.com/dhepper/django-model-path-converter/blob/1096f9b3907c16482b31576beb263c5d2723843a/model_path_converter/__init__.py#L38-L64
klen/makesite
makesite/modules/flask/base/auth/views.py
login
def login(): " View function which handles an authentication request. " form = LoginForm(request.form) # make sure data are valid, but doesn't validate password is right if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() # we use werzeug to validate ...
python
def login(): " View function which handles an authentication request. " form = LoginForm(request.form) # make sure data are valid, but doesn't validate password is right if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() # we use werzeug to validate ...
[ "def", "login", "(", ")", ":", "form", "=", "LoginForm", "(", "request", ".", "form", ")", "# make sure data are valid, but doesn't validate password is right", "if", "form", ".", "validate_on_submit", "(", ")", ":", "user", "=", "User", ".", "query", ".", "filt...
View function which handles an authentication request.
[ "View", "function", "which", "handles", "an", "authentication", "request", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/modules/flask/base/auth/views.py#L21-L33
klen/makesite
makesite/modules/flask/base/auth/views.py
logout
def logout(): " View function which handles a logout request. " users.logout() return redirect(request.referrer or url_for(users._login_manager.login_view))
python
def logout(): " View function which handles a logout request. " users.logout() return redirect(request.referrer or url_for(users._login_manager.login_view))
[ "def", "logout", "(", ")", ":", "users", ".", "logout", "(", ")", "return", "redirect", "(", "request", ".", "referrer", "or", "url_for", "(", "users", ".", "_login_manager", ".", "login_view", ")", ")" ]
View function which handles a logout request.
[ "View", "function", "which", "handles", "a", "logout", "request", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/modules/flask/base/auth/views.py#L38-L41
klen/makesite
makesite/modules/flask/base/auth/views.py
register
def register(): " Registration Form. " form = RegisterForm(request.form) if form.validate_on_submit(): # create an user instance not yet stored in the database user = User( username=form.username.data, email=form.email.data, pw_hash=form.password.data) ...
python
def register(): " Registration Form. " form = RegisterForm(request.form) if form.validate_on_submit(): # create an user instance not yet stored in the database user = User( username=form.username.data, email=form.email.data, pw_hash=form.password.data) ...
[ "def", "register", "(", ")", ":", "form", "=", "RegisterForm", "(", "request", ".", "form", ")", "if", "form", ".", "validate_on_submit", "(", ")", ":", "# create an user instance not yet stored in the database", "user", "=", "User", "(", "username", "=", "form"...
Registration Form.
[ "Registration", "Form", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/modules/flask/base/auth/views.py#L45-L65
danielfrg/datasciencebox
datasciencebox/core/project.py
Project.settings_dir
def settings_dir(self): """ Directory that contains the the settings for the project """ path = os.path.join(self.dir, '.dsb') utils.create_dir(path) return os.path.realpath(path)
python
def settings_dir(self): """ Directory that contains the the settings for the project """ path = os.path.join(self.dir, '.dsb') utils.create_dir(path) return os.path.realpath(path)
[ "def", "settings_dir", "(", "self", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "dir", ",", "'.dsb'", ")", "utils", ".", "create_dir", "(", "path", ")", "return", "os", ".", "path", ".", "realpath", "(", "path", ")" ]
Directory that contains the the settings for the project
[ "Directory", "that", "contains", "the", "the", "settings", "for", "the", "project" ]
train
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L58-L64
danielfrg/datasciencebox
datasciencebox/core/project.py
Project.read_settings
def read_settings(self): """ Read the "dsbfile" file Populates `self.settings` """ logger.debug('Reading settings from: %s', self.settings_path) self.settings = Settings.from_dsbfile(self.settings_path)
python
def read_settings(self): """ Read the "dsbfile" file Populates `self.settings` """ logger.debug('Reading settings from: %s', self.settings_path) self.settings = Settings.from_dsbfile(self.settings_path)
[ "def", "read_settings", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Reading settings from: %s'", ",", "self", ".", "settings_path", ")", "self", ".", "settings", "=", "Settings", ".", "from_dsbfile", "(", "self", ".", "settings_path", ")" ]
Read the "dsbfile" file Populates `self.settings`
[ "Read", "the", "dsbfile", "file", "Populates", "self", ".", "settings" ]
train
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L66-L72
danielfrg/datasciencebox
datasciencebox/core/project.py
Project.read_instances
def read_instances(self): """ Read `.dsb/instances.yaml` Populates `self.cluster` """ logger.debug('Reading instances from: %s', self.instances_path) if os.path.exists(self.instances_path): with open(self.instances_path, 'r') as f: list_ = yaml...
python
def read_instances(self): """ Read `.dsb/instances.yaml` Populates `self.cluster` """ logger.debug('Reading instances from: %s', self.instances_path) if os.path.exists(self.instances_path): with open(self.instances_path, 'r') as f: list_ = yaml...
[ "def", "read_instances", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Reading instances from: %s'", ",", "self", ".", "instances_path", ")", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "instances_path", ")", ":", "with", "open", "(",...
Read `.dsb/instances.yaml` Populates `self.cluster`
[ "Read", ".", "dsb", "/", "instances", ".", "yaml", "Populates", "self", ".", "cluster" ]
train
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L74-L83
danielfrg/datasciencebox
datasciencebox/core/project.py
Project.salt
def salt(self, module, target='*', args=None, kwargs=None, ssh=False): """ Execute a salt (or salt-ssh) command """ if ssh: return salt.salt_ssh(self, target, module, args, kwargs) else: return salt.salt_master(self, target, module, args, kwargs)
python
def salt(self, module, target='*', args=None, kwargs=None, ssh=False): """ Execute a salt (or salt-ssh) command """ if ssh: return salt.salt_ssh(self, target, module, args, kwargs) else: return salt.salt_master(self, target, module, args, kwargs)
[ "def", "salt", "(", "self", ",", "module", ",", "target", "=", "'*'", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "ssh", "=", "False", ")", ":", "if", "ssh", ":", "return", "salt", ".", "salt_ssh", "(", "self", ",", "target", ",", ...
Execute a salt (or salt-ssh) command
[ "Execute", "a", "salt", "(", "or", "salt", "-", "ssh", ")", "command" ]
train
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L113-L120
danielfrg/datasciencebox
datasciencebox/core/project.py
Project.setup_salt_ssh
def setup_salt_ssh(self): """ Setup `salt-ssh` """ self.copy_salt_and_pillar() self.create_roster_file() self.salt_ssh_create_dirs() self.salt_ssh_create_master_file()
python
def setup_salt_ssh(self): """ Setup `salt-ssh` """ self.copy_salt_and_pillar() self.create_roster_file() self.salt_ssh_create_dirs() self.salt_ssh_create_master_file()
[ "def", "setup_salt_ssh", "(", "self", ")", ":", "self", ".", "copy_salt_and_pillar", "(", ")", "self", ".", "create_roster_file", "(", ")", "self", ".", "salt_ssh_create_dirs", "(", ")", "self", ".", "salt_ssh_create_master_file", "(", ")" ]
Setup `salt-ssh`
[ "Setup", "salt", "-", "ssh" ]
train
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L138-L145
danielfrg/datasciencebox
datasciencebox/core/project.py
Project.salt_ssh_create_dirs
def salt_ssh_create_dirs(self): """ Creates the `salt-ssh` required directory structure """ logger.debug('Creating salt-ssh dirs into: %s', self.settings_dir) utils.create_dir(os.path.join(self.settings_dir, 'salt')) utils.create_dir(os.path.join(self.settings_dir, 'pilla...
python
def salt_ssh_create_dirs(self): """ Creates the `salt-ssh` required directory structure """ logger.debug('Creating salt-ssh dirs into: %s', self.settings_dir) utils.create_dir(os.path.join(self.settings_dir, 'salt')) utils.create_dir(os.path.join(self.settings_dir, 'pilla...
[ "def", "salt_ssh_create_dirs", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Creating salt-ssh dirs into: %s'", ",", "self", ".", "settings_dir", ")", "utils", ".", "create_dir", "(", "os", ".", "path", ".", "join", "(", "self", ".", "settings_dir", ...
Creates the `salt-ssh` required directory structure
[ "Creates", "the", "salt", "-", "ssh", "required", "directory", "structure" ]
train
https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/project.py#L153-L162
collectiveacuity/jsonModel
jsonmodel/extensions.py
tabulate
def tabulate(json_model): ''' a function to add the tabulate method to a jsonModel object :param json_model: jsonModel object :return: jsonModel object ''' import types from jsonmodel._extensions import tabulate as _tabulate try: from tabulate import tabulate ...
python
def tabulate(json_model): ''' a function to add the tabulate method to a jsonModel object :param json_model: jsonModel object :return: jsonModel object ''' import types from jsonmodel._extensions import tabulate as _tabulate try: from tabulate import tabulate ...
[ "def", "tabulate", "(", "json_model", ")", ":", "import", "types", "from", "jsonmodel", ".", "_extensions", "import", "tabulate", "as", "_tabulate", "try", ":", "from", "tabulate", "import", "tabulate", "except", ":", "import", "sys", "print", "(", "'jsonmodel...
a function to add the tabulate method to a jsonModel object :param json_model: jsonModel object :return: jsonModel object
[ "a", "function", "to", "add", "the", "tabulate", "method", "to", "a", "jsonModel", "object", ":", "param", "json_model", ":", "jsonModel", "object", ":", "return", ":", "jsonModel", "object" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/extensions.py#L6-L26
rodynnz/xccdf
src/xccdf/models/platform.py
Platform.update_xml_element
def update_xml_element(self): """ Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element """ if not hasattr(self, 'xml_element'): self.xml_element = etree.Element(self.name, nsmap=NSMAP) ...
python
def update_xml_element(self): """ Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element """ if not hasattr(self, 'xml_element'): self.xml_element = etree.Element(self.name, nsmap=NSMAP) ...
[ "def", "update_xml_element", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'xml_element'", ")", ":", "self", ".", "xml_element", "=", "etree", ".", "Element", "(", "self", ".", "name", ",", "nsmap", "=", "NSMAP", ")", "if", "hasattr...
Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element
[ "Updates", "the", "xml", "element", "contents", "to", "matches", "the", "instance", "contents", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/platform.py#L61-L75
rodynnz/xccdf
src/xccdf/models/description.py
Description.update_xml_element
def update_xml_element(self): """ Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element """ super(Description, self).update_xml_element() if hasattr(self, 'lang'): self.xml_elem...
python
def update_xml_element(self): """ Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element """ super(Description, self).update_xml_element() if hasattr(self, 'lang'): self.xml_elem...
[ "def", "update_xml_element", "(", "self", ")", ":", "super", "(", "Description", ",", "self", ")", ".", "update_xml_element", "(", ")", "if", "hasattr", "(", "self", ",", "'lang'", ")", ":", "self", ".", "xml_element", ".", "set", "(", "'{http://www.w3.org...
Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element
[ "Updates", "the", "xml", "element", "contents", "to", "matches", "the", "instance", "contents", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/description.py#L51-L67
ttinies/sc2gameLobby
sc2gameLobby/debugCmds.py
create
def create(*units): """create this unit within the game as specified""" ret = [] for unit in units: # implemented using sc2simulator.ScenarioUnit x, y = unit.position[:2] pt = Point2D(x=x, y=y) unit.tag = 0 # forget any tag because a new unit will be created new = DebugComman...
python
def create(*units): """create this unit within the game as specified""" ret = [] for unit in units: # implemented using sc2simulator.ScenarioUnit x, y = unit.position[:2] pt = Point2D(x=x, y=y) unit.tag = 0 # forget any tag because a new unit will be created new = DebugComman...
[ "def", "create", "(", "*", "units", ")", ":", "ret", "=", "[", "]", "for", "unit", "in", "units", ":", "# implemented using sc2simulator.ScenarioUnit", "x", ",", "y", "=", "unit", ".", "position", "[", ":", "2", "]", "pt", "=", "Point2D", "(", "x", "...
create this unit within the game as specified
[ "create", "this", "unit", "within", "the", "game", "as", "specified" ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/debugCmds.py#L10-L24
ttinies/sc2gameLobby
sc2gameLobby/debugCmds.py
modify
def modify(*units): """set the unit defined by in-game tag with desired properties NOTE: all units must be owned by the same player or the command fails.""" ret = [] for unit in units: # add one command for each attribute for attr, idx in [("energy", 1), ("life", 2), ("shields", 3)]: # see debug...
python
def modify(*units): """set the unit defined by in-game tag with desired properties NOTE: all units must be owned by the same player or the command fails.""" ret = [] for unit in units: # add one command for each attribute for attr, idx in [("energy", 1), ("life", 2), ("shields", 3)]: # see debug...
[ "def", "modify", "(", "*", "units", ")", ":", "ret", "=", "[", "]", "for", "unit", "in", "units", ":", "# add one command for each attribute", "for", "attr", ",", "idx", "in", "[", "(", "\"energy\"", ",", "1", ")", ",", "(", "\"life\"", ",", "2", ")"...
set the unit defined by in-game tag with desired properties NOTE: all units must be owned by the same player or the command fails.
[ "set", "the", "unit", "defined", "by", "in", "-", "game", "tag", "with", "desired", "properties", "NOTE", ":", "all", "units", "must", "be", "owned", "by", "the", "same", "player", "or", "the", "command", "fails", "." ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/debugCmds.py#L28-L41
Parsl/libsubmit
libsubmit/utils.py
wtime_to_minutes
def wtime_to_minutes(time_string): ''' wtime_to_minutes Convert standard wallclock time string to minutes. Args: - Time_string in HH:MM:SS format Returns: (int) minutes ''' hours, mins, seconds = time_string.split(':') return int(hours) * 60 + int(mins) + 1
python
def wtime_to_minutes(time_string): ''' wtime_to_minutes Convert standard wallclock time string to minutes. Args: - Time_string in HH:MM:SS format Returns: (int) minutes ''' hours, mins, seconds = time_string.split(':') return int(hours) * 60 + int(mins) + 1
[ "def", "wtime_to_minutes", "(", "time_string", ")", ":", "hours", ",", "mins", ",", "seconds", "=", "time_string", ".", "split", "(", "':'", ")", "return", "int", "(", "hours", ")", "*", "60", "+", "int", "(", "mins", ")", "+", "1" ]
wtime_to_minutes Convert standard wallclock time string to minutes. Args: - Time_string in HH:MM:SS format Returns: (int) minutes
[ "wtime_to_minutes" ]
train
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/utils.py#L4-L17
trapeze/python-discount
discount/__init__.py
Markdown.rewrite_links
def rewrite_links(self, func): """ Add a callback for rewriting links. The callback should take a single argument, the url, and should return a replacement url. The callback function is called everytime a ``[]()`` or ``<link>`` is processed. You can use this method as ...
python
def rewrite_links(self, func): """ Add a callback for rewriting links. The callback should take a single argument, the url, and should return a replacement url. The callback function is called everytime a ``[]()`` or ``<link>`` is processed. You can use this method as ...
[ "def", "rewrite_links", "(", "self", ",", "func", ")", ":", "@", "libmarkdown", ".", "e_url_callback", "def", "_rewrite_links_func", "(", "string", ",", "size", ",", "context", ")", ":", "ret", "=", "func", "(", "string", "[", ":", "size", "]", ")", "i...
Add a callback for rewriting links. The callback should take a single argument, the url, and should return a replacement url. The callback function is called everytime a ``[]()`` or ``<link>`` is processed. You can use this method as a decorator on the function you want to set...
[ "Add", "a", "callback", "for", "rewriting", "links", "." ]
train
https://github.com/trapeze/python-discount/blob/1cde579dc89bc53ecb3678c34bd8fab39f28cb81/discount/__init__.py#L248-L268
trapeze/python-discount
discount/__init__.py
Markdown.link_attrs
def link_attrs(self, func): """ Add a callback for adding attributes to links. The callback should take a single argument, the url, and should return additional text to be inserted in the link tag, i.e. ``"target="_blank"``. You can use this method as a decorator on the...
python
def link_attrs(self, func): """ Add a callback for adding attributes to links. The callback should take a single argument, the url, and should return additional text to be inserted in the link tag, i.e. ``"target="_blank"``. You can use this method as a decorator on the...
[ "def", "link_attrs", "(", "self", ",", "func", ")", ":", "@", "libmarkdown", ".", "e_flags_callback", "def", "_link_attrs_func", "(", "string", ",", "size", ",", "context", ")", ":", "ret", "=", "func", "(", "string", "[", ":", "size", "]", ")", "if", ...
Add a callback for adding attributes to links. The callback should take a single argument, the url, and should return additional text to be inserted in the link tag, i.e. ``"target="_blank"``. You can use this method as a decorator on the function you want to set as the callbac...
[ "Add", "a", "callback", "for", "adding", "attributes", "to", "links", "." ]
train
https://github.com/trapeze/python-discount/blob/1cde579dc89bc53ecb3678c34bd8fab39f28cb81/discount/__init__.py#L270-L290
metagriffin/morph
morph/__init__.py
isseq
def isseq(obj): ''' Returns True if `obj` is a sequence-like object (but not a string or dict); i.e. a tuple, list, subclass thereof, or having an interface that supports iteration. ''' return \ not isstr(obj) \ and not isdict(obj) \ and ( isinstance(obj, (list, tuple)) \ or callable(g...
python
def isseq(obj): ''' Returns True if `obj` is a sequence-like object (but not a string or dict); i.e. a tuple, list, subclass thereof, or having an interface that supports iteration. ''' return \ not isstr(obj) \ and not isdict(obj) \ and ( isinstance(obj, (list, tuple)) \ or callable(g...
[ "def", "isseq", "(", "obj", ")", ":", "return", "not", "isstr", "(", "obj", ")", "and", "not", "isdict", "(", "obj", ")", "and", "(", "isinstance", "(", "obj", ",", "(", "list", ",", "tuple", ")", ")", "or", "callable", "(", "getattr", "(", "obj"...
Returns True if `obj` is a sequence-like object (but not a string or dict); i.e. a tuple, list, subclass thereof, or having an interface that supports iteration.
[ "Returns", "True", "if", "obj", "is", "a", "sequence", "-", "like", "object", "(", "but", "not", "a", "string", "or", "dict", ")", ";", "i", ".", "e", ".", "a", "tuple", "list", "subclass", "thereof", "or", "having", "an", "interface", "that", "suppo...
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L44-L54
metagriffin/morph
morph/__init__.py
isdict
def isdict(obj): ''' Returns True if `obj` is a dict-like object (but not a string or list); i.e. a dict, subclass thereof, or having an interface that supports key, value, and item iteration. ''' return \ not isstr(obj) \ and ( isinstance(obj, dict) \ or ( callable(getattr(obj, 'keys', No...
python
def isdict(obj): ''' Returns True if `obj` is a dict-like object (but not a string or list); i.e. a dict, subclass thereof, or having an interface that supports key, value, and item iteration. ''' return \ not isstr(obj) \ and ( isinstance(obj, dict) \ or ( callable(getattr(obj, 'keys', No...
[ "def", "isdict", "(", "obj", ")", ":", "return", "not", "isstr", "(", "obj", ")", "and", "(", "isinstance", "(", "obj", ",", "dict", ")", "or", "(", "callable", "(", "getattr", "(", "obj", ",", "'keys'", ",", "None", ")", ")", "and", "callable", ...
Returns True if `obj` is a dict-like object (but not a string or list); i.e. a dict, subclass thereof, or having an interface that supports key, value, and item iteration.
[ "Returns", "True", "if", "obj", "is", "a", "dict", "-", "like", "object", "(", "but", "not", "a", "string", "or", "list", ")", ";", "i", ".", "e", ".", "a", "dict", "subclass", "thereof", "or", "having", "an", "interface", "that", "supports", "key", ...
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L57-L68
metagriffin/morph
morph/__init__.py
tobool
def tobool(obj, default=False): ''' Returns a bool representation of `obj`: if `obj` is not a string, it is returned cast to a boolean by calling `bool()`. Otherwise, it is checked for "truthy" or "falsy" values, and that is returned. If it is not truthy or falsy, `default` is returned (which defaults to ``...
python
def tobool(obj, default=False): ''' Returns a bool representation of `obj`: if `obj` is not a string, it is returned cast to a boolean by calling `bool()`. Otherwise, it is checked for "truthy" or "falsy" values, and that is returned. If it is not truthy or falsy, `default` is returned (which defaults to ``...
[ "def", "tobool", "(", "obj", ",", "default", "=", "False", ")", ":", "if", "isinstance", "(", "obj", ",", "bool", ")", ":", "return", "obj", "if", "not", "isstr", "(", "obj", ")", ":", "return", "bool", "(", "obj", ")", "lobj", "=", "obj", ".", ...
Returns a bool representation of `obj`: if `obj` is not a string, it is returned cast to a boolean by calling `bool()`. Otherwise, it is checked for "truthy" or "falsy" values, and that is returned. If it is not truthy or falsy, `default` is returned (which defaults to ``False``) unless `default` is set to ``Va...
[ "Returns", "a", "bool", "representation", "of", "obj", ":", "if", "obj", "is", "not", "a", "string", "it", "is", "returned", "cast", "to", "a", "boolean", "by", "calling", "bool", "()", ".", "Otherwise", "it", "is", "checked", "for", "truthy", "or", "f...
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L71-L92
metagriffin/morph
morph/__init__.py
tolist
def tolist(obj, flat=True, split=True): ''' Returns `obj` as a list: if it is falsy, returns an empty list; if it is a string and `split` is truthy, then it is split into substrings using Unix shell semantics; if it is sequence-like, a list is returned optionally flattened if `flat` is truthy (see :func:`fl...
python
def tolist(obj, flat=True, split=True): ''' Returns `obj` as a list: if it is falsy, returns an empty list; if it is a string and `split` is truthy, then it is split into substrings using Unix shell semantics; if it is sequence-like, a list is returned optionally flattened if `flat` is truthy (see :func:`fl...
[ "def", "tolist", "(", "obj", ",", "flat", "=", "True", ",", "split", "=", "True", ")", ":", "# todo: it would be \"pretty awesome\" if this could auto-detect", "# comma-separation rather than space-separation", "if", "not", "obj", ":", "return", "[", "]", "if", ...
Returns `obj` as a list: if it is falsy, returns an empty list; if it is a string and `split` is truthy, then it is split into substrings using Unix shell semantics; if it is sequence-like, a list is returned optionally flattened if `flat` is truthy (see :func:`flatten`).
[ "Returns", "obj", "as", "a", "list", ":", "if", "it", "is", "falsy", "returns", "an", "empty", "list", ";", "if", "it", "is", "a", "string", "and", "split", "is", "truthy", "then", "it", "is", "split", "into", "substrings", "using", "Unix", "shell", ...
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L95-L111
metagriffin/morph
morph/__init__.py
flatten
def flatten(obj): ''' TODO: add docs ''' if isseq(obj): ret = [] for item in obj: if isseq(item): ret.extend(flatten(item)) else: ret.append(item) return ret if isdict(obj): ret = dict() for key, value in obj.items(): for skey, sval in _relflatten(value): ...
python
def flatten(obj): ''' TODO: add docs ''' if isseq(obj): ret = [] for item in obj: if isseq(item): ret.extend(flatten(item)) else: ret.append(item) return ret if isdict(obj): ret = dict() for key, value in obj.items(): for skey, sval in _relflatten(value): ...
[ "def", "flatten", "(", "obj", ")", ":", "if", "isseq", "(", "obj", ")", ":", "ret", "=", "[", "]", "for", "item", "in", "obj", ":", "if", "isseq", "(", "item", ")", ":", "ret", ".", "extend", "(", "flatten", "(", "item", ")", ")", "else", ":"...
TODO: add docs
[ "TODO", ":", "add", "docs" ]
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L114-L133
metagriffin/morph
morph/__init__.py
unflatten
def unflatten(obj): ''' TODO: add docs ''' if not isdict(obj): raise ValueError( 'only dict-like objects can be unflattened, not %r' % (obj,)) ret = dict() sub = dict() for key, value in obj.items(): if '.' not in key and '[' not in key: ret[key] = value continue if '.' in ke...
python
def unflatten(obj): ''' TODO: add docs ''' if not isdict(obj): raise ValueError( 'only dict-like objects can be unflattened, not %r' % (obj,)) ret = dict() sub = dict() for key, value in obj.items(): if '.' not in key and '[' not in key: ret[key] = value continue if '.' in ke...
[ "def", "unflatten", "(", "obj", ")", ":", "if", "not", "isdict", "(", "obj", ")", ":", "raise", "ValueError", "(", "'only dict-like objects can be unflattened, not %r'", "%", "(", "obj", ",", ")", ")", "ret", "=", "dict", "(", ")", "sub", "=", "dict", "(...
TODO: add docs
[ "TODO", ":", "add", "docs" ]
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L147-L175
metagriffin/morph
morph/__init__.py
pick
def pick(source, *keys, **kws): ''' Given a `source` dict or object, returns a new dict that contains a subset of keys (each key is a separate positional argument) and/or where each key is a string and has the specified `prefix`, specified as a keyword argument. Also accepts the optional keyword argument `d...
python
def pick(source, *keys, **kws): ''' Given a `source` dict or object, returns a new dict that contains a subset of keys (each key is a separate positional argument) and/or where each key is a string and has the specified `prefix`, specified as a keyword argument. Also accepts the optional keyword argument `d...
[ "def", "pick", "(", "source", ",", "*", "keys", ",", "*", "*", "kws", ")", ":", "rettype", "=", "kws", ".", "pop", "(", "'dict'", ",", "dict", ")", "prefix", "=", "kws", ".", "pop", "(", "'prefix'", ",", "None", ")", "tree", "=", "kws", ".", ...
Given a `source` dict or object, returns a new dict that contains a subset of keys (each key is a separate positional argument) and/or where each key is a string and has the specified `prefix`, specified as a keyword argument. Also accepts the optional keyword argument `dict` which must be a dict-like class tha...
[ "Given", "a", "source", "dict", "or", "object", "returns", "a", "new", "dict", "that", "contains", "a", "subset", "of", "keys", "(", "each", "key", "is", "a", "separate", "positional", "argument", ")", "and", "/", "or", "where", "each", "key", "is", "a...
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L216-L280
metagriffin/morph
morph/__init__.py
xform
def xform(value, xformer): ''' Recursively transforms `value` by calling `xformer` on all keys & values in dictionaries and all values in sequences. Note that `xformer` will be passed each value to transform as the first parameter and other keyword parameters based on type. All transformers MUST support arb...
python
def xform(value, xformer): ''' Recursively transforms `value` by calling `xformer` on all keys & values in dictionaries and all values in sequences. Note that `xformer` will be passed each value to transform as the first parameter and other keyword parameters based on type. All transformers MUST support arb...
[ "def", "xform", "(", "value", ",", "xformer", ")", ":", "def", "_xform", "(", "curval", ",", "*", "*", "kws", ")", ":", "if", "isseq", "(", "curval", ")", ":", "return", "[", "_xform", "(", "val", ",", "index", "=", "idx", ",", "seq", "=", "cur...
Recursively transforms `value` by calling `xformer` on all keys & values in dictionaries and all values in sequences. Note that `xformer` will be passed each value to transform as the first parameter and other keyword parameters based on type. All transformers MUST support arbitrary additional parameters to sta...
[ "Recursively", "transforms", "value", "by", "calling", "xformer", "on", "all", "keys", "&", "values", "in", "dictionaries", "and", "all", "values", "in", "sequences", ".", "Note", "that", "xformer", "will", "be", "passed", "each", "value", "to", "transform", ...
train
https://github.com/metagriffin/morph/blob/907f169b0155712c466d3aac29f0907d0f36b443/morph/__init__.py#L345-L383
rodynnz/xccdf
src/xccdf/models/rule.py
Rule.load_children
def load_children(self): """ Load the subelements from the xml_element in its correspondent classes. :returns: List of child objects. :rtype: list :raises CardinalityException: If there is more than one Version child. """ # Containers children = list() ...
python
def load_children(self): """ Load the subelements from the xml_element in its correspondent classes. :returns: List of child objects. :rtype: list :raises CardinalityException: If there is more than one Version child. """ # Containers children = list() ...
[ "def", "load_children", "(", "self", ")", ":", "# Containers", "children", "=", "list", "(", ")", "statuses", "=", "list", "(", ")", "version", "=", "None", "titles", "=", "list", "(", ")", "descriptions", "=", "list", "(", ")", "platforms", "=", "list...
Load the subelements from the xml_element in its correspondent classes. :returns: List of child objects. :rtype: list :raises CardinalityException: If there is more than one Version child.
[ "Load", "the", "subelements", "from", "the", "xml_element", "in", "its", "correspondent", "classes", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/rule.py#L74-L121
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._evaluate_field
def _evaluate_field(self, record_dict, field_name, field_criteria): ''' a helper method for evaluating record values based upon query criteria :param record_dict: dictionary with model valid data to evaluate :param field_name: string with path to root of query field :param field_criter...
python
def _evaluate_field(self, record_dict, field_name, field_criteria): ''' a helper method for evaluating record values based upon query criteria :param record_dict: dictionary with model valid data to evaluate :param field_name: string with path to root of query field :param field_criter...
[ "def", "_evaluate_field", "(", "self", ",", "record_dict", ",", "field_name", ",", "field_criteria", ")", ":", "# determine value existence criteria", "value_exists", "=", "True", "if", "'value_exists'", "in", "field_criteria", ".", "keys", "(", ")", ":", "if", "n...
a helper method for evaluating record values based upon query criteria :param record_dict: dictionary with model valid data to evaluate :param field_name: string with path to root of query field :param field_criteria: dictionary with query operators and qualifiers :return: boolean (True...
[ "a", "helper", "method", "for", "evaluating", "record", "values", "based", "upon", "query", "criteria" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L548-L730
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._validate_dict
def _validate_dict(self, input_dict, schema_dict, path_to_root, object_title=''): ''' a helper method for recursively validating keys in dictionaries :return input_dict ''' # reconstruct key path to current dictionary in model rules_top_level_key = re.sub('\[\d+\]', '[0]', path_to...
python
def _validate_dict(self, input_dict, schema_dict, path_to_root, object_title=''): ''' a helper method for recursively validating keys in dictionaries :return input_dict ''' # reconstruct key path to current dictionary in model rules_top_level_key = re.sub('\[\d+\]', '[0]', path_to...
[ "def", "_validate_dict", "(", "self", ",", "input_dict", ",", "schema_dict", ",", "path_to_root", ",", "object_title", "=", "''", ")", ":", "# reconstruct key path to current dictionary in model", "rules_top_level_key", "=", "re", ".", "sub", "(", "'\\[\\d+\\]'", ",",...
a helper method for recursively validating keys in dictionaries :return input_dict
[ "a", "helper", "method", "for", "recursively", "validating", "keys", "in", "dictionaries" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L732-L904
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._validate_list
def _validate_list(self, input_list, schema_list, path_to_root, object_title=''): ''' a helper method for recursively validating items in a list :return: input_list ''' # construct rules for list and items rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) ...
python
def _validate_list(self, input_list, schema_list, path_to_root, object_title=''): ''' a helper method for recursively validating items in a list :return: input_list ''' # construct rules for list and items rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) ...
[ "def", "_validate_list", "(", "self", ",", "input_list", ",", "schema_list", ",", "path_to_root", ",", "object_title", "=", "''", ")", ":", "# construct rules for list and items", "rules_path_to_root", "=", "re", ".", "sub", "(", "'\\[\\d+\\]'", ",", "'[0]'", ",",...
a helper method for recursively validating items in a list :return: input_list
[ "a", "helper", "method", "for", "recursively", "validating", "items", "in", "a", "list" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L906-L998
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._validate_number
def _validate_number(self, input_number, path_to_root, object_title=''): ''' a helper method for validating properties of a number :return: input_number ''' rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) input_criteria = self.keyMap[rules_path_to_root]...
python
def _validate_number(self, input_number, path_to_root, object_title=''): ''' a helper method for validating properties of a number :return: input_number ''' rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) input_criteria = self.keyMap[rules_path_to_root]...
[ "def", "_validate_number", "(", "self", ",", "input_number", ",", "path_to_root", ",", "object_title", "=", "''", ")", ":", "rules_path_to_root", "=", "re", ".", "sub", "(", "'\\[\\d+\\]'", ",", "'[0]'", ",", "path_to_root", ")", "input_criteria", "=", "self",...
a helper method for validating properties of a number :return: input_number
[ "a", "helper", "method", "for", "validating", "properties", "of", "a", "number" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1000-L1064
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._validate_string
def _validate_string(self, input_string, path_to_root, object_title=''): ''' a helper method for validating properties of a string :return: input_string ''' rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) input_criteria = self.keyMap[rules_path_to_root]...
python
def _validate_string(self, input_string, path_to_root, object_title=''): ''' a helper method for validating properties of a string :return: input_string ''' rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) input_criteria = self.keyMap[rules_path_to_root]...
[ "def", "_validate_string", "(", "self", ",", "input_string", ",", "path_to_root", ",", "object_title", "=", "''", ")", ":", "rules_path_to_root", "=", "re", ".", "sub", "(", "'\\[\\d+\\]'", ",", "'[0]'", ",", "path_to_root", ")", "input_criteria", "=", "self",...
a helper method for validating properties of a string :return: input_string
[ "a", "helper", "method", "for", "validating", "properties", "of", "a", "string" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1066-L1169
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._validate_boolean
def _validate_boolean(self, input_boolean, path_to_root, object_title=''): ''' a helper method for validating properties of a boolean :return: input_boolean ''' rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) input_criteria = self.keyMap[rules_path_to_r...
python
def _validate_boolean(self, input_boolean, path_to_root, object_title=''): ''' a helper method for validating properties of a boolean :return: input_boolean ''' rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root) input_criteria = self.keyMap[rules_path_to_r...
[ "def", "_validate_boolean", "(", "self", ",", "input_boolean", ",", "path_to_root", ",", "object_title", "=", "''", ")", ":", "rules_path_to_root", "=", "re", ".", "sub", "(", "'\\[\\d+\\]'", ",", "'[0]'", ",", "path_to_root", ")", "input_criteria", "=", "self...
a helper method for validating properties of a boolean :return: input_boolean
[ "a", "helper", "method", "for", "validating", "properties", "of", "a", "boolean" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1171-L1200
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._ingest_dict
def _ingest_dict(self, input_dict, schema_dict, path_to_root): ''' a helper method for ingesting keys, value pairs in a dictionary :return: valid_dict ''' valid_dict = {} # construct path to root for rules rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_...
python
def _ingest_dict(self, input_dict, schema_dict, path_to_root): ''' a helper method for ingesting keys, value pairs in a dictionary :return: valid_dict ''' valid_dict = {} # construct path to root for rules rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_...
[ "def", "_ingest_dict", "(", "self", ",", "input_dict", ",", "schema_dict", ",", "path_to_root", ")", ":", "valid_dict", "=", "{", "}", "# construct path to root for rules", "rules_path_to_root", "=", "re", ".", "sub", "(", "'\\[\\d+\\]'", ",", "'[0]'", ",", "pat...
a helper method for ingesting keys, value pairs in a dictionary :return: valid_dict
[ "a", "helper", "method", "for", "ingesting", "keys", "value", "pairs", "in", "a", "dictionary" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1202-L1272
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._ingest_list
def _ingest_list(self, input_list, schema_list, path_to_root): ''' a helper method for ingesting items in a list :return: valid_list ''' valid_list = [] # construct max list size max_size = None rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_roo...
python
def _ingest_list(self, input_list, schema_list, path_to_root): ''' a helper method for ingesting items in a list :return: valid_list ''' valid_list = [] # construct max list size max_size = None rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_roo...
[ "def", "_ingest_list", "(", "self", ",", "input_list", ",", "schema_list", ",", "path_to_root", ")", ":", "valid_list", "=", "[", "]", "# construct max list size", "max_size", "=", "None", "rules_path_to_root", "=", "re", ".", "sub", "(", "'\\[\\d+\\]'", ",", ...
a helper method for ingesting items in a list :return: valid_list
[ "a", "helper", "method", "for", "ingesting", "items", "in", "a", "list" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1274-L1325
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._ingest_number
def _ingest_number(self, input_number, path_to_root): ''' a helper method for ingesting a number :return: valid_number ''' valid_number = 0.0 try: valid_number = self._validate_number(input_number, path_to_root) except: rules_path_t...
python
def _ingest_number(self, input_number, path_to_root): ''' a helper method for ingesting a number :return: valid_number ''' valid_number = 0.0 try: valid_number = self._validate_number(input_number, path_to_root) except: rules_path_t...
[ "def", "_ingest_number", "(", "self", ",", "input_number", ",", "path_to_root", ")", ":", "valid_number", "=", "0.0", "try", ":", "valid_number", "=", "self", ".", "_validate_number", "(", "input_number", ",", "path_to_root", ")", "except", ":", "rules_path_to_r...
a helper method for ingesting a number :return: valid_number
[ "a", "helper", "method", "for", "ingesting", "a", "number" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1327-L1347
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._ingest_string
def _ingest_string(self, input_string, path_to_root): ''' a helper method for ingesting a string :return: valid_string ''' valid_string = '' try: valid_string = self._validate_string(input_string, path_to_root) except: rules_path_to...
python
def _ingest_string(self, input_string, path_to_root): ''' a helper method for ingesting a string :return: valid_string ''' valid_string = '' try: valid_string = self._validate_string(input_string, path_to_root) except: rules_path_to...
[ "def", "_ingest_string", "(", "self", ",", "input_string", ",", "path_to_root", ")", ":", "valid_string", "=", "''", "try", ":", "valid_string", "=", "self", ".", "_validate_string", "(", "input_string", ",", "path_to_root", ")", "except", ":", "rules_path_to_ro...
a helper method for ingesting a string :return: valid_string
[ "a", "helper", "method", "for", "ingesting", "a", "string" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1349-L1366
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._ingest_boolean
def _ingest_boolean(self, input_boolean, path_to_root): ''' a helper method for ingesting a boolean :return: valid_boolean ''' valid_boolean = False try: valid_boolean = self._validate_boolean(input_boolean, path_to_root) except: ru...
python
def _ingest_boolean(self, input_boolean, path_to_root): ''' a helper method for ingesting a boolean :return: valid_boolean ''' valid_boolean = False try: valid_boolean = self._validate_boolean(input_boolean, path_to_root) except: ru...
[ "def", "_ingest_boolean", "(", "self", ",", "input_boolean", ",", "path_to_root", ")", ":", "valid_boolean", "=", "False", "try", ":", "valid_boolean", "=", "self", ".", "_validate_boolean", "(", "input_boolean", ",", "path_to_root", ")", "except", ":", "rules_p...
a helper method for ingesting a boolean :return: valid_boolean
[ "a", "helper", "method", "for", "ingesting", "a", "boolean" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1368-L1385
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._reconstruct
def _reconstruct(self, path_to_root): ''' a helper method for finding the schema endpoint from a path to root :param path_to_root: string with dot path to root from :return: list, dict, string, number, or boolean at path to root ''' # split path to root into segments ...
python
def _reconstruct(self, path_to_root): ''' a helper method for finding the schema endpoint from a path to root :param path_to_root: string with dot path to root from :return: list, dict, string, number, or boolean at path to root ''' # split path to root into segments ...
[ "def", "_reconstruct", "(", "self", ",", "path_to_root", ")", ":", "# split path to root into segments", "item_pattern", "=", "re", ".", "compile", "(", "'\\d+\\\\]'", ")", "dot_pattern", "=", "re", ".", "compile", "(", "'\\\\.|\\\\['", ")", "path_segments", "=", ...
a helper method for finding the schema endpoint from a path to root :param path_to_root: string with dot path to root from :return: list, dict, string, number, or boolean at path to root
[ "a", "helper", "method", "for", "finding", "the", "schema", "endpoint", "from", "a", "path", "to", "root" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1387-L1412
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel._walk
def _walk(self, path_to_root, record_dict): ''' a helper method for finding the record endpoint from a path to root :param path_to_root: string with dot path to root from :param record_dict: :return: list, dict, string, number, or boolean at path to root ''' # ...
python
def _walk(self, path_to_root, record_dict): ''' a helper method for finding the record endpoint from a path to root :param path_to_root: string with dot path to root from :param record_dict: :return: list, dict, string, number, or boolean at path to root ''' # ...
[ "def", "_walk", "(", "self", ",", "path_to_root", ",", "record_dict", ")", ":", "# split path to root into segments", "item_pattern", "=", "re", ".", "compile", "(", "'\\d+\\\\]'", ")", "dot_pattern", "=", "re", ".", "compile", "(", "'\\\\.|\\\\['", ")", "path_s...
a helper method for finding the record endpoint from a path to root :param path_to_root: string with dot path to root from :param record_dict: :return: list, dict, string, number, or boolean at path to root
[ "a", "helper", "method", "for", "finding", "the", "record", "endpoint", "from", "a", "path", "to", "root" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1414-L1468
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel.validate
def validate(self, input_data, path_to_root='', object_title=''): ''' a core method for validating input against the model input_data is only returned if all data is valid :param input_data: list, dict, string, number, or boolean to validate :param path_to_root: [optio...
python
def validate(self, input_data, path_to_root='', object_title=''): ''' a core method for validating input against the model input_data is only returned if all data is valid :param input_data: list, dict, string, number, or boolean to validate :param path_to_root: [optio...
[ "def", "validate", "(", "self", ",", "input_data", ",", "path_to_root", "=", "''", ",", "object_title", "=", "''", ")", ":", "__name__", "=", "'%s.validate'", "%", "self", ".", "__class__", ".", "__name__", "_path_arg", "=", "'%s(path_to_root=\"...\")'", "%", ...
a core method for validating input against the model input_data is only returned if all data is valid :param input_data: list, dict, string, number, or boolean to validate :param path_to_root: [optional] string with dot-path of model component :param object_title: [optional] string...
[ "a", "core", "method", "for", "validating", "input", "against", "the", "model" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1470-L1540
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel.ingest
def ingest(self, **kwargs): ''' a core method to ingest and validate arbitrary keyword data **NOTE: data is always returned with this method** for each key in the model, a value is returned according to the following priority: 1. value in kwar...
python
def ingest(self, **kwargs): ''' a core method to ingest and validate arbitrary keyword data **NOTE: data is always returned with this method** for each key in the model, a value is returned according to the following priority: 1. value in kwar...
[ "def", "ingest", "(", "self", ",", "*", "*", "kwargs", ")", ":", "__name__", "=", "'%s.ingest'", "%", "self", ".", "__class__", ".", "__name__", "schema_dict", "=", "self", ".", "schema", "path_to_root", "=", "'.'", "valid_data", "=", "self", ".", "_inge...
a core method to ingest and validate arbitrary keyword data **NOTE: data is always returned with this method** for each key in the model, a value is returned according to the following priority: 1. value in kwargs if field passes validation test 2....
[ "a", "core", "method", "to", "ingest", "and", "validate", "arbitrary", "keyword", "data" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1542-L1578
collectiveacuity/jsonModel
jsonmodel/validators.py
jsonModel.query
def query(self, query_criteria, valid_record=None): ''' a core method for querying model valid data with criteria **NOTE: input is only returned if all fields & qualifiers are valid for model :param query_criteria: dictionary with model field names and query qualifiers ...
python
def query(self, query_criteria, valid_record=None): ''' a core method for querying model valid data with criteria **NOTE: input is only returned if all fields & qualifiers are valid for model :param query_criteria: dictionary with model field names and query qualifiers ...
[ "def", "query", "(", "self", ",", "query_criteria", ",", "valid_record", "=", "None", ")", ":", "__name__", "=", "'%s.query'", "%", "self", ".", "__class__", ".", "__name__", "_query_arg", "=", "'%s(query_criteria={...})'", "%", "__name__", "_record_arg", "=", ...
a core method for querying model valid data with criteria **NOTE: input is only returned if all fields & qualifiers are valid for model :param query_criteria: dictionary with model field names and query qualifiers :param valid_record: dictionary with model valid record ...
[ "a", "core", "method", "for", "querying", "model", "valid", "data", "with", "criteria" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1580-L1666
Visgean/urljects
urljects/urljects.py
url_view
def url_view(url_pattern, name=None, priority=None): """ Decorator for registering functional views. Meta decorator syntax has to be used in order to accept arguments. This decorator does not really do anything that magical: This: >>> from urljects import U, url_view >>> @url_view(U / 'my_...
python
def url_view(url_pattern, name=None, priority=None): """ Decorator for registering functional views. Meta decorator syntax has to be used in order to accept arguments. This decorator does not really do anything that magical: This: >>> from urljects import U, url_view >>> @url_view(U / 'my_...
[ "def", "url_view", "(", "url_pattern", ",", "name", "=", "None", ",", "priority", "=", "None", ")", ":", "def", "meta_wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "...
Decorator for registering functional views. Meta decorator syntax has to be used in order to accept arguments. This decorator does not really do anything that magical: This: >>> from urljects import U, url_view >>> @url_view(U / 'my_view') ... def my_view(request) ... pass is equi...
[ "Decorator", "for", "registering", "functional", "views", ".", "Meta", "decorator", "syntax", "has", "to", "be", "used", "in", "order", "to", "accept", "arguments", "." ]
train
https://github.com/Visgean/urljects/blob/29a3ca03f639ea7a9ee2f795ed17941c86b278ba/urljects/urljects.py#L24-L63
Visgean/urljects
urljects/urljects.py
resolve_name
def resolve_name(view): """ Auto guesses name of the view. For function it will be ``view.__name__`` For classes it will be ``view.url_name`` """ if inspect.isfunction(view): return view.__name__ if hasattr(view, 'url_name'): return view.url_name if isinstance(view, six.s...
python
def resolve_name(view): """ Auto guesses name of the view. For function it will be ``view.__name__`` For classes it will be ``view.url_name`` """ if inspect.isfunction(view): return view.__name__ if hasattr(view, 'url_name'): return view.url_name if isinstance(view, six.s...
[ "def", "resolve_name", "(", "view", ")", ":", "if", "inspect", ".", "isfunction", "(", "view", ")", ":", "return", "view", ".", "__name__", "if", "hasattr", "(", "view", ",", "'url_name'", ")", ":", "return", "view", ".", "url_name", "if", "isinstance", ...
Auto guesses name of the view. For function it will be ``view.__name__`` For classes it will be ``view.url_name``
[ "Auto", "guesses", "name", "of", "the", "view", ".", "For", "function", "it", "will", "be", "view", ".", "__name__", "For", "classes", "it", "will", "be", "view", ".", "url_name" ]
train
https://github.com/Visgean/urljects/blob/29a3ca03f639ea7a9ee2f795ed17941c86b278ba/urljects/urljects.py#L66-L78
Visgean/urljects
urljects/urljects.py
url
def url(url_pattern, view, kwargs=None, name=None): """ This is replacement for ``django.conf.urls.url`` function. This url auto calls ``as_view`` method for Class based views and resolves URLPattern objects. If ``name`` is not specified it will try to guess it. :param url_pattern: string with...
python
def url(url_pattern, view, kwargs=None, name=None): """ This is replacement for ``django.conf.urls.url`` function. This url auto calls ``as_view`` method for Class based views and resolves URLPattern objects. If ``name`` is not specified it will try to guess it. :param url_pattern: string with...
[ "def", "url", "(", "url_pattern", ",", "view", ",", "kwargs", "=", "None", ",", "name", "=", "None", ")", ":", "# Special handling for included view", "if", "isinstance", "(", "url_pattern", ",", "URLPattern", ")", "and", "isinstance", "(", "view", ",", "tup...
This is replacement for ``django.conf.urls.url`` function. This url auto calls ``as_view`` method for Class based views and resolves URLPattern objects. If ``name`` is not specified it will try to guess it. :param url_pattern: string with regular expression or URLPattern :param view: function/stri...
[ "This", "is", "replacement", "for", "django", ".", "conf", ".", "urls", ".", "url", "function", ".", "This", "url", "auto", "calls", "as_view", "method", "for", "Class", "based", "views", "and", "resolves", "URLPattern", "objects", "." ]
train
https://github.com/Visgean/urljects/blob/29a3ca03f639ea7a9ee2f795ed17941c86b278ba/urljects/urljects.py#L81-L108
Visgean/urljects
urljects/urljects.py
view_include
def view_include(view_module, namespace=None, app_name=None): """ Includes view in the url, works similar to django include function. Auto imports all class based views that are subclass of ``URLView`` and all functional views that have been decorated with ``url_view``. :param view_module: object o...
python
def view_include(view_module, namespace=None, app_name=None): """ Includes view in the url, works similar to django include function. Auto imports all class based views that are subclass of ``URLView`` and all functional views that have been decorated with ``url_view``. :param view_module: object o...
[ "def", "view_include", "(", "view_module", ",", "namespace", "=", "None", ",", "app_name", "=", "None", ")", ":", "# since Django 1.8 patterns() are deprecated, list should be used instead", "# {priority:[views,]}", "view_dict", "=", "defaultdict", "(", "list", ")", "if",...
Includes view in the url, works similar to django include function. Auto imports all class based views that are subclass of ``URLView`` and all functional views that have been decorated with ``url_view``. :param view_module: object of the module or string with importable path :param namespace: name of ...
[ "Includes", "view", "in", "the", "url", "works", "similar", "to", "django", "include", "function", ".", "Auto", "imports", "all", "class", "based", "views", "that", "are", "subclass", "of", "URLView", "and", "all", "functional", "views", "that", "have", "bee...
train
https://github.com/Visgean/urljects/blob/29a3ca03f639ea7a9ee2f795ed17941c86b278ba/urljects/urljects.py#L111-L148
plotly/octogrid
octogrid/store/store.py
cache_file
def cache_file(file_name): """ Cache a given file for further use (by storing them on disk) """ remote_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name) try: copyfile(file_name, remote_file_path) except Exception, e: raise e
python
def cache_file(file_name): """ Cache a given file for further use (by storing them on disk) """ remote_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name) try: copyfile(file_name, remote_file_path) except Exception, e: raise e
[ "def", "cache_file", "(", "file_name", ")", ":", "remote_file_path", "=", "join", "(", "join", "(", "expanduser", "(", "'~'", ")", ",", "OCTOGRID_DIRECTORY", ")", ",", "file_name", ")", "try", ":", "copyfile", "(", "file_name", ",", "remote_file_path", ")", ...
Cache a given file for further use (by storing them on disk)
[ "Cache", "a", "given", "file", "for", "further", "use", "(", "by", "storing", "them", "on", "disk", ")" ]
train
https://github.com/plotly/octogrid/blob/46237a72c79765fe5a48af7065049c692e6457a7/octogrid/store/store.py#L15-L25
plotly/octogrid
octogrid/store/store.py
copy_file
def copy_file(file_name): """ Copy a given file from the cache storage """ remote_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name) current_path = join(getcwd(), file_name) try: copyfile(remote_file_path, current_path) except Exception, e: raise e
python
def copy_file(file_name): """ Copy a given file from the cache storage """ remote_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name) current_path = join(getcwd(), file_name) try: copyfile(remote_file_path, current_path) except Exception, e: raise e
[ "def", "copy_file", "(", "file_name", ")", ":", "remote_file_path", "=", "join", "(", "join", "(", "expanduser", "(", "'~'", ")", ",", "OCTOGRID_DIRECTORY", ")", ",", "file_name", ")", "current_path", "=", "join", "(", "getcwd", "(", ")", ",", "file_name",...
Copy a given file from the cache storage
[ "Copy", "a", "given", "file", "from", "the", "cache", "storage" ]
train
https://github.com/plotly/octogrid/blob/46237a72c79765fe5a48af7065049c692e6457a7/octogrid/store/store.py#L28-L39
plotly/octogrid
octogrid/store/store.py
is_cached
def is_cached(file_name): """ Check if a given file is available in the cache or not """ gml_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name) return isfile(gml_file_path)
python
def is_cached(file_name): """ Check if a given file is available in the cache or not """ gml_file_path = join(join(expanduser('~'), OCTOGRID_DIRECTORY), file_name) return isfile(gml_file_path)
[ "def", "is_cached", "(", "file_name", ")", ":", "gml_file_path", "=", "join", "(", "join", "(", "expanduser", "(", "'~'", ")", ",", "OCTOGRID_DIRECTORY", ")", ",", "file_name", ")", "return", "isfile", "(", "gml_file_path", ")" ]
Check if a given file is available in the cache or not
[ "Check", "if", "a", "given", "file", "is", "available", "in", "the", "cache", "or", "not" ]
train
https://github.com/plotly/octogrid/blob/46237a72c79765fe5a48af7065049c692e6457a7/octogrid/store/store.py#L42-L49
collectiveacuity/jsonModel
jsonmodel/_extensions.py
tabulate
def tabulate(self, format='html', syntax=''): ''' a function to create a table from the class model keyMap :param format: string with format for table output :param syntax: [optional] string with linguistic syntax :return: string with table ''' from tabulate import tabulate as _tabula...
python
def tabulate(self, format='html', syntax=''): ''' a function to create a table from the class model keyMap :param format: string with format for table output :param syntax: [optional] string with linguistic syntax :return: string with table ''' from tabulate import tabulate as _tabula...
[ "def", "tabulate", "(", "self", ",", "format", "=", "'html'", ",", "syntax", "=", "''", ")", ":", "from", "tabulate", "import", "tabulate", "as", "_tabulate", "# define headers", "headers", "=", "[", "'Field'", ",", "'Datatype'", ",", "'Required'", ",", "'...
a function to create a table from the class model keyMap :param format: string with format for table output :param syntax: [optional] string with linguistic syntax :return: string with table
[ "a", "function", "to", "create", "a", "table", "from", "the", "class", "model", "keyMap" ]
train
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/_extensions.py#L34-L209
klen/makesite
makesite/modules/flask/base/auth/manager.py
UserManager.register
def register(self, app, *args, **kwargs): " Activate loginmanager and principal. " if not self._login_manager or self.app != app: self._login_manager = LoginManager() self._login_manager.user_callback = self.user_loader self._login_manager.setup_app(app) ...
python
def register(self, app, *args, **kwargs): " Activate loginmanager and principal. " if not self._login_manager or self.app != app: self._login_manager = LoginManager() self._login_manager.user_callback = self.user_loader self._login_manager.setup_app(app) ...
[ "def", "register", "(", "self", ",", "app", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_login_manager", "or", "self", ".", "app", "!=", "app", ":", "self", ".", "_login_manager", "=", "LoginManager", "(", ")", "...
Activate loginmanager and principal.
[ "Activate", "loginmanager", "and", "principal", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/modules/flask/base/auth/manager.py#L17-L33
ldiary/marigoso
marigoso/abstract.py
Utils.trim_start
def trim_start(self, string, start, end=None): """ Removes the starting substring. :param string: The entire string. :param start: The starting substring to be removed. :param end: An optional point in the string, defaults to the strings ending :return: A substring cons...
python
def trim_start(self, string, start, end=None): """ Removes the starting substring. :param string: The entire string. :param start: The starting substring to be removed. :param end: An optional point in the string, defaults to the strings ending :return: A substring cons...
[ "def", "trim_start", "(", "self", ",", "string", ",", "start", ",", "end", "=", "None", ")", ":", "extract", "=", "string", "[", "string", ".", "find", "(", "start", ")", "+", "len", "(", "start", ")", ":", "end", "]", "return", "extract", ".", "...
Removes the starting substring. :param string: The entire string. :param start: The starting substring to be removed. :param end: An optional point in the string, defaults to the strings ending :return: A substring consists of the subsequent substring after the ...
[ "Removes", "the", "starting", "substring", ".", ":", "param", "string", ":", "The", "entire", "string", ".", ":", "param", "start", ":", "The", "starting", "substring", "to", "be", "removed", ".", ":", "param", "end", ":", "An", "optional", "point", "in"...
train
https://github.com/ldiary/marigoso/blob/886dd4356f83dd3ea6867df6243ba336119011f1/marigoso/abstract.py#L71-L80
astroswego/plotypus
src/plotypus/plotypus.py
process_star
def process_star(filename, output, *, extension, star_name, period, shift, parameters, period_label, shift_label, **kwargs): """Processes a star's lightcurve, prints its coefficients, and saves its plotted lightcurve to a file. Returns the result of get_lightcurve. """ if star_name is N...
python
def process_star(filename, output, *, extension, star_name, period, shift, parameters, period_label, shift_label, **kwargs): """Processes a star's lightcurve, prints its coefficients, and saves its plotted lightcurve to a file. Returns the result of get_lightcurve. """ if star_name is N...
[ "def", "process_star", "(", "filename", ",", "output", ",", "*", ",", "extension", ",", "star_name", ",", "period", ",", "shift", ",", "parameters", ",", "period_label", ",", "shift_label", ",", "*", "*", "kwargs", ")", ":", "if", "star_name", "is", "Non...
Processes a star's lightcurve, prints its coefficients, and saves its plotted lightcurve to a file. Returns the result of get_lightcurve.
[ "Processes", "a", "star", "s", "lightcurve", "prints", "its", "coefficients", "and", "saves", "its", "plotted", "lightcurve", "to", "a", "file", ".", "Returns", "the", "result", "of", "get_lightcurve", "." ]
train
https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/plotypus.py#L312-L345
authomatic/liveandletdie
liveandletdie/__init__.py
port_in_use
def port_in_use(port, kill=False, logging=False): """ Checks whether a port is free or not. :param int port: The port number to check for. :param bool kill: If ``True`` the process will be killed. :returns: The process id as :class:`int` if in use, otherwis...
python
def port_in_use(port, kill=False, logging=False): """ Checks whether a port is free or not. :param int port: The port number to check for. :param bool kill: If ``True`` the process will be killed. :returns: The process id as :class:`int` if in use, otherwis...
[ "def", "port_in_use", "(", "port", ",", "kill", "=", "False", ",", "logging", "=", "False", ")", ":", "command_template", "=", "'lsof -iTCP:{0} -sTCP:LISTEN'", "process", "=", "subprocess", ".", "Popen", "(", "command_template", ".", "format", "(", "port", ")"...
Checks whether a port is free or not. :param int port: The port number to check for. :param bool kill: If ``True`` the process will be killed. :returns: The process id as :class:`int` if in use, otherwise ``False`` .
[ "Checks", "whether", "a", "port", "is", "free", "or", "not", ".", ":", "param", "int", "port", ":", "The", "port", "number", "to", "check", "for", ".", ":", "param", "bool", "kill", ":", "If", "True", "the", "process", "will", "be", "killed", ".", ...
train
https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L87-L143
authomatic/liveandletdie
liveandletdie/__init__.py
Base._normalize_check_url
def _normalize_check_url(self, check_url): """ Normalizes check_url by: * Adding the `http` scheme if missing * Adding or replacing port with `self.port` """ # TODO: Write tests for this method split_url = urlsplit(check_url) host = splitport(split_url.p...
python
def _normalize_check_url(self, check_url): """ Normalizes check_url by: * Adding the `http` scheme if missing * Adding or replacing port with `self.port` """ # TODO: Write tests for this method split_url = urlsplit(check_url) host = splitport(split_url.p...
[ "def", "_normalize_check_url", "(", "self", ",", "check_url", ")", ":", "# TODO: Write tests for this method", "split_url", "=", "urlsplit", "(", "check_url", ")", "host", "=", "splitport", "(", "split_url", ".", "path", "or", "split_url", ".", "netloc", ")", "[...
Normalizes check_url by: * Adding the `http` scheme if missing * Adding or replacing port with `self.port`
[ "Normalizes", "check_url", "by", ":" ]
train
https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L221-L232
authomatic/liveandletdie
liveandletdie/__init__.py
Base.check
def check(self, check_url=None): """ Checks whether a server is running. :param str check_url: URL where to check whether the server is running. Default is ``"http://{self.host}:{self.port}"``. """ if check_url is not None: self.check_url = s...
python
def check(self, check_url=None): """ Checks whether a server is running. :param str check_url: URL where to check whether the server is running. Default is ``"http://{self.host}:{self.port}"``. """ if check_url is not None: self.check_url = s...
[ "def", "check", "(", "self", ",", "check_url", "=", "None", ")", ":", "if", "check_url", "is", "not", "None", ":", "self", ".", "check_url", "=", "self", ".", "_normalize_check_url", "(", "check_url", ")", "response", "=", "None", "sleeped", "=", "0.0", ...
Checks whether a server is running. :param str check_url: URL where to check whether the server is running. Default is ``"http://{self.host}:{self.port}"``.
[ "Checks", "whether", "a", "server", "is", "running", "." ]
train
https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L234-L268
authomatic/liveandletdie
liveandletdie/__init__.py
Base.live
def live(self, kill_port=False, check_url=None): """ Starts a live server in a separate process and checks whether it is running. :param bool kill_port: If ``True``, processes running on the same port as ``self.port`` will be killed. :param str check_url...
python
def live(self, kill_port=False, check_url=None): """ Starts a live server in a separate process and checks whether it is running. :param bool kill_port: If ``True``, processes running on the same port as ``self.port`` will be killed. :param str check_url...
[ "def", "live", "(", "self", ",", "kill_port", "=", "False", ",", "check_url", "=", "None", ")", ":", "pid", "=", "port_in_use", "(", "self", ".", "port", ",", "kill_port", ")", "if", "pid", ":", "raise", "LiveAndLetDieError", "(", "'Port {0} is already bei...
Starts a live server in a separate process and checks whether it is running. :param bool kill_port: If ``True``, processes running on the same port as ``self.port`` will be killed. :param str check_url: URL where to check whether the server is running. ...
[ "Starts", "a", "live", "server", "in", "a", "separate", "process", "and", "checks", "whether", "it", "is", "running", "." ]
train
https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L270-L312
authomatic/liveandletdie
liveandletdie/__init__.py
Base.die
def die(self): """Stops the server if it is running.""" if self.process: _log(self.logging, 'Stopping {0} server with PID: {1} running at {2}.' .format(self.__class__.__name__, self.process.pid, self.check_url)) ...
python
def die(self): """Stops the server if it is running.""" if self.process: _log(self.logging, 'Stopping {0} server with PID: {1} running at {2}.' .format(self.__class__.__name__, self.process.pid, self.check_url)) ...
[ "def", "die", "(", "self", ")", ":", "if", "self", ".", "process", ":", "_log", "(", "self", ".", "logging", ",", "'Stopping {0} server with PID: {1} running at {2}.'", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "process...
Stops the server if it is running.
[ "Stops", "the", "server", "if", "it", "is", "running", "." ]
train
https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L318-L326
authomatic/liveandletdie
liveandletdie/__init__.py
Base.parse_args
def parse_args(cls, logging=False): """ Parses command line arguments. Looks for --liveandletdie [host] :returns: A ``(str(host), int(port))`` or ``(None, None)`` tuple. """ cls._add_args() args = cls._argument_parser.parse_args() if args.l...
python
def parse_args(cls, logging=False): """ Parses command line arguments. Looks for --liveandletdie [host] :returns: A ``(str(host), int(port))`` or ``(None, None)`` tuple. """ cls._add_args() args = cls._argument_parser.parse_args() if args.l...
[ "def", "parse_args", "(", "cls", ",", "logging", "=", "False", ")", ":", "cls", ".", "_add_args", "(", ")", "args", "=", "cls", ".", "_argument_parser", ".", "parse_args", "(", ")", "if", "args", ".", "liveandletdie", ":", "_log", "(", "logging", ",", ...
Parses command line arguments. Looks for --liveandletdie [host] :returns: A ``(str(host), int(port))`` or ``(None, None)`` tuple.
[ "Parses", "command", "line", "arguments", "." ]
train
https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L341-L359
authomatic/liveandletdie
liveandletdie/__init__.py
Flask.wrap
def wrap(cls, app): """ Adds test live server capability to a Flask app module. :param app: A :class:`flask.Flask` app instance. """ host, port = cls.parse_args() ssl = cls._argument_parser.parse_args().ssl ssl_context = None if host...
python
def wrap(cls, app): """ Adds test live server capability to a Flask app module. :param app: A :class:`flask.Flask` app instance. """ host, port = cls.parse_args() ssl = cls._argument_parser.parse_args().ssl ssl_context = None if host...
[ "def", "wrap", "(", "cls", ",", "app", ")", ":", "host", ",", "port", "=", "cls", ".", "parse_args", "(", ")", "ssl", "=", "cls", ".", "_argument_parser", ".", "parse_args", "(", ")", ".", "ssl", "ssl_context", "=", "None", "if", "host", ":", "if",...
Adds test live server capability to a Flask app module. :param app: A :class:`flask.Flask` app instance.
[ "Adds", "test", "live", "server", "capability", "to", "a", "Flask", "app", "module", ".", ":", "param", "app", ":", "A", ":", "class", ":", "flask", ".", "Flask", "app", "instance", "." ]
train
https://github.com/authomatic/liveandletdie/blob/bf3bcdbd679452ec7c248e9910d85c7fcdca586b/liveandletdie/__init__.py#L411-L454
payplug/payplug-python
payplug/routes.py
url
def url(route, resource_id=None, pagination=None, **parameters): """ Generates an absolute URL to an API resource. :param route: One of the routes available (see the header of this file) :type route: string :param resource_id: The resource ID you want. If None, it will point to the endpoint. :t...
python
def url(route, resource_id=None, pagination=None, **parameters): """ Generates an absolute URL to an API resource. :param route: One of the routes available (see the header of this file) :type route: string :param resource_id: The resource ID you want. If None, it will point to the endpoint. :t...
[ "def", "url", "(", "route", ",", "resource_id", "=", "None", ",", "pagination", "=", "None", ",", "*", "*", "parameters", ")", ":", "route", "=", "route", ".", "format", "(", "*", "*", "parameters", ")", "resource_id_url", "=", "'/'", "+", "str", "("...
Generates an absolute URL to an API resource. :param route: One of the routes available (see the header of this file) :type route: string :param resource_id: The resource ID you want. If None, it will point to the endpoint. :type resource_id: string|None :param pagination: parameters for pagination...
[ "Generates", "an", "absolute", "URL", "to", "an", "API", "resource", "." ]
train
https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/routes.py#L15-L40
marcelluzs/pypostgres
pypostgres/utils.py
is_nested
def is_nested(values): '''Check if values is composed only by iterable elements.''' return (all(isinstance(item, Iterable) for item in values) if isinstance(values, Iterable) else False)
python
def is_nested(values): '''Check if values is composed only by iterable elements.''' return (all(isinstance(item, Iterable) for item in values) if isinstance(values, Iterable) else False)
[ "def", "is_nested", "(", "values", ")", ":", "return", "(", "all", "(", "isinstance", "(", "item", ",", "Iterable", ")", "for", "item", "in", "values", ")", "if", "isinstance", "(", "values", ",", "Iterable", ")", "else", "False", ")" ]
Check if values is composed only by iterable elements.
[ "Check", "if", "values", "is", "composed", "only", "by", "iterable", "elements", "." ]
train
https://github.com/marcelluzs/pypostgres/blob/56e77fbec286d7d6f62e548dd02409e8a0cb463f/pypostgres/utils.py#L6-L9
rodynnz/xccdf
src/xccdf/models/html_element.py
HTMLElement.import_element
def import_element(self, xml_element): """ Imports the element from an lxml element and loads its content. """ super(HTMLElement, self).import_element(xml_element) self.content = self.get_html_content()
python
def import_element(self, xml_element): """ Imports the element from an lxml element and loads its content. """ super(HTMLElement, self).import_element(xml_element) self.content = self.get_html_content()
[ "def", "import_element", "(", "self", ",", "xml_element", ")", ":", "super", "(", "HTMLElement", ",", "self", ")", ".", "import_element", "(", "xml_element", ")", "self", ".", "content", "=", "self", ".", "get_html_content", "(", ")" ]
Imports the element from an lxml element and loads its content.
[ "Imports", "the", "element", "from", "an", "lxml", "element", "and", "loads", "its", "content", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/html_element.py#L44-L51
rodynnz/xccdf
src/xccdf/models/html_element.py
HTMLElement.as_dict
def as_dict(self): """ Serializes the object necessary data in a dictionary. :returns: Serialized data in a dictionary. :rtype: dict """ element_dict = super(HTMLElement, self).as_dict() if hasattr(self, 'content'): element_dict['content'] = self.co...
python
def as_dict(self): """ Serializes the object necessary data in a dictionary. :returns: Serialized data in a dictionary. :rtype: dict """ element_dict = super(HTMLElement, self).as_dict() if hasattr(self, 'content'): element_dict['content'] = self.co...
[ "def", "as_dict", "(", "self", ")", ":", "element_dict", "=", "super", "(", "HTMLElement", ",", "self", ")", ".", "as_dict", "(", ")", "if", "hasattr", "(", "self", ",", "'content'", ")", ":", "element_dict", "[", "'content'", "]", "=", "self", ".", ...
Serializes the object necessary data in a dictionary. :returns: Serialized data in a dictionary. :rtype: dict
[ "Serializes", "the", "object", "necessary", "data", "in", "a", "dictionary", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/html_element.py#L53-L66
rodynnz/xccdf
src/xccdf/models/html_element.py
HTMLElement.get_html_content
def get_html_content(self): """ Parses the element and subelements and parses any HTML enabled text to its original HTML form for rendering. :returns: Parsed HTML enabled text content. :rtype: str """ # Extract full element node content (including subelements) ...
python
def get_html_content(self): """ Parses the element and subelements and parses any HTML enabled text to its original HTML form for rendering. :returns: Parsed HTML enabled text content. :rtype: str """ # Extract full element node content (including subelements) ...
[ "def", "get_html_content", "(", "self", ")", ":", "# Extract full element node content (including subelements)", "html_content", "=", "''", "if", "hasattr", "(", "self", ",", "'xml_element'", ")", ":", "xml", "=", "self", ".", "xml_element", "content_list", "=", "["...
Parses the element and subelements and parses any HTML enabled text to its original HTML form for rendering. :returns: Parsed HTML enabled text content. :rtype: str
[ "Parses", "the", "element", "and", "subelements", "and", "parses", "any", "HTML", "enabled", "text", "to", "its", "original", "HTML", "form", "for", "rendering", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/html_element.py#L68-L99
rodynnz/xccdf
src/xccdf/models/html_element.py
HTMLElement.convert_html_to_xml
def convert_html_to_xml(self): """ Parses the HTML parsed texts and converts its tags to XML valid tags. :returns: HTML enabled text in a XML valid format. :rtype: str """ if hasattr(self, 'content') and self.content != '': regex = r'<(?!/)(?!!)' ...
python
def convert_html_to_xml(self): """ Parses the HTML parsed texts and converts its tags to XML valid tags. :returns: HTML enabled text in a XML valid format. :rtype: str """ if hasattr(self, 'content') and self.content != '': regex = r'<(?!/)(?!!)' ...
[ "def", "convert_html_to_xml", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'content'", ")", "and", "self", ".", "content", "!=", "''", ":", "regex", "=", "r'<(?!/)(?!!)'", "xml_content", "=", "re", ".", "sub", "(", "regex", ",", "'<xhtml:'"...
Parses the HTML parsed texts and converts its tags to XML valid tags. :returns: HTML enabled text in a XML valid format. :rtype: str
[ "Parses", "the", "HTML", "parsed", "texts", "and", "converts", "its", "tags", "to", "XML", "valid", "tags", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/html_element.py#L101-L114
rodynnz/xccdf
src/xccdf/models/html_element.py
HTMLElement.update_xml_element
def update_xml_element(self): """ Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element """ if not hasattr(self, 'xml_element'): self.xml_element = etree.Element(self.name, nsmap=NSMAP) ...
python
def update_xml_element(self): """ Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element """ if not hasattr(self, 'xml_element'): self.xml_element = etree.Element(self.name, nsmap=NSMAP) ...
[ "def", "update_xml_element", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'xml_element'", ")", ":", "self", ".", "xml_element", "=", "etree", ".", "Element", "(", "self", ".", "name", ",", "nsmap", "=", "NSMAP", ")", "for", "elemen...
Updates the xml element contents to matches the instance contents. :returns: Updated XML element. :rtype: lxml.etree._Element
[ "Updates", "the", "xml", "element", "contents", "to", "matches", "the", "instance", "contents", "." ]
train
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/html_element.py#L116-L133
Parsl/libsubmit
libsubmit/providers/kubernetes/kube.py
KubernetesProvider.submit
def submit(self, cmd_string, blocksize, job_name="parsl.auto"): """ Submit a job Args: - cmd_string :(String) - Name of the container to initiate - blocksize :(float) - Number of replicas Kwargs: - job_name (String): Name for job, must be unique ...
python
def submit(self, cmd_string, blocksize, job_name="parsl.auto"): """ Submit a job Args: - cmd_string :(String) - Name of the container to initiate - blocksize :(float) - Number of replicas Kwargs: - job_name (String): Name for job, must be unique ...
[ "def", "submit", "(", "self", ",", "cmd_string", ",", "blocksize", ",", "job_name", "=", "\"parsl.auto\"", ")", ":", "if", "not", "self", ".", "resources", ":", "job_name", "=", "\"{0}-{1}\"", ".", "format", "(", "job_name", ",", "time", ".", "time", "("...
Submit a job Args: - cmd_string :(String) - Name of the container to initiate - blocksize :(float) - Number of replicas Kwargs: - job_name (String): Name for job, must be unique Returns: - None: At capacity, cannot provision more ...
[ "Submit", "a", "job" ]
train
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/providers/kubernetes/kube.py#L69-L104
Parsl/libsubmit
libsubmit/providers/kubernetes/kube.py
KubernetesProvider.cancel
def cancel(self, job_ids): """ Cancels the jobs specified by a list of job ids Args: job_ids : [<job_id> ...] Returns : [True/False...] : If the cancel operation fails the entire list will be False. """ for job in job_ids: logger.debug("Terminating j...
python
def cancel(self, job_ids): """ Cancels the jobs specified by a list of job ids Args: job_ids : [<job_id> ...] Returns : [True/False...] : If the cancel operation fails the entire list will be False. """ for job in job_ids: logger.debug("Terminating j...
[ "def", "cancel", "(", "self", ",", "job_ids", ")", ":", "for", "job", "in", "job_ids", ":", "logger", ".", "debug", "(", "\"Terminating job/proc_id : {0}\"", ".", "format", "(", "job", ")", ")", "# Here we are assuming that for local, the job_ids are the process id's"...
Cancels the jobs specified by a list of job ids Args: job_ids : [<job_id> ...] Returns : [True/False...] : If the cancel operation fails the entire list will be False.
[ "Cancels", "the", "jobs", "specified", "by", "a", "list", "of", "job", "ids" ]
train
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/providers/kubernetes/kube.py#L125-L142
Parsl/libsubmit
libsubmit/providers/kubernetes/kube.py
KubernetesProvider._create_deployment_object
def _create_deployment_object(self, job_name, job_image, deployment_name, port=80, replicas=1, cmd_string=None, engine_json_file='~/.ipython/profile_default/security/ipcontroller-engin...
python
def _create_deployment_object(self, job_name, job_image, deployment_name, port=80, replicas=1, cmd_string=None, engine_json_file='~/.ipython/profile_default/security/ipcontroller-engin...
[ "def", "_create_deployment_object", "(", "self", ",", "job_name", ",", "job_image", ",", "deployment_name", ",", "port", "=", "80", ",", "replicas", "=", "1", ",", "cmd_string", "=", "None", ",", "engine_json_file", "=", "'~/.ipython/profile_default/security/ipcontr...
Create a kubernetes deployment for the job. Args: - job_name (string) : Name of the job and deployment - job_image (string) : Docker image to launch KWargs: - port (integer) : Container port - replicas : Number of replica containers to maintain ...
[ "Create", "a", "kubernetes", "deployment", "for", "the", "job", "." ]
train
https://github.com/Parsl/libsubmit/blob/27a41c16dd6f1c16d830a9ce1c97804920a59f64/libsubmit/providers/kubernetes/kube.py#L159-L235
klen/makesite
makesite/site.py
gen_sites
def gen_sites(path): " Seek sites by path. " for root, _, _ in walklevel(path, 2): try: yield Site(root) except AssertionError: continue
python
def gen_sites(path): " Seek sites by path. " for root, _, _ in walklevel(path, 2): try: yield Site(root) except AssertionError: continue
[ "def", "gen_sites", "(", "path", ")", ":", "for", "root", ",", "_", ",", "_", "in", "walklevel", "(", "path", ",", "2", ")", ":", "try", ":", "yield", "Site", "(", "root", ")", "except", "AssertionError", ":", "continue" ]
Seek sites by path.
[ "Seek", "sites", "by", "path", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L158-L165
klen/makesite
makesite/site.py
find_site
def find_site(site, path=None): " Return inited site by name (project.bracnch) or path " try: return Site(site) except AssertionError: path = path or settings.MAKESITE_HOME if op.sep in site: raise site = site if '.' in site else "%s.master" % site proj...
python
def find_site(site, path=None): " Return inited site by name (project.bracnch) or path " try: return Site(site) except AssertionError: path = path or settings.MAKESITE_HOME if op.sep in site: raise site = site if '.' in site else "%s.master" % site proj...
[ "def", "find_site", "(", "site", ",", "path", "=", "None", ")", ":", "try", ":", "return", "Site", "(", "site", ")", "except", "AssertionError", ":", "path", "=", "path", "or", "settings", ".", "MAKESITE_HOME", "if", "op", ".", "sep", "in", "site", "...
Return inited site by name (project.bracnch) or path
[ "Return", "inited", "site", "by", "name", "(", "project", ".", "bracnch", ")", "or", "path" ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L168-L181
klen/makesite
makesite/site.py
Site.get_info
def get_info(self, full=False): " Return printable information about current site. " if full: context = self.as_dict() return "".join("{0:<25} = {1}\n".format( key, context[key]) for key in sorted(context.iterkeys())) return "%s [%s]" % (self.g...
python
def get_info(self, full=False): " Return printable information about current site. " if full: context = self.as_dict() return "".join("{0:<25} = {1}\n".format( key, context[key]) for key in sorted(context.iterkeys())) return "%s [%s]" % (self.g...
[ "def", "get_info", "(", "self", ",", "full", "=", "False", ")", ":", "if", "full", ":", "context", "=", "self", ".", "as_dict", "(", ")", "return", "\"\"", ".", "join", "(", "\"{0:<25} = {1}\\n\"", ".", "format", "(", "key", ",", "context", "[", "key...
Return printable information about current site.
[ "Return", "printable", "information", "about", "current", "site", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L24-L31
klen/makesite
makesite/site.py
Site.run_check
def run_check(self, template_name=None, service_dir=None): " Run checking scripts. " print_header('Check requirements', sep='-') map(lambda cmd: call("bash %s" % cmd), self._gen_scripts( 'check', template_name=template_name, service_dir=service_dir)) return True
python
def run_check(self, template_name=None, service_dir=None): " Run checking scripts. " print_header('Check requirements', sep='-') map(lambda cmd: call("bash %s" % cmd), self._gen_scripts( 'check', template_name=template_name, service_dir=service_dir)) return True
[ "def", "run_check", "(", "self", ",", "template_name", "=", "None", ",", "service_dir", "=", "None", ")", ":", "print_header", "(", "'Check requirements'", ",", "sep", "=", "'-'", ")", "map", "(", "lambda", "cmd", ":", "call", "(", "\"bash %s\"", "%", "c...
Run checking scripts.
[ "Run", "checking", "scripts", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L38-L44
klen/makesite
makesite/site.py
Site.run_update
def run_update(self, template_name=None, service_dir=None): " Run update scripts. " LOGGER.info('Site Update start.') print_header('Update %s' % self.get_name()) map(call, self._gen_scripts( 'update', template_name=template_name, service_dir=service_dir)) LOGGER.info...
python
def run_update(self, template_name=None, service_dir=None): " Run update scripts. " LOGGER.info('Site Update start.') print_header('Update %s' % self.get_name()) map(call, self._gen_scripts( 'update', template_name=template_name, service_dir=service_dir)) LOGGER.info...
[ "def", "run_update", "(", "self", ",", "template_name", "=", "None", ",", "service_dir", "=", "None", ")", ":", "LOGGER", ".", "info", "(", "'Site Update start.'", ")", "print_header", "(", "'Update %s'", "%", "self", ".", "get_name", "(", ")", ")", "map",...
Run update scripts.
[ "Run", "update", "scripts", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L56-L64
klen/makesite
makesite/site.py
Site.paste_template
def paste_template(self, template_name, template=None, deploy_dir=None): " Paste template. " LOGGER.debug("Paste template: %s" % template_name) deploy_dir = deploy_dir or self.deploy_dir template = template or self._get_template_path(template_name) self.read([op.join(template, s...
python
def paste_template(self, template_name, template=None, deploy_dir=None): " Paste template. " LOGGER.debug("Paste template: %s" % template_name) deploy_dir = deploy_dir or self.deploy_dir template = template or self._get_template_path(template_name) self.read([op.join(template, s...
[ "def", "paste_template", "(", "self", ",", "template_name", ",", "template", "=", "None", ",", "deploy_dir", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "\"Paste template: %s\"", "%", "template_name", ")", "deploy_dir", "=", "deploy_dir", "or", "self",...
Paste template.
[ "Paste", "template", "." ]
train
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L75-L98
ttinies/sc2gameLobby
sc2gameLobby/gameConfig.py
Config.agents
def agents(self): """identify which players are agents (not observers or computers). Errors if flattened.""" ret = [] for player in self.players: if player.isComputer: continue try: if player.observer: continue except: pass ret.appe...
python
def agents(self): """identify which players are agents (not observers or computers). Errors if flattened.""" ret = [] for player in self.players: if player.isComputer: continue try: if player.observer: continue except: pass ret.appe...
[ "def", "agents", "(", "self", ")", ":", "ret", "=", "[", "]", "for", "player", "in", "self", ".", "players", ":", "if", "player", ".", "isComputer", ":", "continue", "try", ":", "if", "player", ".", "observer", ":", "continue", "except", ":", "pass",...
identify which players are agents (not observers or computers). Errors if flattened.
[ "identify", "which", "players", "are", "agents", "(", "not", "observers", "or", "computers", ")", ".", "Errors", "if", "flattened", "." ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/gameConfig.py#L164-L173
ttinies/sc2gameLobby
sc2gameLobby/gameConfig.py
Config.allLobbySlots
def allLobbySlots(self): """the current configuration of the lobby's players, defined before the match starts""" if self.debug: p = ["Lobby Configuration detail:"] + \ [" %s:%s%s"%(p, " "*(12-len(p.type)), p.name)] #[" agent: %s"%p for...
python
def allLobbySlots(self): """the current configuration of the lobby's players, defined before the match starts""" if self.debug: p = ["Lobby Configuration detail:"] + \ [" %s:%s%s"%(p, " "*(12-len(p.type)), p.name)] #[" agent: %s"%p for...
[ "def", "allLobbySlots", "(", "self", ")", ":", "if", "self", ".", "debug", ":", "p", "=", "[", "\"Lobby Configuration detail:\"", "]", "+", "[", "\" %s:%s%s\"", "%", "(", "p", ",", "\" \"", "*", "(", "12", "-", "len", "(", "p", ".", "type", ")", ...
the current configuration of the lobby's players, defined before the match starts
[ "the", "current", "configuration", "of", "the", "lobby", "s", "players", "defined", "before", "the", "match", "starts" ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/gameConfig.py#L186-L196
ttinies/sc2gameLobby
sc2gameLobby/gameConfig.py
Config.connection
def connection(self): """identify the remote connection parameters""" self.getPorts() # acquire if necessary self.getIPaddresses() # acquire if necessary return (self.ipAddress, self.ports)
python
def connection(self): """identify the remote connection parameters""" self.getPorts() # acquire if necessary self.getIPaddresses() # acquire if necessary return (self.ipAddress, self.ports)
[ "def", "connection", "(", "self", ")", ":", "self", ".", "getPorts", "(", ")", "# acquire if necessary", "self", ".", "getIPaddresses", "(", ")", "# acquire if necessary", "return", "(", "self", ".", "ipAddress", ",", "self", ".", "ports", ")" ]
identify the remote connection parameters
[ "identify", "the", "remote", "connection", "parameters" ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/gameConfig.py#L199-L203
ttinies/sc2gameLobby
sc2gameLobby/gameConfig.py
Config.execPath
def execPath(self): """the executable application's path""" vers = self.version.label if self.version else None # executables in Versions folder are stored by baseVersion (modified by game data patches) return self.installedApp.exec_path(vers)
python
def execPath(self): """the executable application's path""" vers = self.version.label if self.version else None # executables in Versions folder are stored by baseVersion (modified by game data patches) return self.installedApp.exec_path(vers)
[ "def", "execPath", "(", "self", ")", ":", "vers", "=", "self", ".", "version", ".", "label", "if", "self", ".", "version", "else", "None", "# executables in Versions folder are stored by baseVersion (modified by game data patches)", "return", "self", ".", "installedApp"...
the executable application's path
[ "the", "executable", "application", "s", "path" ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/gameConfig.py#L206-L209
ttinies/sc2gameLobby
sc2gameLobby/gameConfig.py
Config.installedApp
def installedApp(self): """identify the propery application to launch, given the configuration""" try: return self._installedApp except: # raises if not yet defined self._installedApp = runConfigs.get() # application/install/platform management return self._installedAp...
python
def installedApp(self): """identify the propery application to launch, given the configuration""" try: return self._installedApp except: # raises if not yet defined self._installedApp = runConfigs.get() # application/install/platform management return self._installedAp...
[ "def", "installedApp", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_installedApp", "except", ":", "# raises if not yet defined", "self", ".", "_installedApp", "=", "runConfigs", ".", "get", "(", ")", "# application/install/platform management", "retur...
identify the propery application to launch, given the configuration
[ "identify", "the", "propery", "application", "to", "launch", "given", "the", "configuration" ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/gameConfig.py#L217-L222
ttinies/sc2gameLobby
sc2gameLobby/gameConfig.py
Config.observers
def observers(self): """the players who are actually observers""" ret = [] for player in self.players: try: if player.observer: ret.append(player) except: pass # ignore PlayerRecords which don't have an observer attribute return ret
python
def observers(self): """the players who are actually observers""" ret = [] for player in self.players: try: if player.observer: ret.append(player) except: pass # ignore PlayerRecords which don't have an observer attribute return ret
[ "def", "observers", "(", "self", ")", ":", "ret", "=", "[", "]", "for", "player", "in", "self", ".", "players", ":", "try", ":", "if", "player", ".", "observer", ":", "ret", ".", "append", "(", "player", ")", "except", ":", "pass", "# ignore PlayerRe...
the players who are actually observers
[ "the", "players", "who", "are", "actually", "observers" ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/gameConfig.py#L279-L286
ttinies/sc2gameLobby
sc2gameLobby/gameConfig.py
Config.participants
def participants(self): """agents + computers (i.e. all non-observers)""" ret = [] for p in self.players: try: if p.isComputer: ret.append(p) if not p.isObserver: ret.append(p) # could cause an exception if player isn't a PlayerPreGame ...
python
def participants(self): """agents + computers (i.e. all non-observers)""" ret = [] for p in self.players: try: if p.isComputer: ret.append(p) if not p.isObserver: ret.append(p) # could cause an exception if player isn't a PlayerPreGame ...
[ "def", "participants", "(", "self", ")", ":", "ret", "=", "[", "]", "for", "p", "in", "self", ".", "players", ":", "try", ":", "if", "p", ".", "isComputer", ":", "ret", ".", "append", "(", "p", ")", "if", "not", "p", ".", "isObserver", ":", "re...
agents + computers (i.e. all non-observers)
[ "agents", "+", "computers", "(", "i", ".", "e", ".", "all", "non", "-", "observers", ")" ]
train
https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/gameConfig.py#L294-L302