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 listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
tkhyn/dirsync | dirsync/syncer.py | Syncer.report | def report(self):
""" Print report of work at the end """
# We need only the first 4 significant digits
tt = (str(self._endtime - self._starttime))[:4]
self.log('\n%s finished in %s seconds.' % (__pkg_name__, tt))
self.log('%d directories parsed, %d files copied' %
... | python | def report(self):
""" Print report of work at the end """
# We need only the first 4 significant digits
tt = (str(self._endtime - self._starttime))[:4]
self.log('\n%s finished in %s seconds.' % (__pkg_name__, tt))
self.log('%d directories parsed, %d files copied' %
... | [
"def",
"report",
"(",
"self",
")",
":",
"# We need only the first 4 significant digits",
"tt",
"=",
"(",
"str",
"(",
"self",
".",
"_endtime",
"-",
"self",
".",
"_starttime",
")",
")",
"[",
":",
"4",
"]",
"self",
".",
"log",
"(",
"'\\n%s finished in %s second... | Print report of work at the end | [
"Print",
"report",
"of",
"work",
"at",
"the",
"end"
] | a461a6c31a4cf521c1b6a8bcfcd8602e6288e8ce | https://github.com/tkhyn/dirsync/blob/a461a6c31a4cf521c1b6a8bcfcd8602e6288e8ce/dirsync/syncer.py#L540-L574 | train | 65,000 |
balloob/aiohue | aiohue/groups.py | Group.set_action | async def set_action(self, on=None, bri=None, hue=None, sat=None, xy=None,
ct=None, alert=None, effect=None, transitiontime=None,
bri_inc=None, sat_inc=None, hue_inc=None, ct_inc=None,
xy_inc=None, scene=None):
"""Change action of a grou... | python | async def set_action(self, on=None, bri=None, hue=None, sat=None, xy=None,
ct=None, alert=None, effect=None, transitiontime=None,
bri_inc=None, sat_inc=None, hue_inc=None, ct_inc=None,
xy_inc=None, scene=None):
"""Change action of a grou... | [
"async",
"def",
"set_action",
"(",
"self",
",",
"on",
"=",
"None",
",",
"bri",
"=",
"None",
",",
"hue",
"=",
"None",
",",
"sat",
"=",
"None",
",",
"xy",
"=",
"None",
",",
"ct",
"=",
"None",
",",
"alert",
"=",
"None",
",",
"effect",
"=",
"None",... | Change action of a group. | [
"Change",
"action",
"of",
"a",
"group",
"."
] | c0270637a8a6ce3f5684c8559decac79fb0f0192 | https://github.com/balloob/aiohue/blob/c0270637a8a6ce3f5684c8559decac79fb0f0192/aiohue/groups.py#L54-L80 | train | 65,001 |
ulule/django-badgify | example/management/commands/create_fixtures.py | Command._pre_tasks | def _pre_tasks(self):
"""
Pre-tasks handler.
"""
if self.flushdb:
management.call_command('flush', verbosity=0, interactive=False)
logger.info('Flushed database') | python | def _pre_tasks(self):
"""
Pre-tasks handler.
"""
if self.flushdb:
management.call_command('flush', verbosity=0, interactive=False)
logger.info('Flushed database') | [
"def",
"_pre_tasks",
"(",
"self",
")",
":",
"if",
"self",
".",
"flushdb",
":",
"management",
".",
"call_command",
"(",
"'flush'",
",",
"verbosity",
"=",
"0",
",",
"interactive",
"=",
"False",
")",
"logger",
".",
"info",
"(",
"'Flushed database'",
")"
] | Pre-tasks handler. | [
"Pre",
"-",
"tasks",
"handler",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/example/management/commands/create_fixtures.py#L43-L49 | train | 65,002 |
ulule/django-badgify | example/management/commands/create_fixtures.py | Command._create_users | def _create_users(self):
"""
Creates users.
"""
rn = RandomNicknames()
for name in rn.random_nicks(count=50):
username = '%s%d' % (slugify(name), random.randrange(1, 99))
user = User.objects.create_user(
username=username,
... | python | def _create_users(self):
"""
Creates users.
"""
rn = RandomNicknames()
for name in rn.random_nicks(count=50):
username = '%s%d' % (slugify(name), random.randrange(1, 99))
user = User.objects.create_user(
username=username,
... | [
"def",
"_create_users",
"(",
"self",
")",
":",
"rn",
"=",
"RandomNicknames",
"(",
")",
"for",
"name",
"in",
"rn",
".",
"random_nicks",
"(",
"count",
"=",
"50",
")",
":",
"username",
"=",
"'%s%d'",
"%",
"(",
"slugify",
"(",
"name",
")",
",",
"random",... | Creates users. | [
"Creates",
"users",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/example/management/commands/create_fixtures.py#L51-L63 | train | 65,003 |
ulule/django-badgify | example/management/commands/create_fixtures.py | Command._create_badges | def _create_badges(self):
"""
Creates badges.
"""
rn = RandomNicknames()
for name in rn.random_nicks(count=20):
slug = slugify(name)
badge = Badge.objects.create(
name=name,
slug=slug,
description='Lorem ips... | python | def _create_badges(self):
"""
Creates badges.
"""
rn = RandomNicknames()
for name in rn.random_nicks(count=20):
slug = slugify(name)
badge = Badge.objects.create(
name=name,
slug=slug,
description='Lorem ips... | [
"def",
"_create_badges",
"(",
"self",
")",
":",
"rn",
"=",
"RandomNicknames",
"(",
")",
"for",
"name",
"in",
"rn",
".",
"random_nicks",
"(",
"count",
"=",
"20",
")",
":",
"slug",
"=",
"slugify",
"(",
"name",
")",
"badge",
"=",
"Badge",
".",
"objects"... | Creates badges. | [
"Creates",
"badges",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/example/management/commands/create_fixtures.py#L65-L77 | train | 65,004 |
ulule/django-badgify | example/management/commands/create_fixtures.py | Command._create_awards | def _create_awards(self):
"""
Creates awards.
"""
users = User.objects.all()
for user in users:
everyone_badge = Badge.objects.last()
badge = Badge.objects.order_by('?')[0]
try:
award = Award.objects.create(user=user, badge=bad... | python | def _create_awards(self):
"""
Creates awards.
"""
users = User.objects.all()
for user in users:
everyone_badge = Badge.objects.last()
badge = Badge.objects.order_by('?')[0]
try:
award = Award.objects.create(user=user, badge=bad... | [
"def",
"_create_awards",
"(",
"self",
")",
":",
"users",
"=",
"User",
".",
"objects",
".",
"all",
"(",
")",
"for",
"user",
"in",
"users",
":",
"everyone_badge",
"=",
"Badge",
".",
"objects",
".",
"last",
"(",
")",
"badge",
"=",
"Badge",
".",
"objects... | Creates awards. | [
"Creates",
"awards",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/example/management/commands/create_fixtures.py#L79-L93 | train | 65,005 |
ulule/django-badgify | badgify/utils.py | chunks | def chunks(l, n):
"""
Yields successive n-sized chunks from l.
"""
for i in _range(0, len(l), n):
yield l[i:i + n] | python | def chunks(l, n):
"""
Yields successive n-sized chunks from l.
"""
for i in _range(0, len(l), n):
yield l[i:i + n] | [
"def",
"chunks",
"(",
"l",
",",
"n",
")",
":",
"for",
"i",
"in",
"_range",
"(",
"0",
",",
"len",
"(",
"l",
")",
",",
"n",
")",
":",
"yield",
"l",
"[",
"i",
":",
"i",
"+",
"n",
"]"
] | Yields successive n-sized chunks from l. | [
"Yields",
"successive",
"n",
"-",
"sized",
"chunks",
"from",
"l",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/utils.py#L115-L120 | train | 65,006 |
ulule/django-badgify | badgify/utils.py | sanitize_command_options | def sanitize_command_options(options):
"""
Sanitizes command options.
"""
multiples = [
'badges',
'exclude_badges',
]
for option in multiples:
if options.get(option):
value = options[option]
if value:
options[option] = [v for v in ... | python | def sanitize_command_options(options):
"""
Sanitizes command options.
"""
multiples = [
'badges',
'exclude_badges',
]
for option in multiples:
if options.get(option):
value = options[option]
if value:
options[option] = [v for v in ... | [
"def",
"sanitize_command_options",
"(",
"options",
")",
":",
"multiples",
"=",
"[",
"'badges'",
",",
"'exclude_badges'",
",",
"]",
"for",
"option",
"in",
"multiples",
":",
"if",
"options",
".",
"get",
"(",
"option",
")",
":",
"value",
"=",
"options",
"[",
... | Sanitizes command options. | [
"Sanitizes",
"command",
"options",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/utils.py#L133-L148 | train | 65,007 |
ulule/django-badgify | badgify/registry.py | BadgifyRegistry.register | def register(self, recipe):
"""
Registers a new recipe class.
"""
if not isinstance(recipe, (list, tuple)):
recipe = [recipe, ]
for item in recipe:
recipe = self.get_recipe_instance_from_class(item)
self._registry[recipe.slug] = recipe | python | def register(self, recipe):
"""
Registers a new recipe class.
"""
if not isinstance(recipe, (list, tuple)):
recipe = [recipe, ]
for item in recipe:
recipe = self.get_recipe_instance_from_class(item)
self._registry[recipe.slug] = recipe | [
"def",
"register",
"(",
"self",
",",
"recipe",
")",
":",
"if",
"not",
"isinstance",
"(",
"recipe",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"recipe",
"=",
"[",
"recipe",
",",
"]",
"for",
"item",
"in",
"recipe",
":",
"recipe",
"=",
"self",
"... | Registers a new recipe class. | [
"Registers",
"a",
"new",
"recipe",
"class",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/registry.py#L35-L45 | train | 65,008 |
ulule/django-badgify | badgify/registry.py | BadgifyRegistry.unregister | def unregister(self, recipe):
"""
Unregisters a given recipe class.
"""
recipe = self.get_recipe_instance_from_class(recipe)
if recipe.slug in self._registry:
del self._registry[recipe.slug] | python | def unregister(self, recipe):
"""
Unregisters a given recipe class.
"""
recipe = self.get_recipe_instance_from_class(recipe)
if recipe.slug in self._registry:
del self._registry[recipe.slug] | [
"def",
"unregister",
"(",
"self",
",",
"recipe",
")",
":",
"recipe",
"=",
"self",
".",
"get_recipe_instance_from_class",
"(",
"recipe",
")",
"if",
"recipe",
".",
"slug",
"in",
"self",
".",
"_registry",
":",
"del",
"self",
".",
"_registry",
"[",
"recipe",
... | Unregisters a given recipe class. | [
"Unregisters",
"a",
"given",
"recipe",
"class",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/registry.py#L47-L53 | train | 65,009 |
ulule/django-badgify | badgify/registry.py | BadgifyRegistry.get_recipe_instance | def get_recipe_instance(self, badge):
"""
Returns the recipe instance for the given badge slug.
If badge has not been registered, raises ``exceptions.BadgeNotFound``.
"""
from .exceptions import BadgeNotFound
if badge in self._registry:
return self.recipes[bad... | python | def get_recipe_instance(self, badge):
"""
Returns the recipe instance for the given badge slug.
If badge has not been registered, raises ``exceptions.BadgeNotFound``.
"""
from .exceptions import BadgeNotFound
if badge in self._registry:
return self.recipes[bad... | [
"def",
"get_recipe_instance",
"(",
"self",
",",
"badge",
")",
":",
"from",
".",
"exceptions",
"import",
"BadgeNotFound",
"if",
"badge",
"in",
"self",
".",
"_registry",
":",
"return",
"self",
".",
"recipes",
"[",
"badge",
"]",
"raise",
"BadgeNotFound",
"(",
... | Returns the recipe instance for the given badge slug.
If badge has not been registered, raises ``exceptions.BadgeNotFound``. | [
"Returns",
"the",
"recipe",
"instance",
"for",
"the",
"given",
"badge",
"slug",
".",
"If",
"badge",
"has",
"not",
"been",
"registered",
"raises",
"exceptions",
".",
"BadgeNotFound",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/registry.py#L61-L69 | train | 65,010 |
ulule/django-badgify | badgify/registry.py | BadgifyRegistry.get_recipe_instances | def get_recipe_instances(self, badges=None, excluded=None):
"""
Returns all recipe instances or just those for the given badges.
"""
if badges:
if not isinstance(badges, (list, tuple)):
badges = [badges]
if excluded:
if not isinstance(excl... | python | def get_recipe_instances(self, badges=None, excluded=None):
"""
Returns all recipe instances or just those for the given badges.
"""
if badges:
if not isinstance(badges, (list, tuple)):
badges = [badges]
if excluded:
if not isinstance(excl... | [
"def",
"get_recipe_instances",
"(",
"self",
",",
"badges",
"=",
"None",
",",
"excluded",
"=",
"None",
")",
":",
"if",
"badges",
":",
"if",
"not",
"isinstance",
"(",
"badges",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"badges",
"=",
"[",
"badges"... | Returns all recipe instances or just those for the given badges. | [
"Returns",
"all",
"recipe",
"instances",
"or",
"just",
"those",
"for",
"the",
"given",
"badges",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/registry.py#L71-L88 | train | 65,011 |
nosegae/NoseGAE | nosegae.py | NoseGAE._init_taskqueue_stub | def _init_taskqueue_stub(self, **stub_kwargs):
"""Initializes the taskqueue stub using nosegae config magic"""
task_args = {}
# root_path is required so the stub can find 'queue.yaml' or 'queue.yml'
if 'root_path' not in stub_kwargs:
for p in self._app_path:
#... | python | def _init_taskqueue_stub(self, **stub_kwargs):
"""Initializes the taskqueue stub using nosegae config magic"""
task_args = {}
# root_path is required so the stub can find 'queue.yaml' or 'queue.yml'
if 'root_path' not in stub_kwargs:
for p in self._app_path:
#... | [
"def",
"_init_taskqueue_stub",
"(",
"self",
",",
"*",
"*",
"stub_kwargs",
")",
":",
"task_args",
"=",
"{",
"}",
"# root_path is required so the stub can find 'queue.yaml' or 'queue.yml'",
"if",
"'root_path'",
"not",
"in",
"stub_kwargs",
":",
"for",
"p",
"in",
"self",
... | Initializes the taskqueue stub using nosegae config magic | [
"Initializes",
"the",
"taskqueue",
"stub",
"using",
"nosegae",
"config",
"magic"
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/nosegae.py#L192-L205 | train | 65,012 |
nosegae/NoseGAE | nosegae.py | NoseGAE._init_datastore_v3_stub | def _init_datastore_v3_stub(self, **stub_kwargs):
"""Initializes the datastore stub using nosegae config magic"""
task_args = dict(datastore_file=self._data_path)
task_args.update(stub_kwargs)
self.testbed.init_datastore_v3_stub(**task_args) | python | def _init_datastore_v3_stub(self, **stub_kwargs):
"""Initializes the datastore stub using nosegae config magic"""
task_args = dict(datastore_file=self._data_path)
task_args.update(stub_kwargs)
self.testbed.init_datastore_v3_stub(**task_args) | [
"def",
"_init_datastore_v3_stub",
"(",
"self",
",",
"*",
"*",
"stub_kwargs",
")",
":",
"task_args",
"=",
"dict",
"(",
"datastore_file",
"=",
"self",
".",
"_data_path",
")",
"task_args",
".",
"update",
"(",
"stub_kwargs",
")",
"self",
".",
"testbed",
".",
"... | Initializes the datastore stub using nosegae config magic | [
"Initializes",
"the",
"datastore",
"stub",
"using",
"nosegae",
"config",
"magic"
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/nosegae.py#L207-L211 | train | 65,013 |
nosegae/NoseGAE | nosegae.py | NoseGAE._init_user_stub | def _init_user_stub(self, **stub_kwargs):
"""Initializes the user stub using nosegae config magic"""
# do a little dance to keep the same kwargs for multiple tests in the same class
# because the user stub will barf if you pass these items into it
# stub = user_service_stub.UserServiceSt... | python | def _init_user_stub(self, **stub_kwargs):
"""Initializes the user stub using nosegae config magic"""
# do a little dance to keep the same kwargs for multiple tests in the same class
# because the user stub will barf if you pass these items into it
# stub = user_service_stub.UserServiceSt... | [
"def",
"_init_user_stub",
"(",
"self",
",",
"*",
"*",
"stub_kwargs",
")",
":",
"# do a little dance to keep the same kwargs for multiple tests in the same class",
"# because the user stub will barf if you pass these items into it",
"# stub = user_service_stub.UserServiceStub(**stub_kw_args)"... | Initializes the user stub using nosegae config magic | [
"Initializes",
"the",
"user",
"stub",
"using",
"nosegae",
"config",
"magic"
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/nosegae.py#L213-L224 | train | 65,014 |
nosegae/NoseGAE | nosegae.py | NoseGAE._init_modules_stub | def _init_modules_stub(self, **_):
"""Initializes the modules stub based off of your current yaml files
Implements solution from
http://stackoverflow.com/questions/28166558/invalidmoduleerror-when-using-testbed-to-unit-test-google-app-engine
"""
from google.appengine.api import ... | python | def _init_modules_stub(self, **_):
"""Initializes the modules stub based off of your current yaml files
Implements solution from
http://stackoverflow.com/questions/28166558/invalidmoduleerror-when-using-testbed-to-unit-test-google-app-engine
"""
from google.appengine.api import ... | [
"def",
"_init_modules_stub",
"(",
"self",
",",
"*",
"*",
"_",
")",
":",
"from",
"google",
".",
"appengine",
".",
"api",
"import",
"request_info",
"# edit all_versions per modules & versions thereof needing tests",
"all_versions",
"=",
"{",
"}",
"# {'default': [1], 'ands... | Initializes the modules stub based off of your current yaml files
Implements solution from
http://stackoverflow.com/questions/28166558/invalidmoduleerror-when-using-testbed-to-unit-test-google-app-engine | [
"Initializes",
"the",
"modules",
"stub",
"based",
"off",
"of",
"your",
"current",
"yaml",
"files"
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/nosegae.py#L226-L249 | train | 65,015 |
nosegae/NoseGAE | nosegae.py | NoseGAE._init_stub | def _init_stub(self, stub_init, **stub_kwargs):
"""Initializes all other stubs for consistency's sake"""
getattr(self.testbed, stub_init, lambda **kwargs: None)(**stub_kwargs) | python | def _init_stub(self, stub_init, **stub_kwargs):
"""Initializes all other stubs for consistency's sake"""
getattr(self.testbed, stub_init, lambda **kwargs: None)(**stub_kwargs) | [
"def",
"_init_stub",
"(",
"self",
",",
"stub_init",
",",
"*",
"*",
"stub_kwargs",
")",
":",
"getattr",
"(",
"self",
".",
"testbed",
",",
"stub_init",
",",
"lambda",
"*",
"*",
"kwargs",
":",
"None",
")",
"(",
"*",
"*",
"stub_kwargs",
")"
] | Initializes all other stubs for consistency's sake | [
"Initializes",
"all",
"other",
"stubs",
"for",
"consistency",
"s",
"sake"
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/nosegae.py#L251-L253 | train | 65,016 |
nosegae/NoseGAE | examples/modules_example/printenv.py | html_for_env_var | def html_for_env_var(key):
"""Returns an HTML snippet for an environment variable.
Args:
key: A string representing an environment variable name.
Returns:
String HTML representing the value and variable.
"""
value = os.getenv(key)
return KEY_VALUE_TEMPLATE.format(key, value) | python | def html_for_env_var(key):
"""Returns an HTML snippet for an environment variable.
Args:
key: A string representing an environment variable name.
Returns:
String HTML representing the value and variable.
"""
value = os.getenv(key)
return KEY_VALUE_TEMPLATE.format(key, value) | [
"def",
"html_for_env_var",
"(",
"key",
")",
":",
"value",
"=",
"os",
".",
"getenv",
"(",
"key",
")",
"return",
"KEY_VALUE_TEMPLATE",
".",
"format",
"(",
"key",
",",
"value",
")"
] | Returns an HTML snippet for an environment variable.
Args:
key: A string representing an environment variable name.
Returns:
String HTML representing the value and variable. | [
"Returns",
"an",
"HTML",
"snippet",
"for",
"an",
"environment",
"variable",
"."
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/examples/modules_example/printenv.py#L33-L43 | train | 65,017 |
nosegae/NoseGAE | examples/modules_example/printenv.py | html_for_cgi_argument | def html_for_cgi_argument(argument, form):
"""Returns an HTML snippet for a CGI argument.
Args:
argument: A string representing an CGI argument name in a form.
form: A CGI FieldStorage object.
Returns:
String HTML representing the CGI value and variable.
"""
value = form[ar... | python | def html_for_cgi_argument(argument, form):
"""Returns an HTML snippet for a CGI argument.
Args:
argument: A string representing an CGI argument name in a form.
form: A CGI FieldStorage object.
Returns:
String HTML representing the CGI value and variable.
"""
value = form[ar... | [
"def",
"html_for_cgi_argument",
"(",
"argument",
",",
"form",
")",
":",
"value",
"=",
"form",
"[",
"argument",
"]",
".",
"value",
"if",
"argument",
"in",
"form",
"else",
"None",
"return",
"KEY_VALUE_TEMPLATE",
".",
"format",
"(",
"argument",
",",
"value",
... | Returns an HTML snippet for a CGI argument.
Args:
argument: A string representing an CGI argument name in a form.
form: A CGI FieldStorage object.
Returns:
String HTML representing the CGI value and variable. | [
"Returns",
"an",
"HTML",
"snippet",
"for",
"a",
"CGI",
"argument",
"."
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/examples/modules_example/printenv.py#L46-L57 | train | 65,018 |
nosegae/NoseGAE | examples/modules_example/printenv.py | html_for_modules_method | def html_for_modules_method(method_name, *args, **kwargs):
"""Returns an HTML snippet for a Modules API method.
Args:
method_name: A string containing a Modules API method.
args: Positional arguments to be passed to the method.
kwargs: Keyword arguments to be passed to the method.
... | python | def html_for_modules_method(method_name, *args, **kwargs):
"""Returns an HTML snippet for a Modules API method.
Args:
method_name: A string containing a Modules API method.
args: Positional arguments to be passed to the method.
kwargs: Keyword arguments to be passed to the method.
... | [
"def",
"html_for_modules_method",
"(",
"method_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"method",
"=",
"getattr",
"(",
"modules",
",",
"method_name",
")",
"value",
"=",
"method",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"retur... | Returns an HTML snippet for a Modules API method.
Args:
method_name: A string containing a Modules API method.
args: Positional arguments to be passed to the method.
kwargs: Keyword arguments to be passed to the method.
Returns:
String HTML representing the Modules API method a... | [
"Returns",
"an",
"HTML",
"snippet",
"for",
"a",
"Modules",
"API",
"method",
"."
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/examples/modules_example/printenv.py#L60-L73 | train | 65,019 |
nosegae/NoseGAE | examples/modules_example/printenv.py | MainHandler.get | def get(self):
"""GET handler that serves environment data."""
environment_variables_output = [html_for_env_var(key)
for key in sorted(os.environ)]
cgi_arguments_output = []
if os.getenv('CONTENT_TYPE') == 'application/x-www-form-urlencoded':
... | python | def get(self):
"""GET handler that serves environment data."""
environment_variables_output = [html_for_env_var(key)
for key in sorted(os.environ)]
cgi_arguments_output = []
if os.getenv('CONTENT_TYPE') == 'application/x-www-form-urlencoded':
... | [
"def",
"get",
"(",
"self",
")",
":",
"environment_variables_output",
"=",
"[",
"html_for_env_var",
"(",
"key",
")",
"for",
"key",
"in",
"sorted",
"(",
"os",
".",
"environ",
")",
"]",
"cgi_arguments_output",
"=",
"[",
"]",
"if",
"os",
".",
"getenv",
"(",
... | GET handler that serves environment data. | [
"GET",
"handler",
"that",
"serves",
"environment",
"data",
"."
] | fca9fab22b480bb9721ecaa0967a636107648d92 | https://github.com/nosegae/NoseGAE/blob/fca9fab22b480bb9721ecaa0967a636107648d92/examples/modules_example/printenv.py#L78-L117 | train | 65,020 |
ulule/django-badgify | badgify/commands.py | sync_badges | def sync_badges(**kwargs):
"""
Iterates over registered recipes and creates missing badges.
"""
update = kwargs.get('update', False)
created_badges = []
instances = registry.get_recipe_instances()
for instance in instances:
reset_queries()
badge, created = instance.create_ba... | python | def sync_badges(**kwargs):
"""
Iterates over registered recipes and creates missing badges.
"""
update = kwargs.get('update', False)
created_badges = []
instances = registry.get_recipe_instances()
for instance in instances:
reset_queries()
badge, created = instance.create_ba... | [
"def",
"sync_badges",
"(",
"*",
"*",
"kwargs",
")",
":",
"update",
"=",
"kwargs",
".",
"get",
"(",
"'update'",
",",
"False",
")",
"created_badges",
"=",
"[",
"]",
"instances",
"=",
"registry",
".",
"get_recipe_instances",
"(",
")",
"for",
"instance",
"in... | Iterates over registered recipes and creates missing badges. | [
"Iterates",
"over",
"registered",
"recipes",
"and",
"creates",
"missing",
"badges",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/commands.py#L17-L32 | train | 65,021 |
ulule/django-badgify | badgify/commands.py | sync_awards | def sync_awards(**kwargs):
"""
Iterates over registered recipes and possibly creates awards.
"""
badges = kwargs.get('badges')
excluded = kwargs.get('exclude_badges')
disable_signals = kwargs.get('disable_signals')
batch_size = kwargs.get('batch_size', None)
db_read = kwargs.get('db_read... | python | def sync_awards(**kwargs):
"""
Iterates over registered recipes and possibly creates awards.
"""
badges = kwargs.get('badges')
excluded = kwargs.get('exclude_badges')
disable_signals = kwargs.get('disable_signals')
batch_size = kwargs.get('batch_size', None)
db_read = kwargs.get('db_read... | [
"def",
"sync_awards",
"(",
"*",
"*",
"kwargs",
")",
":",
"badges",
"=",
"kwargs",
".",
"get",
"(",
"'badges'",
")",
"excluded",
"=",
"kwargs",
".",
"get",
"(",
"'exclude_badges'",
")",
"disable_signals",
"=",
"kwargs",
".",
"get",
"(",
"'disable_signals'",... | Iterates over registered recipes and possibly creates awards. | [
"Iterates",
"over",
"registered",
"recipes",
"and",
"possibly",
"creates",
"awards",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/commands.py#L58-L82 | train | 65,022 |
ulule/django-badgify | badgify/commands.py | show_stats | def show_stats(**kwargs):
"""
Shows badges stats.
"""
db_read = kwargs.get('db_read', DEFAULT_DB_ALIAS)
badges = (Badge.objects.using(db_read)
.all()
.annotate(u_count=Count('users'))
.order_by('u_count'))
for bad... | python | def show_stats(**kwargs):
"""
Shows badges stats.
"""
db_read = kwargs.get('db_read', DEFAULT_DB_ALIAS)
badges = (Badge.objects.using(db_read)
.all()
.annotate(u_count=Count('users'))
.order_by('u_count'))
for bad... | [
"def",
"show_stats",
"(",
"*",
"*",
"kwargs",
")",
":",
"db_read",
"=",
"kwargs",
".",
"get",
"(",
"'db_read'",
",",
"DEFAULT_DB_ALIAS",
")",
"badges",
"=",
"(",
"Badge",
".",
"objects",
".",
"using",
"(",
"db_read",
")",
".",
"all",
"(",
")",
".",
... | Shows badges stats. | [
"Shows",
"badges",
"stats",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/commands.py#L85-L100 | train | 65,023 |
ulule/django-badgify | badgify/recipe.py | BaseRecipe.get_current_user_ids | def get_current_user_ids(self, db_read=None):
"""
Returns current user ids and the count.
"""
db_read = db_read or self.db_read
return self.user_ids.using(db_read) | python | def get_current_user_ids(self, db_read=None):
"""
Returns current user ids and the count.
"""
db_read = db_read or self.db_read
return self.user_ids.using(db_read) | [
"def",
"get_current_user_ids",
"(",
"self",
",",
"db_read",
"=",
"None",
")",
":",
"db_read",
"=",
"db_read",
"or",
"self",
".",
"db_read",
"return",
"self",
".",
"user_ids",
".",
"using",
"(",
"db_read",
")"
] | Returns current user ids and the count. | [
"Returns",
"current",
"user",
"ids",
"and",
"the",
"count",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/recipe.py#L174-L180 | train | 65,024 |
ulule/django-badgify | badgify/management/commands/badgify_sync.py | Command.add_arguments | def add_arguments(self, parser):
"""
Command arguments.
"""
super(Command, self).add_arguments(parser)
parser.add_argument('--badges',
action='store',
dest='badges',
type=str)
parser.add... | python | def add_arguments(self, parser):
"""
Command arguments.
"""
super(Command, self).add_arguments(parser)
parser.add_argument('--badges',
action='store',
dest='badges',
type=str)
parser.add... | [
"def",
"add_arguments",
"(",
"self",
",",
"parser",
")",
":",
"super",
"(",
"Command",
",",
"self",
")",
".",
"add_arguments",
"(",
"parser",
")",
"parser",
".",
"add_argument",
"(",
"'--badges'",
",",
"action",
"=",
"'store'",
",",
"dest",
"=",
"'badges... | Command arguments. | [
"Command",
"arguments",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/management/commands/badgify_sync.py#L14-L46 | train | 65,025 |
sunlightlabs/name-cleaver | name_cleaver/cleaver.py | OrganizationNameCleaver.compare | def compare(cls, match, subject):
"""
Accepts two OrganizationName objects and returns an arbitrary,
numerical score based upon how well the names match.
"""
if match.expand().lower() == subject.expand().lower():
return 4
elif match.kernel().lower() ==... | python | def compare(cls, match, subject):
"""
Accepts two OrganizationName objects and returns an arbitrary,
numerical score based upon how well the names match.
"""
if match.expand().lower() == subject.expand().lower():
return 4
elif match.kernel().lower() ==... | [
"def",
"compare",
"(",
"cls",
",",
"match",
",",
"subject",
")",
":",
"if",
"match",
".",
"expand",
"(",
")",
".",
"lower",
"(",
")",
"==",
"subject",
".",
"expand",
"(",
")",
".",
"lower",
"(",
")",
":",
"return",
"4",
"elif",
"match",
".",
"k... | Accepts two OrganizationName objects and returns an arbitrary,
numerical score based upon how well the names match. | [
"Accepts",
"two",
"OrganizationName",
"objects",
"and",
"returns",
"an",
"arbitrary",
"numerical",
"score",
"based",
"upon",
"how",
"well",
"the",
"names",
"match",
"."
] | 48d3838fd9521235bd1586017fa4b31236ffc88e | https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/cleaver.py#L265-L280 | train | 65,026 |
ulule/django-badgify | badgify/templatetags/badgify_tags.py | badgify_badges | def badgify_badges(**kwargs):
"""
Returns all badges or only awarded badges for the given user.
"""
User = get_user_model()
user = kwargs.get('user', None)
username = kwargs.get('username', None)
if username:
try:
user = User.objects.get(username=username)
except ... | python | def badgify_badges(**kwargs):
"""
Returns all badges or only awarded badges for the given user.
"""
User = get_user_model()
user = kwargs.get('user', None)
username = kwargs.get('username', None)
if username:
try:
user = User.objects.get(username=username)
except ... | [
"def",
"badgify_badges",
"(",
"*",
"*",
"kwargs",
")",
":",
"User",
"=",
"get_user_model",
"(",
")",
"user",
"=",
"kwargs",
".",
"get",
"(",
"'user'",
",",
"None",
")",
"username",
"=",
"kwargs",
".",
"get",
"(",
"'username'",
",",
"None",
")",
"if",... | Returns all badges or only awarded badges for the given user. | [
"Returns",
"all",
"badges",
"or",
"only",
"awarded",
"badges",
"for",
"the",
"given",
"user",
"."
] | 1bf233ffeb6293ee659454de7b3794682128b6ca | https://github.com/ulule/django-badgify/blob/1bf233ffeb6293ee659454de7b3794682128b6ca/badgify/templatetags/badgify_tags.py#L13-L29 | train | 65,027 |
sunlightlabs/name-cleaver | name_cleaver/names.py | OrganizationName.without_extra_phrases | def without_extra_phrases(self):
"""Removes parenthethical and dashed phrases"""
# the last parenthesis is optional, because sometimes they are truncated
name = re.sub(r'\s*\([^)]*\)?\s*$', '', self.name)
name = re.sub(r'(?i)\s* formerly.*$', '', name)
name = re.sub(r'(?i)\s*and ... | python | def without_extra_phrases(self):
"""Removes parenthethical and dashed phrases"""
# the last parenthesis is optional, because sometimes they are truncated
name = re.sub(r'\s*\([^)]*\)?\s*$', '', self.name)
name = re.sub(r'(?i)\s* formerly.*$', '', name)
name = re.sub(r'(?i)\s*and ... | [
"def",
"without_extra_phrases",
"(",
"self",
")",
":",
"# the last parenthesis is optional, because sometimes they are truncated",
"name",
"=",
"re",
".",
"sub",
"(",
"r'\\s*\\([^)]*\\)?\\s*$'",
",",
"''",
",",
"self",
".",
"name",
")",
"name",
"=",
"re",
".",
"sub"... | Removes parenthethical and dashed phrases | [
"Removes",
"parenthethical",
"and",
"dashed",
"phrases"
] | 48d3838fd9521235bd1586017fa4b31236ffc88e | https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/names.py#L98-L120 | train | 65,028 |
sunlightlabs/name-cleaver | name_cleaver/names.py | OrganizationName.kernel | def kernel(self):
""" The 'kernel' is an attempt to get at just the most pithy words in the name """
stop_words = [ y.lower() for y in self.abbreviations.values() + self.filler_words ]
kernel = ' '.join([ x for x in self.expand().split() if x.lower() not in stop_words ])
# this is a hac... | python | def kernel(self):
""" The 'kernel' is an attempt to get at just the most pithy words in the name """
stop_words = [ y.lower() for y in self.abbreviations.values() + self.filler_words ]
kernel = ' '.join([ x for x in self.expand().split() if x.lower() not in stop_words ])
# this is a hac... | [
"def",
"kernel",
"(",
"self",
")",
":",
"stop_words",
"=",
"[",
"y",
".",
"lower",
"(",
")",
"for",
"y",
"in",
"self",
".",
"abbreviations",
".",
"values",
"(",
")",
"+",
"self",
".",
"filler_words",
"]",
"kernel",
"=",
"' '",
".",
"join",
"(",
"... | The 'kernel' is an attempt to get at just the most pithy words in the name | [
"The",
"kernel",
"is",
"an",
"attempt",
"to",
"get",
"at",
"just",
"the",
"most",
"pithy",
"words",
"in",
"the",
"name"
] | 48d3838fd9521235bd1586017fa4b31236ffc88e | https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/names.py#L129-L138 | train | 65,029 |
sunlightlabs/name-cleaver | name_cleaver/names.py | PersonName.detect_and_fix_two_part_surname | def detect_and_fix_two_part_surname(self, args):
"""
This detects common family name prefixes and joins them to the last name,
so names like "De Kuyper" don't end up with "De" as a middle name.
"""
i = 0
while i < len(args) - 1:
if args[i].lower() in self.fami... | python | def detect_and_fix_two_part_surname(self, args):
"""
This detects common family name prefixes and joins them to the last name,
so names like "De Kuyper" don't end up with "De" as a middle name.
"""
i = 0
while i < len(args) - 1:
if args[i].lower() in self.fami... | [
"def",
"detect_and_fix_two_part_surname",
"(",
"self",
",",
"args",
")",
":",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"args",
")",
"-",
"1",
":",
"if",
"args",
"[",
"i",
"]",
".",
"lower",
"(",
")",
"in",
"self",
".",
"family_name_prefixes",
... | This detects common family name prefixes and joins them to the last name,
so names like "De Kuyper" don't end up with "De" as a middle name. | [
"This",
"detects",
"common",
"family",
"name",
"prefixes",
"and",
"joins",
"them",
"to",
"the",
"last",
"name",
"so",
"names",
"like",
"De",
"Kuyper",
"don",
"t",
"end",
"up",
"with",
"De",
"as",
"a",
"middle",
"name",
"."
] | 48d3838fd9521235bd1586017fa4b31236ffc88e | https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/names.py#L256-L268 | train | 65,030 |
sunlightlabs/name-cleaver | name_cleaver/names.py | PersonName.case_name_parts | def case_name_parts(self):
"""
Convert all the parts of the name to the proper case... carefully!
"""
if not self.is_mixed_case():
self.honorific = self.honorific.title() if self.honorific else None
self.nick = self.nick.title() if self.nick else None
... | python | def case_name_parts(self):
"""
Convert all the parts of the name to the proper case... carefully!
"""
if not self.is_mixed_case():
self.honorific = self.honorific.title() if self.honorific else None
self.nick = self.nick.title() if self.nick else None
... | [
"def",
"case_name_parts",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_mixed_case",
"(",
")",
":",
"self",
".",
"honorific",
"=",
"self",
".",
"honorific",
".",
"title",
"(",
")",
"if",
"self",
".",
"honorific",
"else",
"None",
"self",
".",
"... | Convert all the parts of the name to the proper case... carefully! | [
"Convert",
"all",
"the",
"parts",
"of",
"the",
"name",
"to",
"the",
"proper",
"case",
"...",
"carefully!"
] | 48d3838fd9521235bd1586017fa4b31236ffc88e | https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/names.py#L286-L311 | train | 65,031 |
ungarj/s2reader | s2reader/cli/inspect.py | main | def main(args=None):
"""Print metadata as JSON strings."""
args = sys.argv[1:]
parser = argparse.ArgumentParser()
parser.add_argument("safe_file", type=str, nargs='+')
parser.add_argument("--granules", action="store_true")
parsed = parser.parse_args(args)
pp = pprint.PrettyPrinter()
for... | python | def main(args=None):
"""Print metadata as JSON strings."""
args = sys.argv[1:]
parser = argparse.ArgumentParser()
parser.add_argument("safe_file", type=str, nargs='+')
parser.add_argument("--granules", action="store_true")
parsed = parser.parse_args(args)
pp = pprint.PrettyPrinter()
for... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"safe_file\"",
",",
"type",
"=",
"str",
",",
"... | Print metadata as JSON strings. | [
"Print",
"metadata",
"as",
"JSON",
"strings",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/cli/inspect.py#L10-L54 | train | 65,032 |
ungarj/s2reader | s2reader/s2reader.py | open | def open(safe_file):
"""Return a SentinelDataSet object."""
if os.path.isdir(safe_file) or os.path.isfile(safe_file):
return SentinelDataSet(safe_file)
else:
raise IOError("file not found: %s" % safe_file) | python | def open(safe_file):
"""Return a SentinelDataSet object."""
if os.path.isdir(safe_file) or os.path.isfile(safe_file):
return SentinelDataSet(safe_file)
else:
raise IOError("file not found: %s" % safe_file) | [
"def",
"open",
"(",
"safe_file",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"safe_file",
")",
"or",
"os",
".",
"path",
".",
"isfile",
"(",
"safe_file",
")",
":",
"return",
"SentinelDataSet",
"(",
"safe_file",
")",
"else",
":",
"raise",
"IO... | Return a SentinelDataSet object. | [
"Return",
"a",
"SentinelDataSet",
"object",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L25-L30 | train | 65,033 |
ungarj/s2reader | s2reader/s2reader.py | _granule_identifier_to_xml_name | def _granule_identifier_to_xml_name(granule_identifier):
"""
Very ugly way to convert the granule identifier.
e.g.
From
Granule Identifier:
S2A_OPER_MSI_L1C_TL_SGS__20150817T131818_A000792_T28QBG_N01.03
To
Granule Metadata XML name:
S2A_OPER_MTD_L1C_TL_SGS__20150817T131818_A000792_T... | python | def _granule_identifier_to_xml_name(granule_identifier):
"""
Very ugly way to convert the granule identifier.
e.g.
From
Granule Identifier:
S2A_OPER_MSI_L1C_TL_SGS__20150817T131818_A000792_T28QBG_N01.03
To
Granule Metadata XML name:
S2A_OPER_MTD_L1C_TL_SGS__20150817T131818_A000792_T... | [
"def",
"_granule_identifier_to_xml_name",
"(",
"granule_identifier",
")",
":",
"# Replace \"MSI\" with \"MTD\".",
"changed_item_type",
"=",
"re",
".",
"sub",
"(",
"\"_MSI_\"",
",",
"\"_MTD_\"",
",",
"granule_identifier",
")",
"# Split string up by underscores.",
"split_by_und... | Very ugly way to convert the granule identifier.
e.g.
From
Granule Identifier:
S2A_OPER_MSI_L1C_TL_SGS__20150817T131818_A000792_T28QBG_N01.03
To
Granule Metadata XML name:
S2A_OPER_MTD_L1C_TL_SGS__20150817T131818_A000792_T28QBG.xml | [
"Very",
"ugly",
"way",
"to",
"convert",
"the",
"granule",
"identifier",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L553-L577 | train | 65,034 |
ungarj/s2reader | s2reader/s2reader.py | _polygon_from_coords | def _polygon_from_coords(coords, fix_geom=False, swap=True, dims=2):
"""
Return Shapely Polygon from coordinates.
- coords: list of alterating latitude / longitude coordinates
- fix_geom: automatically fix geometry
"""
assert len(coords) % dims == 0
number_of_points = len(coords)/dims
c... | python | def _polygon_from_coords(coords, fix_geom=False, swap=True, dims=2):
"""
Return Shapely Polygon from coordinates.
- coords: list of alterating latitude / longitude coordinates
- fix_geom: automatically fix geometry
"""
assert len(coords) % dims == 0
number_of_points = len(coords)/dims
c... | [
"def",
"_polygon_from_coords",
"(",
"coords",
",",
"fix_geom",
"=",
"False",
",",
"swap",
"=",
"True",
",",
"dims",
"=",
"2",
")",
":",
"assert",
"len",
"(",
"coords",
")",
"%",
"dims",
"==",
"0",
"number_of_points",
"=",
"len",
"(",
"coords",
")",
"... | Return Shapely Polygon from coordinates.
- coords: list of alterating latitude / longitude coordinates
- fix_geom: automatically fix geometry | [
"Return",
"Shapely",
"Polygon",
"from",
"coordinates",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L580-L603 | train | 65,035 |
ungarj/s2reader | s2reader/s2reader.py | SentinelDataSet.product_metadata_path | def product_metadata_path(self):
"""Return path to product metadata XML file."""
data_object_section = self._manifest_safe.find("dataObjectSection")
for data_object in data_object_section:
# Find product metadata XML.
if data_object.attrib.get("ID") == "S2_Level-1C_Produc... | python | def product_metadata_path(self):
"""Return path to product metadata XML file."""
data_object_section = self._manifest_safe.find("dataObjectSection")
for data_object in data_object_section:
# Find product metadata XML.
if data_object.attrib.get("ID") == "S2_Level-1C_Produc... | [
"def",
"product_metadata_path",
"(",
"self",
")",
":",
"data_object_section",
"=",
"self",
".",
"_manifest_safe",
".",
"find",
"(",
"\"dataObjectSection\"",
")",
"for",
"data_object",
"in",
"data_object_section",
":",
"# Find product metadata XML.",
"if",
"data_object",... | Return path to product metadata XML file. | [
"Return",
"path",
"to",
"product",
"metadata",
"XML",
"file",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L96-L116 | train | 65,036 |
ungarj/s2reader | s2reader/s2reader.py | SentinelDataSet.footprint | def footprint(self):
"""Return product footprint."""
product_footprint = self._product_metadata.iter("Product_Footprint")
# I don't know why two "Product_Footprint" items are found.
for element in product_footprint:
global_footprint = None
for global_footprint in ... | python | def footprint(self):
"""Return product footprint."""
product_footprint = self._product_metadata.iter("Product_Footprint")
# I don't know why two "Product_Footprint" items are found.
for element in product_footprint:
global_footprint = None
for global_footprint in ... | [
"def",
"footprint",
"(",
"self",
")",
":",
"product_footprint",
"=",
"self",
".",
"_product_metadata",
".",
"iter",
"(",
"\"Product_Footprint\"",
")",
"# I don't know why two \"Product_Footprint\" items are found.",
"for",
"element",
"in",
"product_footprint",
":",
"globa... | Return product footprint. | [
"Return",
"product",
"footprint",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L173-L181 | train | 65,037 |
ungarj/s2reader | s2reader/s2reader.py | SentinelDataSet.granules | def granules(self):
"""Return list of SentinelGranule objects."""
for element in self._product_metadata.iter("Product_Info"):
product_organisation = element.find("Product_Organisation")
if self.product_format == 'SAFE':
return [
SentinelGranule(_id.find("G... | python | def granules(self):
"""Return list of SentinelGranule objects."""
for element in self._product_metadata.iter("Product_Info"):
product_organisation = element.find("Product_Organisation")
if self.product_format == 'SAFE':
return [
SentinelGranule(_id.find("G... | [
"def",
"granules",
"(",
"self",
")",
":",
"for",
"element",
"in",
"self",
".",
"_product_metadata",
".",
"iter",
"(",
"\"Product_Info\"",
")",
":",
"product_organisation",
"=",
"element",
".",
"find",
"(",
"\"Product_Organisation\"",
")",
"if",
"self",
".",
... | Return list of SentinelGranule objects. | [
"Return",
"list",
"of",
"SentinelGranule",
"objects",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L184-L203 | train | 65,038 |
ungarj/s2reader | s2reader/s2reader.py | SentinelDataSet.granule_paths | def granule_paths(self, band_id):
"""Return the path of all granules of a given band."""
band_id = str(band_id).zfill(2)
try:
assert isinstance(band_id, str)
assert band_id in BAND_IDS
except AssertionError:
raise AttributeError(
"band ... | python | def granule_paths(self, band_id):
"""Return the path of all granules of a given band."""
band_id = str(band_id).zfill(2)
try:
assert isinstance(band_id, str)
assert band_id in BAND_IDS
except AssertionError:
raise AttributeError(
"band ... | [
"def",
"granule_paths",
"(",
"self",
",",
"band_id",
")",
":",
"band_id",
"=",
"str",
"(",
"band_id",
")",
".",
"zfill",
"(",
"2",
")",
"try",
":",
"assert",
"isinstance",
"(",
"band_id",
",",
"str",
")",
"assert",
"band_id",
"in",
"BAND_IDS",
"except"... | Return the path of all granules of a given band. | [
"Return",
"the",
"path",
"of",
"all",
"granules",
"of",
"a",
"given",
"band",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L205-L218 | train | 65,039 |
ungarj/s2reader | s2reader/s2reader.py | SentinelGranule.metadata_path | def metadata_path(self):
"""Determine the metadata path."""
xml_name = _granule_identifier_to_xml_name(self.granule_identifier)
metadata_path = os.path.join(self.granule_path, xml_name)
try:
assert os.path.isfile(metadata_path) or \
metadata_path in self.datas... | python | def metadata_path(self):
"""Determine the metadata path."""
xml_name = _granule_identifier_to_xml_name(self.granule_identifier)
metadata_path = os.path.join(self.granule_path, xml_name)
try:
assert os.path.isfile(metadata_path) or \
metadata_path in self.datas... | [
"def",
"metadata_path",
"(",
"self",
")",
":",
"xml_name",
"=",
"_granule_identifier_to_xml_name",
"(",
"self",
".",
"granule_identifier",
")",
"metadata_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"granule_path",
",",
"xml_name",
")",
"try",... | Determine the metadata path. | [
"Determine",
"the",
"metadata",
"path",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L273-L283 | train | 65,040 |
ungarj/s2reader | s2reader/s2reader.py | SentinelGranule.tci_path | def tci_path(self):
"""Return the path to the granules TrueColorImage."""
tci_paths = [
path for path in self.dataset._product_metadata.xpath(
".//Granule[@granuleIdentifier='%s']/IMAGE_FILE/text()"
% self.granule_identifier
) if path.endswith('TCI... | python | def tci_path(self):
"""Return the path to the granules TrueColorImage."""
tci_paths = [
path for path in self.dataset._product_metadata.xpath(
".//Granule[@granuleIdentifier='%s']/IMAGE_FILE/text()"
% self.granule_identifier
) if path.endswith('TCI... | [
"def",
"tci_path",
"(",
"self",
")",
":",
"tci_paths",
"=",
"[",
"path",
"for",
"path",
"in",
"self",
".",
"dataset",
".",
"_product_metadata",
".",
"xpath",
"(",
"\".//Granule[@granuleIdentifier='%s']/IMAGE_FILE/text()\"",
"%",
"self",
".",
"granule_identifier",
... | Return the path to the granules TrueColorImage. | [
"Return",
"the",
"path",
"to",
"the",
"granules",
"TrueColorImage",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L291-L307 | train | 65,041 |
ungarj/s2reader | s2reader/s2reader.py | SentinelGranule.cloud_percent | def cloud_percent(self):
"""Return percentage of cloud coverage."""
image_content_qi = self._metadata.findtext(
(
"""n1:Quality_Indicators_Info/Image_Content_QI/"""
"""CLOUDY_PIXEL_PERCENTAGE"""
),
namespaces=self._nsmap)
return... | python | def cloud_percent(self):
"""Return percentage of cloud coverage."""
image_content_qi = self._metadata.findtext(
(
"""n1:Quality_Indicators_Info/Image_Content_QI/"""
"""CLOUDY_PIXEL_PERCENTAGE"""
),
namespaces=self._nsmap)
return... | [
"def",
"cloud_percent",
"(",
"self",
")",
":",
"image_content_qi",
"=",
"self",
".",
"_metadata",
".",
"findtext",
"(",
"(",
"\"\"\"n1:Quality_Indicators_Info/Image_Content_QI/\"\"\"",
"\"\"\"CLOUDY_PIXEL_PERCENTAGE\"\"\"",
")",
",",
"namespaces",
"=",
"self",
".",
"_ns... | Return percentage of cloud coverage. | [
"Return",
"percentage",
"of",
"cloud",
"coverage",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L310-L318 | train | 65,042 |
ungarj/s2reader | s2reader/s2reader.py | SentinelGranule.footprint | def footprint(self):
"""Find and return footprint as Shapely Polygon."""
# Check whether product or granule footprint needs to be calculated.
tile_geocoding = self._metadata.iter("Tile_Geocoding").next()
resolution = 10
searchstring = ".//*[@resolution='%s']" % resolution
... | python | def footprint(self):
"""Find and return footprint as Shapely Polygon."""
# Check whether product or granule footprint needs to be calculated.
tile_geocoding = self._metadata.iter("Tile_Geocoding").next()
resolution = 10
searchstring = ".//*[@resolution='%s']" % resolution
... | [
"def",
"footprint",
"(",
"self",
")",
":",
"# Check whether product or granule footprint needs to be calculated.",
"tile_geocoding",
"=",
"self",
".",
"_metadata",
".",
"iter",
"(",
"\"Tile_Geocoding\"",
")",
".",
"next",
"(",
")",
"resolution",
"=",
"10",
"searchstri... | Find and return footprint as Shapely Polygon. | [
"Find",
"and",
"return",
"footprint",
"as",
"Shapely",
"Polygon",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L321-L339 | train | 65,043 |
ungarj/s2reader | s2reader/s2reader.py | SentinelGranule.cloudmask | def cloudmask(self):
"""Return cloudmask as a shapely geometry."""
polys = list(self._get_mask(mask_type="MSK_CLOUDS"))
return MultiPolygon([
poly["geometry"]
for poly in polys
if poly["attributes"]["maskType"] == "OPAQUE"
]).buffer(0) | python | def cloudmask(self):
"""Return cloudmask as a shapely geometry."""
polys = list(self._get_mask(mask_type="MSK_CLOUDS"))
return MultiPolygon([
poly["geometry"]
for poly in polys
if poly["attributes"]["maskType"] == "OPAQUE"
]).buffer(0) | [
"def",
"cloudmask",
"(",
"self",
")",
":",
"polys",
"=",
"list",
"(",
"self",
".",
"_get_mask",
"(",
"mask_type",
"=",
"\"MSK_CLOUDS\"",
")",
")",
"return",
"MultiPolygon",
"(",
"[",
"poly",
"[",
"\"geometry\"",
"]",
"for",
"poly",
"in",
"polys",
"if",
... | Return cloudmask as a shapely geometry. | [
"Return",
"cloudmask",
"as",
"a",
"shapely",
"geometry",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L342-L349 | train | 65,044 |
ungarj/s2reader | s2reader/s2reader.py | SentinelGranule.band_path | def band_path(self, band_id, for_gdal=False, absolute=False):
"""Return paths of given band's jp2 files for all granules."""
band_id = str(band_id).zfill(2)
if not isinstance(band_id, str) or band_id not in BAND_IDS:
raise ValueError("band ID not valid: %s" % band_id)
if self... | python | def band_path(self, band_id, for_gdal=False, absolute=False):
"""Return paths of given band's jp2 files for all granules."""
band_id = str(band_id).zfill(2)
if not isinstance(band_id, str) or band_id not in BAND_IDS:
raise ValueError("band ID not valid: %s" % band_id)
if self... | [
"def",
"band_path",
"(",
"self",
",",
"band_id",
",",
"for_gdal",
"=",
"False",
",",
"absolute",
"=",
"False",
")",
":",
"band_id",
"=",
"str",
"(",
"band_id",
")",
".",
"zfill",
"(",
"2",
")",
"if",
"not",
"isinstance",
"(",
"band_id",
",",
"str",
... | Return paths of given band's jp2 files for all granules. | [
"Return",
"paths",
"of",
"given",
"band",
"s",
"jp2",
"files",
"for",
"all",
"granules",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/s2reader.py#L357-L428 | train | 65,045 |
buckhx/QuadKey | quadkey/tile_system.py | TileSystem.geo_to_pixel | def geo_to_pixel(geo, level):
"""Transform from geo coordinates to pixel coordinates"""
lat, lon = float(geo[0]), float(geo[1])
lat = TileSystem.clip(lat, TileSystem.LATITUDE_RANGE)
lon = TileSystem.clip(lon, TileSystem.LONGITUDE_RANGE)
x = (lon + 180) / 360
sin_lat = sin... | python | def geo_to_pixel(geo, level):
"""Transform from geo coordinates to pixel coordinates"""
lat, lon = float(geo[0]), float(geo[1])
lat = TileSystem.clip(lat, TileSystem.LATITUDE_RANGE)
lon = TileSystem.clip(lon, TileSystem.LONGITUDE_RANGE)
x = (lon + 180) / 360
sin_lat = sin... | [
"def",
"geo_to_pixel",
"(",
"geo",
",",
"level",
")",
":",
"lat",
",",
"lon",
"=",
"float",
"(",
"geo",
"[",
"0",
"]",
")",
",",
"float",
"(",
"geo",
"[",
"1",
"]",
")",
"lat",
"=",
"TileSystem",
".",
"clip",
"(",
"lat",
",",
"TileSystem",
".",... | Transform from geo coordinates to pixel coordinates | [
"Transform",
"from",
"geo",
"coordinates",
"to",
"pixel",
"coordinates"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/tile_system.py#L55-L69 | train | 65,046 |
buckhx/QuadKey | quadkey/tile_system.py | TileSystem.pixel_to_geo | def pixel_to_geo(pixel, level):
"""Transform from pixel to geo coordinates"""
pixel_x = pixel[0]
pixel_y = pixel[1]
map_size = float(TileSystem.map_size(level))
x = (TileSystem.clip(pixel_x, (0, map_size - 1)) / map_size) - 0.5
y = 0.5 - (TileSystem.clip(pixel_y, (0, map_... | python | def pixel_to_geo(pixel, level):
"""Transform from pixel to geo coordinates"""
pixel_x = pixel[0]
pixel_y = pixel[1]
map_size = float(TileSystem.map_size(level))
x = (TileSystem.clip(pixel_x, (0, map_size - 1)) / map_size) - 0.5
y = 0.5 - (TileSystem.clip(pixel_y, (0, map_... | [
"def",
"pixel_to_geo",
"(",
"pixel",
",",
"level",
")",
":",
"pixel_x",
"=",
"pixel",
"[",
"0",
"]",
"pixel_y",
"=",
"pixel",
"[",
"1",
"]",
"map_size",
"=",
"float",
"(",
"TileSystem",
".",
"map_size",
"(",
"level",
")",
")",
"x",
"=",
"(",
"TileS... | Transform from pixel to geo coordinates | [
"Transform",
"from",
"pixel",
"to",
"geo",
"coordinates"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/tile_system.py#L73-L82 | train | 65,047 |
buckhx/QuadKey | quadkey/tile_system.py | TileSystem.tile_to_pixel | def tile_to_pixel(tile, centered=False):
"""Transform tile to pixel coordinates"""
pixel = [tile[0] * 256, tile[1] * 256]
if centered:
# should clip on max map size
pixel = [pix + 128 for pix in pixel]
return pixel[0], pixel[1] | python | def tile_to_pixel(tile, centered=False):
"""Transform tile to pixel coordinates"""
pixel = [tile[0] * 256, tile[1] * 256]
if centered:
# should clip on max map size
pixel = [pix + 128 for pix in pixel]
return pixel[0], pixel[1] | [
"def",
"tile_to_pixel",
"(",
"tile",
",",
"centered",
"=",
"False",
")",
":",
"pixel",
"=",
"[",
"tile",
"[",
"0",
"]",
"*",
"256",
",",
"tile",
"[",
"1",
"]",
"*",
"256",
"]",
"if",
"centered",
":",
"# should clip on max map size",
"pixel",
"=",
"["... | Transform tile to pixel coordinates | [
"Transform",
"tile",
"to",
"pixel",
"coordinates"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/tile_system.py#L90-L96 | train | 65,048 |
buckhx/QuadKey | quadkey/tile_system.py | TileSystem.tile_to_quadkey | def tile_to_quadkey(tile, level):
"""Transform tile coordinates to a quadkey"""
tile_x = tile[0]
tile_y = tile[1]
quadkey = ""
for i in xrange(level):
bit = level - i
digit = ord('0')
mask = 1 << (bit - 1) # if (bit - 1) > 0 else 1 >> (bit - 1... | python | def tile_to_quadkey(tile, level):
"""Transform tile coordinates to a quadkey"""
tile_x = tile[0]
tile_y = tile[1]
quadkey = ""
for i in xrange(level):
bit = level - i
digit = ord('0')
mask = 1 << (bit - 1) # if (bit - 1) > 0 else 1 >> (bit - 1... | [
"def",
"tile_to_quadkey",
"(",
"tile",
",",
"level",
")",
":",
"tile_x",
"=",
"tile",
"[",
"0",
"]",
"tile_y",
"=",
"tile",
"[",
"1",
"]",
"quadkey",
"=",
"\"\"",
"for",
"i",
"in",
"xrange",
"(",
"level",
")",
":",
"bit",
"=",
"level",
"-",
"i",
... | Transform tile coordinates to a quadkey | [
"Transform",
"tile",
"coordinates",
"to",
"a",
"quadkey"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/tile_system.py#L100-L114 | train | 65,049 |
buckhx/QuadKey | quadkey/tile_system.py | TileSystem.quadkey_to_tile | def quadkey_to_tile(quadkey):
"""Transform quadkey to tile coordinates"""
tile_x, tile_y = (0, 0)
level = len(quadkey)
for i in xrange(level):
bit = level - i
mask = 1 << (bit - 1)
if quadkey[level - bit] == '1':
tile_x |= mask
... | python | def quadkey_to_tile(quadkey):
"""Transform quadkey to tile coordinates"""
tile_x, tile_y = (0, 0)
level = len(quadkey)
for i in xrange(level):
bit = level - i
mask = 1 << (bit - 1)
if quadkey[level - bit] == '1':
tile_x |= mask
... | [
"def",
"quadkey_to_tile",
"(",
"quadkey",
")",
":",
"tile_x",
",",
"tile_y",
"=",
"(",
"0",
",",
"0",
")",
"level",
"=",
"len",
"(",
"quadkey",
")",
"for",
"i",
"in",
"xrange",
"(",
"level",
")",
":",
"bit",
"=",
"level",
"-",
"i",
"mask",
"=",
... | Transform quadkey to tile coordinates | [
"Transform",
"quadkey",
"to",
"tile",
"coordinates"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/tile_system.py#L117-L131 | train | 65,050 |
hanguokai/youku | youku/youku_oauth.py | YoukuOauth.authorize_url | def authorize_url(self, state=''):
""" return user authorize url
"""
url = 'https://openapi.youku.com/v2/oauth2/authorize?'
params = {
'client_id': self.client_id,
'response_type': 'code',
'state': state,
'redirect_uri': self.redirect_uri
... | python | def authorize_url(self, state=''):
""" return user authorize url
"""
url = 'https://openapi.youku.com/v2/oauth2/authorize?'
params = {
'client_id': self.client_id,
'response_type': 'code',
'state': state,
'redirect_uri': self.redirect_uri
... | [
"def",
"authorize_url",
"(",
"self",
",",
"state",
"=",
"''",
")",
":",
"url",
"=",
"'https://openapi.youku.com/v2/oauth2/authorize?'",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'response_type'",
":",
"'code'",
",",
"'state'",
":",
... | return user authorize url | [
"return",
"user",
"authorize",
"url"
] | b2df060c7dccfad990bcfa289fff68bb77d1e69b | https://github.com/hanguokai/youku/blob/b2df060c7dccfad990bcfa289fff68bb77d1e69b/youku/youku_oauth.py#L28-L38 | train | 65,051 |
hanguokai/youku | youku/util.py | remove_none_value | def remove_none_value(data):
"""remove item from dict if value is None.
return new dict.
"""
return dict((k, v) for k, v in data.items() if v is not None) | python | def remove_none_value(data):
"""remove item from dict if value is None.
return new dict.
"""
return dict((k, v) for k, v in data.items() if v is not None) | [
"def",
"remove_none_value",
"(",
"data",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"data",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",
")"
] | remove item from dict if value is None.
return new dict. | [
"remove",
"item",
"from",
"dict",
"if",
"value",
"is",
"None",
".",
"return",
"new",
"dict",
"."
] | b2df060c7dccfad990bcfa289fff68bb77d1e69b | https://github.com/hanguokai/youku/blob/b2df060c7dccfad990bcfa289fff68bb77d1e69b/youku/util.py#L50-L54 | train | 65,052 |
wiheto/fetchopenfmri | fetchopenfmri/fetch.py | get_dataset | def get_dataset(ds,dataDir,removecompressed=1):
"""
A function which attempts downloads and uncompresses the latest version of an openfmri.fmri dataset.
PARAMETERS
:ds: dataset number of the openfMRI.org dataset (integer) without zero padding. I.e. can just be 212 (doesn't need to be 000212).
:da... | python | def get_dataset(ds,dataDir,removecompressed=1):
"""
A function which attempts downloads and uncompresses the latest version of an openfmri.fmri dataset.
PARAMETERS
:ds: dataset number of the openfMRI.org dataset (integer) without zero padding. I.e. can just be 212 (doesn't need to be 000212).
:da... | [
"def",
"get_dataset",
"(",
"ds",
",",
"dataDir",
",",
"removecompressed",
"=",
"1",
")",
":",
"#Convert input ds to string incase it is put in via function",
"ds",
"=",
"str",
"(",
"ds",
")",
"#The final character of the dataset can be a letter",
"lettersuffix",
"=",
"''"... | A function which attempts downloads and uncompresses the latest version of an openfmri.fmri dataset.
PARAMETERS
:ds: dataset number of the openfMRI.org dataset (integer) without zero padding. I.e. can just be 212 (doesn't need to be 000212).
:dataDir: where to save the data. Will get saved in 'dataDir/ope... | [
"A",
"function",
"which",
"attempts",
"downloads",
"and",
"uncompresses",
"the",
"latest",
"version",
"of",
"an",
"openfmri",
".",
"fmri",
"dataset",
"."
] | 2539f24ad795a29496a29b3a4252cba86a5e45f0 | https://github.com/wiheto/fetchopenfmri/blob/2539f24ad795a29496a29b3a4252cba86a5e45f0/fetchopenfmri/fetch.py#L40-L109 | train | 65,053 |
hanguokai/youku | youku/youku_upload.py | YoukuUpload.prepare_video_params | def prepare_video_params(self, title=None, tags='Others', description='',
copyright_type='original', public_type='all',
category=None, watch_password=None,
latitude=None, longitude=None, shoot_time=None
)... | python | def prepare_video_params(self, title=None, tags='Others', description='',
copyright_type='original', public_type='all',
category=None, watch_password=None,
latitude=None, longitude=None, shoot_time=None
)... | [
"def",
"prepare_video_params",
"(",
"self",
",",
"title",
"=",
"None",
",",
"tags",
"=",
"'Others'",
",",
"description",
"=",
"''",
",",
"copyright_type",
"=",
"'original'",
",",
"public_type",
"=",
"'all'",
",",
"category",
"=",
"None",
",",
"watch_password... | util method for create video params to upload.
Only need to provide a minimum of two essential parameters:
title and tags, other video params are optional. All params spec
see: http://cloud.youku.com/docs?id=110#create .
Args:
title: string, 2-50 characters.
tag... | [
"util",
"method",
"for",
"create",
"video",
"params",
"to",
"upload",
"."
] | b2df060c7dccfad990bcfa289fff68bb77d1e69b | https://github.com/hanguokai/youku/blob/b2df060c7dccfad990bcfa289fff68bb77d1e69b/youku/youku_upload.py#L59-L109 | train | 65,054 |
hanguokai/youku | youku/youku_upload.py | YoukuUpload._save_upload_state_to_file | def _save_upload_state_to_file(self):
"""if create and create_file has execute, save upload state
to file for next resume upload if current upload process is
interrupted.
"""
if os.access(self.file_dir, os.W_OK | os.R_OK | os.X_OK):
save_file = self.file + '.upload'
... | python | def _save_upload_state_to_file(self):
"""if create and create_file has execute, save upload state
to file for next resume upload if current upload process is
interrupted.
"""
if os.access(self.file_dir, os.W_OK | os.R_OK | os.X_OK):
save_file = self.file + '.upload'
... | [
"def",
"_save_upload_state_to_file",
"(",
"self",
")",
":",
"if",
"os",
".",
"access",
"(",
"self",
".",
"file_dir",
",",
"os",
".",
"W_OK",
"|",
"os",
".",
"R_OK",
"|",
"os",
".",
"X_OK",
")",
":",
"save_file",
"=",
"self",
".",
"file",
"+",
"'.up... | if create and create_file has execute, save upload state
to file for next resume upload if current upload process is
interrupted. | [
"if",
"create",
"and",
"create_file",
"has",
"execute",
"save",
"upload",
"state",
"to",
"file",
"for",
"next",
"resume",
"upload",
"if",
"current",
"upload",
"process",
"is",
"interrupted",
"."
] | b2df060c7dccfad990bcfa289fff68bb77d1e69b | https://github.com/hanguokai/youku/blob/b2df060c7dccfad990bcfa289fff68bb77d1e69b/youku/youku_upload.py#L138-L150 | train | 65,055 |
hanguokai/youku | youku/youku_upload.py | YoukuUpload.upload | def upload(self, params={}):
"""start uploading the file until upload is complete or error.
This is the main method to used, If you do not care about
state of process.
Args:
params: a dict object describe video info, eg title,
tags, description, ... | python | def upload(self, params={}):
"""start uploading the file until upload is complete or error.
This is the main method to used, If you do not care about
state of process.
Args:
params: a dict object describe video info, eg title,
tags, description, ... | [
"def",
"upload",
"(",
"self",
",",
"params",
"=",
"{",
"}",
")",
":",
"if",
"self",
".",
"upload_token",
"is",
"not",
"None",
":",
"# resume upload",
"status",
"=",
"self",
".",
"check",
"(",
")",
"if",
"status",
"[",
"'status'",
"]",
"!=",
"4",
":... | start uploading the file until upload is complete or error.
This is the main method to used, If you do not care about
state of process.
Args:
params: a dict object describe video info, eg title,
tags, description, category.
all video para... | [
"start",
"uploading",
"the",
"file",
"until",
"upload",
"is",
"complete",
"or",
"error",
".",
"This",
"is",
"the",
"main",
"method",
"to",
"used",
"If",
"you",
"do",
"not",
"care",
"about",
"state",
"of",
"process",
"."
] | b2df060c7dccfad990bcfa289fff68bb77d1e69b | https://github.com/hanguokai/youku/blob/b2df060c7dccfad990bcfa289fff68bb77d1e69b/youku/youku_upload.py#L291-L321 | train | 65,056 |
jbittel/django-ldap-sync | ldap_sync/sync.py | SyncLDAP.sync_users | def sync_users(self):
"""Synchronize LDAP users with local user model."""
if self.settings.USER_FILTER:
user_attributes = self.settings.USER_ATTRIBUTES.keys() + self.settings.USER_EXTRA_ATTRIBUTES
ldap_users = self.ldap.search(self.settings.USER_FILTER, user_attributes)
... | python | def sync_users(self):
"""Synchronize LDAP users with local user model."""
if self.settings.USER_FILTER:
user_attributes = self.settings.USER_ATTRIBUTES.keys() + self.settings.USER_EXTRA_ATTRIBUTES
ldap_users = self.ldap.search(self.settings.USER_FILTER, user_attributes)
... | [
"def",
"sync_users",
"(",
"self",
")",
":",
"if",
"self",
".",
"settings",
".",
"USER_FILTER",
":",
"user_attributes",
"=",
"self",
".",
"settings",
".",
"USER_ATTRIBUTES",
".",
"keys",
"(",
")",
"+",
"self",
".",
"settings",
".",
"USER_EXTRA_ATTRIBUTES",
... | Synchronize LDAP users with local user model. | [
"Synchronize",
"LDAP",
"users",
"with",
"local",
"user",
"model",
"."
] | d9ad679b32c16cf77b9d025728868fc2e1af41cd | https://github.com/jbittel/django-ldap-sync/blob/d9ad679b32c16cf77b9d025728868fc2e1af41cd/ldap_sync/sync.py#L45-L51 | train | 65,057 |
ungarj/s2reader | s2reader/cli/transform.py | main | def main(args=sys.argv[1:]):
"""Generate EO O&M XML metadata."""
parser = argparse.ArgumentParser()
parser.add_argument("filename", nargs=1)
parser.add_argument("--granule-id", dest="granule_id",
help=(
"Optional. Specify a granule to export metadata from."
)
)
parser... | python | def main(args=sys.argv[1:]):
"""Generate EO O&M XML metadata."""
parser = argparse.ArgumentParser()
parser.add_argument("filename", nargs=1)
parser.add_argument("--granule-id", dest="granule_id",
help=(
"Optional. Specify a granule to export metadata from."
)
)
parser... | [
"def",
"main",
"(",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"filename\"",
",",
"nargs",
"=",
"1",
")",
"parser",
".",
"add_argume... | Generate EO O&M XML metadata. | [
"Generate",
"EO",
"O&M",
"XML",
"metadata",
"."
] | 376fd7ee1d15cce0849709c149d694663a7bc0ef | https://github.com/ungarj/s2reader/blob/376fd7ee1d15cce0849709c149d694663a7bc0ef/s2reader/cli/transform.py#L348-L415 | train | 65,058 |
buckhx/QuadKey | quadkey/__init__.py | QuadKey.is_ancestor | def is_ancestor(self, node):
"""
If node is ancestor of self
Get the difference in level
If not, None
"""
if self.level <= node.level or self.key[:len(node.key)] != node.key:
return None
return self.level - node.level | python | def is_ancestor(self, node):
"""
If node is ancestor of self
Get the difference in level
If not, None
"""
if self.level <= node.level or self.key[:len(node.key)] != node.key:
return None
return self.level - node.level | [
"def",
"is_ancestor",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"level",
"<=",
"node",
".",
"level",
"or",
"self",
".",
"key",
"[",
":",
"len",
"(",
"node",
".",
"key",
")",
"]",
"!=",
"node",
".",
"key",
":",
"return",
"None",
"re... | If node is ancestor of self
Get the difference in level
If not, None | [
"If",
"node",
"is",
"ancestor",
"of",
"self",
"Get",
"the",
"difference",
"in",
"level",
"If",
"not",
"None"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/__init__.py#L33-L41 | train | 65,059 |
buckhx/QuadKey | quadkey/__init__.py | QuadKey.xdifference | def xdifference(self, to):
""" Generator
Gives the difference of quadkeys between self and to
Generator in case done on a low level
Only works with quadkeys of same level
"""
x,y = 0,1
assert self.level == to.level
self_tile = list(self.to_tile... | python | def xdifference(self, to):
""" Generator
Gives the difference of quadkeys between self and to
Generator in case done on a low level
Only works with quadkeys of same level
"""
x,y = 0,1
assert self.level == to.level
self_tile = list(self.to_tile... | [
"def",
"xdifference",
"(",
"self",
",",
"to",
")",
":",
"x",
",",
"y",
"=",
"0",
",",
"1",
"assert",
"self",
".",
"level",
"==",
"to",
".",
"level",
"self_tile",
"=",
"list",
"(",
"self",
".",
"to_tile",
"(",
")",
"[",
"0",
"]",
")",
"to_tile",... | Generator
Gives the difference of quadkeys between self and to
Generator in case done on a low level
Only works with quadkeys of same level | [
"Generator",
"Gives",
"the",
"difference",
"of",
"quadkeys",
"between",
"self",
"and",
"to",
"Generator",
"in",
"case",
"done",
"on",
"a",
"low",
"level",
"Only",
"works",
"with",
"quadkeys",
"of",
"same",
"level"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/__init__.py#L58-L78 | train | 65,060 |
buckhx/QuadKey | quadkey/__init__.py | QuadKey.unwind | def unwind(self):
""" Get a list of all ancestors in descending order of level, including a new instance of self
"""
return [ QuadKey(self.key[:l+1]) for l in reversed(range(len(self.key))) ] | python | def unwind(self):
""" Get a list of all ancestors in descending order of level, including a new instance of self
"""
return [ QuadKey(self.key[:l+1]) for l in reversed(range(len(self.key))) ] | [
"def",
"unwind",
"(",
"self",
")",
":",
"return",
"[",
"QuadKey",
"(",
"self",
".",
"key",
"[",
":",
"l",
"+",
"1",
"]",
")",
"for",
"l",
"in",
"reversed",
"(",
"range",
"(",
"len",
"(",
"self",
".",
"key",
")",
")",
")",
"]"
] | Get a list of all ancestors in descending order of level, including a new instance of self | [
"Get",
"a",
"list",
"of",
"all",
"ancestors",
"in",
"descending",
"order",
"of",
"level",
"including",
"a",
"new",
"instance",
"of",
"self"
] | 546338f9b50b578ea765d3bf84b944db48dbec5b | https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/__init__.py#L85-L88 | train | 65,061 |
jbittel/django-ldap-sync | ldap_sync/settings.py | LDAPSettings.validate | def validate(self):
"""Apply validation rules for loaded settings."""
if self.GROUP_ATTRIBUTES and self.GROUPNAME_FIELD not in self.GROUP_ATTRIBUTES.values():
raise ImproperlyConfigured("LDAP_SYNC_GROUP_ATTRIBUTES must contain '%s'" % self.GROUPNAME_FIELD)
if not self.model._meta.ge... | python | def validate(self):
"""Apply validation rules for loaded settings."""
if self.GROUP_ATTRIBUTES and self.GROUPNAME_FIELD not in self.GROUP_ATTRIBUTES.values():
raise ImproperlyConfigured("LDAP_SYNC_GROUP_ATTRIBUTES must contain '%s'" % self.GROUPNAME_FIELD)
if not self.model._meta.ge... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"self",
".",
"GROUP_ATTRIBUTES",
"and",
"self",
".",
"GROUPNAME_FIELD",
"not",
"in",
"self",
".",
"GROUP_ATTRIBUTES",
".",
"values",
"(",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"LDAP_SYNC_GROUP_ATTRIBUTE... | Apply validation rules for loaded settings. | [
"Apply",
"validation",
"rules",
"for",
"loaded",
"settings",
"."
] | d9ad679b32c16cf77b9d025728868fc2e1af41cd | https://github.com/jbittel/django-ldap-sync/blob/d9ad679b32c16cf77b9d025728868fc2e1af41cd/ldap_sync/settings.py#L34-L43 | train | 65,062 |
jbittel/django-ldap-sync | ldap_sync/search.py | LDAPSearch.search | def search(self, filterstr, attrlist):
"""Query the configured LDAP server."""
return self._paged_search_ext_s(self.settings.BASE, ldap.SCOPE_SUBTREE, filterstr=filterstr,
attrlist=attrlist, page_size=self.settings.PAGE_SIZE) | python | def search(self, filterstr, attrlist):
"""Query the configured LDAP server."""
return self._paged_search_ext_s(self.settings.BASE, ldap.SCOPE_SUBTREE, filterstr=filterstr,
attrlist=attrlist, page_size=self.settings.PAGE_SIZE) | [
"def",
"search",
"(",
"self",
",",
"filterstr",
",",
"attrlist",
")",
":",
"return",
"self",
".",
"_paged_search_ext_s",
"(",
"self",
".",
"settings",
".",
"BASE",
",",
"ldap",
".",
"SCOPE_SUBTREE",
",",
"filterstr",
"=",
"filterstr",
",",
"attrlist",
"=",... | Query the configured LDAP server. | [
"Query",
"the",
"configured",
"LDAP",
"server",
"."
] | d9ad679b32c16cf77b9d025728868fc2e1af41cd | https://github.com/jbittel/django-ldap-sync/blob/d9ad679b32c16cf77b9d025728868fc2e1af41cd/ldap_sync/search.py#L41-L44 | train | 65,063 |
tsroten/yweather | yweather.py | Client.fetch_lid | def fetch_lid(self, woeid):
"""Fetch a location's corresponding LID.
Args:
woeid: (string) the location's WOEID.
Returns:
a string containing the requested LID or None if the LID could
not be found.
Raises:
urllib.error.URLError: urllib.... | python | def fetch_lid(self, woeid):
"""Fetch a location's corresponding LID.
Args:
woeid: (string) the location's WOEID.
Returns:
a string containing the requested LID or None if the LID could
not be found.
Raises:
urllib.error.URLError: urllib.... | [
"def",
"fetch_lid",
"(",
"self",
",",
"woeid",
")",
":",
"rss",
"=",
"self",
".",
"_fetch_xml",
"(",
"LID_LOOKUP_URL",
".",
"format",
"(",
"woeid",
",",
"\"f\"",
")",
")",
"# We are pulling the LID from the permalink tag in the XML file",
"# returned by Yahoo.",
"tr... | Fetch a location's corresponding LID.
Args:
woeid: (string) the location's WOEID.
Returns:
a string containing the requested LID or None if the LID could
not be found.
Raises:
urllib.error.URLError: urllib.request could not open the URL
... | [
"Fetch",
"a",
"location",
"s",
"corresponding",
"LID",
"."
] | 085db1df0be1925d5d7410e9160682b3a087bd61 | https://github.com/tsroten/yweather/blob/085db1df0be1925d5d7410e9160682b3a087bd61/yweather.py#L107-L142 | train | 65,064 |
tsroten/yweather | yweather.py | Client.fetch_woeid | def fetch_woeid(self, location):
"""Fetch a location's corresponding WOEID.
Args:
location: (string) a location (e.g. 23454 or Berlin, Germany).
Returns:
a string containing the location's corresponding WOEID or None if
the WOEID could not be found.
... | python | def fetch_woeid(self, location):
"""Fetch a location's corresponding WOEID.
Args:
location: (string) a location (e.g. 23454 or Berlin, Germany).
Returns:
a string containing the location's corresponding WOEID or None if
the WOEID could not be found.
... | [
"def",
"fetch_woeid",
"(",
"self",
",",
"location",
")",
":",
"rss",
"=",
"self",
".",
"_fetch_xml",
"(",
"WOEID_LOOKUP_URL",
".",
"format",
"(",
"quote",
"(",
"location",
")",
")",
")",
"try",
":",
"woeid",
"=",
"rss",
".",
"find",
"(",
"\"results/Res... | Fetch a location's corresponding WOEID.
Args:
location: (string) a location (e.g. 23454 or Berlin, Germany).
Returns:
a string containing the location's corresponding WOEID or None if
the WOEID could not be found.
Raises:
urllib.error.URLErr... | [
"Fetch",
"a",
"location",
"s",
"corresponding",
"WOEID",
"."
] | 085db1df0be1925d5d7410e9160682b3a087bd61 | https://github.com/tsroten/yweather/blob/085db1df0be1925d5d7410e9160682b3a087bd61/yweather.py#L273-L297 | train | 65,065 |
tsroten/yweather | yweather.py | Client._degrees_to_direction | def _degrees_to_direction(self, degrees):
"""Convert wind direction from degrees to compass direction."""
try:
degrees = float(degrees)
except ValueError:
return None
if degrees < 0 or degrees > 360:
return None
if degrees <= 11.25 or degrees >... | python | def _degrees_to_direction(self, degrees):
"""Convert wind direction from degrees to compass direction."""
try:
degrees = float(degrees)
except ValueError:
return None
if degrees < 0 or degrees > 360:
return None
if degrees <= 11.25 or degrees >... | [
"def",
"_degrees_to_direction",
"(",
"self",
",",
"degrees",
")",
":",
"try",
":",
"degrees",
"=",
"float",
"(",
"degrees",
")",
"except",
"ValueError",
":",
"return",
"None",
"if",
"degrees",
"<",
"0",
"or",
"degrees",
">",
"360",
":",
"return",
"None",... | Convert wind direction from degrees to compass direction. | [
"Convert",
"wind",
"direction",
"from",
"degrees",
"to",
"compass",
"direction",
"."
] | 085db1df0be1925d5d7410e9160682b3a087bd61 | https://github.com/tsroten/yweather/blob/085db1df0be1925d5d7410e9160682b3a087bd61/yweather.py#L299-L340 | train | 65,066 |
tsroten/yweather | yweather.py | Client._fetch_xml | def _fetch_xml(self, url):
"""Fetch a url and parse the document's XML."""
with contextlib.closing(urlopen(url)) as f:
return xml.etree.ElementTree.parse(f).getroot() | python | def _fetch_xml(self, url):
"""Fetch a url and parse the document's XML."""
with contextlib.closing(urlopen(url)) as f:
return xml.etree.ElementTree.parse(f).getroot() | [
"def",
"_fetch_xml",
"(",
"self",
",",
"url",
")",
":",
"with",
"contextlib",
".",
"closing",
"(",
"urlopen",
"(",
"url",
")",
")",
"as",
"f",
":",
"return",
"xml",
".",
"etree",
".",
"ElementTree",
".",
"parse",
"(",
"f",
")",
".",
"getroot",
"(",... | Fetch a url and parse the document's XML. | [
"Fetch",
"a",
"url",
"and",
"parse",
"the",
"document",
"s",
"XML",
"."
] | 085db1df0be1925d5d7410e9160682b3a087bd61 | https://github.com/tsroten/yweather/blob/085db1df0be1925d5d7410e9160682b3a087bd61/yweather.py#L342-L345 | train | 65,067 |
galaxy-genome-annotation/python-apollo | apollo/cannedvalues/__init__.py | CannedValuesClient.show_value | def show_value(self, value):
"""
Get a specific canned value
:type value: str
:param value: Canned value to show
:rtype: dict
:return: A dictionnary containing canned value description
"""
values = self.get_values()
values = [x for x in values if... | python | def show_value(self, value):
"""
Get a specific canned value
:type value: str
:param value: Canned value to show
:rtype: dict
:return: A dictionnary containing canned value description
"""
values = self.get_values()
values = [x for x in values if... | [
"def",
"show_value",
"(",
"self",
",",
"value",
")",
":",
"values",
"=",
"self",
".",
"get_values",
"(",
")",
"values",
"=",
"[",
"x",
"for",
"x",
"in",
"values",
"if",
"x",
"[",
"'label'",
"]",
"==",
"value",
"]",
"if",
"len",
"(",
"values",
")"... | Get a specific canned value
:type value: str
:param value: Canned value to show
:rtype: dict
:return: A dictionnary containing canned value description | [
"Get",
"a",
"specific",
"canned",
"value"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/cannedvalues/__init__.py#L39-L54 | train | 65,068 |
galaxy-genome-annotation/python-apollo | apollo/cannedkeys/__init__.py | CannedKeysClient.show_key | def show_key(self, value):
"""
Get a specific canned key
:type value: str
:param value: Canned key to show
:rtype: dict
:return: A dictionnary containing canned key description
"""
keys = self.get_keys()
keys = [x for x in keys if x['label'] == v... | python | def show_key(self, value):
"""
Get a specific canned key
:type value: str
:param value: Canned key to show
:rtype: dict
:return: A dictionnary containing canned key description
"""
keys = self.get_keys()
keys = [x for x in keys if x['label'] == v... | [
"def",
"show_key",
"(",
"self",
",",
"value",
")",
":",
"keys",
"=",
"self",
".",
"get_keys",
"(",
")",
"keys",
"=",
"[",
"x",
"for",
"x",
"in",
"keys",
"if",
"x",
"[",
"'label'",
"]",
"==",
"value",
"]",
"if",
"len",
"(",
"keys",
")",
"==",
... | Get a specific canned key
:type value: str
:param value: Canned key to show
:rtype: dict
:return: A dictionnary containing canned key description | [
"Get",
"a",
"specific",
"canned",
"key"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/cannedkeys/__init__.py#L39-L54 | train | 65,069 |
cytomine/Cytomine-python-client | cytomine/models/image.py | ImageInstance.download | def download(self, dest_pattern="{originalFilename}", override=True, parent=False):
"""
Download the original image.
Parameters
----------
dest_pattern : str, optional
Destination path for the downloaded image. "{X}" patterns are replaced by the value of X attribute
... | python | def download(self, dest_pattern="{originalFilename}", override=True, parent=False):
"""
Download the original image.
Parameters
----------
dest_pattern : str, optional
Destination path for the downloaded image. "{X}" patterns are replaced by the value of X attribute
... | [
"def",
"download",
"(",
"self",
",",
"dest_pattern",
"=",
"\"{originalFilename}\"",
",",
"override",
"=",
"True",
",",
"parent",
"=",
"False",
")",
":",
"if",
"self",
".",
"id",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Cannot download image with no ID... | Download the original image.
Parameters
----------
dest_pattern : str, optional
Destination path for the downloaded image. "{X}" patterns are replaced by the value of X attribute
if it exists.
override : bool, optional
True if a file with same name ca... | [
"Download",
"the",
"original",
"image",
"."
] | bac19722b900dd32c6cfd6bdb9354fc784d33bc4 | https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/models/image.py#L136-L167 | train | 65,070 |
cytomine/Cytomine-python-client | cytomine/models/image.py | ImageInstance.dump | def dump(self, dest_pattern="{id}.jpg", override=True, max_size=None, bits=8, contrast=None, gamma=None,
colormap=None, inverse=None):
"""
Download the image with optional image modifications.
Parameters
----------
dest_pattern : str, optional
Destinatio... | python | def dump(self, dest_pattern="{id}.jpg", override=True, max_size=None, bits=8, contrast=None, gamma=None,
colormap=None, inverse=None):
"""
Download the image with optional image modifications.
Parameters
----------
dest_pattern : str, optional
Destinatio... | [
"def",
"dump",
"(",
"self",
",",
"dest_pattern",
"=",
"\"{id}.jpg\"",
",",
"override",
"=",
"True",
",",
"max_size",
"=",
"None",
",",
"bits",
"=",
"8",
",",
"contrast",
"=",
"None",
",",
"gamma",
"=",
"None",
",",
"colormap",
"=",
"None",
",",
"inve... | Download the image with optional image modifications.
Parameters
----------
dest_pattern : str, optional
Destination path for the downloaded image. "{X}" patterns are replaced by the value of X attribute
if it exists.
override : bool, optional
True if... | [
"Download",
"the",
"image",
"with",
"optional",
"image",
"modifications",
"."
] | bac19722b900dd32c6cfd6bdb9354fc784d33bc4 | https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/models/image.py#L169-L235 | train | 65,071 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcoreTask.filtered_elements | def filtered_elements(self, model):
"""Return iterator based on `element_type`."""
if isinstance(model, self.element_type):
yield model
yield from (e for e in model.eAllContents() if isinstance(e, self.element_type)) | python | def filtered_elements(self, model):
"""Return iterator based on `element_type`."""
if isinstance(model, self.element_type):
yield model
yield from (e for e in model.eAllContents() if isinstance(e, self.element_type)) | [
"def",
"filtered_elements",
"(",
"self",
",",
"model",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"self",
".",
"element_type",
")",
":",
"yield",
"model",
"yield",
"from",
"(",
"e",
"for",
"e",
"in",
"model",
".",
"eAllContents",
"(",
")",
"if",
... | Return iterator based on `element_type`. | [
"Return",
"iterator",
"based",
"on",
"element_type",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L23-L27 | train | 65,072 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcoreTask.folder_path_for_package | def folder_path_for_package(cls, package: ecore.EPackage):
"""Returns path to folder holding generated artifact for given element."""
parent = package.eContainer()
if parent:
return os.path.join(cls.folder_path_for_package(parent), package.name)
return package.name | python | def folder_path_for_package(cls, package: ecore.EPackage):
"""Returns path to folder holding generated artifact for given element."""
parent = package.eContainer()
if parent:
return os.path.join(cls.folder_path_for_package(parent), package.name)
return package.name | [
"def",
"folder_path_for_package",
"(",
"cls",
",",
"package",
":",
"ecore",
".",
"EPackage",
")",
":",
"parent",
"=",
"package",
".",
"eContainer",
"(",
")",
"if",
"parent",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"cls",
".",
"folder_path_for... | Returns path to folder holding generated artifact for given element. | [
"Returns",
"path",
"to",
"folder",
"holding",
"generated",
"artifact",
"for",
"given",
"element",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L30-L35 | train | 65,073 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcorePackageInitTask.imported_classifiers_package | def imported_classifiers_package(p: ecore.EPackage):
"""Determines which classifiers have to be imported into given package."""
classes = {c for c in p.eClassifiers if isinstance(c, ecore.EClass)}
references = itertools.chain(*(c.eAllReferences() for c in classes))
references_types = (r... | python | def imported_classifiers_package(p: ecore.EPackage):
"""Determines which classifiers have to be imported into given package."""
classes = {c for c in p.eClassifiers if isinstance(c, ecore.EClass)}
references = itertools.chain(*(c.eAllReferences() for c in classes))
references_types = (r... | [
"def",
"imported_classifiers_package",
"(",
"p",
":",
"ecore",
".",
"EPackage",
")",
":",
"classes",
"=",
"{",
"c",
"for",
"c",
"in",
"p",
".",
"eClassifiers",
"if",
"isinstance",
"(",
"c",
",",
"ecore",
".",
"EClass",
")",
"}",
"references",
"=",
"ite... | Determines which classifiers have to be imported into given package. | [
"Determines",
"which",
"classifiers",
"have",
"to",
"be",
"imported",
"into",
"given",
"package",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L59-L71 | train | 65,074 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcorePackageModuleTask.imported_classifiers | def imported_classifiers(p: ecore.EPackage):
"""Determines which classifiers have to be imported into given module."""
classes = {c for c in p.eClassifiers if isinstance(c, ecore.EClass)}
supertypes = itertools.chain(*(c.eAllSuperTypes() for c in classes))
imported = {c for c in superty... | python | def imported_classifiers(p: ecore.EPackage):
"""Determines which classifiers have to be imported into given module."""
classes = {c for c in p.eClassifiers if isinstance(c, ecore.EClass)}
supertypes = itertools.chain(*(c.eAllSuperTypes() for c in classes))
imported = {c for c in superty... | [
"def",
"imported_classifiers",
"(",
"p",
":",
"ecore",
".",
"EPackage",
")",
":",
"classes",
"=",
"{",
"c",
"for",
"c",
"in",
"p",
".",
"eClassifiers",
"if",
"isinstance",
"(",
"c",
",",
"ecore",
".",
"EClass",
")",
"}",
"supertypes",
"=",
"itertools",... | Determines which classifiers have to be imported into given module. | [
"Determines",
"which",
"classifiers",
"have",
"to",
"be",
"imported",
"into",
"given",
"module",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L87-L102 | train | 65,075 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcorePackageModuleTask.classes | def classes(p: ecore.EPackage):
"""Returns classes in package in ordered by number of bases."""
classes = (c for c in p.eClassifiers if isinstance(c, ecore.EClass))
return sorted(classes, key=lambda c: len(set(c.eAllSuperTypes()))) | python | def classes(p: ecore.EPackage):
"""Returns classes in package in ordered by number of bases."""
classes = (c for c in p.eClassifiers if isinstance(c, ecore.EClass))
return sorted(classes, key=lambda c: len(set(c.eAllSuperTypes()))) | [
"def",
"classes",
"(",
"p",
":",
"ecore",
".",
"EPackage",
")",
":",
"classes",
"=",
"(",
"c",
"for",
"c",
"in",
"p",
".",
"eClassifiers",
"if",
"isinstance",
"(",
"c",
",",
"ecore",
".",
"EClass",
")",
")",
"return",
"sorted",
"(",
"classes",
",",... | Returns classes in package in ordered by number of bases. | [
"Returns",
"classes",
"in",
"package",
"in",
"ordered",
"by",
"number",
"of",
"bases",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L105-L108 | train | 65,076 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcoreGenerator.filter_pyfqn | def filter_pyfqn(cls, value, relative_to=0):
"""
Returns Python form of fully qualified name.
Args:
relative_to: If greater 0, the returned path is relative to the first n directories.
"""
def collect_packages(element, packages):
parent = element.eContai... | python | def filter_pyfqn(cls, value, relative_to=0):
"""
Returns Python form of fully qualified name.
Args:
relative_to: If greater 0, the returned path is relative to the first n directories.
"""
def collect_packages(element, packages):
parent = element.eContai... | [
"def",
"filter_pyfqn",
"(",
"cls",
",",
"value",
",",
"relative_to",
"=",
"0",
")",
":",
"def",
"collect_packages",
"(",
"element",
",",
"packages",
")",
":",
"parent",
"=",
"element",
".",
"eContainer",
"(",
")",
"if",
"parent",
":",
"collect_packages",
... | Returns Python form of fully qualified name.
Args:
relative_to: If greater 0, the returned path is relative to the first n directories. | [
"Returns",
"Python",
"form",
"of",
"fully",
"qualified",
"name",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L264-L289 | train | 65,077 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcoreGenerator.create_environment | def create_environment(self, **kwargs):
"""
Return a new Jinja environment.
Derived classes may override method to pass additional parameters or to change the template
loader type.
"""
environment = super().create_environment(**kwargs)
environment.tests.update({
... | python | def create_environment(self, **kwargs):
"""
Return a new Jinja environment.
Derived classes may override method to pass additional parameters or to change the template
loader type.
"""
environment = super().create_environment(**kwargs)
environment.tests.update({
... | [
"def",
"create_environment",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"environment",
"=",
"super",
"(",
")",
".",
"create_environment",
"(",
"*",
"*",
"kwargs",
")",
"environment",
".",
"tests",
".",
"update",
"(",
"{",
"'type'",
":",
"self",
".... | Return a new Jinja environment.
Derived classes may override method to pass additional parameters or to change the template
loader type. | [
"Return",
"a",
"new",
"Jinja",
"environment",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L302-L331 | train | 65,078 |
pyecore/pyecoregen | pyecoregen/ecore.py | EcoreGenerator.generate | def generate(self, model, outfolder, *, exclude=None):
"""
Generate model code.
Args:
model: The meta-model to generate code for.
outfolder: Path to the directoty that will contain the generated code.
exclude: List of referenced resources for which code was a... | python | def generate(self, model, outfolder, *, exclude=None):
"""
Generate model code.
Args:
model: The meta-model to generate code for.
outfolder: Path to the directoty that will contain the generated code.
exclude: List of referenced resources for which code was a... | [
"def",
"generate",
"(",
"self",
",",
"model",
",",
"outfolder",
",",
"*",
",",
"exclude",
"=",
"None",
")",
":",
"with",
"pythonic_names",
"(",
")",
":",
"super",
"(",
")",
".",
"generate",
"(",
"model",
",",
"outfolder",
")",
"check_dependency",
"=",
... | Generate model code.
Args:
model: The meta-model to generate code for.
outfolder: Path to the directoty that will contain the generated code.
exclude: List of referenced resources for which code was already generated
(to prevent regeneration). | [
"Generate",
"model",
"code",
"."
] | 8c7a792f46d7d94e5d13e00e2967dd237351a4cf | https://github.com/pyecore/pyecoregen/blob/8c7a792f46d7d94e5d13e00e2967dd237351a4cf/pyecoregen/ecore.py#L333-L356 | train | 65,079 |
galaxy-genome-annotation/python-apollo | apollo/groups/__init__.py | GroupsClient.show_group | def show_group(self, group_id):
"""
Get information about a group
:type group_id: int
:param group_id: Group ID Number
:rtype: dict
:return: a dictionary containing group information
"""
res = self.post('loadGroups', {'groupId': group_id})
if isi... | python | def show_group(self, group_id):
"""
Get information about a group
:type group_id: int
:param group_id: Group ID Number
:rtype: dict
:return: a dictionary containing group information
"""
res = self.post('loadGroups', {'groupId': group_id})
if isi... | [
"def",
"show_group",
"(",
"self",
",",
"group_id",
")",
":",
"res",
"=",
"self",
".",
"post",
"(",
"'loadGroups'",
",",
"{",
"'groupId'",
":",
"group_id",
"}",
")",
"if",
"isinstance",
"(",
"res",
",",
"list",
")",
":",
"return",
"_fix_group",
"(",
"... | Get information about a group
:type group_id: int
:param group_id: Group ID Number
:rtype: dict
:return: a dictionary containing group information | [
"Get",
"information",
"about",
"a",
"group"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/groups/__init__.py#L41-L55 | train | 65,080 |
galaxy-genome-annotation/python-apollo | apollo/groups/__init__.py | GroupsClient.get_organism_permissions | def get_organism_permissions(self, group):
"""
Get the group's organism permissions
:type group: str
:param group: group name
:rtype: list
:return: a list containing organism permissions (if any)
"""
data = {
'name': group,
}
... | python | def get_organism_permissions(self, group):
"""
Get the group's organism permissions
:type group: str
:param group: group name
:rtype: list
:return: a list containing organism permissions (if any)
"""
data = {
'name': group,
}
... | [
"def",
"get_organism_permissions",
"(",
"self",
",",
"group",
")",
":",
"data",
"=",
"{",
"'name'",
":",
"group",
",",
"}",
"response",
"=",
"_fix_group",
"(",
"self",
".",
"post",
"(",
"'getOrganismPermissionsForGroup'",
",",
"data",
")",
")",
"return",
"... | Get the group's organism permissions
:type group: str
:param group: group name
:rtype: list
:return: a list containing organism permissions (if any) | [
"Get",
"the",
"group",
"s",
"organism",
"permissions"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/groups/__init__.py#L94-L108 | train | 65,081 |
galaxy-genome-annotation/python-apollo | apollo/groups/__init__.py | GroupsClient.get_group_admin | def get_group_admin(self, group):
"""
Get the group's admins
:type group: str
:param group: group name
:rtype: list
:return: a list containing group admins
"""
data = {
'name': group,
}
response = _fix_group(self.post('getGrou... | python | def get_group_admin(self, group):
"""
Get the group's admins
:type group: str
:param group: group name
:rtype: list
:return: a list containing group admins
"""
data = {
'name': group,
}
response = _fix_group(self.post('getGrou... | [
"def",
"get_group_admin",
"(",
"self",
",",
"group",
")",
":",
"data",
"=",
"{",
"'name'",
":",
"group",
",",
"}",
"response",
"=",
"_fix_group",
"(",
"self",
".",
"post",
"(",
"'getGroupAdmin'",
",",
"data",
")",
")",
"return",
"response"
] | Get the group's admins
:type group: str
:param group: group name
:rtype: list
:return: a list containing group admins | [
"Get",
"the",
"group",
"s",
"admins"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/groups/__init__.py#L187-L201 | train | 65,082 |
galaxy-genome-annotation/python-apollo | apollo/groups/__init__.py | GroupsClient.get_group_creator | def get_group_creator(self, group):
"""
Get the group's creator
:type group: str
:param group: group name
:rtype: list
:return: creator userId
"""
data = {
'name': group,
}
response = _fix_group(self.post('getGroupCreator', da... | python | def get_group_creator(self, group):
"""
Get the group's creator
:type group: str
:param group: group name
:rtype: list
:return: creator userId
"""
data = {
'name': group,
}
response = _fix_group(self.post('getGroupCreator', da... | [
"def",
"get_group_creator",
"(",
"self",
",",
"group",
")",
":",
"data",
"=",
"{",
"'name'",
":",
"group",
",",
"}",
"response",
"=",
"_fix_group",
"(",
"self",
".",
"post",
"(",
"'getGroupCreator'",
",",
"data",
")",
")",
"return",
"response"
] | Get the group's creator
:type group: str
:param group: group name
:rtype: list
:return: creator userId | [
"Get",
"the",
"group",
"s",
"creator"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/groups/__init__.py#L203-L217 | train | 65,083 |
globocom/tornado-es | tornadoes/__init__.py | ESConnection._create_query_string | def _create_query_string(params):
"""
Support Elasticsearch 5.X
"""
parameters = params or {}
for param, value in parameters.items():
param_value = str(value).lower() if isinstance(value, bool) else value
parameters[param] = param_value
return ur... | python | def _create_query_string(params):
"""
Support Elasticsearch 5.X
"""
parameters = params or {}
for param, value in parameters.items():
param_value = str(value).lower() if isinstance(value, bool) else value
parameters[param] = param_value
return ur... | [
"def",
"_create_query_string",
"(",
"params",
")",
":",
"parameters",
"=",
"params",
"or",
"{",
"}",
"for",
"param",
",",
"value",
"in",
"parameters",
".",
"items",
"(",
")",
":",
"param_value",
"=",
"str",
"(",
"value",
")",
".",
"lower",
"(",
")",
... | Support Elasticsearch 5.X | [
"Support",
"Elasticsearch",
"5",
".",
"X"
] | f805ba766db1d4f3119583490aa99dbb71ad5680 | https://github.com/globocom/tornado-es/blob/f805ba766db1d4f3119583490aa99dbb71ad5680/tornadoes/__init__.py#L26-L36 | train | 65,084 |
galaxy-genome-annotation/python-apollo | apollo/status/__init__.py | StatusClient.show_status | def show_status(self, status):
"""
Get a specific status
:type status: str
:param status: Status to show
:rtype: dict
:return: A dictionnary containing status description
"""
statuses = self.get_statuses()
statuses = [x for x in statuses if x['va... | python | def show_status(self, status):
"""
Get a specific status
:type status: str
:param status: Status to show
:rtype: dict
:return: A dictionnary containing status description
"""
statuses = self.get_statuses()
statuses = [x for x in statuses if x['va... | [
"def",
"show_status",
"(",
"self",
",",
"status",
")",
":",
"statuses",
"=",
"self",
".",
"get_statuses",
"(",
")",
"statuses",
"=",
"[",
"x",
"for",
"x",
"in",
"statuses",
"if",
"x",
"[",
"'value'",
"]",
"==",
"status",
"]",
"if",
"len",
"(",
"sta... | Get a specific status
:type status: str
:param status: Status to show
:rtype: dict
:return: A dictionnary containing status description | [
"Get",
"a",
"specific",
"status"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/status/__init__.py#L35-L50 | train | 65,085 |
galaxy-genome-annotation/python-apollo | apollo/annotations/__init__.py | AnnotationsClient.add_attribute | def add_attribute(self, feature_id, attribute_key, attribute_value, organism=None, sequence=None):
"""
Add an attribute to a feature
:type feature_id: str
:param feature_id: Feature UUID
:type attribute_key: str
:param attribute_key: Attribute Key
:type attribu... | python | def add_attribute(self, feature_id, attribute_key, attribute_value, organism=None, sequence=None):
"""
Add an attribute to a feature
:type feature_id: str
:param feature_id: Feature UUID
:type attribute_key: str
:param attribute_key: Attribute Key
:type attribu... | [
"def",
"add_attribute",
"(",
"self",
",",
"feature_id",
",",
"attribute_key",
",",
"attribute_value",
",",
"organism",
"=",
"None",
",",
"sequence",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'features'",
":",
"[",
"{",
"'uniquename'",
":",
"feature_id",
",... | Add an attribute to a feature
:type feature_id: str
:param feature_id: Feature UUID
:type attribute_key: str
:param attribute_key: Attribute Key
:type attribute_value: str
:param attribute_value: Attribute Value
:type organism: str
:param organism: Org... | [
"Add",
"an",
"attribute",
"to",
"a",
"feature"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/annotations/__init__.py#L216-L254 | train | 65,086 |
galaxy-genome-annotation/python-apollo | apollo/annotations/__init__.py | AnnotationsClient.add_dbxref | def add_dbxref(self, feature_id, db, accession, organism=None, sequence=None):
"""
Add a dbxref to a feature
:type feature_id: str
:param feature_id: Feature UUID
:type db: str
:param db: DB Name (e.g. PMID)
:type accession: str
:param accession: Access... | python | def add_dbxref(self, feature_id, db, accession, organism=None, sequence=None):
"""
Add a dbxref to a feature
:type feature_id: str
:param feature_id: Feature UUID
:type db: str
:param db: DB Name (e.g. PMID)
:type accession: str
:param accession: Access... | [
"def",
"add_dbxref",
"(",
"self",
",",
"feature_id",
",",
"db",
",",
"accession",
",",
"organism",
"=",
"None",
",",
"sequence",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'features'",
":",
"[",
"{",
"'uniquename'",
":",
"feature_id",
",",
"'dbxrefs'",
... | Add a dbxref to a feature
:type feature_id: str
:param feature_id: Feature UUID
:type db: str
:param db: DB Name (e.g. PMID)
:type accession: str
:param accession: Accession Value
:type organism: str
:param organism: Organism Common Name
:type... | [
"Add",
"a",
"dbxref",
"to",
"a",
"feature"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/annotations/__init__.py#L341-L379 | train | 65,087 |
galaxy-genome-annotation/python-apollo | apollo/users/__init__.py | UsersClient._handle_empty | def _handle_empty(self, user, response):
"""Apollo likes to return empty user arrays, even when you REALLY
want a user response back... like creating a user."""
if len(response.keys()) == 0:
response = self.show_user(user)
# And sometimes show_user can return nothing. As... | python | def _handle_empty(self, user, response):
"""Apollo likes to return empty user arrays, even when you REALLY
want a user response back... like creating a user."""
if len(response.keys()) == 0:
response = self.show_user(user)
# And sometimes show_user can return nothing. As... | [
"def",
"_handle_empty",
"(",
"self",
",",
"user",
",",
"response",
")",
":",
"if",
"len",
"(",
"response",
".",
"keys",
"(",
")",
")",
"==",
"0",
":",
"response",
"=",
"self",
".",
"show_user",
"(",
"user",
")",
"# And sometimes show_user can return nothin... | Apollo likes to return empty user arrays, even when you REALLY
want a user response back... like creating a user. | [
"Apollo",
"likes",
"to",
"return",
"empty",
"user",
"arrays",
"even",
"when",
"you",
"REALLY",
"want",
"a",
"user",
"response",
"back",
"...",
"like",
"creating",
"a",
"user",
"."
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/users/__init__.py#L41-L50 | train | 65,088 |
galaxy-genome-annotation/python-apollo | apollo/users/__init__.py | UsersClient.show_user | def show_user(self, user):
"""
Get a specific user
:type user: str
:param user: User Email
:rtype: dict
:return: a dictionary containing user information
"""
res = self.post('loadUsers', {'userId': user})
if isinstance(res, list) and len(res) > 0... | python | def show_user(self, user):
"""
Get a specific user
:type user: str
:param user: User Email
:rtype: dict
:return: a dictionary containing user information
"""
res = self.post('loadUsers', {'userId': user})
if isinstance(res, list) and len(res) > 0... | [
"def",
"show_user",
"(",
"self",
",",
"user",
")",
":",
"res",
"=",
"self",
".",
"post",
"(",
"'loadUsers'",
",",
"{",
"'userId'",
":",
"user",
"}",
")",
"if",
"isinstance",
"(",
"res",
",",
"list",
")",
"and",
"len",
"(",
"res",
")",
">",
"0",
... | Get a specific user
:type user: str
:param user: User Email
:rtype: dict
:return: a dictionary containing user information | [
"Get",
"a",
"specific",
"user"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/users/__init__.py#L69-L82 | train | 65,089 |
galaxy-genome-annotation/python-apollo | apollo/__init__.py | require_user | def require_user(wa, email):
"""Require that the user has an account"""
cache_key = 'user-list'
try:
# Get the cached value
data = userCache[cache_key]
except KeyError:
# If we hit a key error above, indicating that
# we couldn't find the key, we'll simply re-request
... | python | def require_user(wa, email):
"""Require that the user has an account"""
cache_key = 'user-list'
try:
# Get the cached value
data = userCache[cache_key]
except KeyError:
# If we hit a key error above, indicating that
# we couldn't find the key, we'll simply re-request
... | [
"def",
"require_user",
"(",
"wa",
",",
"email",
")",
":",
"cache_key",
"=",
"'user-list'",
"try",
":",
"# Get the cached value",
"data",
"=",
"userCache",
"[",
"cache_key",
"]",
"except",
"KeyError",
":",
"# If we hit a key error above, indicating that",
"# we couldn'... | Require that the user has an account | [
"Require",
"that",
"the",
"user",
"has",
"an",
"account"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/__init__.py#L49-L62 | train | 65,090 |
galaxy-genome-annotation/python-apollo | apollo/__init__.py | accessible_organisms | def accessible_organisms(user, orgs):
"""Get the list of organisms accessible to a user, filtered by `orgs`"""
permission_map = {
x['organism']: x['permissions']
for x in user.organismPermissions
if 'WRITE' in x['permissions'] or
'READ' in x['permissions'] or
'ADMINISTRAT... | python | def accessible_organisms(user, orgs):
"""Get the list of organisms accessible to a user, filtered by `orgs`"""
permission_map = {
x['organism']: x['permissions']
for x in user.organismPermissions
if 'WRITE' in x['permissions'] or
'READ' in x['permissions'] or
'ADMINISTRAT... | [
"def",
"accessible_organisms",
"(",
"user",
",",
"orgs",
")",
":",
"permission_map",
"=",
"{",
"x",
"[",
"'organism'",
"]",
":",
"x",
"[",
"'permissions'",
"]",
"for",
"x",
"in",
"user",
".",
"organismPermissions",
"if",
"'WRITE'",
"in",
"x",
"[",
"'perm... | Get the list of organisms accessible to a user, filtered by `orgs` | [
"Get",
"the",
"list",
"of",
"organisms",
"accessible",
"to",
"a",
"user",
"filtered",
"by",
"orgs"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/__init__.py#L65-L83 | train | 65,091 |
cytomine/Cytomine-python-client | cytomine/cytomine.py | Cytomine.connect | def connect(cls, host, public_key, private_key, verbose=0, use_cache=True):
"""
Connect the client with the given host and the provided credentials.
Parameters
----------
host : str
The Cytomine host (without protocol).
public_key : str
The Cytomi... | python | def connect(cls, host, public_key, private_key, verbose=0, use_cache=True):
"""
Connect the client with the given host and the provided credentials.
Parameters
----------
host : str
The Cytomine host (without protocol).
public_key : str
The Cytomi... | [
"def",
"connect",
"(",
"cls",
",",
"host",
",",
"public_key",
",",
"private_key",
",",
"verbose",
"=",
"0",
",",
"use_cache",
"=",
"True",
")",
":",
"return",
"cls",
"(",
"host",
",",
"public_key",
",",
"private_key",
",",
"verbose",
",",
"use_cache",
... | Connect the client with the given host and the provided credentials.
Parameters
----------
host : str
The Cytomine host (without protocol).
public_key : str
The Cytomine public key.
private_key : str
The Cytomine private key.
verbose :... | [
"Connect",
"the",
"client",
"with",
"the",
"given",
"host",
"and",
"the",
"provided",
"credentials",
"."
] | bac19722b900dd32c6cfd6bdb9354fc784d33bc4 | https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/cytomine.py#L151-L173 | train | 65,092 |
cytomine/Cytomine-python-client | cytomine/cytomine.py | Cytomine.connect_from_cli | def connect_from_cli(cls, argv, use_cache=True):
"""
Connect with data taken from a command line interface.
Parameters
----------
argv: list
Command line parameters (executable name excluded)
use_cache : bool
True to use HTTP cache, False otherwis... | python | def connect_from_cli(cls, argv, use_cache=True):
"""
Connect with data taken from a command line interface.
Parameters
----------
argv: list
Command line parameters (executable name excluded)
use_cache : bool
True to use HTTP cache, False otherwis... | [
"def",
"connect_from_cli",
"(",
"cls",
",",
"argv",
",",
"use_cache",
"=",
"True",
")",
":",
"argparse",
"=",
"cls",
".",
"_add_cytomine_cli_args",
"(",
"ArgumentParser",
"(",
")",
")",
"params",
",",
"_",
"=",
"argparse",
".",
"parse_known_args",
"(",
"ar... | Connect with data taken from a command line interface.
Parameters
----------
argv: list
Command line parameters (executable name excluded)
use_cache : bool
True to use HTTP cache, False otherwise.
Returns
-------
client : Cytomine
... | [
"Connect",
"with",
"data",
"taken",
"from",
"a",
"command",
"line",
"interface",
"."
] | bac19722b900dd32c6cfd6bdb9354fc784d33bc4 | https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/cytomine.py#L176-L201 | train | 65,093 |
cytomine/Cytomine-python-client | cytomine/cytomine.py | Cytomine._parse_url | def _parse_url(host, provided_protocol=None):
"""
Process the provided host and protocol to return them in a standardized
way that can be subsequently used by Cytomine methods.
If the protocol is not specified, HTTP is the default.
Only HTTP and HTTPS schemes are supported.
... | python | def _parse_url(host, provided_protocol=None):
"""
Process the provided host and protocol to return them in a standardized
way that can be subsequently used by Cytomine methods.
If the protocol is not specified, HTTP is the default.
Only HTTP and HTTPS schemes are supported.
... | [
"def",
"_parse_url",
"(",
"host",
",",
"provided_protocol",
"=",
"None",
")",
":",
"protocol",
"=",
"\"http\"",
"# default protocol",
"if",
"host",
".",
"startswith",
"(",
"\"http://\"",
")",
":",
"protocol",
"=",
"\"http\"",
"elif",
"host",
".",
"startswith",... | Process the provided host and protocol to return them in a standardized
way that can be subsequently used by Cytomine methods.
If the protocol is not specified, HTTP is the default.
Only HTTP and HTTPS schemes are supported.
Parameters
----------
host: str
Th... | [
"Process",
"the",
"provided",
"host",
"and",
"protocol",
"to",
"return",
"them",
"in",
"a",
"standardized",
"way",
"that",
"can",
"be",
"subsequently",
"used",
"by",
"Cytomine",
"methods",
".",
"If",
"the",
"protocol",
"is",
"not",
"specified",
"HTTP",
"is",... | bac19722b900dd32c6cfd6bdb9354fc784d33bc4 | https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/cytomine.py#L234-L276 | train | 65,094 |
cytomine/Cytomine-python-client | cytomine/cytomine.py | Cytomine.upload_crop | def upload_crop(self, ims_host, filename, id_annot, id_storage,
id_project=None, sync=False, protocol=None):
"""
Upload the crop associated with an annotation as a new image.
Parameters
----------
ims_host: str
Cytomine IMS host, with or without the ... | python | def upload_crop(self, ims_host, filename, id_annot, id_storage,
id_project=None, sync=False, protocol=None):
"""
Upload the crop associated with an annotation as a new image.
Parameters
----------
ims_host: str
Cytomine IMS host, with or without the ... | [
"def",
"upload_crop",
"(",
"self",
",",
"ims_host",
",",
"filename",
",",
"id_annot",
",",
"id_storage",
",",
"id_project",
"=",
"None",
",",
"sync",
"=",
"False",
",",
"protocol",
"=",
"None",
")",
":",
"if",
"not",
"protocol",
":",
"protocol",
"=",
"... | Upload the crop associated with an annotation as a new image.
Parameters
----------
ims_host: str
Cytomine IMS host, with or without the protocol
filename: str
Filename to give to the newly created image
id_annot: int
Identifier of the annotat... | [
"Upload",
"the",
"crop",
"associated",
"with",
"an",
"annotation",
"as",
"a",
"new",
"image",
"."
] | bac19722b900dd32c6cfd6bdb9354fc784d33bc4 | https://github.com/cytomine/Cytomine-python-client/blob/bac19722b900dd32c6cfd6bdb9354fc784d33bc4/cytomine/cytomine.py#L594-L655 | train | 65,095 |
galaxy-genome-annotation/python-apollo | apollo/cannedcomments/__init__.py | CannedCommentsClient.show_comment | def show_comment(self, value):
"""
Get a specific canned comment
:type value: str
:param value: Canned comment to show
:rtype: dict
:return: A dictionnary containing canned comment description
"""
comments = self.get_comments()
comments = [x for ... | python | def show_comment(self, value):
"""
Get a specific canned comment
:type value: str
:param value: Canned comment to show
:rtype: dict
:return: A dictionnary containing canned comment description
"""
comments = self.get_comments()
comments = [x for ... | [
"def",
"show_comment",
"(",
"self",
",",
"value",
")",
":",
"comments",
"=",
"self",
".",
"get_comments",
"(",
")",
"comments",
"=",
"[",
"x",
"for",
"x",
"in",
"comments",
"if",
"x",
"[",
"'comment'",
"]",
"==",
"value",
"]",
"if",
"len",
"(",
"co... | Get a specific canned comment
:type value: str
:param value: Canned comment to show
:rtype: dict
:return: A dictionnary containing canned comment description | [
"Get",
"a",
"specific",
"canned",
"comment"
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/cannedcomments/__init__.py#L39-L54 | train | 65,096 |
galaxy-genome-annotation/python-apollo | arrow/cli.py | arrow | def arrow(ctx, apollo_instance, verbose, log_level):
"""Command line wrappers around Apollo functions. While this sounds
unexciting, with arrow and jq you can easily build powerful command line
scripts."""
set_logging_level(log_level)
# We abuse this, knowing that calls to one will fail.
try:
... | python | def arrow(ctx, apollo_instance, verbose, log_level):
"""Command line wrappers around Apollo functions. While this sounds
unexciting, with arrow and jq you can easily build powerful command line
scripts."""
set_logging_level(log_level)
# We abuse this, knowing that calls to one will fail.
try:
... | [
"def",
"arrow",
"(",
"ctx",
",",
"apollo_instance",
",",
"verbose",
",",
"log_level",
")",
":",
"set_logging_level",
"(",
"log_level",
")",
"# We abuse this, knowing that calls to one will fail.",
"try",
":",
"ctx",
".",
"gi",
"=",
"get_apollo_instance",
"(",
"apoll... | Command line wrappers around Apollo functions. While this sounds
unexciting, with arrow and jq you can easily build powerful command line
scripts. | [
"Command",
"line",
"wrappers",
"around",
"Apollo",
"functions",
".",
"While",
"this",
"sounds",
"unexciting",
"with",
"arrow",
"and",
"jq",
"you",
"can",
"easily",
"build",
"powerful",
"command",
"line",
"scripts",
"."
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/arrow/cli.py#L134-L147 | train | 65,097 |
galaxy-genome-annotation/python-apollo | arrow/cli.py | json_loads | def json_loads(data):
"""Load json data, allowing - to represent stdin."""
if data is None:
return ""
if data == "-":
return json.load(sys.stdin)
elif os.path.exists(data):
with open(data, 'r') as handle:
return json.load(handle)
else:
return json.loads(d... | python | def json_loads(data):
"""Load json data, allowing - to represent stdin."""
if data is None:
return ""
if data == "-":
return json.load(sys.stdin)
elif os.path.exists(data):
with open(data, 'r') as handle:
return json.load(handle)
else:
return json.loads(d... | [
"def",
"json_loads",
"(",
"data",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"\"\"",
"if",
"data",
"==",
"\"-\"",
":",
"return",
"json",
".",
"load",
"(",
"sys",
".",
"stdin",
")",
"elif",
"os",
".",
"path",
".",
"exists",
"(",
"data",
... | Load json data, allowing - to represent stdin. | [
"Load",
"json",
"data",
"allowing",
"-",
"to",
"represent",
"stdin",
"."
] | 2bc9991302abe4402ec2885dcaac35915475b387 | https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/arrow/cli.py#L150-L161 | train | 65,098 |
maykinmedia/django-timeline-logger | timeline_logger/management/commands/report_mailing.py | Command.get_queryset | def get_queryset(self, **options):
"""
Filters the list of log objects to display
"""
days = options.get('days')
queryset = TimelineLog.objects.order_by('-timestamp')
if days:
try:
start = timezone.now() - timedelta(days=days)
excep... | python | def get_queryset(self, **options):
"""
Filters the list of log objects to display
"""
days = options.get('days')
queryset = TimelineLog.objects.order_by('-timestamp')
if days:
try:
start = timezone.now() - timedelta(days=days)
excep... | [
"def",
"get_queryset",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"days",
"=",
"options",
".",
"get",
"(",
"'days'",
")",
"queryset",
"=",
"TimelineLog",
".",
"objects",
".",
"order_by",
"(",
"'-timestamp'",
")",
"if",
"days",
":",
"try",
":",
... | Filters the list of log objects to display | [
"Filters",
"the",
"list",
"of",
"log",
"objects",
"to",
"display"
] | 1bc67b6283eb94c84e0936e3a882e1b63cfb5ed3 | https://github.com/maykinmedia/django-timeline-logger/blob/1bc67b6283eb94c84e0936e3a882e1b63cfb5ed3/timeline_logger/management/commands/report_mailing.py#L47-L61 | train | 65,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.