id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
52,600 | dev-pipeline/dev-pipeline-configure | lib/devpipeline_configure/cache.py | _CachedConfig.write | def write(self):
"""Write the configuration."""
if self.dirty:
with open(self._cache_path, "w") as output_file:
self._config.write(output_file) | python | def write(self):
"""Write the configuration."""
if self.dirty:
with open(self._cache_path, "w") as output_file:
self._config.write(output_file) | [
"def",
"write",
"(",
"self",
")",
":",
"if",
"self",
".",
"dirty",
":",
"with",
"open",
"(",
"self",
".",
"_cache_path",
",",
"\"w\"",
")",
"as",
"output_file",
":",
"self",
".",
"_config",
".",
"write",
"(",
"output_file",
")"
] | Write the configuration. | [
"Write",
"the",
"configuration",
"."
] | 26de2dd1b39d9a77d5417244f09319e7dce47495 | https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/cache.py#L121-L125 |
52,601 | leandroarndt/djangospam | djangospam/cookie/middleware.py | SpamCookieMiddleware.process_request | def process_request(self, request):
"""Discovers if a request is from a knwon spam bot and denies access."""
if COOKIE_KEY in request.COOKIES and \
request.COOKIES[COOKIE_KEY] == COOKIE_SPAM:
# Is a known spammer.
response = HttpResponse("")
... | python | def process_request(self, request):
"""Discovers if a request is from a knwon spam bot and denies access."""
if COOKIE_KEY in request.COOKIES and \
request.COOKIES[COOKIE_KEY] == COOKIE_SPAM:
# Is a known spammer.
response = HttpResponse("")
... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"if",
"COOKIE_KEY",
"in",
"request",
".",
"COOKIES",
"and",
"request",
".",
"COOKIES",
"[",
"COOKIE_KEY",
"]",
"==",
"COOKIE_SPAM",
":",
"# Is a known spammer.",
"response",
"=",
"HttpResponse",
... | Discovers if a request is from a knwon spam bot and denies access. | [
"Discovers",
"if",
"a",
"request",
"is",
"from",
"a",
"knwon",
"spam",
"bot",
"and",
"denies",
"access",
"."
] | 57fa9cfbf54a40f0e0652d0155dbb3451c14b69d | https://github.com/leandroarndt/djangospam/blob/57fa9cfbf54a40f0e0652d0155dbb3451c14b69d/djangospam/cookie/middleware.py#L17-L34 |
52,602 | leandroarndt/djangospam | djangospam/cookie/middleware.py | SpamCookieMiddleware.process_response | def process_response(self, request, response):
"""Sets "Ok" cookie on unknown users."""
if COOKIE_KEY not in request.COOKIES:
# Unknown user, set cookie and go on...
response.set_cookie(COOKIE_KEY, COOKIE_PASS, httponly=True,
expires=datetime.now()+tim... | python | def process_response(self, request, response):
"""Sets "Ok" cookie on unknown users."""
if COOKIE_KEY not in request.COOKIES:
# Unknown user, set cookie and go on...
response.set_cookie(COOKIE_KEY, COOKIE_PASS, httponly=True,
expires=datetime.now()+tim... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"COOKIE_KEY",
"not",
"in",
"request",
".",
"COOKIES",
":",
"# Unknown user, set cookie and go on...",
"response",
".",
"set_cookie",
"(",
"COOKIE_KEY",
",",
"COOKIE_PASS",
","... | Sets "Ok" cookie on unknown users. | [
"Sets",
"Ok",
"cookie",
"on",
"unknown",
"users",
"."
] | 57fa9cfbf54a40f0e0652d0155dbb3451c14b69d | https://github.com/leandroarndt/djangospam/blob/57fa9cfbf54a40f0e0652d0155dbb3451c14b69d/djangospam/cookie/middleware.py#L36-L46 |
52,603 | the01/paps-settings | setup.py | get_version | def get_version():
"""
Parse the version information from the init file
"""
version_file = os.path.join("paps_settings", "__init__.py")
initfile_lines = open(version_file, 'rt').readlines()
version_reg = r"^__version__ = ['\"]([^'\"]*)['\"]"
for line in initfile_lines:
mo = re.search... | python | def get_version():
"""
Parse the version information from the init file
"""
version_file = os.path.join("paps_settings", "__init__.py")
initfile_lines = open(version_file, 'rt').readlines()
version_reg = r"^__version__ = ['\"]([^'\"]*)['\"]"
for line in initfile_lines:
mo = re.search... | [
"def",
"get_version",
"(",
")",
":",
"version_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"paps_settings\"",
",",
"\"__init__.py\"",
")",
"initfile_lines",
"=",
"open",
"(",
"version_file",
",",
"'rt'",
")",
".",
"readlines",
"(",
")",
"version_reg",
... | Parse the version information from the init file | [
"Parse",
"the",
"version",
"information",
"from",
"the",
"init",
"file"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/setup.py#L29-L42 |
52,604 | dcaune/perseus-lib-python-common | majormode/perseus/utils/string_util.py | inicap_string | def inicap_string(string,
cleanse=False):
"""
Convert the first letter of each word to capital letter without
touching the rest of the word.
@param string: a string.
@param cleanse: ``True`` to remove any separator character from the
string, such as comma; ``False`` to keeps any ch... | python | def inicap_string(string,
cleanse=False):
"""
Convert the first letter of each word to capital letter without
touching the rest of the word.
@param string: a string.
@param cleanse: ``True`` to remove any separator character from the
string, such as comma; ``False`` to keeps any ch... | [
"def",
"inicap_string",
"(",
"string",
",",
"cleanse",
"=",
"False",
")",
":",
"return",
"string",
"and",
"' '",
".",
"join",
"(",
"word",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"+",
"word",
"[",
"1",
":",
"]",
"for",
"word",
"in",
"(",
"string",... | Convert the first letter of each word to capital letter without
touching the rest of the word.
@param string: a string.
@param cleanse: ``True`` to remove any separator character from the
string, such as comma; ``False`` to keeps any character but space.
@return: a string for which the first ... | [
"Convert",
"the",
"first",
"letter",
"of",
"each",
"word",
"to",
"capital",
"letter",
"without",
"touching",
"the",
"rest",
"of",
"the",
"word",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/string_util.py#L60-L75 |
52,605 | dcaune/perseus-lib-python-common | majormode/perseus/utils/string_util.py | is_email_address | def is_email_address(string):
"""
Check whether the specified string corresponds to an email address.
@param string: a string that is expected to be an email address.
@return: ``True`` if the string corresponds to an email address,
``False`` otherwise.
"""
return string and isinstance(... | python | def is_email_address(string):
"""
Check whether the specified string corresponds to an email address.
@param string: a string that is expected to be an email address.
@return: ``True`` if the string corresponds to an email address,
``False`` otherwise.
"""
return string and isinstance(... | [
"def",
"is_email_address",
"(",
"string",
")",
":",
"return",
"string",
"and",
"isinstance",
"(",
"string",
",",
"base_string",
")",
"and",
"REGEX_PATTERN_EMAIL_ADDRESS",
".",
"match",
"(",
"string",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
")"
] | Check whether the specified string corresponds to an email address.
@param string: a string that is expected to be an email address.
@return: ``True`` if the string corresponds to an email address,
``False`` otherwise. | [
"Check",
"whether",
"the",
"specified",
"string",
"corresponds",
"to",
"an",
"email",
"address",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/string_util.py#L78-L88 |
52,606 | dcaune/perseus-lib-python-common | majormode/perseus/utils/string_util.py | string_to_keywords | def string_to_keywords(string,
keyword_minimal_length=1):
"""
Remove any punctuation character from the specified list of keywords,
remove any double or more space character and represent Unicode
characters in ASCII.
@param keywords: a list of keywords strip out any punctuation characters.... | python | def string_to_keywords(string,
keyword_minimal_length=1):
"""
Remove any punctuation character from the specified list of keywords,
remove any double or more space character and represent Unicode
characters in ASCII.
@param keywords: a list of keywords strip out any punctuation characters.... | [
"def",
"string_to_keywords",
"(",
"string",
",",
"keyword_minimal_length",
"=",
"1",
")",
":",
"# Convert the string to ASCII lower characters.",
"ascii_string",
"=",
"unidecode",
".",
"unidecode",
"(",
"string",
")",
".",
"lower",
"(",
")",
"# Replace any punctuation c... | Remove any punctuation character from the specified list of keywords,
remove any double or more space character and represent Unicode
characters in ASCII.
@param keywords: a list of keywords strip out any punctuation characters.
@param keyword_minimal_length: minimal number of characters of the
... | [
"Remove",
"any",
"punctuation",
"character",
"from",
"the",
"specified",
"list",
"of",
"keywords",
"remove",
"any",
"double",
"or",
"more",
"space",
"character",
"and",
"represent",
"Unicode",
"characters",
"in",
"ASCII",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/string_util.py#L91-L122 |
52,607 | dev-pipeline/dev-pipeline-scm | lib/devpipeline_scm/__init__.py | _SimpleScm.checkout | def checkout(self, *args, **kwargs):
"""This function checks out source code."""
self._call_helper("Checking out", self.real.checkout, *args, **kwargs) | python | def checkout(self, *args, **kwargs):
"""This function checks out source code."""
self._call_helper("Checking out", self.real.checkout, *args, **kwargs) | [
"def",
"checkout",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_call_helper",
"(",
"\"Checking out\"",
",",
"self",
".",
"real",
".",
"checkout",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | This function checks out source code. | [
"This",
"function",
"checks",
"out",
"source",
"code",
"."
] | 58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca | https://github.com/dev-pipeline/dev-pipeline-scm/blob/58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca/lib/devpipeline_scm/__init__.py#L78-L80 |
52,608 | dev-pipeline/dev-pipeline-scm | lib/devpipeline_scm/__init__.py | _SimpleScm.update | def update(self, *args, **kwargs):
"""This funcion updates a checkout of source code."""
self._call_helper("Updating", self.real.update, *args, **kwargs) | python | def update(self, *args, **kwargs):
"""This funcion updates a checkout of source code."""
self._call_helper("Updating", self.real.update, *args, **kwargs) | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_call_helper",
"(",
"\"Updating\"",
",",
"self",
".",
"real",
".",
"update",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | This funcion updates a checkout of source code. | [
"This",
"funcion",
"updates",
"a",
"checkout",
"of",
"source",
"code",
"."
] | 58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca | https://github.com/dev-pipeline/dev-pipeline-scm/blob/58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca/lib/devpipeline_scm/__init__.py#L82-L84 |
52,609 | dev-pipeline/dev-pipeline-build-order | lib/devpipeline_buildorder/dot.py | _print_layers | def _print_layers(targets, components, tasks):
"""
Print dependency information, grouping components based on their position
in the dependency graph. Components with no dependnecies will be in layer
0, components that only depend on layer 0 will be in layer 1, and so on.
If there's a circular depe... | python | def _print_layers(targets, components, tasks):
"""
Print dependency information, grouping components based on their position
in the dependency graph. Components with no dependnecies will be in layer
0, components that only depend on layer 0 will be in layer 1, and so on.
If there's a circular depe... | [
"def",
"_print_layers",
"(",
"targets",
",",
"components",
",",
"tasks",
")",
":",
"layer",
"=",
"0",
"expected_count",
"=",
"len",
"(",
"tasks",
")",
"counts",
"=",
"{",
"}",
"def",
"_add_layer",
"(",
"resolved",
",",
"dep_fn",
")",
":",
"nonlocal",
"... | Print dependency information, grouping components based on their position
in the dependency graph. Components with no dependnecies will be in layer
0, components that only depend on layer 0 will be in layer 1, and so on.
If there's a circular dependency, those nodes and their dependencies will
be colo... | [
"Print",
"dependency",
"information",
"grouping",
"components",
"based",
"on",
"their",
"position",
"in",
"the",
"dependency",
"graph",
".",
"Components",
"with",
"no",
"dependnecies",
"will",
"be",
"in",
"layer",
"0",
"components",
"that",
"only",
"depend",
"on... | 02d661efc4c7c600e756cc26b1f26923735af8c9 | https://github.com/dev-pipeline/dev-pipeline-build-order/blob/02d661efc4c7c600e756cc26b1f26923735af8c9/lib/devpipeline_buildorder/dot.py#L69-L109 |
52,610 | dev-pipeline/dev-pipeline-build-order | lib/devpipeline_buildorder/dot.py | _print_graph | def _print_graph(targets, components, tasks):
"""
Print dependency information using a dot directed graph. The graph will
contain explicitly requested targets plus any dependencies.
If there's a circular dependency, those nodes and their dependencies will
be colored red.
Arguments
targets... | python | def _print_graph(targets, components, tasks):
"""
Print dependency information using a dot directed graph. The graph will
contain explicitly requested targets plus any dependencies.
If there's a circular dependency, those nodes and their dependencies will
be colored red.
Arguments
targets... | [
"def",
"_print_graph",
"(",
"targets",
",",
"components",
",",
"tasks",
")",
":",
"indentation",
"=",
"\" \"",
"*",
"4",
"_do_dot",
"(",
"targets",
",",
"components",
",",
"tasks",
",",
"lambda",
"resolved",
",",
"dep_fn",
":",
"dep_fn",
"(",
"indentation"... | Print dependency information using a dot directed graph. The graph will
contain explicitly requested targets plus any dependencies.
If there's a circular dependency, those nodes and their dependencies will
be colored red.
Arguments
targets - the targets explicitly requested
components - full ... | [
"Print",
"dependency",
"information",
"using",
"a",
"dot",
"directed",
"graph",
".",
"The",
"graph",
"will",
"contain",
"explicitly",
"requested",
"targets",
"plus",
"any",
"dependencies",
"."
] | 02d661efc4c7c600e756cc26b1f26923735af8c9 | https://github.com/dev-pipeline/dev-pipeline-build-order/blob/02d661efc4c7c600e756cc26b1f26923735af8c9/lib/devpipeline_buildorder/dot.py#L120-L138 |
52,611 | dev-pipeline/dev-pipeline-build-order | lib/devpipeline_buildorder/dot.py | _print_dot | def _print_dot(targets, components, tasks):
"""
Deprecated function; use print_graph.
Arguments
targets - the targets explicitly requested
components - full configuration for all components in a project
"""
print("Warning: dot option is deprecated. Use graph instead.", file=sys.stderr)
... | python | def _print_dot(targets, components, tasks):
"""
Deprecated function; use print_graph.
Arguments
targets - the targets explicitly requested
components - full configuration for all components in a project
"""
print("Warning: dot option is deprecated. Use graph instead.", file=sys.stderr)
... | [
"def",
"_print_dot",
"(",
"targets",
",",
"components",
",",
"tasks",
")",
":",
"print",
"(",
"\"Warning: dot option is deprecated. Use graph instead.\"",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"_print_graph",
"(",
"targets",
",",
"components",
",",
"tasks"... | Deprecated function; use print_graph.
Arguments
targets - the targets explicitly requested
components - full configuration for all components in a project | [
"Deprecated",
"function",
";",
"use",
"print_graph",
"."
] | 02d661efc4c7c600e756cc26b1f26923735af8c9 | https://github.com/dev-pipeline/dev-pipeline-build-order/blob/02d661efc4c7c600e756cc26b1f26923735af8c9/lib/devpipeline_buildorder/dot.py#L147-L156 |
52,612 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase._get_selected_item | def _get_selected_item(self):
"""The currently selected item"""
selection = self.get_selection()
if selection.get_mode() != gtk.SELECTION_SINGLE:
raise AttributeError('selected_item not valid for select_multiple')
model, selected = selection.get_selected()
if selected... | python | def _get_selected_item(self):
"""The currently selected item"""
selection = self.get_selection()
if selection.get_mode() != gtk.SELECTION_SINGLE:
raise AttributeError('selected_item not valid for select_multiple')
model, selected = selection.get_selected()
if selected... | [
"def",
"_get_selected_item",
"(",
"self",
")",
":",
"selection",
"=",
"self",
".",
"get_selection",
"(",
")",
"if",
"selection",
".",
"get_mode",
"(",
")",
"!=",
"gtk",
".",
"SELECTION_SINGLE",
":",
"raise",
"AttributeError",
"(",
"'selected_item not valid for s... | The currently selected item | [
"The",
"currently",
"selected",
"item"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L136-L143 |
52,613 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase._get_selected_items | def _get_selected_items(self):
"""List of currently selected items"""
selection = self.get_selection()
if selection.get_mode() != gtk.SELECTION_MULTIPLE:
raise AttributeError('selected_items only valid for '
'select_multiple')
model, selected_... | python | def _get_selected_items(self):
"""List of currently selected items"""
selection = self.get_selection()
if selection.get_mode() != gtk.SELECTION_MULTIPLE:
raise AttributeError('selected_items only valid for '
'select_multiple')
model, selected_... | [
"def",
"_get_selected_items",
"(",
"self",
")",
":",
"selection",
"=",
"self",
".",
"get_selection",
"(",
")",
"if",
"selection",
".",
"get_mode",
"(",
")",
"!=",
"gtk",
".",
"SELECTION_MULTIPLE",
":",
"raise",
"AttributeError",
"(",
"'selected_items only valid ... | List of currently selected items | [
"List",
"of",
"currently",
"selected",
"items"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L163-L173 |
52,614 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase._get_selected_ids | def _get_selected_ids(self):
"""List of currently selected ids"""
selection = self.get_selection()
if selection.get_mode() != gtk.SELECTION_MULTIPLE:
raise AttributeError('selected_ids only valid for select_multiple')
model, selected_paths = selection.get_selected_rows()
... | python | def _get_selected_ids(self):
"""List of currently selected ids"""
selection = self.get_selection()
if selection.get_mode() != gtk.SELECTION_MULTIPLE:
raise AttributeError('selected_ids only valid for select_multiple')
model, selected_paths = selection.get_selected_rows()
... | [
"def",
"_get_selected_ids",
"(",
"self",
")",
":",
"selection",
"=",
"self",
".",
"get_selection",
"(",
")",
"if",
"selection",
".",
"get_mode",
"(",
")",
"!=",
"gtk",
".",
"SELECTION_MULTIPLE",
":",
"raise",
"AttributeError",
"(",
"'selected_ids only valid for ... | List of currently selected ids | [
"List",
"of",
"currently",
"selected",
"ids"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L209-L218 |
52,615 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase.update | def update(self, item):
"""Manually update an item's display in the list
:param item: The item to be updated.
"""
self.model.set(self._iter_for(item), 0, item) | python | def update(self, item):
"""Manually update an item's display in the list
:param item: The item to be updated.
"""
self.model.set(self._iter_for(item), 0, item) | [
"def",
"update",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"model",
".",
"set",
"(",
"self",
".",
"_iter_for",
"(",
"item",
")",
",",
"0",
",",
"item",
")"
] | Manually update an item's display in the list
:param item: The item to be updated. | [
"Manually",
"update",
"an",
"item",
"s",
"display",
"in",
"the",
"list"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L244-L249 |
52,616 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase.move_item_down | def move_item_down(self, item):
"""Move an item down in the list.
Essentially swap it with the item below it.
:param item: The item to be moved.
"""
next_iter = self._next_iter_for(item)
if next_iter is not None:
self.model.swap(self._iter_for(item), next_it... | python | def move_item_down(self, item):
"""Move an item down in the list.
Essentially swap it with the item below it.
:param item: The item to be moved.
"""
next_iter = self._next_iter_for(item)
if next_iter is not None:
self.model.swap(self._iter_for(item), next_it... | [
"def",
"move_item_down",
"(",
"self",
",",
"item",
")",
":",
"next_iter",
"=",
"self",
".",
"_next_iter_for",
"(",
"item",
")",
"if",
"next_iter",
"is",
"not",
"None",
":",
"self",
".",
"model",
".",
"swap",
"(",
"self",
".",
"_iter_for",
"(",
"item",
... | Move an item down in the list.
Essentially swap it with the item below it.
:param item: The item to be moved. | [
"Move",
"an",
"item",
"down",
"in",
"the",
"list",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L251-L260 |
52,617 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase.move_item_up | def move_item_up(self, item):
"""Move an item up in the list.
Essentially swap it with the item above it.
:param item: The item to be moved.
"""
prev_iter = self._prev_iter_for(item)
if prev_iter is not None:
self.model.swap(prev_iter, self._iter_for(item)) | python | def move_item_up(self, item):
"""Move an item up in the list.
Essentially swap it with the item above it.
:param item: The item to be moved.
"""
prev_iter = self._prev_iter_for(item)
if prev_iter is not None:
self.model.swap(prev_iter, self._iter_for(item)) | [
"def",
"move_item_up",
"(",
"self",
",",
"item",
")",
":",
"prev_iter",
"=",
"self",
".",
"_prev_iter_for",
"(",
"item",
")",
"if",
"prev_iter",
"is",
"not",
"None",
":",
"self",
".",
"model",
".",
"swap",
"(",
"prev_iter",
",",
"self",
".",
"_iter_for... | Move an item up in the list.
Essentially swap it with the item above it.
:param item: The item to be moved. | [
"Move",
"an",
"item",
"up",
"in",
"the",
"list",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L262-L271 |
52,618 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase.item_after | def item_after(self, item):
"""The item after an item
"""
next_iter = self._next_iter_for(item)
if next_iter is not None:
return self._object_at_iter(next_iter) | python | def item_after(self, item):
"""The item after an item
"""
next_iter = self._next_iter_for(item)
if next_iter is not None:
return self._object_at_iter(next_iter) | [
"def",
"item_after",
"(",
"self",
",",
"item",
")",
":",
"next_iter",
"=",
"self",
".",
"_next_iter_for",
"(",
"item",
")",
"if",
"next_iter",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_object_at_iter",
"(",
"next_iter",
")"
] | The item after an item | [
"The",
"item",
"after",
"an",
"item"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L273-L278 |
52,619 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase.item_before | def item_before(self, item):
"""The item before an item
:param item: The item to get the previous item relative to
"""
prev_iter = self._prev_iter_for(item)
if prev_iter is not None:
return self._object_at_iter(prev_iter) | python | def item_before(self, item):
"""The item before an item
:param item: The item to get the previous item relative to
"""
prev_iter = self._prev_iter_for(item)
if prev_iter is not None:
return self._object_at_iter(prev_iter) | [
"def",
"item_before",
"(",
"self",
",",
"item",
")",
":",
"prev_iter",
"=",
"self",
".",
"_prev_iter_for",
"(",
"item",
")",
"if",
"prev_iter",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_object_at_iter",
"(",
"prev_iter",
")"
] | The item before an item
:param item: The item to get the previous item relative to | [
"The",
"item",
"before",
"an",
"item"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L280-L287 |
52,620 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase.set_visible_func | def set_visible_func(self, visible_func):
"""Set the function to decide visibility of an item
:param visible_func: A callable that returns a boolean result to
decide if an item should be visible, for
example::
de... | python | def set_visible_func(self, visible_func):
"""Set the function to decide visibility of an item
:param visible_func: A callable that returns a boolean result to
decide if an item should be visible, for
example::
de... | [
"def",
"set_visible_func",
"(",
"self",
",",
"visible_func",
")",
":",
"self",
".",
"model_filter",
".",
"set_visible_func",
"(",
"self",
".",
"_internal_visible_func",
",",
"visible_func",
",",
")",
"self",
".",
"_visible_func",
"=",
"visible_func",
"self",
"."... | Set the function to decide visibility of an item
:param visible_func: A callable that returns a boolean result to
decide if an item should be visible, for
example::
def is_visible(item):
... | [
"Set",
"the",
"function",
"to",
"decide",
"visibility",
"of",
"an",
"item"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L289-L304 |
52,621 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTreeViewBase.sort_by | def sort_by(self, attr_or_key, direction='asc'):
"""Sort the view by an attribute or key
:param attr_or_key: The attribute or key to sort by
:param direction: Either `asc` or `desc` indicating the direction of
sorting
"""
# work out the direction
... | python | def sort_by(self, attr_or_key, direction='asc'):
"""Sort the view by an attribute or key
:param attr_or_key: The attribute or key to sort by
:param direction: Either `asc` or `desc` indicating the direction of
sorting
"""
# work out the direction
... | [
"def",
"sort_by",
"(",
"self",
",",
"attr_or_key",
",",
"direction",
"=",
"'asc'",
")",
":",
"# work out the direction",
"if",
"direction",
"in",
"(",
"'+'",
",",
"'asc'",
",",
"gtk",
".",
"SORT_ASCENDING",
")",
":",
"direction",
"=",
"gtk",
".",
"SORT_ASC... | Sort the view by an attribute or key
:param attr_or_key: The attribute or key to sort by
:param direction: Either `asc` or `desc` indicating the direction of
sorting | [
"Sort",
"the",
"view",
"by",
"an",
"attribute",
"or",
"key"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L314-L335 |
52,622 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectList.insert | def insert(self, position, item, select=False):
"""Insert an item at the specified position in the list.
:param position: The position to insert the item at
:param item: The item to be added
:param select: Whether the item should be selected after adding
"""
if item in s... | python | def insert(self, position, item, select=False):
"""Insert an item at the specified position in the list.
:param position: The position to insert the item at
:param item: The item to be added
:param select: Whether the item should be selected after adding
"""
if item in s... | [
"def",
"insert",
"(",
"self",
",",
"position",
",",
"item",
",",
"select",
"=",
"False",
")",
":",
"if",
"item",
"in",
"self",
":",
"raise",
"ValueError",
"(",
"\"item %s already in list\"",
"%",
"item",
")",
"modeliter",
"=",
"self",
".",
"model",
".",
... | Insert an item at the specified position in the list.
:param position: The position to insert the item at
:param item: The item to be added
:param select: Whether the item should be selected after adding | [
"Insert",
"an",
"item",
"at",
"the",
"specified",
"position",
"in",
"the",
"list",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L523-L536 |
52,623 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTree.extend | def extend(self, iter, parent=None):
"""Add a sequence of items to the end of the list
:param iter: The iterable of items to add.
:param parent: The node to add the items as a child of, or None for
top-level nodes.
"""
for item in iter:
self.ap... | python | def extend(self, iter, parent=None):
"""Add a sequence of items to the end of the list
:param iter: The iterable of items to add.
:param parent: The node to add the items as a child of, or None for
top-level nodes.
"""
for item in iter:
self.ap... | [
"def",
"extend",
"(",
"self",
",",
"iter",
",",
"parent",
"=",
"None",
")",
":",
"for",
"item",
"in",
"iter",
":",
"self",
".",
"append",
"(",
"item",
",",
"parent",
")"
] | Add a sequence of items to the end of the list
:param iter: The iterable of items to add.
:param parent: The node to add the items as a child of, or None for
top-level nodes. | [
"Add",
"a",
"sequence",
"of",
"items",
"to",
"the",
"end",
"of",
"the",
"list"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L656-L664 |
52,624 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/view.py | ObjectTree.expand_item | def expand_item(self, item, open_all=True):
"""Display a node as expanded
:param item: The item to show expanded
:param open_all: Whether all child nodes should be recursively
expanded.
"""
self.expand_row(self._view_path_for(item), open_all) | python | def expand_item(self, item, open_all=True):
"""Display a node as expanded
:param item: The item to show expanded
:param open_all: Whether all child nodes should be recursively
expanded.
"""
self.expand_row(self._view_path_for(item), open_all) | [
"def",
"expand_item",
"(",
"self",
",",
"item",
",",
"open_all",
"=",
"True",
")",
":",
"self",
".",
"expand_row",
"(",
"self",
".",
"_view_path_for",
"(",
"item",
")",
",",
"open_all",
")"
] | Display a node as expanded
:param item: The item to show expanded
:param open_all: Whether all child nodes should be recursively
expanded. | [
"Display",
"a",
"node",
"as",
"expanded"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/view.py#L666-L673 |
52,625 | dcaune/perseus-lib-python-common | majormode/perseus/model/obj.py | jsonify | def jsonify(obj, trimmable=False):
"""
Serialize an object to a JSON formatted string.
@param obj: an instance to convert to a JSON formatted string.
@param trimmable: indicate whether null attributes of this object
need to be stripped out the JSON formatted string.
@return: a JSON ... | python | def jsonify(obj, trimmable=False):
"""
Serialize an object to a JSON formatted string.
@param obj: an instance to convert to a JSON formatted string.
@param trimmable: indicate whether null attributes of this object
need to be stripped out the JSON formatted string.
@return: a JSON ... | [
"def",
"jsonify",
"(",
"obj",
",",
"trimmable",
"=",
"False",
")",
":",
"# def jsonify_ex(obj, trimmable=False):",
"# if obj is None:",
"# return None",
"# elif isinstance(obj, (basestring, bool, int, long, float, complex)):",
"# return obj",
"# elif isinsta... | Serialize an object to a JSON formatted string.
@param obj: an instance to convert to a JSON formatted string.
@param trimmable: indicate whether null attributes of this object
need to be stripped out the JSON formatted string.
@return: a JSON formatted string. | [
"Serialize",
"an",
"object",
"to",
"a",
"JSON",
"formatted",
"string",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/obj.py#L48-L82 |
52,626 | dcaune/perseus-lib-python-common | majormode/perseus/model/obj.py | stringify | def stringify(obj, trimmable=False):
"""
Convert an object to a stringified version of this object where the
initial object's attribute values have been stringified when these
values are not native Python types.
This function differs from the standard Python ``str`` as the latter
returns a stri... | python | def stringify(obj, trimmable=False):
"""
Convert an object to a stringified version of this object where the
initial object's attribute values have been stringified when these
values are not native Python types.
This function differs from the standard Python ``str`` as the latter
returns a stri... | [
"def",
"stringify",
"(",
"obj",
",",
"trimmable",
"=",
"False",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"obj",
",",
"(",
"basestring",
",",
"bool",
",",
"int",
",",
"long",
",",
"float",
",",
"complex",
... | Convert an object to a stringified version of this object where the
initial object's attribute values have been stringified when these
values are not native Python types.
This function differs from the standard Python ``str`` as the latter
returns a string version of object, while this function returns... | [
"Convert",
"an",
"object",
"to",
"a",
"stringified",
"version",
"of",
"this",
"object",
"where",
"the",
"initial",
"object",
"s",
"attribute",
"values",
"have",
"been",
"stringified",
"when",
"these",
"values",
"are",
"not",
"native",
"Python",
"types",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/obj.py#L98-L136 |
52,627 | dcaune/perseus-lib-python-common | majormode/perseus/model/obj.py | shallow_copy | def shallow_copy(obj, attribute_names,
ignore_missing_attributes=True):
"""
Return a shallow copy of the given object, including only the
specified attributes of this object.
@param obj: an object to copy.
@param attribute_names: a list of names of the attributes to copy.
@param igno... | python | def shallow_copy(obj, attribute_names,
ignore_missing_attributes=True):
"""
Return a shallow copy of the given object, including only the
specified attributes of this object.
@param obj: an object to copy.
@param attribute_names: a list of names of the attributes to copy.
@param igno... | [
"def",
"shallow_copy",
"(",
"obj",
",",
"attribute_names",
",",
"ignore_missing_attributes",
"=",
"True",
")",
":",
"shallow_object",
"=",
"copy",
".",
"copy",
"(",
"obj",
")",
"shallow_object",
".",
"__dict__",
"=",
"{",
"}",
"for",
"attribute_name",
"in",
... | Return a shallow copy of the given object, including only the
specified attributes of this object.
@param obj: an object to copy.
@param attribute_names: a list of names of the attributes to copy.
@param ignore_missing_attributes: ``False`` indicates that the function
can ignore attributes t... | [
"Return",
"a",
"shallow",
"copy",
"of",
"the",
"given",
"object",
"including",
"only",
"the",
"specified",
"attributes",
"of",
"this",
"object",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/obj.py#L279-L315 |
52,628 | dcaune/perseus-lib-python-common | majormode/perseus/model/obj.py | Object.from_json | def from_json(payload):
"""
Build an object from a JSON dictionary.
@param payload: a JSON dictionary which key/value pairs represent
the members of the Python object to build, or ``None``.
@return: an instance ``Object`` with members built from the key/value
... | python | def from_json(payload):
"""
Build an object from a JSON dictionary.
@param payload: a JSON dictionary which key/value pairs represent
the members of the Python object to build, or ``None``.
@return: an instance ``Object`` with members built from the key/value
... | [
"def",
"from_json",
"(",
"payload",
")",
":",
"if",
"payload",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"payload",
",",
"dict",
")",
":",
"return",
"Object",
"(",
"*",
"*",
"dict",
"(",
"[",
"(",
"k",
",",
"v",
"if",
"not",
"... | Build an object from a JSON dictionary.
@param payload: a JSON dictionary which key/value pairs represent
the members of the Python object to build, or ``None``.
@return: an instance ``Object`` with members built from the key/value
pairs of the given JSON dictionary, or ``Non... | [
"Build",
"an",
"object",
"from",
"a",
"JSON",
"dictionary",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/obj.py#L184-L208 |
52,629 | leandroarndt/djangospam | djangospam/cookie/moderator.py | CookieModerator.allow | def allow(self, comment, content_object, request):
"""Tests comment post requests for the djangospam cookie."""
# Tests for cookie:
if settings.COOKIE_KEY not in request.COOKIES \
and (settings.DISCARD_SPAM or settings.DISCARD_NO_COOKIE):
return False
elif set... | python | def allow(self, comment, content_object, request):
"""Tests comment post requests for the djangospam cookie."""
# Tests for cookie:
if settings.COOKIE_KEY not in request.COOKIES \
and (settings.DISCARD_SPAM or settings.DISCARD_NO_COOKIE):
return False
elif set... | [
"def",
"allow",
"(",
"self",
",",
"comment",
",",
"content_object",
",",
"request",
")",
":",
"# Tests for cookie:",
"if",
"settings",
".",
"COOKIE_KEY",
"not",
"in",
"request",
".",
"COOKIES",
"and",
"(",
"settings",
".",
"DISCARD_SPAM",
"or",
"settings",
"... | Tests comment post requests for the djangospam cookie. | [
"Tests",
"comment",
"post",
"requests",
"for",
"the",
"djangospam",
"cookie",
"."
] | 57fa9cfbf54a40f0e0652d0155dbb3451c14b69d | https://github.com/leandroarndt/djangospam/blob/57fa9cfbf54a40f0e0652d0155dbb3451c14b69d/djangospam/cookie/moderator.py#L66-L76 |
52,630 | agile4you/SchemaFactory | schema_factory/types.py | NodeType.validate | def validate(self, value):
"""Base validation method. Check if type is valid, or try brute casting.
Args:
value (object): A value for validation.
Returns:
Base_type instance.
Raises:
SchemaError, if validation or type casting fails.
"""
... | python | def validate(self, value):
"""Base validation method. Check if type is valid, or try brute casting.
Args:
value (object): A value for validation.
Returns:
Base_type instance.
Raises:
SchemaError, if validation or type casting fails.
"""
... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"cast_callback",
"=",
"self",
".",
"cast_callback",
"if",
"self",
".",
"cast_callback",
"else",
"self",
".",
"cast_type",
"try",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"self",
... | Base validation method. Check if type is valid, or try brute casting.
Args:
value (object): A value for validation.
Returns:
Base_type instance.
Raises:
SchemaError, if validation or type casting fails. | [
"Base",
"validation",
"method",
".",
"Check",
"if",
"type",
"is",
"valid",
"or",
"try",
"brute",
"casting",
"."
] | 515e3fb84cddf70fc17e5d300c74c3a63539f223 | https://github.com/agile4you/SchemaFactory/blob/515e3fb84cddf70fc17e5d300c74c3a63539f223/schema_factory/types.py#L36-L55 |
52,631 | agile4you/SchemaFactory | schema_factory/types.py | Timestamp.cast_callback | def cast_callback(value):
"""Override `cast_callback` method.
"""
# Postgresql / MySQL drivers change the format on 'TIMESTAMP' columns;
if 'T' in value:
value = value.replace('T', ' ')
return datetime.strptime(value.split('.')[0], '%Y-%m-%d %H:%M:%S') | python | def cast_callback(value):
"""Override `cast_callback` method.
"""
# Postgresql / MySQL drivers change the format on 'TIMESTAMP' columns;
if 'T' in value:
value = value.replace('T', ' ')
return datetime.strptime(value.split('.')[0], '%Y-%m-%d %H:%M:%S') | [
"def",
"cast_callback",
"(",
"value",
")",
":",
"# Postgresql / MySQL drivers change the format on 'TIMESTAMP' columns;",
"if",
"'T'",
"in",
"value",
":",
"value",
"=",
"value",
".",
"replace",
"(",
"'T'",
",",
"' '",
")",
"return",
"datetime",
".",
"strptime",
"(... | Override `cast_callback` method. | [
"Override",
"cast_callback",
"method",
"."
] | 515e3fb84cddf70fc17e5d300c74c3a63539f223 | https://github.com/agile4you/SchemaFactory/blob/515e3fb84cddf70fc17e5d300c74c3a63539f223/schema_factory/types.py#L154-L162 |
52,632 | dev-pipeline/dev-pipeline-configure | lib/devpipeline_configure/config.py | _is_cache_dir_appropriate | def _is_cache_dir_appropriate(cache_dir, cache_file):
"""
Determine if a directory is acceptable for building.
A directory is suitable if any of the following are true:
- it doesn't exist
- it is empty
- it contains an existing build cache
"""
if os.path.exists(cache_dir):
... | python | def _is_cache_dir_appropriate(cache_dir, cache_file):
"""
Determine if a directory is acceptable for building.
A directory is suitable if any of the following are true:
- it doesn't exist
- it is empty
- it contains an existing build cache
"""
if os.path.exists(cache_dir):
... | [
"def",
"_is_cache_dir_appropriate",
"(",
"cache_dir",
",",
"cache_file",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"cache_dir",
")",
":",
"files",
"=",
"os",
".",
"listdir",
"(",
"cache_dir",
")",
"if",
"cache_file",
"in",
"files",
":",
"ret... | Determine if a directory is acceptable for building.
A directory is suitable if any of the following are true:
- it doesn't exist
- it is empty
- it contains an existing build cache | [
"Determine",
"if",
"a",
"directory",
"is",
"acceptable",
"for",
"building",
"."
] | 26de2dd1b39d9a77d5417244f09319e7dce47495 | https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/config.py#L30-L44 |
52,633 | dev-pipeline/dev-pipeline-configure | lib/devpipeline_configure/config.py | process_config | def process_config(raw_path, cache_dir, cache_file, **kwargs):
"""
Read a build configuration and create it, storing the result in a build
cache.
Arguments
raw_path -- path to a build configuration
cache_dir -- the directory where cache should be written
cache_file -- The filename to write ... | python | def process_config(raw_path, cache_dir, cache_file, **kwargs):
"""
Read a build configuration and create it, storing the result in a build
cache.
Arguments
raw_path -- path to a build configuration
cache_dir -- the directory where cache should be written
cache_file -- The filename to write ... | [
"def",
"process_config",
"(",
"raw_path",
",",
"cache_dir",
",",
"cache_file",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"_create_cache",
"(",
"raw_path",
",",
"cache_dir",
",",
"cache_file",
")",
"for",
"modifier",
"in",
"_CONFIG_MODIFIERS",
":",
"m... | Read a build configuration and create it, storing the result in a build
cache.
Arguments
raw_path -- path to a build configuration
cache_dir -- the directory where cache should be written
cache_file -- The filename to write the cache. This will live inside
cache_dir.
**kwargs... | [
"Read",
"a",
"build",
"configuration",
"and",
"create",
"it",
"storing",
"the",
"result",
"in",
"a",
"build",
"cache",
"."
] | 26de2dd1b39d9a77d5417244f09319e7dce47495 | https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/config.py#L142-L164 |
52,634 | dArignac/ip_assembler | ip_assembler/admin.py | IPAdmin.get_urls | def get_urls(self):
"""
Returns the urls for the model.
"""
urls = super(IPAdmin, self).get_urls()
my_urls = patterns(
'',
url(r'^batch_process_ips/$', self.admin_site.admin_view(self.batch_process_ips_view), name='batch_process_ips_view')
)
... | python | def get_urls(self):
"""
Returns the urls for the model.
"""
urls = super(IPAdmin, self).get_urls()
my_urls = patterns(
'',
url(r'^batch_process_ips/$', self.admin_site.admin_view(self.batch_process_ips_view), name='batch_process_ips_view')
)
... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"urls",
"=",
"super",
"(",
"IPAdmin",
",",
"self",
")",
".",
"get_urls",
"(",
")",
"my_urls",
"=",
"patterns",
"(",
"''",
",",
"url",
"(",
"r'^batch_process_ips/$'",
",",
"self",
".",
"admin_site",
".",
"admin_... | Returns the urls for the model. | [
"Returns",
"the",
"urls",
"for",
"the",
"model",
"."
] | 39cf948925d7f79db872d1bf57771d158e8d6a33 | https://github.com/dArignac/ip_assembler/blob/39cf948925d7f79db872d1bf57771d158e8d6a33/ip_assembler/admin.py#L17-L26 |
52,635 | RI-imaging/qpsphere | qpsphere/models/mod_mie.py | field2ap_corr | def field2ap_corr(field):
"""Determine amplitude and offset-corrected phase from a field
The phase jumps sometimes appear after phase unwrapping.
Parameters
----------
field: 2d complex np.ndarray
Complex input field
Returns
-------
amp: 2d real np.ndarray
Amplitude da... | python | def field2ap_corr(field):
"""Determine amplitude and offset-corrected phase from a field
The phase jumps sometimes appear after phase unwrapping.
Parameters
----------
field: 2d complex np.ndarray
Complex input field
Returns
-------
amp: 2d real np.ndarray
Amplitude da... | [
"def",
"field2ap_corr",
"(",
"field",
")",
":",
"phase",
"=",
"unwrap",
".",
"unwrap_phase",
"(",
"np",
".",
"angle",
"(",
"field",
")",
",",
"seed",
"=",
"47",
")",
"samples",
"=",
"[",
"]",
"samples",
".",
"append",
"(",
"phase",
"[",
":",
",",
... | Determine amplitude and offset-corrected phase from a field
The phase jumps sometimes appear after phase unwrapping.
Parameters
----------
field: 2d complex np.ndarray
Complex input field
Returns
-------
amp: 2d real np.ndarray
Amplitude data
pha: 2d real np.ndarray
... | [
"Determine",
"amplitude",
"and",
"offset",
"-",
"corrected",
"phase",
"from",
"a",
"field"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_mie.py#L9-L36 |
52,636 | RI-imaging/qpsphere | qpsphere/models/mod_mie.py | mie | def mie(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=1e-7, grid_size=(80, 80),
center=(39.5, 39.5), focus=0, arp=True):
"""Mie-simulated field behind a dielectric sphere
Parameters
----------
radius: float
Radius of the sphere [m]
sphere... | python | def mie(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=1e-7, grid_size=(80, 80),
center=(39.5, 39.5), focus=0, arp=True):
"""Mie-simulated field behind a dielectric sphere
Parameters
----------
radius: float
Radius of the sphere [m]
sphere... | [
"def",
"mie",
"(",
"radius",
"=",
"5e-6",
",",
"sphere_index",
"=",
"1.339",
",",
"medium_index",
"=",
"1.333",
",",
"wavelength",
"=",
"550e-9",
",",
"pixel_size",
"=",
"1e-7",
",",
"grid_size",
"=",
"(",
"80",
",",
"80",
")",
",",
"center",
"=",
"(... | Mie-simulated field behind a dielectric sphere
Parameters
----------
radius: float
Radius of the sphere [m]
sphere_index: float
Refractive index of the sphere
medium_index: float
Refractive index of the surrounding medium
wavelength: float
Vacuum wavelength of th... | [
"Mie",
"-",
"simulated",
"field",
"behind",
"a",
"dielectric",
"sphere"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_mie.py#L39-L124 |
52,637 | mogproject/mog-commons-python | src/mog_commons/collection.py | get_single_item | def get_single_item(d):
"""Get an item from a dict which contains just one item."""
assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
return next(six.iteritems(d)) | python | def get_single_item(d):
"""Get an item from a dict which contains just one item."""
assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
return next(six.iteritems(d)) | [
"def",
"get_single_item",
"(",
"d",
")",
":",
"assert",
"len",
"(",
"d",
")",
"==",
"1",
",",
"'Single-item dict must have just one item, not %d.'",
"%",
"len",
"(",
"d",
")",
"return",
"next",
"(",
"six",
".",
"iteritems",
"(",
"d",
")",
")"
] | Get an item from a dict which contains just one item. | [
"Get",
"an",
"item",
"from",
"a",
"dict",
"which",
"contains",
"just",
"one",
"item",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/collection.py#L8-L11 |
52,638 | mogproject/mog-commons-python | src/mog_commons/collection.py | get_single_key | def get_single_key(d):
"""Get a key from a dict which contains just one item."""
assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
return next(six.iterkeys(d)) | python | def get_single_key(d):
"""Get a key from a dict which contains just one item."""
assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
return next(six.iterkeys(d)) | [
"def",
"get_single_key",
"(",
"d",
")",
":",
"assert",
"len",
"(",
"d",
")",
"==",
"1",
",",
"'Single-item dict must have just one item, not %d.'",
"%",
"len",
"(",
"d",
")",
"return",
"next",
"(",
"six",
".",
"iterkeys",
"(",
"d",
")",
")"
] | Get a key from a dict which contains just one item. | [
"Get",
"a",
"key",
"from",
"a",
"dict",
"which",
"contains",
"just",
"one",
"item",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/collection.py#L14-L17 |
52,639 | mogproject/mog-commons-python | src/mog_commons/collection.py | get_single_value | def get_single_value(d):
"""Get a value from a dict which contains just one item."""
assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
return next(six.itervalues(d)) | python | def get_single_value(d):
"""Get a value from a dict which contains just one item."""
assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
return next(six.itervalues(d)) | [
"def",
"get_single_value",
"(",
"d",
")",
":",
"assert",
"len",
"(",
"d",
")",
"==",
"1",
",",
"'Single-item dict must have just one item, not %d.'",
"%",
"len",
"(",
"d",
")",
"return",
"next",
"(",
"six",
".",
"itervalues",
"(",
"d",
")",
")"
] | Get a value from a dict which contains just one item. | [
"Get",
"a",
"value",
"from",
"a",
"dict",
"which",
"contains",
"just",
"one",
"item",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/collection.py#L20-L23 |
52,640 | mogproject/mog-commons-python | src/mog_commons/collection.py | distinct | def distinct(xs):
"""Get the list of distinct values with preserving order."""
# don't use collections.OrderedDict because we do support Python 2.6
seen = set()
return [x for x in xs if x not in seen and not seen.add(x)] | python | def distinct(xs):
"""Get the list of distinct values with preserving order."""
# don't use collections.OrderedDict because we do support Python 2.6
seen = set()
return [x for x in xs if x not in seen and not seen.add(x)] | [
"def",
"distinct",
"(",
"xs",
")",
":",
"# don't use collections.OrderedDict because we do support Python 2.6",
"seen",
"=",
"set",
"(",
")",
"return",
"[",
"x",
"for",
"x",
"in",
"xs",
"if",
"x",
"not",
"in",
"seen",
"and",
"not",
"seen",
".",
"add",
"(",
... | Get the list of distinct values with preserving order. | [
"Get",
"the",
"list",
"of",
"distinct",
"values",
"with",
"preserving",
"order",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/collection.py#L26-L30 |
52,641 | datasets-org/confobj | confobj/config.py | Config.configure | def configure(self):
# type: () -> None
"""
Configures object based on its initialization
"""
for i in vars(self):
if i.startswith("_"):
continue
val = self.__get(i, return_type=type(getattr(self, i)))
if val is not None:
... | python | def configure(self):
# type: () -> None
"""
Configures object based on its initialization
"""
for i in vars(self):
if i.startswith("_"):
continue
val = self.__get(i, return_type=type(getattr(self, i)))
if val is not None:
... | [
"def",
"configure",
"(",
"self",
")",
":",
"# type: () -> None",
"for",
"i",
"in",
"vars",
"(",
"self",
")",
":",
"if",
"i",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"continue",
"val",
"=",
"self",
".",
"__get",
"(",
"i",
",",
"return_type",
"=",
... | Configures object based on its initialization | [
"Configures",
"object",
"based",
"on",
"its",
"initialization"
] | f21f2eefcacc45095210bcb4ddd315bda43481d5 | https://github.com/datasets-org/confobj/blob/f21f2eefcacc45095210bcb4ddd315bda43481d5/confobj/config.py#L40-L50 |
52,642 | dArignac/ip_assembler | ip_assembler/tasks.py | UpdateLocationsIfNecessaryTask.run | def run(self, **kwargs):
"""
Does the magic!
"""
logger.info('UpdateLocationsIfNecessaryTask was called')
# read last ip count
try:
with open(app_settings.IP_ASSEMBLER_IP_CHANGED_FILE, 'r') as f:
content_list = f.readlines()
if... | python | def run(self, **kwargs):
"""
Does the magic!
"""
logger.info('UpdateLocationsIfNecessaryTask was called')
# read last ip count
try:
with open(app_settings.IP_ASSEMBLER_IP_CHANGED_FILE, 'r') as f:
content_list = f.readlines()
if... | [
"def",
"run",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"info",
"(",
"'UpdateLocationsIfNecessaryTask was called'",
")",
"# read last ip count",
"try",
":",
"with",
"open",
"(",
"app_settings",
".",
"IP_ASSEMBLER_IP_CHANGED_FILE",
",",
"'r'",
... | Does the magic! | [
"Does",
"the",
"magic!"
] | 39cf948925d7f79db872d1bf57771d158e8d6a33 | https://github.com/dArignac/ip_assembler/blob/39cf948925d7f79db872d1bf57771d158e8d6a33/ip_assembler/tasks.py#L37-L75 |
52,643 | dArignac/ip_assembler | ip_assembler/tasks.py | IPEMailChecker.run | def run(self, **kwargs):
"""
Checks the IMAP mailbox for new mails and tries to handle them.
"""
try:
# connect to server and login
box = imaplib.IMAP4_SSL(settings.IMAP_SERVER)
box.login(settings.IMAP_USERNAME, settings.IMAP_PASSWORD)
box.... | python | def run(self, **kwargs):
"""
Checks the IMAP mailbox for new mails and tries to handle them.
"""
try:
# connect to server and login
box = imaplib.IMAP4_SSL(settings.IMAP_SERVER)
box.login(settings.IMAP_USERNAME, settings.IMAP_PASSWORD)
box.... | [
"def",
"run",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"# connect to server and login",
"box",
"=",
"imaplib",
".",
"IMAP4_SSL",
"(",
"settings",
".",
"IMAP_SERVER",
")",
"box",
".",
"login",
"(",
"settings",
".",
"IMAP_USERNAME",
",",
... | Checks the IMAP mailbox for new mails and tries to handle them. | [
"Checks",
"the",
"IMAP",
"mailbox",
"for",
"new",
"mails",
"and",
"tries",
"to",
"handle",
"them",
"."
] | 39cf948925d7f79db872d1bf57771d158e8d6a33 | https://github.com/dArignac/ip_assembler/blob/39cf948925d7f79db872d1bf57771d158e8d6a33/ip_assembler/tasks.py#L180-L233 |
52,644 | jacobian/trlo | trlo.py | authorize | def authorize(client_key, client_secret, credfile=CONFIG_FILE, app='trlo.py',
expiration='never', scope='read,write'):
"""
Authorize with Trello, saving creds to `credfile`.
"""
# 1. Obtain the request token.
oauth = OAuth1Session(client_key, client_secret=client_secret)
request_to... | python | def authorize(client_key, client_secret, credfile=CONFIG_FILE, app='trlo.py',
expiration='never', scope='read,write'):
"""
Authorize with Trello, saving creds to `credfile`.
"""
# 1. Obtain the request token.
oauth = OAuth1Session(client_key, client_secret=client_secret)
request_to... | [
"def",
"authorize",
"(",
"client_key",
",",
"client_secret",
",",
"credfile",
"=",
"CONFIG_FILE",
",",
"app",
"=",
"'trlo.py'",
",",
"expiration",
"=",
"'never'",
",",
"scope",
"=",
"'read,write'",
")",
":",
"# 1. Obtain the request token.",
"oauth",
"=",
"OAuth... | Authorize with Trello, saving creds to `credfile`. | [
"Authorize",
"with",
"Trello",
"saving",
"creds",
"to",
"credfile",
"."
] | caa2d869fc35ab9d067281541f77000b7e994d37 | https://github.com/jacobian/trlo/blob/caa2d869fc35ab9d067281541f77000b7e994d37/trlo.py#L22-L62 |
52,645 | decryptus/sonicprobe | sonicprobe/validator/country.py | SPValidatorCountry.getCountry | def getCountry(value):
"""
returns the country name from country code
@return string
"""
if not helpers.has_len(value):
return False
return COUNTRIES.get(str(value).lower(), False) | python | def getCountry(value):
"""
returns the country name from country code
@return string
"""
if not helpers.has_len(value):
return False
return COUNTRIES.get(str(value).lower(), False) | [
"def",
"getCountry",
"(",
"value",
")",
":",
"if",
"not",
"helpers",
".",
"has_len",
"(",
"value",
")",
":",
"return",
"False",
"return",
"COUNTRIES",
".",
"get",
"(",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
",",
"False",
")"
] | returns the country name from country code
@return string | [
"returns",
"the",
"country",
"name",
"from",
"country",
"code"
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/validator/country.py#L256-L265 |
52,646 | decryptus/sonicprobe | sonicprobe/validator/country.py | SPValidatorCountry.validate | def validate(value):
"""
checks if given value is a valid country codes
@param string value
@return bool
"""
if not helpers.has_len(value):
return False
return COUNTRIES.has_key(str(value).lower()) | python | def validate(value):
"""
checks if given value is a valid country codes
@param string value
@return bool
"""
if not helpers.has_len(value):
return False
return COUNTRIES.has_key(str(value).lower()) | [
"def",
"validate",
"(",
"value",
")",
":",
"if",
"not",
"helpers",
".",
"has_len",
"(",
"value",
")",
":",
"return",
"False",
"return",
"COUNTRIES",
".",
"has_key",
"(",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
")"
] | checks if given value is a valid country codes
@param string value
@return bool | [
"checks",
"if",
"given",
"value",
"is",
"a",
"valid",
"country",
"codes"
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/validator/country.py#L277-L287 |
52,647 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/column.py | Column.create_treecolumn | def create_treecolumn(self, objectlist):
"""Create a gtk.TreeViewColumn for the configuration.
"""
col = gtk.TreeViewColumn(self.title)
col.set_data('pygtkhelpers::objectlist', objectlist)
col.set_data('pygtkhelpers::column', self)
col.props.visible = self.visible
... | python | def create_treecolumn(self, objectlist):
"""Create a gtk.TreeViewColumn for the configuration.
"""
col = gtk.TreeViewColumn(self.title)
col.set_data('pygtkhelpers::objectlist', objectlist)
col.set_data('pygtkhelpers::column', self)
col.props.visible = self.visible
... | [
"def",
"create_treecolumn",
"(",
"self",
",",
"objectlist",
")",
":",
"col",
"=",
"gtk",
".",
"TreeViewColumn",
"(",
"self",
".",
"title",
")",
"col",
".",
"set_data",
"(",
"'pygtkhelpers::objectlist'",
",",
"objectlist",
")",
"col",
".",
"set_data",
"(",
... | Create a gtk.TreeViewColumn for the configuration. | [
"Create",
"a",
"gtk",
".",
"TreeViewColumn",
"for",
"the",
"configuration",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/column.py#L203-L234 |
52,648 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/column.py | Column.render_tooltip | def render_tooltip(self, tooltip, obj):
"""Render the tooltip for this column for an object
"""
if self.tooltip_attr:
val = getattr(obj, self.tooltip_attr)
elif self.tooltip_value:
val = self.tooltip_value
else:
return False
setter = ge... | python | def render_tooltip(self, tooltip, obj):
"""Render the tooltip for this column for an object
"""
if self.tooltip_attr:
val = getattr(obj, self.tooltip_attr)
elif self.tooltip_value:
val = self.tooltip_value
else:
return False
setter = ge... | [
"def",
"render_tooltip",
"(",
"self",
",",
"tooltip",
",",
"obj",
")",
":",
"if",
"self",
".",
"tooltip_attr",
":",
"val",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"tooltip_attr",
")",
"elif",
"self",
".",
"tooltip_value",
":",
"val",
"=",
"self",... | Render the tooltip for this column for an object | [
"Render",
"the",
"tooltip",
"for",
"this",
"column",
"for",
"an",
"object"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/column.py#L252-L266 |
52,649 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/toolsupport.py | choose_tool_key | def choose_tool_key(full_configuration, keys):
"""
Select the key for a tool from a list of supported tools.
This function is designed to help when multiple keys can be used to specify
an option (e.g., during migration from one name to another). The values in
keys should be ordered based on prefer... | python | def choose_tool_key(full_configuration, keys):
"""
Select the key for a tool from a list of supported tools.
This function is designed to help when multiple keys can be used to specify
an option (e.g., during migration from one name to another). The values in
keys should be ordered based on prefer... | [
"def",
"choose_tool_key",
"(",
"full_configuration",
",",
"keys",
")",
":",
"tool_key",
"=",
"_choose_key",
"(",
"full_configuration",
".",
"config",
",",
"keys",
")",
"if",
"tool_key",
"!=",
"keys",
"[",
"0",
"]",
":",
"full_configuration",
".",
"executor",
... | Select the key for a tool from a list of supported tools.
This function is designed to help when multiple keys can be used to specify
an option (e.g., during migration from one name to another). The values in
keys should be ordered based on preference, as that's the order they'll be
checked. If anyth... | [
"Select",
"the",
"key",
"for",
"a",
"tool",
"from",
"a",
"list",
"of",
"supported",
"tools",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/toolsupport.py#L49-L68 |
52,650 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/toolsupport.py | tool_builder | def tool_builder(component, key, tool_map, *args):
"""This helper function initializes a tool with the given args."""
# pylint: disable=protected-access
tool_name = component.get(key)
if tool_name:
tool_fn = tool_map.get(tool_name)
if tool_fn:
return tool_fn[0](*args)
... | python | def tool_builder(component, key, tool_map, *args):
"""This helper function initializes a tool with the given args."""
# pylint: disable=protected-access
tool_name = component.get(key)
if tool_name:
tool_fn = tool_map.get(tool_name)
if tool_fn:
return tool_fn[0](*args)
... | [
"def",
"tool_builder",
"(",
"component",
",",
"key",
",",
"tool_map",
",",
"*",
"args",
")",
":",
"# pylint: disable=protected-access",
"tool_name",
"=",
"component",
".",
"get",
"(",
"key",
")",
"if",
"tool_name",
":",
"tool_fn",
"=",
"tool_map",
".",
"get"... | This helper function initializes a tool with the given args. | [
"This",
"helper",
"function",
"initializes",
"a",
"tool",
"with",
"the",
"given",
"args",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/toolsupport.py#L71-L80 |
52,651 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/toolsupport.py | args_builder | def args_builder(prefix, current_target, args_dict, value_found_fn):
"""
Process arguments a tool cares about.
Since most tools require configuration, this function helps deal with the
boilerplate. Each option will be processed based on all modifications
supported by dev-pipeline (i.e., profiles a... | python | def args_builder(prefix, current_target, args_dict, value_found_fn):
"""
Process arguments a tool cares about.
Since most tools require configuration, this function helps deal with the
boilerplate. Each option will be processed based on all modifications
supported by dev-pipeline (i.e., profiles a... | [
"def",
"args_builder",
"(",
"prefix",
",",
"current_target",
",",
"args_dict",
",",
"value_found_fn",
")",
":",
"current_config",
"=",
"current_target",
".",
"config",
"for",
"key",
",",
"separator",
"in",
"args_dict",
".",
"items",
"(",
")",
":",
"option",
... | Process arguments a tool cares about.
Since most tools require configuration, this function helps deal with the
boilerplate. Each option will be processed based on all modifications
supported by dev-pipeline (i.e., profiles and overrides) in the proper
order.
Arguments:
prefix -- The prefix f... | [
"Process",
"arguments",
"a",
"tool",
"cares",
"about",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/toolsupport.py#L115-L142 |
52,652 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/toolsupport.py | build_flex_args_keys | def build_flex_args_keys(components):
"""
Helper function to build a list of options.
Some tools require require variations of the same options (e.g., cflags
for debug vs release builds), but manually creating those options is
cumbersome and error-prone. This function handles that work by combinin... | python | def build_flex_args_keys(components):
"""
Helper function to build a list of options.
Some tools require require variations of the same options (e.g., cflags
for debug vs release builds), but manually creating those options is
cumbersome and error-prone. This function handles that work by combinin... | [
"def",
"build_flex_args_keys",
"(",
"components",
")",
":",
"def",
"_prepend_first",
"(",
"components",
",",
"sub_components",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"first",
"in",
"components",
"[",
"0",
"]",
":",
"for",
"sub_component",
"in",
"sub_componen... | Helper function to build a list of options.
Some tools require require variations of the same options (e.g., cflags
for debug vs release builds), but manually creating those options is
cumbersome and error-prone. This function handles that work by combining
all possible comintations of the values in c... | [
"Helper",
"function",
"to",
"build",
"a",
"list",
"of",
"options",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/toolsupport.py#L145-L170 |
52,653 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/toolsupport.py | _NullJoiner.join | def join(self, vals):
"""
Either return the non-list value or raise an Exception.
Arguments:
vals - a list of values to process
"""
if len(vals) == 1:
return vals[0]
raise Exception(
"Too many values for {}:{}".format(self._component_name,... | python | def join(self, vals):
"""
Either return the non-list value or raise an Exception.
Arguments:
vals - a list of values to process
"""
if len(vals) == 1:
return vals[0]
raise Exception(
"Too many values for {}:{}".format(self._component_name,... | [
"def",
"join",
"(",
"self",
",",
"vals",
")",
":",
"if",
"len",
"(",
"vals",
")",
"==",
"1",
":",
"return",
"vals",
"[",
"0",
"]",
"raise",
"Exception",
"(",
"\"Too many values for {}:{}\"",
".",
"format",
"(",
"self",
".",
"_component_name",
",",
"sel... | Either return the non-list value or raise an Exception.
Arguments:
vals - a list of values to process | [
"Either",
"return",
"the",
"non",
"-",
"list",
"value",
"or",
"raise",
"an",
"Exception",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/toolsupport.py#L91-L102 |
52,654 | tundish/turberfield-dialogue | turberfield/dialogue/handlers.py | TerminalHandler.handle_audio | def handle_audio(obj, wait=False):
"""Handle an audio event.
This function plays an audio file.
Currently only `.wav` format is supported.
:param obj: An :py:class:`~turberfield.dialogue.model.Model.Audio`
object.
:param bool wait: Force a blocking wait until playba... | python | def handle_audio(obj, wait=False):
"""Handle an audio event.
This function plays an audio file.
Currently only `.wav` format is supported.
:param obj: An :py:class:`~turberfield.dialogue.model.Model.Audio`
object.
:param bool wait: Force a blocking wait until playba... | [
"def",
"handle_audio",
"(",
"obj",
",",
"wait",
"=",
"False",
")",
":",
"if",
"not",
"simpleaudio",
":",
"return",
"obj",
"fp",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"obj",
".",
"package",
",",
"obj",
".",
"resource",
")",
"data",
"=",
"... | Handle an audio event.
This function plays an audio file.
Currently only `.wav` format is supported.
:param obj: An :py:class:`~turberfield.dialogue.model.Model.Audio`
object.
:param bool wait: Force a blocking wait until playback is complete.
:return: The supplied ... | [
"Handle",
"an",
"audio",
"event",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/handlers.py#L63-L100 |
52,655 | tundish/turberfield-dialogue | turberfield/dialogue/handlers.py | TerminalHandler.handle_interlude | def handle_interlude(
self, obj, folder, index, ensemble,
loop=None, **kwargs
):
"""Handle an interlude event.
Interlude functions permit branching. They return a folder which the
application can choose to adopt as the next supplier of dialogue.
This handler calls t... | python | def handle_interlude(
self, obj, folder, index, ensemble,
loop=None, **kwargs
):
"""Handle an interlude event.
Interlude functions permit branching. They return a folder which the
application can choose to adopt as the next supplier of dialogue.
This handler calls t... | [
"def",
"handle_interlude",
"(",
"self",
",",
"obj",
",",
"folder",
",",
"index",
",",
"ensemble",
",",
"loop",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"folder",
".",
"metadata",
"else",
":",
"return",... | Handle an interlude event.
Interlude functions permit branching. They return a folder which the
application can choose to adopt as the next supplier of dialogue.
This handler calls the interlude with the supplied arguments and
returns the result.
:param obj: A callable object.... | [
"Handle",
"an",
"interlude",
"event",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/handlers.py#L102-L130 |
52,656 | tundish/turberfield-dialogue | turberfield/dialogue/handlers.py | TerminalHandler.handle_line | def handle_line(self, obj):
"""Handle a line event.
This function displays a line of dialogue. It generates a blocking wait
for a period of time calculated from the length of the line.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Line` object.
:return: The supplie... | python | def handle_line(self, obj):
"""Handle a line event.
This function displays a line of dialogue. It generates a blocking wait
for a period of time calculated from the length of the line.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Line` object.
:return: The supplie... | [
"def",
"handle_line",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"persona",
"is",
"None",
":",
"return",
"obj",
"name",
"=",
"getattr",
"(",
"obj",
".",
"persona",
",",
"\"_name\"",
",",
"\"\"",
")",
"print",
"(",
"textwrap",
".",
"indent",... | Handle a line event.
This function displays a line of dialogue. It generates a blocking wait
for a period of time calculated from the length of the line.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Line` object.
:return: The supplied object. | [
"Handle",
"a",
"line",
"event",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/handlers.py#L132-L166 |
52,657 | tundish/turberfield-dialogue | turberfield/dialogue/handlers.py | TerminalHandler.handle_memory | def handle_memory(self, obj):
"""Handle a memory event.
This function accesses the internal database. It writes a record
containing state information and an optional note.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Memory`
object.
:return: The suppli... | python | def handle_memory(self, obj):
"""Handle a memory event.
This function accesses the internal database. It writes a record
containing state information and an optional note.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Memory`
object.
:return: The suppli... | [
"def",
"handle_memory",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"subject",
"is",
"not",
"None",
":",
"with",
"self",
".",
"con",
"as",
"db",
":",
"SchemaBase",
".",
"note",
"(",
"db",
",",
"obj",
".",
"subject",
",",
"obj",
".",
"sta... | Handle a memory event.
This function accesses the internal database. It writes a record
containing state information and an optional note.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Memory`
object.
:return: The supplied object. | [
"Handle",
"a",
"memory",
"event",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/handlers.py#L168-L189 |
52,658 | tundish/turberfield-dialogue | turberfield/dialogue/handlers.py | TerminalHandler.handle_property | def handle_property(self, obj):
"""Handle a property event.
This function will set an attribute on an object if the event requires
it.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Property`
object.
:return: The supplied object.
"""
if ... | python | def handle_property(self, obj):
"""Handle a property event.
This function will set an attribute on an object if the event requires
it.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Property`
object.
:return: The supplied object.
"""
if ... | [
"def",
"handle_property",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"object",
"is",
"not",
"None",
":",
"try",
":",
"setattr",
"(",
"obj",
".",
"object",
",",
"obj",
".",
"attr",
",",
"obj",
".",
"val",
")",
"except",
"AttributeError",
"... | Handle a property event.
This function will set an attribute on an object if the event requires
it.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Property`
object.
:return: The supplied object. | [
"Handle",
"a",
"property",
"event",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/handlers.py#L191-L217 |
52,659 | tundish/turberfield-dialogue | turberfield/dialogue/handlers.py | TerminalHandler.handle_scene | def handle_scene(self, obj):
"""Handle a scene event.
This function applies a blocking wait at the start of a scene.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Shot`
object.
:return: The supplied object.
"""
print(
"{t.dim}{scene... | python | def handle_scene(self, obj):
"""Handle a scene event.
This function applies a blocking wait at the start of a scene.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Shot`
object.
:return: The supplied object.
"""
print(
"{t.dim}{scene... | [
"def",
"handle_scene",
"(",
"self",
",",
"obj",
")",
":",
"print",
"(",
"\"{t.dim}{scene}{t.normal}\"",
".",
"format",
"(",
"scene",
"=",
"obj",
".",
"scene",
".",
"capitalize",
"(",
")",
",",
"t",
"=",
"self",
".",
"terminal",
")",
",",
"end",
"=",
... | Handle a scene event.
This function applies a blocking wait at the start of a scene.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Shot`
object.
:return: The supplied object. | [
"Handle",
"a",
"scene",
"event",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/handlers.py#L219-L237 |
52,660 | tundish/turberfield-dialogue | turberfield/dialogue/handlers.py | TerminalHandler.handle_shot | def handle_shot(self, obj):
"""Handle a shot event.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Shot` object.
:return: The supplied object.
"""
print(
"{t.dim}{shot}{t.normal}".format(
shot=obj.name.capitalize(), t=self.terminal
... | python | def handle_shot(self, obj):
"""Handle a shot event.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Shot` object.
:return: The supplied object.
"""
print(
"{t.dim}{shot}{t.normal}".format(
shot=obj.name.capitalize(), t=self.terminal
... | [
"def",
"handle_shot",
"(",
"self",
",",
"obj",
")",
":",
"print",
"(",
"\"{t.dim}{shot}{t.normal}\"",
".",
"format",
"(",
"shot",
"=",
"obj",
".",
"name",
".",
"capitalize",
"(",
")",
",",
"t",
"=",
"self",
".",
"terminal",
")",
",",
"end",
"=",
"\"\... | Handle a shot event.
:param obj: A :py:class:`~turberfield.dialogue.model.Model.Shot` object.
:return: The supplied object. | [
"Handle",
"a",
"shot",
"event",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/handlers.py#L250-L264 |
52,661 | decryptus/sonicprobe | sonicprobe/libs/threading_tcp_server.py | KillableThreadingTCPServer.process_request_thread | def process_request_thread(self, mainthread):
"""obtain request from queue instead of directly from server socket"""
life_time = time.time()
nb_requests = 0
while not mainthread.killed():
if self.max_life_time > 0:
if (time.time() - life_time) >= self.max_l... | python | def process_request_thread(self, mainthread):
"""obtain request from queue instead of directly from server socket"""
life_time = time.time()
nb_requests = 0
while not mainthread.killed():
if self.max_life_time > 0:
if (time.time() - life_time) >= self.max_l... | [
"def",
"process_request_thread",
"(",
"self",
",",
"mainthread",
")",
":",
"life_time",
"=",
"time",
".",
"time",
"(",
")",
"nb_requests",
"=",
"0",
"while",
"not",
"mainthread",
".",
"killed",
"(",
")",
":",
"if",
"self",
".",
"max_life_time",
">",
"0",... | obtain request from queue instead of directly from server socket | [
"obtain",
"request",
"from",
"queue",
"instead",
"of",
"directly",
"from",
"server",
"socket"
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/threading_tcp_server.py#L123-L145 |
52,662 | MinchinWeb/minchin.releaser | minchin/releaser/make_release.py | build_distribution | def build_distribution():
"""Build distributions of the code."""
result = invoke.run('python setup.py sdist bdist_egg bdist_wheel',
warn=True, hide=True)
if result.ok:
print("[{}GOOD{}] Distribution built without errors."
.format(GOOD_COLOR, RESET_COLOR))
el... | python | def build_distribution():
"""Build distributions of the code."""
result = invoke.run('python setup.py sdist bdist_egg bdist_wheel',
warn=True, hide=True)
if result.ok:
print("[{}GOOD{}] Distribution built without errors."
.format(GOOD_COLOR, RESET_COLOR))
el... | [
"def",
"build_distribution",
"(",
")",
":",
"result",
"=",
"invoke",
".",
"run",
"(",
"'python setup.py sdist bdist_egg bdist_wheel'",
",",
"warn",
"=",
"True",
",",
"hide",
"=",
"True",
")",
"if",
"result",
".",
"ok",
":",
"print",
"(",
"\"[{}GOOD{}] Distribu... | Build distributions of the code. | [
"Build",
"distributions",
"of",
"the",
"code",
"."
] | cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4 | https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/make_release.py#L171-L182 |
52,663 | MinchinWeb/minchin.releaser | minchin/releaser/make_release.py | other_dependencies | def other_dependencies(ctx, server, environment):
"""Install things that need to be in place before installing the main package."""
if 'extra_packages' in ctx.releaser:
server = server.lower()
extra_pkgs = []
if server in ["local"]:
if 'local' in ctx.releaser.extra_packages:
... | python | def other_dependencies(ctx, server, environment):
"""Install things that need to be in place before installing the main package."""
if 'extra_packages' in ctx.releaser:
server = server.lower()
extra_pkgs = []
if server in ["local"]:
if 'local' in ctx.releaser.extra_packages:
... | [
"def",
"other_dependencies",
"(",
"ctx",
",",
"server",
",",
"environment",
")",
":",
"if",
"'extra_packages'",
"in",
"ctx",
".",
"releaser",
":",
"server",
"=",
"server",
".",
"lower",
"(",
")",
"extra_pkgs",
"=",
"[",
"]",
"if",
"server",
"in",
"[",
... | Install things that need to be in place before installing the main package. | [
"Install",
"things",
"that",
"need",
"to",
"be",
"in",
"place",
"before",
"installing",
"the",
"main",
"package",
"."
] | cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4 | https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/make_release.py#L185-L220 |
52,664 | MinchinWeb/minchin.releaser | minchin/releaser/make_release.py | check_local_install | def check_local_install(ctx, version, ext, server="local"):
"""
Upload and install works?
Uploads a distribution to PyPI, and then tests to see if I can download and
install it.
Returns:
str: string summazing operation
"""
here = Path(ctx.releaser.here).resolve()
dist_dir = her... | python | def check_local_install(ctx, version, ext, server="local"):
"""
Upload and install works?
Uploads a distribution to PyPI, and then tests to see if I can download and
install it.
Returns:
str: string summazing operation
"""
here = Path(ctx.releaser.here).resolve()
dist_dir = her... | [
"def",
"check_local_install",
"(",
"ctx",
",",
"version",
",",
"ext",
",",
"server",
"=",
"\"local\"",
")",
":",
"here",
"=",
"Path",
"(",
"ctx",
".",
"releaser",
".",
"here",
")",
".",
"resolve",
"(",
")",
"dist_dir",
"=",
"here",
"/",
"'dist'",
"al... | Upload and install works?
Uploads a distribution to PyPI, and then tests to see if I can download and
install it.
Returns:
str: string summazing operation | [
"Upload",
"and",
"install",
"works?"
] | cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4 | https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/make_release.py#L223-L303 |
52,665 | tuxpiper/cloudcast | cloudcast/iscm/__init__.py | ISCM.iscm_md_update_dict | def iscm_md_update_dict(self, keypath, data):
"""
Update a metadata dictionary entry
"""
current = self.metadata
for k in string.split(keypath, "."):
if not current.has_key(k):
current[k] = {}
current = current[k]
current.update(dat... | python | def iscm_md_update_dict(self, keypath, data):
"""
Update a metadata dictionary entry
"""
current = self.metadata
for k in string.split(keypath, "."):
if not current.has_key(k):
current[k] = {}
current = current[k]
current.update(dat... | [
"def",
"iscm_md_update_dict",
"(",
"self",
",",
"keypath",
",",
"data",
")",
":",
"current",
"=",
"self",
".",
"metadata",
"for",
"k",
"in",
"string",
".",
"split",
"(",
"keypath",
",",
"\".\"",
")",
":",
"if",
"not",
"current",
".",
"has_key",
"(",
... | Update a metadata dictionary entry | [
"Update",
"a",
"metadata",
"dictionary",
"entry"
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/iscm/__init__.py#L84-L93 |
52,666 | tuxpiper/cloudcast | cloudcast/iscm/__init__.py | ISCM.iscm_md_append_array | def iscm_md_append_array(self, arraypath, member):
"""
Append a member to a metadata array entry
"""
array_path = string.split(arraypath, ".")
array_key = array_path.pop()
current = self.metadata
for k in array_path:
if not current.has_key(k):
... | python | def iscm_md_append_array(self, arraypath, member):
"""
Append a member to a metadata array entry
"""
array_path = string.split(arraypath, ".")
array_key = array_path.pop()
current = self.metadata
for k in array_path:
if not current.has_key(k):
... | [
"def",
"iscm_md_append_array",
"(",
"self",
",",
"arraypath",
",",
"member",
")",
":",
"array_path",
"=",
"string",
".",
"split",
"(",
"arraypath",
",",
"\".\"",
")",
"array_key",
"=",
"array_path",
".",
"pop",
"(",
")",
"current",
"=",
"self",
".",
"met... | Append a member to a metadata array entry | [
"Append",
"a",
"member",
"to",
"a",
"metadata",
"array",
"entry"
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/iscm/__init__.py#L95-L110 |
52,667 | tuxpiper/cloudcast | cloudcast/iscm/__init__.py | ISCM.context_lookup | def context_lookup(self, vars):
"""
Lookup the variables in the provided dictionary, resolve with entries
in the context
"""
while isinstance(vars, IscmExpr):
vars = vars.resolve(self.context)
#
for (k,v) in vars.items():
if isinstance(v, I... | python | def context_lookup(self, vars):
"""
Lookup the variables in the provided dictionary, resolve with entries
in the context
"""
while isinstance(vars, IscmExpr):
vars = vars.resolve(self.context)
#
for (k,v) in vars.items():
if isinstance(v, I... | [
"def",
"context_lookup",
"(",
"self",
",",
"vars",
")",
":",
"while",
"isinstance",
"(",
"vars",
",",
"IscmExpr",
")",
":",
"vars",
"=",
"vars",
".",
"resolve",
"(",
"self",
".",
"context",
")",
"#",
"for",
"(",
"k",
",",
"v",
")",
"in",
"vars",
... | Lookup the variables in the provided dictionary, resolve with entries
in the context | [
"Lookup",
"the",
"variables",
"in",
"the",
"provided",
"dictionary",
"resolve",
"with",
"entries",
"in",
"the",
"context"
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/iscm/__init__.py#L118-L129 |
52,668 | tuxpiper/cloudcast | cloudcast/iscm/__init__.py | ISCM.apply_to | def apply_to(self, launchable):
"""
Apply this ISCM configuration into a launchable resource, such as
an EC2 instance or an AutoScalingGroup LaunchConfig.
"""
# Update user data
if launchable.get_property("UserData") is not None:
raise NotImplementedError("It'... | python | def apply_to(self, launchable):
"""
Apply this ISCM configuration into a launchable resource, such as
an EC2 instance or an AutoScalingGroup LaunchConfig.
"""
# Update user data
if launchable.get_property("UserData") is not None:
raise NotImplementedError("It'... | [
"def",
"apply_to",
"(",
"self",
",",
"launchable",
")",
":",
"# Update user data",
"if",
"launchable",
".",
"get_property",
"(",
"\"UserData\"",
")",
"is",
"not",
"None",
":",
"raise",
"NotImplementedError",
"(",
"\"It's not yet supported to append SCM to existing userd... | Apply this ISCM configuration into a launchable resource, such as
an EC2 instance or an AutoScalingGroup LaunchConfig. | [
"Apply",
"this",
"ISCM",
"configuration",
"into",
"a",
"launchable",
"resource",
"such",
"as",
"an",
"EC2",
"instance",
"or",
"an",
"AutoScalingGroup",
"LaunchConfig",
"."
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/iscm/__init__.py#L131-L175 |
52,669 | decryptus/sonicprobe | sonicprobe/libs/anysql.py | register_uri_backend | def register_uri_backend(uri_scheme, create_method, module, c14n_uri_method, escape, cast, is_connected):
"""
This method is intended to be used by backends only.
It lets them register their services, identified by the URI scheme,
at import time. The associated method create_method must take one
pa... | python | def register_uri_backend(uri_scheme, create_method, module, c14n_uri_method, escape, cast, is_connected):
"""
This method is intended to be used by backends only.
It lets them register their services, identified by the URI scheme,
at import time. The associated method create_method must take one
pa... | [
"def",
"register_uri_backend",
"(",
"uri_scheme",
",",
"create_method",
",",
"module",
",",
"c14n_uri_method",
",",
"escape",
",",
"cast",
",",
"is_connected",
")",
":",
"try",
":",
"delta_api",
"=",
"__compare_api_level",
"(",
"module",
".",
"apilevel",
",",
... | This method is intended to be used by backends only.
It lets them register their services, identified by the URI scheme,
at import time. The associated method create_method must take one
parameter: the complete requested RFC 3986 compliant URI.
The associated module must be compliant with DBAPI v2.0 b... | [
"This",
"method",
"is",
"intended",
"to",
"be",
"used",
"by",
"backends",
"only",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/anysql.py#L464-L508 |
52,670 | decryptus/sonicprobe | sonicprobe/libs/anysql.py | cursor.setoutputsize | def setoutputsize(self, size, column = None):
"As in DBAPI2.0"
if column is None:
self.__dbapi2_cursor.setoutputsize(size)
else:
self.__dbapi2_cursor.setoutputsize(size, column) | python | def setoutputsize(self, size, column = None):
"As in DBAPI2.0"
if column is None:
self.__dbapi2_cursor.setoutputsize(size)
else:
self.__dbapi2_cursor.setoutputsize(size, column) | [
"def",
"setoutputsize",
"(",
"self",
",",
"size",
",",
"column",
"=",
"None",
")",
":",
"if",
"column",
"is",
"None",
":",
"self",
".",
"__dbapi2_cursor",
".",
"setoutputsize",
"(",
"size",
")",
"else",
":",
"self",
".",
"__dbapi2_cursor",
".",
"setoutpu... | As in DBAPI2.0 | [
"As",
"in",
"DBAPI2",
".",
"0"
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/anysql.py#L297-L302 |
52,671 | decryptus/sonicprobe | sonicprobe/libs/anysql.py | connection.__connect | def __connect(self):
"""
Connect to the database.
"""
self.__methods = _get_methods_by_uri(self.sqluri)
uri_connect_method = self.__methods[METHOD_CONNECT]
self.__dbapi2_conn = uri_connect_method(self.sqluri) | python | def __connect(self):
"""
Connect to the database.
"""
self.__methods = _get_methods_by_uri(self.sqluri)
uri_connect_method = self.__methods[METHOD_CONNECT]
self.__dbapi2_conn = uri_connect_method(self.sqluri) | [
"def",
"__connect",
"(",
"self",
")",
":",
"self",
".",
"__methods",
"=",
"_get_methods_by_uri",
"(",
"self",
".",
"sqluri",
")",
"uri_connect_method",
"=",
"self",
".",
"__methods",
"[",
"METHOD_CONNECT",
"]",
"self",
".",
"__dbapi2_conn",
"=",
"uri_connect_m... | Connect to the database. | [
"Connect",
"to",
"the",
"database",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/anysql.py#L360-L367 |
52,672 | decryptus/sonicprobe | sonicprobe/libs/anysql.py | connection.reconnect | def reconnect(self, query = None, log_reconnect = False):
"""
Reconnect to the database.
"""
uri = list(urisup.uri_help_split(self.sqluri))
if uri[1]:
authority = list(uri[1])
if authority[1]:
authority[1] = None
uri[1] =... | python | def reconnect(self, query = None, log_reconnect = False):
"""
Reconnect to the database.
"""
uri = list(urisup.uri_help_split(self.sqluri))
if uri[1]:
authority = list(uri[1])
if authority[1]:
authority[1] = None
uri[1] =... | [
"def",
"reconnect",
"(",
"self",
",",
"query",
"=",
"None",
",",
"log_reconnect",
"=",
"False",
")",
":",
"uri",
"=",
"list",
"(",
"urisup",
".",
"uri_help_split",
"(",
"self",
".",
"sqluri",
")",
")",
"if",
"uri",
"[",
"1",
"]",
":",
"authority",
... | Reconnect to the database. | [
"Reconnect",
"to",
"the",
"database",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/anysql.py#L374-L387 |
52,673 | yero13/na3x | na3x/integration/integrator.py | Integrator.perform | def perform(self):
"""
Performs bulk operation
"""
for request in self._cfg[Integrator._CFG_KEY_REQUESTS]:
request_type = self._cfg[Integrator._CFG_KEY_REQUESTS][request][Integrator._CFG_KEY_REQUEST_TYPE]
request_cfg_file = self._cfg[Integrator._CFG_KEY_REQUESTS][... | python | def perform(self):
"""
Performs bulk operation
"""
for request in self._cfg[Integrator._CFG_KEY_REQUESTS]:
request_type = self._cfg[Integrator._CFG_KEY_REQUESTS][request][Integrator._CFG_KEY_REQUEST_TYPE]
request_cfg_file = self._cfg[Integrator._CFG_KEY_REQUESTS][... | [
"def",
"perform",
"(",
"self",
")",
":",
"for",
"request",
"in",
"self",
".",
"_cfg",
"[",
"Integrator",
".",
"_CFG_KEY_REQUESTS",
"]",
":",
"request_type",
"=",
"self",
".",
"_cfg",
"[",
"Integrator",
".",
"_CFG_KEY_REQUESTS",
"]",
"[",
"request",
"]",
... | Performs bulk operation | [
"Performs",
"bulk",
"operation"
] | b31ef801ea574081125020a7d0f9c4242f8f8b02 | https://github.com/yero13/na3x/blob/b31ef801ea574081125020a7d0f9c4242f8f8b02/na3x/integration/integrator.py#L31-L39 |
52,674 | euphoris/webpat | webpat/db.py | get_session | def get_session():
"""Gets a session. If there's no yet, creates one.
:returns: a session
"""
if hasattr(g, 'session'):
return g.session
sess = create_session(bind=current_app.config['DATABASE_ENGINE'])
try:
g.session = sess
except RuntimeError:
pass
return sess | python | def get_session():
"""Gets a session. If there's no yet, creates one.
:returns: a session
"""
if hasattr(g, 'session'):
return g.session
sess = create_session(bind=current_app.config['DATABASE_ENGINE'])
try:
g.session = sess
except RuntimeError:
pass
return sess | [
"def",
"get_session",
"(",
")",
":",
"if",
"hasattr",
"(",
"g",
",",
"'session'",
")",
":",
"return",
"g",
".",
"session",
"sess",
"=",
"create_session",
"(",
"bind",
"=",
"current_app",
".",
"config",
"[",
"'DATABASE_ENGINE'",
"]",
")",
"try",
":",
"g... | Gets a session. If there's no yet, creates one.
:returns: a session | [
"Gets",
"a",
"session",
".",
"If",
"there",
"s",
"no",
"yet",
"creates",
"one",
"."
] | eaa51a7eab6cb1aeec2f1dc4b064f3342aa161f4 | https://github.com/euphoris/webpat/blob/eaa51a7eab6cb1aeec2f1dc4b064f3342aa161f4/webpat/db.py#L15-L27 |
52,675 | the01/paps-settings | paps_settings/plugin.py | SettingsPlugin._plugin_get | def _plugin_get(self, plugin_name):
"""
Find plugins in controller
:param plugin_name: Name of the plugin to find
:type plugin_name: str | None
:return: Plugin or None and error message
:rtype: (settable_plugin.SettablePlugin | None, str)
"""
if not plugi... | python | def _plugin_get(self, plugin_name):
"""
Find plugins in controller
:param plugin_name: Name of the plugin to find
:type plugin_name: str | None
:return: Plugin or None and error message
:rtype: (settable_plugin.SettablePlugin | None, str)
"""
if not plugi... | [
"def",
"_plugin_get",
"(",
"self",
",",
"plugin_name",
")",
":",
"if",
"not",
"plugin_name",
":",
"return",
"None",
",",
"u\"Plugin name not set\"",
"for",
"plugin",
"in",
"self",
".",
"controller",
".",
"plugins",
":",
"if",
"not",
"isinstance",
"(",
"plugi... | Find plugins in controller
:param plugin_name: Name of the plugin to find
:type plugin_name: str | None
:return: Plugin or None and error message
:rtype: (settable_plugin.SettablePlugin | None, str) | [
"Find",
"plugins",
"in",
"controller"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/paps_settings/plugin.py#L98-L114 |
52,676 | dev-pipeline/dev-pipeline-build | lib/devpipeline_build/builder.py | _make_builder | def _make_builder(config, current_target):
"""
Create and return a Builder for a component.
Arguments
component - The component the builder should be created for.
"""
tool_key = devpipeline_core.toolsupport.choose_tool_key(
current_target, _BUILD_TOOL_KEYS
)
return devpipeline_... | python | def _make_builder(config, current_target):
"""
Create and return a Builder for a component.
Arguments
component - The component the builder should be created for.
"""
tool_key = devpipeline_core.toolsupport.choose_tool_key(
current_target, _BUILD_TOOL_KEYS
)
return devpipeline_... | [
"def",
"_make_builder",
"(",
"config",
",",
"current_target",
")",
":",
"tool_key",
"=",
"devpipeline_core",
".",
"toolsupport",
".",
"choose_tool_key",
"(",
"current_target",
",",
"_BUILD_TOOL_KEYS",
")",
"return",
"devpipeline_core",
".",
"toolsupport",
".",
"tool... | Create and return a Builder for a component.
Arguments
component - The component the builder should be created for. | [
"Create",
"and",
"return",
"a",
"Builder",
"for",
"a",
"component",
"."
] | 52e3e22b1c433fb7c3902acc46d6f3ac2c6fc426 | https://github.com/dev-pipeline/dev-pipeline-build/blob/52e3e22b1c433fb7c3902acc46d6f3ac2c6fc426/lib/devpipeline_build/builder.py#L93-L106 |
52,677 | dev-pipeline/dev-pipeline-build | lib/devpipeline_build/builder.py | build_task | def build_task(current_target):
"""
Build a target.
Arguments
target - The target to build.
"""
target = current_target.config
try:
builder = _make_builder(target, current_target)
build_path = _get_build_path(target, builder)
if not os.path.exists(build_path):
... | python | def build_task(current_target):
"""
Build a target.
Arguments
target - The target to build.
"""
target = current_target.config
try:
builder = _make_builder(target, current_target)
build_path = _get_build_path(target, builder)
if not os.path.exists(build_path):
... | [
"def",
"build_task",
"(",
"current_target",
")",
":",
"target",
"=",
"current_target",
".",
"config",
"try",
":",
"builder",
"=",
"_make_builder",
"(",
"target",
",",
"current_target",
")",
"build_path",
"=",
"_get_build_path",
"(",
"target",
",",
"builder",
"... | Build a target.
Arguments
target - The target to build. | [
"Build",
"a",
"target",
"."
] | 52e3e22b1c433fb7c3902acc46d6f3ac2c6fc426 | https://github.com/dev-pipeline/dev-pipeline-build/blob/52e3e22b1c433fb7c3902acc46d6f3ac2c6fc426/lib/devpipeline_build/builder.py#L163-L192 |
52,678 | openknowledge-archive/datapackage-registry-py | datapackage_registry/registry.py | Registry._get_registry | def _get_registry(self, registry_path_or_url):
'''Return a dict with objects mapped by their id from a CSV endpoint'''
if os.path.isfile(registry_path_or_url):
with open(registry_path_or_url, 'r') as f:
reader = compat.csv_dict_reader(f.readlines())
else:
... | python | def _get_registry(self, registry_path_or_url):
'''Return a dict with objects mapped by their id from a CSV endpoint'''
if os.path.isfile(registry_path_or_url):
with open(registry_path_or_url, 'r') as f:
reader = compat.csv_dict_reader(f.readlines())
else:
... | [
"def",
"_get_registry",
"(",
"self",
",",
"registry_path_or_url",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"registry_path_or_url",
")",
":",
"with",
"open",
"(",
"registry_path_or_url",
",",
"'r'",
")",
"as",
"f",
":",
"reader",
"=",
"compat"... | Return a dict with objects mapped by their id from a CSV endpoint | [
"Return",
"a",
"dict",
"with",
"objects",
"mapped",
"by",
"their",
"id",
"from",
"a",
"CSV",
"endpoint"
] | 02ba4d1ae6a75d8960abef0ffec3e9ec49ed26f9 | https://github.com/openknowledge-archive/datapackage-registry-py/blob/02ba4d1ae6a75d8960abef0ffec3e9ec49ed26f9/datapackage_registry/registry.py#L89-L100 |
52,679 | openknowledge-archive/datapackage-registry-py | datapackage_registry/registry.py | Registry._load_json_file_or_url | def _load_json_file_or_url(self, json_path_or_url):
'''Return the JSON at the local path or URL as a dict
This method raises DataPackageRegistryException if there were any
errors.
'''
try:
if os.path.isfile(json_path_or_url):
with open(json_path_or_ur... | python | def _load_json_file_or_url(self, json_path_or_url):
'''Return the JSON at the local path or URL as a dict
This method raises DataPackageRegistryException if there were any
errors.
'''
try:
if os.path.isfile(json_path_or_url):
with open(json_path_or_ur... | [
"def",
"_load_json_file_or_url",
"(",
"self",
",",
"json_path_or_url",
")",
":",
"try",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"json_path_or_url",
")",
":",
"with",
"open",
"(",
"json_path_or_url",
",",
"'r'",
")",
"as",
"f",
":",
"result",
"=... | Return the JSON at the local path or URL as a dict
This method raises DataPackageRegistryException if there were any
errors. | [
"Return",
"the",
"JSON",
"at",
"the",
"local",
"path",
"or",
"URL",
"as",
"a",
"dict"
] | 02ba4d1ae6a75d8960abef0ffec3e9ec49ed26f9 | https://github.com/openknowledge-archive/datapackage-registry-py/blob/02ba4d1ae6a75d8960abef0ffec3e9ec49ed26f9/datapackage_registry/registry.py#L112-L131 |
52,680 | leandroarndt/djangospam | djangospam/akismet/moderator.py | Akismet.allow | def allow(self, comment, content_object, request):
"""Moderates comments."""
POST = urlencode({
"blog": settings.AKISMET_BLOG.encode("utf-8"),
"user_ip": comment.ip_address,
"user_agent": request.META.get('HTTP_USER_AGENT', "").
... | python | def allow(self, comment, content_object, request):
"""Moderates comments."""
POST = urlencode({
"blog": settings.AKISMET_BLOG.encode("utf-8"),
"user_ip": comment.ip_address,
"user_agent": request.META.get('HTTP_USER_AGENT', "").
... | [
"def",
"allow",
"(",
"self",
",",
"comment",
",",
"content_object",
",",
"request",
")",
":",
"POST",
"=",
"urlencode",
"(",
"{",
"\"blog\"",
":",
"settings",
".",
"AKISMET_BLOG",
".",
"encode",
"(",
"\"utf-8\"",
")",
",",
"\"user_ip\"",
":",
"comment",
... | Moderates comments. | [
"Moderates",
"comments",
"."
] | 57fa9cfbf54a40f0e0652d0155dbb3451c14b69d | https://github.com/leandroarndt/djangospam/blob/57fa9cfbf54a40f0e0652d0155dbb3451c14b69d/djangospam/akismet/moderator.py#L96-L126 |
52,681 | tuxpiper/cloudcast | cloudcast/iscm/phased.py | Phase.get_dict_repr | def get_dict_repr(self):
"""
Return a dictionary representation of this phase.
This will be used for checksumming, in order to uniquely compare
instance images against their requirements
"""
return dict(
phase_name = self.phase_name,
phase_type = s... | python | def get_dict_repr(self):
"""
Return a dictionary representation of this phase.
This will be used for checksumming, in order to uniquely compare
instance images against their requirements
"""
return dict(
phase_name = self.phase_name,
phase_type = s... | [
"def",
"get_dict_repr",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"phase_name",
"=",
"self",
".",
"phase_name",
",",
"phase_type",
"=",
"self",
".",
"phase_type",
",",
"actions",
"=",
"self",
".",
"actions",
")"
] | Return a dictionary representation of this phase.
This will be used for checksumming, in order to uniquely compare
instance images against their requirements | [
"Return",
"a",
"dictionary",
"representation",
"of",
"this",
"phase",
".",
"This",
"will",
"be",
"used",
"for",
"checksumming",
"in",
"order",
"to",
"uniquely",
"compare",
"instance",
"images",
"against",
"their",
"requirements"
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/iscm/phased.py#L135-L145 |
52,682 | zengbin93/zb | zb/base.py | ZbList.discrete_index | def discrete_index(self, indices):
"""get elements by discrete indices
:param indices: list
discrete indices
:return: elements
"""
elements = []
for i in indices:
elements.append(self[i])
return elements | python | def discrete_index(self, indices):
"""get elements by discrete indices
:param indices: list
discrete indices
:return: elements
"""
elements = []
for i in indices:
elements.append(self[i])
return elements | [
"def",
"discrete_index",
"(",
"self",
",",
"indices",
")",
":",
"elements",
"=",
"[",
"]",
"for",
"i",
"in",
"indices",
":",
"elements",
".",
"append",
"(",
"self",
"[",
"i",
"]",
")",
"return",
"elements"
] | get elements by discrete indices
:param indices: list
discrete indices
:return: elements | [
"get",
"elements",
"by",
"discrete",
"indices"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/base.py#L28-L38 |
52,683 | impact27/registrator | registrator/image.py | register_images | def register_images(im0, im1, *, rmMean=True, correctScale=True):
"""Finds the rotation, scaling and translation of im1 relative to im0
Parameters
----------
im0: First image
im1: Second image
rmMean: Set to true to remove the mean (Default)
Returns
-------
angle: The angle differe... | python | def register_images(im0, im1, *, rmMean=True, correctScale=True):
"""Finds the rotation, scaling and translation of im1 relative to im0
Parameters
----------
im0: First image
im1: Second image
rmMean: Set to true to remove the mean (Default)
Returns
-------
angle: The angle differe... | [
"def",
"register_images",
"(",
"im0",
",",
"im1",
",",
"*",
",",
"rmMean",
"=",
"True",
",",
"correctScale",
"=",
"True",
")",
":",
"# sanitize input",
"im0",
"=",
"np",
".",
"asarray",
"(",
"im0",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"im1",... | Finds the rotation, scaling and translation of im1 relative to im0
Parameters
----------
im0: First image
im1: Second image
rmMean: Set to true to remove the mean (Default)
Returns
-------
angle: The angle difference
scale: The scale difference
[y, x]: The offset
im2: The r... | [
"Finds",
"the",
"rotation",
"scaling",
"and",
"translation",
"of",
"im1",
"relative",
"to",
"im0"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L60-L104 |
52,684 | impact27/registrator | registrator/image.py | find_rotation_scale | def find_rotation_scale(im0, im1, isccs=False):
"""Compares the images and return the best guess for the rotation angle,
and scale difference.
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
isccs: boolean, default False
Set to True if the ... | python | def find_rotation_scale(im0, im1, isccs=False):
"""Compares the images and return the best guess for the rotation angle,
and scale difference.
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
isccs: boolean, default False
Set to True if the ... | [
"def",
"find_rotation_scale",
"(",
"im0",
",",
"im1",
",",
"isccs",
"=",
"False",
")",
":",
"# sanitize input",
"im0",
"=",
"np",
".",
"asarray",
"(",
"im0",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"im1",
"=",
"np",
".",
"asarray",
"(",
"im1",
... | Compares the images and return the best guess for the rotation angle,
and scale difference.
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
isccs: boolean, default False
Set to True if the images are alredy DFT and in CCS representation
Re... | [
"Compares",
"the",
"images",
"and",
"return",
"the",
"best",
"guess",
"for",
"the",
"rotation",
"angle",
"and",
"scale",
"difference",
"."
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L107-L155 |
52,685 | impact27/registrator | registrator/image.py | find_shift_cc | def find_shift_cc(im0, im1, ylim=None, xlim=None, subpix=True):
"""Finds the best shift between im0 and im1 using cross correlation
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
ylim: 2 numbers, optional
The y limits of the search (if None fu... | python | def find_shift_cc(im0, im1, ylim=None, xlim=None, subpix=True):
"""Finds the best shift between im0 and im1 using cross correlation
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
ylim: 2 numbers, optional
The y limits of the search (if None fu... | [
"def",
"find_shift_cc",
"(",
"im0",
",",
"im1",
",",
"ylim",
"=",
"None",
",",
"xlim",
"=",
"None",
",",
"subpix",
"=",
"True",
")",
":",
"# sanitize input",
"im0",
"=",
"np",
".",
"asarray",
"(",
"im0",
",",
"dtype",
"=",
"np",
".",
"float32",
")"... | Finds the best shift between im0 and im1 using cross correlation
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
ylim: 2 numbers, optional
The y limits of the search (if None full range is searched)
xlim: 2 numbers, optional
Ibidem with... | [
"Finds",
"the",
"best",
"shift",
"between",
"im0",
"and",
"im1",
"using",
"cross",
"correlation"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L253-L317 |
52,686 | impact27/registrator | registrator/image.py | combine_images | def combine_images(imgs, register=True):
"""Combine similar images into one to reduce the noise
Parameters
----------
imgs: list of 2d array
Series of images
register: Boolean, default False
True if the images should be register before combination
Returns
-------
im: 2d... | python | def combine_images(imgs, register=True):
"""Combine similar images into one to reduce the noise
Parameters
----------
imgs: list of 2d array
Series of images
register: Boolean, default False
True if the images should be register before combination
Returns
-------
im: 2d... | [
"def",
"combine_images",
"(",
"imgs",
",",
"register",
"=",
"True",
")",
":",
"imgs",
"=",
"np",
".",
"asarray",
"(",
"imgs",
",",
"dtype",
"=",
"\"float\"",
")",
"if",
"register",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"imgs",
".",
"shape"... | Combine similar images into one to reduce the noise
Parameters
----------
imgs: list of 2d array
Series of images
register: Boolean, default False
True if the images should be register before combination
Returns
-------
im: 2d array
The result image
Notes
-... | [
"Combine",
"similar",
"images",
"into",
"one",
"to",
"reduce",
"the",
"noise"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L320-L344 |
52,687 | impact27/registrator | registrator/image.py | dft_optsize | def dft_optsize(im, shape=None):
"""Resize image for optimal DFT and computes it
Parameters
----------
im: 2d array
The image
shape: 2 numbers, optional
The shape of the output image (None will optimize the shape)
Returns
-------
dft: 2d array
The dft in CCS rep... | python | def dft_optsize(im, shape=None):
"""Resize image for optimal DFT and computes it
Parameters
----------
im: 2d array
The image
shape: 2 numbers, optional
The shape of the output image (None will optimize the shape)
Returns
-------
dft: 2d array
The dft in CCS rep... | [
"def",
"dft_optsize",
"(",
"im",
",",
"shape",
"=",
"None",
")",
":",
"im",
"=",
"np",
".",
"asarray",
"(",
"im",
")",
"# save shape",
"initshape",
"=",
"im",
".",
"shape",
"# get optimal size",
"if",
"shape",
"is",
"None",
":",
"ys",
"=",
"cv2",
"."... | Resize image for optimal DFT and computes it
Parameters
----------
im: 2d array
The image
shape: 2 numbers, optional
The shape of the output image (None will optimize the shape)
Returns
-------
dft: 2d array
The dft in CCS representation
Notes
-----
Th ... | [
"Resize",
"image",
"for",
"optimal",
"DFT",
"and",
"computes",
"it"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L526-L559 |
52,688 | impact27/registrator | registrator/image.py | dft_optsize_same | def dft_optsize_same(im0, im1):
"""Resize 2 image same size for optimal DFT and computes it
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
Returns
-------
dft0: 2d array
The dft of the first image
dft1: 2d array
The dft of... | python | def dft_optsize_same(im0, im1):
"""Resize 2 image same size for optimal DFT and computes it
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
Returns
-------
dft0: 2d array
The dft of the first image
dft1: 2d array
The dft of... | [
"def",
"dft_optsize_same",
"(",
"im0",
",",
"im1",
")",
":",
"im0",
"=",
"np",
".",
"asarray",
"(",
"im0",
")",
"im1",
"=",
"np",
".",
"asarray",
"(",
"im1",
")",
"# save shape",
"shape0",
"=",
"im0",
".",
"shape",
"shape1",
"=",
"im1",
".",
"shape... | Resize 2 image same size for optimal DFT and computes it
Parameters
----------
im0: 2d array
First image
im1: 2d array
Second image
Returns
-------
dft0: 2d array
The dft of the first image
dft1: 2d array
The dft of the second image
Notes
-----
... | [
"Resize",
"2",
"image",
"same",
"size",
"for",
"optimal",
"DFT",
"and",
"computes",
"it"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L562-L596 |
52,689 | impact27/registrator | registrator/image.py | rotate_scale | def rotate_scale(im, angle, scale, borderValue=0, interp=cv2.INTER_CUBIC):
"""Rotates and scales the image
Parameters
----------
im: 2d array
The image
angle: number
The angle, in radians, to rotate
scale: positive number
The scale factor
borderValue: number, default... | python | def rotate_scale(im, angle, scale, borderValue=0, interp=cv2.INTER_CUBIC):
"""Rotates and scales the image
Parameters
----------
im: 2d array
The image
angle: number
The angle, in radians, to rotate
scale: positive number
The scale factor
borderValue: number, default... | [
"def",
"rotate_scale",
"(",
"im",
",",
"angle",
",",
"scale",
",",
"borderValue",
"=",
"0",
",",
"interp",
"=",
"cv2",
".",
"INTER_CUBIC",
")",
":",
"im",
"=",
"np",
".",
"asarray",
"(",
"im",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"rows",
... | Rotates and scales the image
Parameters
----------
im: 2d array
The image
angle: number
The angle, in radians, to rotate
scale: positive number
The scale factor
borderValue: number, default 0
The value for the pixels outside the border (default 0)
Returns
... | [
"Rotates",
"and",
"scales",
"the",
"image"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L599-L631 |
52,690 | impact27/registrator | registrator/image.py | shift_image | def shift_image(im, shift, borderValue=0):
"""shift the image
Parameters
----------
im: 2d array
The image
shift: 2 numbers
(y,x) the shift in y and x direction
borderValue: number, default 0
The value for the pixels outside the border (default 0)
Returns
------... | python | def shift_image(im, shift, borderValue=0):
"""shift the image
Parameters
----------
im: 2d array
The image
shift: 2 numbers
(y,x) the shift in y and x direction
borderValue: number, default 0
The value for the pixels outside the border (default 0)
Returns
------... | [
"def",
"shift_image",
"(",
"im",
",",
"shift",
",",
"borderValue",
"=",
"0",
")",
":",
"im",
"=",
"np",
".",
"asarray",
"(",
"im",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"rows",
",",
"cols",
"=",
"im",
".",
"shape",
"M",
"=",
"np",
".",
... | shift the image
Parameters
----------
im: 2d array
The image
shift: 2 numbers
(y,x) the shift in y and x direction
borderValue: number, default 0
The value for the pixels outside the border (default 0)
Returns
-------
im: 2d array
The shifted image
... | [
"shift",
"the",
"image"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L634-L662 |
52,691 | impact27/registrator | registrator/image.py | ccs_normalize | def ccs_normalize(compIM, ccsnorm):
""" normalize the ccs representation
Parameters
----------
compIM: 2d array
The CCS image in CCS representation
ccsnorm: 2d array
The normalization matrix in ccs representation
Returns
-------
compIM: 2d array
The normalized C... | python | def ccs_normalize(compIM, ccsnorm):
""" normalize the ccs representation
Parameters
----------
compIM: 2d array
The CCS image in CCS representation
ccsnorm: 2d array
The normalization matrix in ccs representation
Returns
-------
compIM: 2d array
The normalized C... | [
"def",
"ccs_normalize",
"(",
"compIM",
",",
"ccsnorm",
")",
":",
"compIM",
"=",
"np",
".",
"asarray",
"(",
"compIM",
")",
"ccsnorm",
"=",
"np",
".",
"asarray",
"(",
"ccsnorm",
")",
"ys",
"=",
"ccsnorm",
".",
"shape",
"[",
"0",
"]",
"xs",
"=",
"ccsn... | normalize the ccs representation
Parameters
----------
compIM: 2d array
The CCS image in CCS representation
ccsnorm: 2d array
The normalization matrix in ccs representation
Returns
-------
compIM: 2d array
The normalized CCS image
Notes
-----
(basically... | [
"normalize",
"the",
"ccs",
"representation"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L887-L922 |
52,692 | impact27/registrator | registrator/image.py | gauss_fit | def gauss_fit(X, Y):
"""
Fit the function to a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
(The return from scipy.optimize.curve_fit)
popt : array
Optimal values for the parameters
pcov : 2d array
... | python | def gauss_fit(X, Y):
"""
Fit the function to a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
(The return from scipy.optimize.curve_fit)
popt : array
Optimal values for the parameters
pcov : 2d array
... | [
"def",
"gauss_fit",
"(",
"X",
",",
"Y",
")",
":",
"X",
"=",
"np",
".",
"asarray",
"(",
"X",
")",
"Y",
"=",
"np",
".",
"asarray",
"(",
"Y",
")",
"# Can not have negative values",
"Y",
"[",
"Y",
"<",
"0",
"]",
"=",
"0",
"# define gauss function",
"de... | Fit the function to a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
(The return from scipy.optimize.curve_fit)
popt : array
Optimal values for the parameters
pcov : 2d array
The estimated covariance of popt... | [
"Fit",
"the",
"function",
"to",
"a",
"gaussian",
"."
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L925-L961 |
52,693 | impact27/registrator | registrator/image.py | gauss_fit_log | def gauss_fit_log(X, Y):
"""
Fit the log of the input to the log of a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
mean: number
The mean of the gaussian curve
var: number
The variance of the gaussian c... | python | def gauss_fit_log(X, Y):
"""
Fit the log of the input to the log of a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
mean: number
The mean of the gaussian curve
var: number
The variance of the gaussian c... | [
"def",
"gauss_fit_log",
"(",
"X",
",",
"Y",
")",
":",
"X",
"=",
"np",
".",
"asarray",
"(",
"X",
")",
"Y",
"=",
"np",
".",
"asarray",
"(",
"Y",
")",
"# take log data",
"Data",
"=",
"np",
".",
"log",
"(",
"Y",
")",
"# Get Di and Xi",
"D",
"=",
"[... | Fit the log of the input to the log of a gaussian.
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
mean: number
The mean of the gaussian curve
var: number
The variance of the gaussian curve
Notes
-----
The lea... | [
"Fit",
"the",
"log",
"of",
"the",
"input",
"to",
"the",
"log",
"of",
"a",
"gaussian",
"."
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L964-L1016 |
52,694 | impact27/registrator | registrator/image.py | center_of_mass | def center_of_mass(X, Y):
"""Get center of mass
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
res: number
The position of the center of mass in X
Notes
-----
Uses least squares
"""
X = np.asarray(X)
Y = ... | python | def center_of_mass(X, Y):
"""Get center of mass
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
res: number
The position of the center of mass in X
Notes
-----
Uses least squares
"""
X = np.asarray(X)
Y = ... | [
"def",
"center_of_mass",
"(",
"X",
",",
"Y",
")",
":",
"X",
"=",
"np",
".",
"asarray",
"(",
"X",
")",
"Y",
"=",
"np",
".",
"asarray",
"(",
"Y",
")",
"return",
"(",
"X",
"*",
"Y",
")",
".",
"sum",
"(",
")",
"/",
"Y",
".",
"sum",
"(",
")"
] | Get center of mass
Parameters
----------
X: 1d array
X values
Y: 1d array
Y values
Returns
-------
res: number
The position of the center of mass in X
Notes
-----
Uses least squares | [
"Get",
"center",
"of",
"mass"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L1019-L1040 |
52,695 | impact27/registrator | registrator/image.py | get_peak_pos | def get_peak_pos(im, wrap=False):
"""Get the peak position with subpixel precision
Parameters
----------
im: 2d array
The image containing a peak
wrap: boolean, defaults False
True if the image reoresents a torric world
Returns
-------
[y,x]: 2 numbers
The posit... | python | def get_peak_pos(im, wrap=False):
"""Get the peak position with subpixel precision
Parameters
----------
im: 2d array
The image containing a peak
wrap: boolean, defaults False
True if the image reoresents a torric world
Returns
-------
[y,x]: 2 numbers
The posit... | [
"def",
"get_peak_pos",
"(",
"im",
",",
"wrap",
"=",
"False",
")",
":",
"im",
"=",
"np",
".",
"asarray",
"(",
"im",
")",
"# remove invalid values (assuming im>0)",
"im",
"[",
"np",
".",
"logical_not",
"(",
"np",
".",
"isfinite",
"(",
"im",
")",
")",
"]"... | Get the peak position with subpixel precision
Parameters
----------
im: 2d array
The image containing a peak
wrap: boolean, defaults False
True if the image reoresents a torric world
Returns
-------
[y,x]: 2 numbers
The position of the highest peak with subpixel pre... | [
"Get",
"the",
"peak",
"position",
"with",
"subpixel",
"precision"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L1043-L1120 |
52,696 | impact27/registrator | registrator/image.py | centered_mag_sq_ccs | def centered_mag_sq_ccs(im):
"""return centered squared magnitude
Parameters
----------
im: 2d array
A CCS DFT image
Returns
-------
im: 2d array
A centered image of the magnitude of the DFT
Notes
-----
Check doc Intel* Image Processing Library
https://www.c... | python | def centered_mag_sq_ccs(im):
"""return centered squared magnitude
Parameters
----------
im: 2d array
A CCS DFT image
Returns
-------
im: 2d array
A centered image of the magnitude of the DFT
Notes
-----
Check doc Intel* Image Processing Library
https://www.c... | [
"def",
"centered_mag_sq_ccs",
"(",
"im",
")",
":",
"im",
"=",
"np",
".",
"asarray",
"(",
"im",
")",
"# multiply image by image* to get squared magnitude",
"im",
"=",
"cv2",
".",
"mulSpectrums",
"(",
"im",
",",
"im",
",",
"flags",
"=",
"0",
",",
"conjB",
"=... | return centered squared magnitude
Parameters
----------
im: 2d array
A CCS DFT image
Returns
-------
im: 2d array
A centered image of the magnitude of the DFT
Notes
-----
Check doc Intel* Image Processing Library
https://www.comp.nus.edu.sg/~cs4243/doc/ipl.pdf
... | [
"return",
"centered",
"squared",
"magnitude"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L1141-L1187 |
52,697 | impact27/registrator | registrator/image.py | is_overexposed | def is_overexposed(ims):
"""Simple test to check if image is overexposed
Parameters
----------
im: 2d array integer
the image
Returns
-------
overexposed: Bool
Is the image overexposed
"""
if len(np.shape(ims)) == 3:
return [is_overexposed(im) for im in ims]
... | python | def is_overexposed(ims):
"""Simple test to check if image is overexposed
Parameters
----------
im: 2d array integer
the image
Returns
-------
overexposed: Bool
Is the image overexposed
"""
if len(np.shape(ims)) == 3:
return [is_overexposed(im) for im in ims]
... | [
"def",
"is_overexposed",
"(",
"ims",
")",
":",
"if",
"len",
"(",
"np",
".",
"shape",
"(",
"ims",
")",
")",
"==",
"3",
":",
"return",
"[",
"is_overexposed",
"(",
"im",
")",
"for",
"im",
"in",
"ims",
"]",
"ims",
"=",
"np",
".",
"array",
"(",
"ims... | Simple test to check if image is overexposed
Parameters
----------
im: 2d array integer
the image
Returns
-------
overexposed: Bool
Is the image overexposed | [
"Simple",
"test",
"to",
"check",
"if",
"image",
"is",
"overexposed"
] | 04c099d83e0466207dc5b2e40d9b03db020d4dad | https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L1190-L1208 |
52,698 | bazwilliams/python-taps-aff | tapsaff/__init__.py | TapsAff.is_taps_aff | def is_taps_aff(self):
"""Returns True if taps aff for this location"""
request = requests.get('https://www.taps-aff.co.uk/api/%s' % self.location)
if request.status_code == 200:
try:
taps = request.json()['taps']['status']
if taps == 'aff':
... | python | def is_taps_aff(self):
"""Returns True if taps aff for this location"""
request = requests.get('https://www.taps-aff.co.uk/api/%s' % self.location)
if request.status_code == 200:
try:
taps = request.json()['taps']['status']
if taps == 'aff':
... | [
"def",
"is_taps_aff",
"(",
"self",
")",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"'https://www.taps-aff.co.uk/api/%s'",
"%",
"self",
".",
"location",
")",
"if",
"request",
".",
"status_code",
"==",
"200",
":",
"try",
":",
"taps",
"=",
"request",
"... | Returns True if taps aff for this location | [
"Returns",
"True",
"if",
"taps",
"aff",
"for",
"this",
"location"
] | 949d615495a8bbc836bd63772c8dd3dd2c407c75 | https://github.com/bazwilliams/python-taps-aff/blob/949d615495a8bbc836bd63772c8dd3dd2c407c75/tapsaff/__init__.py#L16-L32 |
52,699 | winstonwolff/expectorant | expectorant/expector.py | equal | def equal(actual, expected):
'''
Compare actual and expected using ==
>>> expect = Expector([])
>>> expect(1).to_not(equal, 2)
(True, 'equal: expect 1 == 2')
>>> expect(1).to(equal, 1)
(True, 'equal: expect 1 == 1')
'''
is_passing = (actual == expected)
types_to_diff = (str, d... | python | def equal(actual, expected):
'''
Compare actual and expected using ==
>>> expect = Expector([])
>>> expect(1).to_not(equal, 2)
(True, 'equal: expect 1 == 2')
>>> expect(1).to(equal, 1)
(True, 'equal: expect 1 == 1')
'''
is_passing = (actual == expected)
types_to_diff = (str, d... | [
"def",
"equal",
"(",
"actual",
",",
"expected",
")",
":",
"is_passing",
"=",
"(",
"actual",
"==",
"expected",
")",
"types_to_diff",
"=",
"(",
"str",
",",
"dict",
",",
"list",
",",
"tuple",
")",
"if",
"not",
"is_passing",
"and",
"isinstance",
"(",
"expe... | Compare actual and expected using ==
>>> expect = Expector([])
>>> expect(1).to_not(equal, 2)
(True, 'equal: expect 1 == 2')
>>> expect(1).to(equal, 1)
(True, 'equal: expect 1 == 1') | [
"Compare",
"actual",
"and",
"expected",
"using",
"=="
] | cb9e4c1656d7c1f4394f0b0fbeb968a833030031 | https://github.com/winstonwolff/expectorant/blob/cb9e4c1656d7c1f4394f0b0fbeb968a833030031/expectorant/expector.py#L105-L126 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.