repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
estilen/simplebrowser | simplebrowser/browser.py | SimpleBrowser.post | def post(self, **kwargs):
"""Send a POST request to the currently loaded website's URL.
The browser will automatically fill out the form. If `data` dict has
been passed into ``kwargs``, the contained input values will override
the automatically filled out values.
Returns:
... | python | def post(self, **kwargs):
"""Send a POST request to the currently loaded website's URL.
The browser will automatically fill out the form. If `data` dict has
been passed into ``kwargs``, the contained input values will override
the automatically filled out values.
Returns:
... | [
"def",
"post",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_url",
"is",
"None",
":",
"raise",
"NoWebsiteLoadedError",
"(",
"'request submission requires a loaded website'",
")",
"data",
"=",
"kwargs",
".",
"get",
"(",
"'data'",
",",
... | Send a POST request to the currently loaded website's URL.
The browser will automatically fill out the form. If `data` dict has
been passed into ``kwargs``, the contained input values will override
the automatically filled out values.
Returns:
`Response` object of a success... | [
"Send",
"a",
"POST",
"request",
"to",
"the",
"currently",
"loaded",
"website",
"s",
"URL",
"."
] | train | https://github.com/estilen/simplebrowser/blob/76c1c0d770f8a209a7a32fa65ed46f9d6e60f91b/simplebrowser/browser.py#L97-L122 |
tBaxter/tango-shared-core | build/lib/tango_shared/views.py | build_howto | def build_howto(request=None):
"""
Searches for "how_to.md" files in app directories.
Creates user-friendly admin how-to section from apps that have them.
"""
how_tos = {}
for app in settings.INSTALLED_APPS:
mod = import_module(app)
app_dir = os.path.dirname(mod.__file__)
... | python | def build_howto(request=None):
"""
Searches for "how_to.md" files in app directories.
Creates user-friendly admin how-to section from apps that have them.
"""
how_tos = {}
for app in settings.INSTALLED_APPS:
mod = import_module(app)
app_dir = os.path.dirname(mod.__file__)
... | [
"def",
"build_howto",
"(",
"request",
"=",
"None",
")",
":",
"how_tos",
"=",
"{",
"}",
"for",
"app",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"mod",
"=",
"import_module",
"(",
"app",
")",
"app_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"... | Searches for "how_to.md" files in app directories.
Creates user-friendly admin how-to section from apps that have them. | [
"Searches",
"for",
"how_to",
".",
"md",
"files",
"in",
"app",
"directories",
".",
"Creates",
"user",
"-",
"friendly",
"admin",
"how",
"-",
"to",
"section",
"from",
"apps",
"that",
"have",
"them",
"."
] | train | https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/views.py#L41-L57 |
armstrong/armstrong.apps.related_content | armstrong/apps/related_content/admin.py | formfield_for_foreignkey_helper | def formfield_for_foreignkey_helper(inline, *args, **kwargs):
"""
The implementation for ``RelatedContentInline.formfield_for_foreignkey``
This takes the takes all of the ``args`` and ``kwargs`` from the call to
``formfield_for_foreignkey`` and operates on this. It returns the updated
``args`` and... | python | def formfield_for_foreignkey_helper(inline, *args, **kwargs):
"""
The implementation for ``RelatedContentInline.formfield_for_foreignkey``
This takes the takes all of the ``args`` and ``kwargs`` from the call to
``formfield_for_foreignkey`` and operates on this. It returns the updated
``args`` and... | [
"def",
"formfield_for_foreignkey_helper",
"(",
"inline",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"db_field",
"=",
"args",
"[",
"0",
"]",
"if",
"db_field",
".",
"name",
"!=",
"\"related_type\"",
":",
"return",
"args",
",",
"kwargs",
"initial_fi... | The implementation for ``RelatedContentInline.formfield_for_foreignkey``
This takes the takes all of the ``args`` and ``kwargs`` from the call to
``formfield_for_foreignkey`` and operates on this. It returns the updated
``args`` and ``kwargs`` to be passed on to ``super``.
This is solely an implement... | [
"The",
"implementation",
"for",
"RelatedContentInline",
".",
"formfield_for_foreignkey"
] | train | https://github.com/armstrong/armstrong.apps.related_content/blob/f57b6908d3c76c4a44b2241c676ab5d86391106c/armstrong/apps/related_content/admin.py#L46-L68 |
neithere/django-navigation | navigation/decorators.py | breadcrumb | def breadcrumb(crumb, coerce_to=None):
"""
Usage::
from navigation.decorators import breadcrumb
@breadcrumb('greeting')
def some_view(request):
return 'Hello world!'
@breadcrumb(lambda request: u'greeting for %s' % request.user.username)
def some_view(reque... | python | def breadcrumb(crumb, coerce_to=None):
"""
Usage::
from navigation.decorators import breadcrumb
@breadcrumb('greeting')
def some_view(request):
return 'Hello world!'
@breadcrumb(lambda request: u'greeting for %s' % request.user.username)
def some_view(reque... | [
"def",
"breadcrumb",
"(",
"crumb",
",",
"coerce_to",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"view",
")",
":",
"@",
"wraps",
"(",
"view",
")",
"def",
"inner",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"v... | Usage::
from navigation.decorators import breadcrumb
@breadcrumb('greeting')
def some_view(request):
return 'Hello world!'
@breadcrumb(lambda request: u'greeting for %s' % request.user.username)
def some_view(request):
return 'Hello %s!' % request.user.... | [
"Usage",
"::"
] | train | https://github.com/neithere/django-navigation/blob/aff8d671a8431c84dde65cba6236ea8c16a08b4d/navigation/decorators.py#L18-L59 |
DasIch/argvard | argvard/signature.py | Signature.from_string | def from_string(cls, string, option=True):
"""
Returns a :class:`Signature` object based on the given `string`. If
`option` is `True`, repetitions or optional patterns will not be
allowed.
If the `string` cannot be parsed, :exc:`InvalidSignature` is raised.
"""
r... | python | def from_string(cls, string, option=True):
"""
Returns a :class:`Signature` object based on the given `string`. If
`option` is `True`, repetitions or optional patterns will not be
allowed.
If the `string` cannot be parsed, :exc:`InvalidSignature` is raised.
"""
r... | [
"def",
"from_string",
"(",
"cls",
",",
"string",
",",
"option",
"=",
"True",
")",
":",
"return",
"cls",
"(",
"_parse_signature",
"(",
"string",
",",
"option",
"=",
"option",
")",
")"
] | Returns a :class:`Signature` object based on the given `string`. If
`option` is `True`, repetitions or optional patterns will not be
allowed.
If the `string` cannot be parsed, :exc:`InvalidSignature` is raised. | [
"Returns",
"a",
":",
"class",
":",
"Signature",
"object",
"based",
"on",
"the",
"given",
"string",
".",
"If",
"option",
"is",
"True",
"repetitions",
"or",
"optional",
"patterns",
"will",
"not",
"be",
"allowed",
"."
] | train | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/signature.py#L151-L159 |
DasIch/argvard | argvard/signature.py | Signature.usage | def usage(self):
"""
A usage string that describes the signature.
"""
return u' '.join(u'<%s>' % pattern.usage for pattern in self.patterns) | python | def usage(self):
"""
A usage string that describes the signature.
"""
return u' '.join(u'<%s>' % pattern.usage for pattern in self.patterns) | [
"def",
"usage",
"(",
"self",
")",
":",
"return",
"u' '",
".",
"join",
"(",
"u'<%s>'",
"%",
"pattern",
".",
"usage",
"for",
"pattern",
"in",
"self",
".",
"patterns",
")"
] | A usage string that describes the signature. | [
"A",
"usage",
"string",
"that",
"describes",
"the",
"signature",
"."
] | train | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/signature.py#L165-L169 |
DasIch/argvard | argvard/signature.py | Signature.parse | def parse(self, argv):
"""
Parses the given `argv` and returns a dictionary mapping argument names
to the values found in `argv`.
"""
rv = {}
for pattern in self.patterns:
pattern.apply(rv, argv)
return rv | python | def parse(self, argv):
"""
Parses the given `argv` and returns a dictionary mapping argument names
to the values found in `argv`.
"""
rv = {}
for pattern in self.patterns:
pattern.apply(rv, argv)
return rv | [
"def",
"parse",
"(",
"self",
",",
"argv",
")",
":",
"rv",
"=",
"{",
"}",
"for",
"pattern",
"in",
"self",
".",
"patterns",
":",
"pattern",
".",
"apply",
"(",
"rv",
",",
"argv",
")",
"return",
"rv"
] | Parses the given `argv` and returns a dictionary mapping argument names
to the values found in `argv`. | [
"Parses",
"the",
"given",
"argv",
"and",
"returns",
"a",
"dictionary",
"mapping",
"argument",
"names",
"to",
"the",
"values",
"found",
"in",
"argv",
"."
] | train | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/signature.py#L171-L179 |
almcc/cinder-data | cinder_data/cache.py | MemoryCache.get_record | def get_record(self, name, record_id):
"""Retrieve a record with a given type name and record id.
Args:
name (string): The name which the record is stored under.
record_id (int): The id of the record requested.
Returns:
:class:`cinder_data.model.CinderModel`... | python | def get_record(self, name, record_id):
"""Retrieve a record with a given type name and record id.
Args:
name (string): The name which the record is stored under.
record_id (int): The id of the record requested.
Returns:
:class:`cinder_data.model.CinderModel`... | [
"def",
"get_record",
"(",
"self",
",",
"name",
",",
"record_id",
")",
":",
"if",
"name",
"in",
"self",
".",
"_cache",
":",
"if",
"record_id",
"in",
"self",
".",
"_cache",
"[",
"name",
"]",
":",
"return",
"self",
".",
"_cache",
"[",
"name",
"]",
"["... | Retrieve a record with a given type name and record id.
Args:
name (string): The name which the record is stored under.
record_id (int): The id of the record requested.
Returns:
:class:`cinder_data.model.CinderModel`: The cached model. | [
"Retrieve",
"a",
"record",
"with",
"a",
"given",
"type",
"name",
"and",
"record",
"id",
"."
] | train | https://github.com/almcc/cinder-data/blob/4159a5186c4b4fc32354749892e86130530f6ec5/cinder_data/cache.py#L55-L67 |
almcc/cinder-data | cinder_data/cache.py | MemoryCache.get_records | def get_records(self, name):
"""Return all the records for the given name in the cache.
Args:
name (string): The name which the required models are stored under.
Returns:
list: A list of :class:`cinder_data.model.CinderModel` models.
"""
if name in self.... | python | def get_records(self, name):
"""Return all the records for the given name in the cache.
Args:
name (string): The name which the required models are stored under.
Returns:
list: A list of :class:`cinder_data.model.CinderModel` models.
"""
if name in self.... | [
"def",
"get_records",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_cache",
":",
"return",
"self",
".",
"_cache",
"[",
"name",
"]",
".",
"values",
"(",
")",
"else",
":",
"return",
"[",
"]"
] | Return all the records for the given name in the cache.
Args:
name (string): The name which the required models are stored under.
Returns:
list: A list of :class:`cinder_data.model.CinderModel` models. | [
"Return",
"all",
"the",
"records",
"for",
"the",
"given",
"name",
"in",
"the",
"cache",
"."
] | train | https://github.com/almcc/cinder-data/blob/4159a5186c4b4fc32354749892e86130530f6ec5/cinder_data/cache.py#L69-L81 |
almcc/cinder-data | cinder_data/cache.py | MemoryCache.set_record | def set_record(self, name, record_id, record):
"""Save a record into the cache.
Args:
name (string): The name to save the model under.
record_id (int): The record id.
record (:class:`cinder_data.model.CinderModel`): The model
"""
if name not in self._... | python | def set_record(self, name, record_id, record):
"""Save a record into the cache.
Args:
name (string): The name to save the model under.
record_id (int): The record id.
record (:class:`cinder_data.model.CinderModel`): The model
"""
if name not in self._... | [
"def",
"set_record",
"(",
"self",
",",
"name",
",",
"record_id",
",",
"record",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_cache",
":",
"self",
".",
"_cache",
"[",
"name",
"]",
"=",
"{",
"}",
"self",
".",
"_cache",
"[",
"name",
"]",
"[",... | Save a record into the cache.
Args:
name (string): The name to save the model under.
record_id (int): The record id.
record (:class:`cinder_data.model.CinderModel`): The model | [
"Save",
"a",
"record",
"into",
"the",
"cache",
"."
] | train | https://github.com/almcc/cinder-data/blob/4159a5186c4b4fc32354749892e86130530f6ec5/cinder_data/cache.py#L83-L93 |
mayfield/shellish | shellish/data.py | hone_cache | def hone_cache(maxsize=128, maxage=None, refineby='startswith',
store_partials=False):
""" A caching decorator that follows after the style of lru_cache. Calls
that are sharper than previous requests are returned from the cache after
honing in on the requested results using the `refineby` tec... | python | def hone_cache(maxsize=128, maxage=None, refineby='startswith',
store_partials=False):
""" A caching decorator that follows after the style of lru_cache. Calls
that are sharper than previous requests are returned from the cache after
honing in on the requested results using the `refineby` tec... | [
"def",
"hone_cache",
"(",
"maxsize",
"=",
"128",
",",
"maxage",
"=",
"None",
",",
"refineby",
"=",
"'startswith'",
",",
"store_partials",
"=",
"False",
")",
":",
"if",
"not",
"callable",
"(",
"refineby",
")",
":",
"finder",
"=",
"hone_cache_finders",
"[",
... | A caching decorator that follows after the style of lru_cache. Calls
that are sharper than previous requests are returned from the cache after
honing in on the requested results using the `refineby` technique.
The `refineby` technique can be `startswith`, `container` or a user
defined function used to ... | [
"A",
"caching",
"decorator",
"that",
"follows",
"after",
"the",
"style",
"of",
"lru_cache",
".",
"Calls",
"that",
"are",
"sharper",
"than",
"previous",
"requests",
"are",
"returned",
"from",
"the",
"cache",
"after",
"honing",
"in",
"on",
"the",
"requested",
... | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L96-L133 |
mayfield/shellish | shellish/data.py | make_hone_cache_wrapper | def make_hone_cache_wrapper(inner_func, maxsize, maxage, finder,
store_partials):
""" Keeps a cache of requests we've already made and use that for
generating results if possible. If the user asked for a root prior
to this call we can use it to skip a new lookup using `finder`. ... | python | def make_hone_cache_wrapper(inner_func, maxsize, maxage, finder,
store_partials):
""" Keeps a cache of requests we've already made and use that for
generating results if possible. If the user asked for a root prior
to this call we can use it to skip a new lookup using `finder`. ... | [
"def",
"make_hone_cache_wrapper",
"(",
"inner_func",
",",
"maxsize",
",",
"maxage",
",",
"finder",
",",
"store_partials",
")",
":",
"hits",
"=",
"misses",
"=",
"partials",
"=",
"0",
"cache",
"=",
"TTLMapping",
"(",
"maxsize",
",",
"maxage",
")",
"def",
"wr... | Keeps a cache of requests we've already made and use that for
generating results if possible. If the user asked for a root prior
to this call we can use it to skip a new lookup using `finder`. A
top-level lookup will effectively serves as a global cache. | [
"Keeps",
"a",
"cache",
"of",
"requests",
"we",
"ve",
"already",
"made",
"and",
"use",
"that",
"for",
"generating",
"results",
"if",
"possible",
".",
"If",
"the",
"user",
"asked",
"for",
"a",
"root",
"prior",
"to",
"this",
"call",
"we",
"can",
"use",
"i... | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L151-L204 |
mayfield/shellish | shellish/data.py | ttl_cache | def ttl_cache(maxage, maxsize=128):
""" A time-to-live caching decorator that follows after the style of
lru_cache. The `maxage` argument is time-to-live in seconds for each
cache result. Any cache entries over the maxage are lazily replaced. """
def decorator(inner_func):
wrapper = make_ttl_... | python | def ttl_cache(maxage, maxsize=128):
""" A time-to-live caching decorator that follows after the style of
lru_cache. The `maxage` argument is time-to-live in seconds for each
cache result. Any cache entries over the maxage are lazily replaced. """
def decorator(inner_func):
wrapper = make_ttl_... | [
"def",
"ttl_cache",
"(",
"maxage",
",",
"maxsize",
"=",
"128",
")",
":",
"def",
"decorator",
"(",
"inner_func",
")",
":",
"wrapper",
"=",
"make_ttl_cache_wrapper",
"(",
"inner_func",
",",
"maxage",
",",
"maxsize",
")",
"return",
"functools",
".",
"update_wra... | A time-to-live caching decorator that follows after the style of
lru_cache. The `maxage` argument is time-to-live in seconds for each
cache result. Any cache entries over the maxage are lazily replaced. | [
"A",
"time",
"-",
"to",
"-",
"live",
"caching",
"decorator",
"that",
"follows",
"after",
"the",
"style",
"of",
"lru_cache",
".",
"The",
"maxage",
"argument",
"is",
"time",
"-",
"to",
"-",
"live",
"in",
"seconds",
"for",
"each",
"cache",
"result",
".",
... | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L207-L215 |
mayfield/shellish | shellish/data.py | make_ttl_cache_wrapper | def make_ttl_cache_wrapper(inner_func, maxage, maxsize, typed=False):
""" Use the function signature as a key for a ttl mapping. Any misses
will defer to the wrapped function and its result is stored for future
calls. """
hits = misses = 0
cache = TTLMapping(maxsize, maxage)
def wrapper(*args... | python | def make_ttl_cache_wrapper(inner_func, maxage, maxsize, typed=False):
""" Use the function signature as a key for a ttl mapping. Any misses
will defer to the wrapped function and its result is stored for future
calls. """
hits = misses = 0
cache = TTLMapping(maxsize, maxage)
def wrapper(*args... | [
"def",
"make_ttl_cache_wrapper",
"(",
"inner_func",
",",
"maxage",
",",
"maxsize",
",",
"typed",
"=",
"False",
")",
":",
"hits",
"=",
"misses",
"=",
"0",
"cache",
"=",
"TTLMapping",
"(",
"maxsize",
",",
"maxage",
")",
"def",
"wrapper",
"(",
"*",
"args",
... | Use the function signature as a key for a ttl mapping. Any misses
will defer to the wrapped function and its result is stored for future
calls. | [
"Use",
"the",
"function",
"signature",
"as",
"a",
"key",
"for",
"a",
"ttl",
"mapping",
".",
"Any",
"misses",
"will",
"defer",
"to",
"the",
"wrapped",
"function",
"and",
"its",
"result",
"is",
"stored",
"for",
"future",
"calls",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L218-L251 |
mayfield/shellish | shellish/data.py | TTLMapping.gc | def gc(self):
""" Garbage collect overflow and/or aged entries. """
manifest = []
overlimit = len(self.data) - self.maxsize \
if self.maxsize is not None else 0
now = self.ttl is not None and self.timer()
for key, entry in self.data.items():
if overlimit >... | python | def gc(self):
""" Garbage collect overflow and/or aged entries. """
manifest = []
overlimit = len(self.data) - self.maxsize \
if self.maxsize is not None else 0
now = self.ttl is not None and self.timer()
for key, entry in self.data.items():
if overlimit >... | [
"def",
"gc",
"(",
"self",
")",
":",
"manifest",
"=",
"[",
"]",
"overlimit",
"=",
"len",
"(",
"self",
".",
"data",
")",
"-",
"self",
".",
"maxsize",
"if",
"self",
".",
"maxsize",
"is",
"not",
"None",
"else",
"0",
"now",
"=",
"self",
".",
"ttl",
... | Garbage collect overflow and/or aged entries. | [
"Garbage",
"collect",
"overflow",
"and",
"/",
"or",
"aged",
"entries",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L77-L90 |
vilmibm/done | done/Commands.py | run | def run(command, options, args):
"""Run the requested command. args is either a list of descriptions or a list of strings to filter by"""
if command == "backend":
subprocess.call(("sqlite3", db_path))
if command == "add":
dp = pdt.Calendar()
due = mktime(dp.parse(options.due)[0]) i... | python | def run(command, options, args):
"""Run the requested command. args is either a list of descriptions or a list of strings to filter by"""
if command == "backend":
subprocess.call(("sqlite3", db_path))
if command == "add":
dp = pdt.Calendar()
due = mktime(dp.parse(options.due)[0]) i... | [
"def",
"run",
"(",
"command",
",",
"options",
",",
"args",
")",
":",
"if",
"command",
"==",
"\"backend\"",
":",
"subprocess",
".",
"call",
"(",
"(",
"\"sqlite3\"",
",",
"db_path",
")",
")",
"if",
"command",
"==",
"\"add\"",
":",
"dp",
"=",
"pdt",
"."... | Run the requested command. args is either a list of descriptions or a list of strings to filter by | [
"Run",
"the",
"requested",
"command",
".",
"args",
"is",
"either",
"a",
"list",
"of",
"descriptions",
"or",
"a",
"list",
"of",
"strings",
"to",
"filter",
"by"
] | train | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/done/Commands.py#L25-L76 |
vilmibm/done | done/Commands.py | match | def match(command, options, args):
"""disambiguate a command (expanding, for eg, lis into list) and validate the number of args passed for it"""
build = ""
possible = commands
for l in command:
build += l
possible = filter(lambda w: w.startswith(build), possible)
if len(possible... | python | def match(command, options, args):
"""disambiguate a command (expanding, for eg, lis into list) and validate the number of args passed for it"""
build = ""
possible = commands
for l in command:
build += l
possible = filter(lambda w: w.startswith(build), possible)
if len(possible... | [
"def",
"match",
"(",
"command",
",",
"options",
",",
"args",
")",
":",
"build",
"=",
"\"\"",
"possible",
"=",
"commands",
"for",
"l",
"in",
"command",
":",
"build",
"+=",
"l",
"possible",
"=",
"filter",
"(",
"lambda",
"w",
":",
"w",
".",
"startswith"... | disambiguate a command (expanding, for eg, lis into list) and validate the number of args passed for it | [
"disambiguate",
"a",
"command",
"(",
"expanding",
"for",
"eg",
"lis",
"into",
"list",
")",
"and",
"validate",
"the",
"number",
"of",
"args",
"passed",
"for",
"it"
] | train | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/done/Commands.py#L84-L103 |
vex1023/vxUtils | vxUtils/PrettyLogger.py | add_console_logger | def add_console_logger(logger, level='info'):
"""
增加console作为日志输入.
"""
logger.setLevel(getattr(logging, level.upper()))
if not logger.handlers:
# Set up color if we are in a tty and curses is installed
color = False
if curses and sys.stderr.isatty():
try:
... | python | def add_console_logger(logger, level='info'):
"""
增加console作为日志输入.
"""
logger.setLevel(getattr(logging, level.upper()))
if not logger.handlers:
# Set up color if we are in a tty and curses is installed
color = False
if curses and sys.stderr.isatty():
try:
... | [
"def",
"add_console_logger",
"(",
"logger",
",",
"level",
"=",
"'info'",
")",
":",
"logger",
".",
"setLevel",
"(",
"getattr",
"(",
"logging",
",",
"level",
".",
"upper",
"(",
")",
")",
")",
"if",
"not",
"logger",
".",
"handlers",
":",
"# Set up color if ... | 增加console作为日志输入. | [
"增加console作为日志输入",
"."
] | train | https://github.com/vex1023/vxUtils/blob/58120a206cf96c4231d1e63d271c9d533d5f0a89/vxUtils/PrettyLogger.py#L80-L99 |
thomasbiddle/Kippt-for-Python | kippt/notifications.py | Notifications.mark_read | def mark_read(self):
""" Mark notifications as read.
CURRENT UNSUPPORTED:
https://github.com/kippt/api-documentation/blob/master/endpoints/notifications/POST_notifications.md
"""
# Obviously remove the exception when Kippt says the support it.
raise NotImplementedError(... | python | def mark_read(self):
""" Mark notifications as read.
CURRENT UNSUPPORTED:
https://github.com/kippt/api-documentation/blob/master/endpoints/notifications/POST_notifications.md
"""
# Obviously remove the exception when Kippt says the support it.
raise NotImplementedError(... | [
"def",
"mark_read",
"(",
"self",
")",
":",
"# Obviously remove the exception when Kippt says the support it.",
"raise",
"NotImplementedError",
"(",
"\"The Kippt API does not yet support marking notifications as read.\"",
")",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"\"acti... | Mark notifications as read.
CURRENT UNSUPPORTED:
https://github.com/kippt/api-documentation/blob/master/endpoints/notifications/POST_notifications.md | [
"Mark",
"notifications",
"as",
"read",
"."
] | train | https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/notifications.py#L32-L50 |
BenDoan/perform | perform.py | _run_program | def _run_program(name, *args, **kwargs):
"""Runs program name with the arguments of *args
:param shell: if true, runs the command in the shell
:type shell: bool
:param return_object: if true, returns a CommandOutput object
:type return_object: bool
:param ro: same as return_object
:type r... | python | def _run_program(name, *args, **kwargs):
"""Runs program name with the arguments of *args
:param shell: if true, runs the command in the shell
:type shell: bool
:param return_object: if true, returns a CommandOutput object
:type return_object: bool
:param ro: same as return_object
:type r... | [
"def",
"_run_program",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"shell",
"=",
"kwargs",
".",
"get",
"(",
"\"shell\"",
",",
"False",
")",
"return_object",
"=",
"kwargs",
".",
"get",
"(",
"\"ro\"",
",",
"False",
")",
"return_ob... | Runs program name with the arguments of *args
:param shell: if true, runs the command in the shell
:type shell: bool
:param return_object: if true, returns a CommandOutput object
:type return_object: bool
:param ro: same as return_object
:type ro: bool
:param no_return: doesn't return re... | [
"Runs",
"program",
"name",
"with",
"the",
"arguments",
"of",
"*",
"args"
] | train | https://github.com/BenDoan/perform/blob/3434c5c68fb7661d74f03404c71bb5fbebe1900f/perform.py#L79-L126 |
BenDoan/perform | perform.py | get_programs | def get_programs():
"""Returns a generator that yields the available executable programs
:returns: a generator that yields the programs available after a refresh_listing()
:rtype: generator
"""
programs = []
os.environ['PATH'] += os.pathsep + os.getcwd()
for p in os.environ['PATH'].split(os... | python | def get_programs():
"""Returns a generator that yields the available executable programs
:returns: a generator that yields the programs available after a refresh_listing()
:rtype: generator
"""
programs = []
os.environ['PATH'] += os.pathsep + os.getcwd()
for p in os.environ['PATH'].split(os... | [
"def",
"get_programs",
"(",
")",
":",
"programs",
"=",
"[",
"]",
"os",
".",
"environ",
"[",
"'PATH'",
"]",
"+=",
"os",
".",
"pathsep",
"+",
"os",
".",
"getcwd",
"(",
")",
"for",
"p",
"in",
"os",
".",
"environ",
"[",
"'PATH'",
"]",
".",
"split",
... | Returns a generator that yields the available executable programs
:returns: a generator that yields the programs available after a refresh_listing()
:rtype: generator | [
"Returns",
"a",
"generator",
"that",
"yields",
"the",
"available",
"executable",
"programs"
] | train | https://github.com/BenDoan/perform/blob/3434c5c68fb7661d74f03404c71bb5fbebe1900f/perform.py#L128-L140 |
BenDoan/perform | perform.py | _underscore_run_program | def _underscore_run_program(name, *args, **kwargs):
"""Runs the 'name' program, use this if there are illegal python method characters in the program name
>>> _underscore_run_program("echo", "Hello")
'Hello'
>>> _underscore_run_program("echo", "Hello", return_object=True).stdout
'Hello'
>>> _un... | python | def _underscore_run_program(name, *args, **kwargs):
"""Runs the 'name' program, use this if there are illegal python method characters in the program name
>>> _underscore_run_program("echo", "Hello")
'Hello'
>>> _underscore_run_program("echo", "Hello", return_object=True).stdout
'Hello'
>>> _un... | [
"def",
"_underscore_run_program",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"in",
"get_programs",
"(",
")",
"or",
"kwargs",
".",
"get",
"(",
"\"shell\"",
",",
"False",
")",
":",
"return",
"_run_program",
"(",
"name... | Runs the 'name' program, use this if there are illegal python method characters in the program name
>>> _underscore_run_program("echo", "Hello")
'Hello'
>>> _underscore_run_program("echo", "Hello", return_object=True).stdout
'Hello'
>>> _underscore_run_program("echo", "Hello", ro=True).stdout
'... | [
"Runs",
"the",
"name",
"program",
"use",
"this",
"if",
"there",
"are",
"illegal",
"python",
"method",
"characters",
"in",
"the",
"program",
"name"
] | train | https://github.com/BenDoan/perform/blob/3434c5c68fb7661d74f03404c71bb5fbebe1900f/perform.py#L142-L155 |
BenDoan/perform | perform.py | refresh_listing | def refresh_listing():
"""Refreshes the list of programs attached to the perform module from
the path"""
for program in get_programs():
if re.match(r'^[a-zA-Z_][a-zA-Z_0-9]*$', program) is not None:
globals()[program] = partial(_run_program, program)
globals()["_"] = _underscore_run... | python | def refresh_listing():
"""Refreshes the list of programs attached to the perform module from
the path"""
for program in get_programs():
if re.match(r'^[a-zA-Z_][a-zA-Z_0-9]*$', program) is not None:
globals()[program] = partial(_run_program, program)
globals()["_"] = _underscore_run... | [
"def",
"refresh_listing",
"(",
")",
":",
"for",
"program",
"in",
"get_programs",
"(",
")",
":",
"if",
"re",
".",
"match",
"(",
"r'^[a-zA-Z_][a-zA-Z_0-9]*$'",
",",
"program",
")",
"is",
"not",
"None",
":",
"globals",
"(",
")",
"[",
"program",
"]",
"=",
... | Refreshes the list of programs attached to the perform module from
the path | [
"Refreshes",
"the",
"list",
"of",
"programs",
"attached",
"to",
"the",
"perform",
"module",
"from",
"the",
"path"
] | train | https://github.com/BenDoan/perform/blob/3434c5c68fb7661d74f03404c71bb5fbebe1900f/perform.py#L157-L164 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur.load | def load(path=None):
""" Compile le lemmatiseur localement
"""
if path is None:
path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), "data"))
path = os.path.join(path, "compiled.pickle")
with open(path, "rb") as file:
return loa... | python | def load(path=None):
""" Compile le lemmatiseur localement
"""
if path is None:
path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), "data"))
path = os.path.join(path, "compiled.pickle")
with open(path, "rb") as file:
return loa... | [
"def",
"load",
"(",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspat... | Compile le lemmatiseur localement | [
"Compile",
"le",
"lemmatiseur",
"localement"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L62-L69 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur.assims | def assims(self, mot):
""" Cherche si la chaîne a peut subir une assimilation, renvoie cette chaîne éventuellement assimilée.
:param mot: Mot pour lequel on doit vérifier des assimilations
:type mot: str
:return: Mot assimilé
:rtype: str
"""
for replaced, replace... | python | def assims(self, mot):
""" Cherche si la chaîne a peut subir une assimilation, renvoie cette chaîne éventuellement assimilée.
:param mot: Mot pour lequel on doit vérifier des assimilations
:type mot: str
:return: Mot assimilé
:rtype: str
"""
for replaced, replace... | [
"def",
"assims",
"(",
"self",
",",
"mot",
")",
":",
"for",
"replaced",
",",
"replacement",
"in",
"self",
".",
"_assimsq",
".",
"items",
"(",
")",
":",
"if",
"mot",
".",
"startswith",
"(",
"replaced",
")",
":",
"mot",
"=",
"mot",
".",
"replace",
"("... | Cherche si la chaîne a peut subir une assimilation, renvoie cette chaîne éventuellement assimilée.
:param mot: Mot pour lequel on doit vérifier des assimilations
:type mot: str
:return: Mot assimilé
:rtype: str | [
"Cherche",
"si",
"la",
"chaîne",
"a",
"peut",
"subir",
"une",
"assimilation",
"renvoie",
"cette",
"chaîne",
"éventuellement",
"assimilée",
"."
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L78-L90 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur.morpho | def morpho(self, m):
""" Renvoie la chaîne de rang m dans la liste des morphologies donnée par le fichier data/morphos.la
:param m: Indice de morphologie
:type m: int
:return: Chaîne de rang m dans la liste des morphologies donnée par le fichier data/morphos.la
:rtype: str
... | python | def morpho(self, m):
""" Renvoie la chaîne de rang m dans la liste des morphologies donnée par le fichier data/morphos.la
:param m: Indice de morphologie
:type m: int
:return: Chaîne de rang m dans la liste des morphologies donnée par le fichier data/morphos.la
:rtype: str
... | [
"def",
"morpho",
"(",
"self",
",",
"m",
")",
":",
"l",
"=",
"\"fr\"",
"# TODO : Si ajout langue de traduction, il faudra convertir ce qui suit",
"###################",
"# if self._morphos.keys().contains(_cible.mid(0,2))) l = _cible.mid(0,2:",
"# elif (_cible.size() > 4) and (_morphos.ke... | Renvoie la chaîne de rang m dans la liste des morphologies donnée par le fichier data/morphos.la
:param m: Indice de morphologie
:type m: int
:return: Chaîne de rang m dans la liste des morphologies donnée par le fichier data/morphos.la
:rtype: str | [
"Renvoie",
"la",
"chaîne",
"de",
"rang",
"m",
"dans",
"la",
"liste",
"des",
"morphologies",
"donnée",
"par",
"le",
"fichier",
"data",
"/",
"morphos",
".",
"la"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L126-L147 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur.lemmatise_multiple | def lemmatise_multiple(self, string, pos=False, get_lemma_object=False, as_list=True):
""" Lemmatise une liste complète
:param string: Chaîne à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param ... | python | def lemmatise_multiple(self, string, pos=False, get_lemma_object=False, as_list=True):
""" Lemmatise une liste complète
:param string: Chaîne à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param ... | [
"def",
"lemmatise_multiple",
"(",
"self",
",",
"string",
",",
"pos",
"=",
"False",
",",
"get_lemma_object",
"=",
"False",
",",
"as_list",
"=",
"True",
")",
":",
"mots",
"=",
"SPACES",
".",
"split",
"(",
"string",
")",
"resultats",
"=",
"[",
"self",
"."... | Lemmatise une liste complète
:param string: Chaîne à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param as_list: Retrieve a list of generators instead of a list if set to false | [
"Lemmatise",
"une",
"liste",
"complète"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L162-L174 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur._lemmatise_assims | def _lemmatise_assims(self, f, *args, **kwargs):
""" Lemmatise un mot f avec son assimilation
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param results: Current results
"... | python | def _lemmatise_assims(self, f, *args, **kwargs):
""" Lemmatise un mot f avec son assimilation
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param results: Current results
"... | [
"def",
"_lemmatise_assims",
"(",
"self",
",",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"forme_assimilee",
"=",
"self",
".",
"assims",
"(",
"f",
")",
"if",
"forme_assimilee",
"!=",
"f",
":",
"for",
"proposal",
"in",
"self",
".",
"_lem... | Lemmatise un mot f avec son assimilation
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param results: Current results | [
"Lemmatise",
"un",
"mot",
"f",
"avec",
"son",
"assimilation"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L176-L187 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur._lemmatise_roman_numerals | def _lemmatise_roman_numerals(self, form, pos=False, get_lemma_object=False):
""" Lemmatise un mot f si c'est un nombre romain
:param form: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
"""
... | python | def _lemmatise_roman_numerals(self, form, pos=False, get_lemma_object=False):
""" Lemmatise un mot f si c'est un nombre romain
:param form: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
"""
... | [
"def",
"_lemmatise_roman_numerals",
"(",
"self",
",",
"form",
",",
"pos",
"=",
"False",
",",
"get_lemma_object",
"=",
"False",
")",
":",
"if",
"estRomain",
"(",
"form",
")",
":",
"_lemma",
"=",
"Lemme",
"(",
"cle",
"=",
"form",
",",
"graphie_accentuee",
... | Lemmatise un mot f si c'est un nombre romain
:param form: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma | [
"Lemmatise",
"un",
"mot",
"f",
"si",
"c",
"est",
"un",
"nombre",
"romain"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L189-L209 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur._lemmatise_contractions | def _lemmatise_contractions(self, f, *args, **kwargs):
""" Lemmatise un mot f avec sa contraction
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise()
"""
fd = f
for contraction, decontraction in self._contractions.items():
if fd.endswith(co... | python | def _lemmatise_contractions(self, f, *args, **kwargs):
""" Lemmatise un mot f avec sa contraction
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise()
"""
fd = f
for contraction, decontraction in self._contractions.items():
if fd.endswith(co... | [
"def",
"_lemmatise_contractions",
"(",
"self",
",",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"fd",
"=",
"f",
"for",
"contraction",
",",
"decontraction",
"in",
"self",
".",
"_contractions",
".",
"items",
"(",
")",
":",
"if",
"fd",
"."... | Lemmatise un mot f avec sa contraction
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise() | [
"Lemmatise",
"un",
"mot",
"f",
"avec",
"sa",
"contraction"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L211-L225 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur._lemmatise_desassims | def _lemmatise_desassims(self, f, *args, **kwargs):
""" Lemmatise un mot f avec sa désassimilation
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise()
"""
forme_assimilee = self.desassims(f)
if forme_assimilee != f:
for proposal in self._le... | python | def _lemmatise_desassims(self, f, *args, **kwargs):
""" Lemmatise un mot f avec sa désassimilation
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise()
"""
forme_assimilee = self.desassims(f)
if forme_assimilee != f:
for proposal in self._le... | [
"def",
"_lemmatise_desassims",
"(",
"self",
",",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"forme_assimilee",
"=",
"self",
".",
"desassims",
"(",
"f",
")",
"if",
"forme_assimilee",
"!=",
"f",
":",
"for",
"proposal",
"in",
"self",
".",
... | Lemmatise un mot f avec sa désassimilation
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise() | [
"Lemmatise",
"un",
"mot",
"f",
"avec",
"sa",
"désassimilation"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L227-L236 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur._lemmatise_suffixe | def _lemmatise_suffixe(self, f, *args, **kwargs):
""" Lemmatise un mot f si il finit par un suffixe
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise()
"""
for suffixe in self._suffixes:
if f.endswith(suffixe) and suffixe != f:
yiel... | python | def _lemmatise_suffixe(self, f, *args, **kwargs):
""" Lemmatise un mot f si il finit par un suffixe
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise()
"""
for suffixe in self._suffixes:
if f.endswith(suffixe) and suffixe != f:
yiel... | [
"def",
"_lemmatise_suffixe",
"(",
"self",
",",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"suffixe",
"in",
"self",
".",
"_suffixes",
":",
"if",
"f",
".",
"endswith",
"(",
"suffixe",
")",
"and",
"suffixe",
"!=",
"f",
":",
"yiel... | Lemmatise un mot f si il finit par un suffixe
:param f: Mot à lemmatiser
:yield: Match formated like in _lemmatise() | [
"Lemmatise",
"un",
"mot",
"f",
"si",
"il",
"finit",
"par",
"un",
"suffixe"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L238-L246 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur.lemmatise | def lemmatise(self, f, pos=False, get_lemma_object=False, lower=True):
""" Lemmatise un mot f
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param lower: Need to check lowercase ver... | python | def lemmatise(self, f, pos=False, get_lemma_object=False, lower=True):
""" Lemmatise un mot f
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param lower: Need to check lowercase ver... | [
"def",
"lemmatise",
"(",
"self",
",",
"f",
",",
"pos",
"=",
"False",
",",
"get_lemma_object",
"=",
"False",
",",
"lower",
"=",
"True",
")",
":",
"if",
"lower",
":",
"# We do not run numeral on lower",
"yield",
"from",
"self",
".",
"_lemmatise_roman_numerals",
... | Lemmatise un mot f
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param lower: Need to check lowercase version | [
"Lemmatise",
"un",
"mot",
"f"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L248-L270 |
PonteIneptique/collatinus-python | pycollatinus/lemmatiseur.py | Lemmatiseur._lemmatise | def _lemmatise(self, form, pos=False, get_lemma_object=False):
""" Lemmatise un mot f
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param check_assims: Vérifie les assimilations.
... | python | def _lemmatise(self, form, pos=False, get_lemma_object=False):
""" Lemmatise un mot f
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param check_assims: Vérifie les assimilations.
... | [
"def",
"_lemmatise",
"(",
"self",
",",
"form",
",",
"pos",
"=",
"False",
",",
"get_lemma_object",
"=",
"False",
")",
":",
"result",
"=",
"[",
"]",
"if",
"not",
"form",
":",
"return",
"result",
"# formes irrégulières",
"for",
"irr",
"in",
"self",
".",
"... | Lemmatise un mot f
:param f: Mot à lemmatiser
:param pos: Récupère la POS
:param get_lemma_object: Retrieve Lemma object instead of string representation of lemma
:param check_assims: Vérifie les assimilations. | [
"Lemmatise",
"un",
"mot",
"f"
] | train | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L272-L329 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP.connect | def connect(host, port, username, password):
"""Connect and login to an FTP server and return ftplib.FTP object."""
# Instantiate ftplib client
session = ftplib.FTP()
# Connect to host without auth
session.connect(host, port)
# Authenticate connection
session.lo... | python | def connect(host, port, username, password):
"""Connect and login to an FTP server and return ftplib.FTP object."""
# Instantiate ftplib client
session = ftplib.FTP()
# Connect to host without auth
session.connect(host, port)
# Authenticate connection
session.lo... | [
"def",
"connect",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
")",
":",
"# Instantiate ftplib client",
"session",
"=",
"ftplib",
".",
"FTP",
"(",
")",
"# Connect to host without auth",
"session",
".",
"connect",
"(",
"host",
",",
"port",
")",
... | Connect and login to an FTP server and return ftplib.FTP object. | [
"Connect",
"and",
"login",
"to",
"an",
"FTP",
"server",
"and",
"return",
"ftplib",
".",
"FTP",
"object",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L22-L32 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP.get | def get(self, remote, local=None, keep_dir_structure=False):
"""
Download a remote file on the fto sever to a local directory.
:param remote: File path of remote source file
:param local: Directory of local destination directory
:param keep_dir_structure: If True, replicates the... | python | def get(self, remote, local=None, keep_dir_structure=False):
"""
Download a remote file on the fto sever to a local directory.
:param remote: File path of remote source file
:param local: Directory of local destination directory
:param keep_dir_structure: If True, replicates the... | [
"def",
"get",
"(",
"self",
",",
"remote",
",",
"local",
"=",
"None",
",",
"keep_dir_structure",
"=",
"False",
")",
":",
"if",
"local",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"local",
")",
":",
"os",
".",
"chdir",
"(",
"local",
")",
"elif",
... | Download a remote file on the fto sever to a local directory.
:param remote: File path of remote source file
:param local: Directory of local destination directory
:param keep_dir_structure: If True, replicates the remote files folder structure | [
"Download",
"a",
"remote",
"file",
"on",
"the",
"fto",
"sever",
"to",
"a",
"local",
"directory",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L48-L79 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP.chdir | def chdir(self, directory_path, make=False):
"""Change directories and optionally make the directory if it doesn't exist."""
if os.sep in directory_path:
for directory in directory_path.split(os.sep):
if make and not self.directory_exists(directory):
try:
... | python | def chdir(self, directory_path, make=False):
"""Change directories and optionally make the directory if it doesn't exist."""
if os.sep in directory_path:
for directory in directory_path.split(os.sep):
if make and not self.directory_exists(directory):
try:
... | [
"def",
"chdir",
"(",
"self",
",",
"directory_path",
",",
"make",
"=",
"False",
")",
":",
"if",
"os",
".",
"sep",
"in",
"directory_path",
":",
"for",
"directory",
"in",
"directory_path",
".",
"split",
"(",
"os",
".",
"sep",
")",
":",
"if",
"make",
"an... | Change directories and optionally make the directory if it doesn't exist. | [
"Change",
"directories",
"and",
"optionally",
"make",
"the",
"directory",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L81-L93 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP.listdir | def listdir(self, directory_path=None, hidden_files=False):
"""
Return a list of files and directories in a given directory.
:param directory_path: Optional str (defaults to current directory)
:param hidden_files: Include hidden files
:return: Directory listing
"""
... | python | def listdir(self, directory_path=None, hidden_files=False):
"""
Return a list of files and directories in a given directory.
:param directory_path: Optional str (defaults to current directory)
:param hidden_files: Include hidden files
:return: Directory listing
"""
... | [
"def",
"listdir",
"(",
"self",
",",
"directory_path",
"=",
"None",
",",
"hidden_files",
"=",
"False",
")",
":",
"# Change current directory if a directory path is specified, otherwise use current",
"if",
"directory_path",
":",
"self",
".",
"chdir",
"(",
"directory_path",
... | Return a list of files and directories in a given directory.
:param directory_path: Optional str (defaults to current directory)
:param hidden_files: Include hidden files
:return: Directory listing | [
"Return",
"a",
"list",
"of",
"files",
"and",
"directories",
"in",
"a",
"given",
"directory",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L95-L113 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP.delete | def delete(self, file_path):
"""Remove the file named filename from the server."""
if os.sep in file_path:
directory, file_name = file_path.rsplit(os.sep, 1)
self.chdir(directory)
return self.session.delete(file_name)
else:
return self.session.del... | python | def delete(self, file_path):
"""Remove the file named filename from the server."""
if os.sep in file_path:
directory, file_name = file_path.rsplit(os.sep, 1)
self.chdir(directory)
return self.session.delete(file_name)
else:
return self.session.del... | [
"def",
"delete",
"(",
"self",
",",
"file_path",
")",
":",
"if",
"os",
".",
"sep",
"in",
"file_path",
":",
"directory",
",",
"file_name",
"=",
"file_path",
".",
"rsplit",
"(",
"os",
".",
"sep",
",",
"1",
")",
"self",
".",
"chdir",
"(",
"directory",
... | Remove the file named filename from the server. | [
"Remove",
"the",
"file",
"named",
"filename",
"from",
"the",
"server",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L119-L127 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP.directory_exists | def directory_exists(self, directory):
"""Check if directory exists (in current location)"""
file_list = []
self.session.retrlines('LIST', file_list.append)
return any(f.split()[-1] == directory and f.upper().startswith('D') for f in file_list) | python | def directory_exists(self, directory):
"""Check if directory exists (in current location)"""
file_list = []
self.session.retrlines('LIST', file_list.append)
return any(f.split()[-1] == directory and f.upper().startswith('D') for f in file_list) | [
"def",
"directory_exists",
"(",
"self",
",",
"directory",
")",
":",
"file_list",
"=",
"[",
"]",
"self",
".",
"session",
".",
"retrlines",
"(",
"'LIST'",
",",
"file_list",
".",
"append",
")",
"return",
"any",
"(",
"f",
".",
"split",
"(",
")",
"[",
"-"... | Check if directory exists (in current location) | [
"Check",
"if",
"directory",
"exists",
"(",
"in",
"current",
"location",
")"
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L129-L133 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP._retrieve_binary | def _retrieve_binary(self, file_name):
"""Retrieve a file in binary transfer mode."""
with open(file_name, 'wb') as f:
return self.session.retrbinary('RETR ' + file_name, f.write) | python | def _retrieve_binary(self, file_name):
"""Retrieve a file in binary transfer mode."""
with open(file_name, 'wb') as f:
return self.session.retrbinary('RETR ' + file_name, f.write) | [
"def",
"_retrieve_binary",
"(",
"self",
",",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'wb'",
")",
"as",
"f",
":",
"return",
"self",
".",
"session",
".",
"retrbinary",
"(",
"'RETR '",
"+",
"file_name",
",",
"f",
".",
"write",
")"
] | Retrieve a file in binary transfer mode. | [
"Retrieve",
"a",
"file",
"in",
"binary",
"transfer",
"mode",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L139-L142 |
mrstephenneal/dirutility | dirutility/ftp.py | FTP._store_binary | def _store_binary(self, local_path, remote):
"""Store a file in binary via ftp."""
# Destination directory
dst_dir = os.path.dirname(remote)
# Destination file name
dst_file = os.path.basename(remote)
# File upload command
dst_cmd = 'STOR {0}'.format(dst_file)
... | python | def _store_binary(self, local_path, remote):
"""Store a file in binary via ftp."""
# Destination directory
dst_dir = os.path.dirname(remote)
# Destination file name
dst_file = os.path.basename(remote)
# File upload command
dst_cmd = 'STOR {0}'.format(dst_file)
... | [
"def",
"_store_binary",
"(",
"self",
",",
"local_path",
",",
"remote",
")",
":",
"# Destination directory",
"dst_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"remote",
")",
"# Destination file name",
"dst_file",
"=",
"os",
".",
"path",
".",
"basename",
... | Store a file in binary via ftp. | [
"Store",
"a",
"file",
"in",
"binary",
"via",
"ftp",
"."
] | train | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L144-L161 |
krukas/Trionyx | trionyx/trionyx/forms/accounts.py | UserUpdateForm.clean_new_password2 | def clean_new_password2(self):
"""Validate password when set"""
password1 = self.cleaned_data.get('new_password1')
password2 = self.cleaned_data.get('new_password2')
if password1 or password2:
if password1 != password2:
raise forms.ValidationError(
... | python | def clean_new_password2(self):
"""Validate password when set"""
password1 = self.cleaned_data.get('new_password1')
password2 = self.cleaned_data.get('new_password2')
if password1 or password2:
if password1 != password2:
raise forms.ValidationError(
... | [
"def",
"clean_new_password2",
"(",
"self",
")",
":",
"password1",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"'new_password1'",
")",
"password2",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"'new_password2'",
")",
"if",
"password1",
"or",
"pas... | Validate password when set | [
"Validate",
"password",
"when",
"set"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/forms/accounts.py#L69-L80 |
wtsi-hgi/python-baton-wrapper | baton/_baton/_baton_runner.py | BatonRunner.validate_baton_binaries_location | def validate_baton_binaries_location(baton_binaries_directory: str) -> Optional[Exception]:
"""
Validates that the given directory contains the baton binaries required to use the runner.
:param baton_binaries_directory: the directory to check
:return: exception that describes the issue e... | python | def validate_baton_binaries_location(baton_binaries_directory: str) -> Optional[Exception]:
"""
Validates that the given directory contains the baton binaries required to use the runner.
:param baton_binaries_directory: the directory to check
:return: exception that describes the issue e... | [
"def",
"validate_baton_binaries_location",
"(",
"baton_binaries_directory",
":",
"str",
")",
"->",
"Optional",
"[",
"Exception",
"]",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"baton_binaries_directory",
")",
":",
"return",
"ValueError",
"(",
"\"The given ... | Validates that the given directory contains the baton binaries required to use the runner.
:param baton_binaries_directory: the directory to check
:return: exception that describes the issue else `None` if no issues | [
"Validates",
"that",
"the",
"given",
"directory",
"contains",
"the",
"baton",
"binaries",
"required",
"to",
"use",
"the",
"runner",
".",
":",
"param",
"baton_binaries_directory",
":",
"the",
"directory",
"to",
"check",
":",
"return",
":",
"exception",
"that",
... | train | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/_baton_runner.py#L36-L53 |
wtsi-hgi/python-baton-wrapper | baton/_baton/_baton_runner.py | BatonRunner._raise_any_errors_given_in_baton_out | def _raise_any_errors_given_in_baton_out(baton_out_as_json: List[Dict]):
"""
Raises any errors that baton has expressed in its output.
:param baton_out_as_json: the output baton gave as parsed serialization
"""
if not isinstance(baton_out_as_json, list):
baton_out_as_... | python | def _raise_any_errors_given_in_baton_out(baton_out_as_json: List[Dict]):
"""
Raises any errors that baton has expressed in its output.
:param baton_out_as_json: the output baton gave as parsed serialization
"""
if not isinstance(baton_out_as_json, list):
baton_out_as_... | [
"def",
"_raise_any_errors_given_in_baton_out",
"(",
"baton_out_as_json",
":",
"List",
"[",
"Dict",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"baton_out_as_json",
",",
"list",
")",
":",
"baton_out_as_json",
"=",
"[",
"baton_out_as_json",
"]",
"for",
"baton_ite... | Raises any errors that baton has expressed in its output.
:param baton_out_as_json: the output baton gave as parsed serialization | [
"Raises",
"any",
"errors",
"that",
"baton",
"has",
"expressed",
"in",
"its",
"output",
".",
":",
"param",
"baton_out_as_json",
":",
"the",
"output",
"baton",
"gave",
"as",
"parsed",
"serialization"
] | train | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/_baton_runner.py#L56-L78 |
wtsi-hgi/python-baton-wrapper | baton/_baton/_baton_runner.py | BatonRunner.run_baton_query | def run_baton_query(self, baton_binary: BatonBinary, program_arguments: List[str]=None, input_data: Any=None) \
-> List[Dict]:
"""
Runs a baton query.
:param baton_binary: the baton binary to use
:param program_arguments: arguments to give to the baton binary
:param i... | python | def run_baton_query(self, baton_binary: BatonBinary, program_arguments: List[str]=None, input_data: Any=None) \
-> List[Dict]:
"""
Runs a baton query.
:param baton_binary: the baton binary to use
:param program_arguments: arguments to give to the baton binary
:param i... | [
"def",
"run_baton_query",
"(",
"self",
",",
"baton_binary",
":",
"BatonBinary",
",",
"program_arguments",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"input_data",
":",
"Any",
"=",
"None",
")",
"->",
"List",
"[",
"Dict",
"]",
":",
"if",
"program_argu... | Runs a baton query.
:param baton_binary: the baton binary to use
:param program_arguments: arguments to give to the baton binary
:param input_data: input data to the baton binary
:return: parsed serialization returned by baton | [
"Runs",
"a",
"baton",
"query",
".",
":",
"param",
"baton_binary",
":",
"the",
"baton",
"binary",
"to",
"use",
":",
"param",
"program_arguments",
":",
"arguments",
"to",
"give",
"to",
"the",
"baton",
"binary",
":",
"param",
"input_data",
":",
"input",
"data... | train | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/_baton_runner.py#L96-L127 |
wtsi-hgi/python-baton-wrapper | baton/_baton/_baton_runner.py | BatonRunner._run_command | def _run_command(self, arguments: List[str], input_data: Any=None, output_encoding: str="utf-8") -> str:
"""
Run a command as a subprocess.
Ignores errors given over stderr if there is output on stdout (this is the case where baton has been run
correctly and has expressed the error in i... | python | def _run_command(self, arguments: List[str], input_data: Any=None, output_encoding: str="utf-8") -> str:
"""
Run a command as a subprocess.
Ignores errors given over stderr if there is output on stdout (this is the case where baton has been run
correctly and has expressed the error in i... | [
"def",
"_run_command",
"(",
"self",
",",
"arguments",
":",
"List",
"[",
"str",
"]",
",",
"input_data",
":",
"Any",
"=",
"None",
",",
"output_encoding",
":",
"str",
"=",
"\"utf-8\"",
")",
"->",
"str",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"("... | Run a command as a subprocess.
Ignores errors given over stderr if there is output on stdout (this is the case where baton has been run
correctly and has expressed the error in it's JSON out, which can be handled more appropriately upstream to this
method.)
:param arguments: the argumen... | [
"Run",
"a",
"command",
"as",
"a",
"subprocess",
"."
] | train | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/_baton_runner.py#L129-L157 |
inveniosoftware-attic/invenio-knowledge | invenio_knowledge/forms.py | collection_choices | def collection_choices():
"""Return collection choices."""
from invenio_collections.models import Collection
return [(0, _('-None-'))] + [
(c.id, c.name) for c in Collection.query.all()
] | python | def collection_choices():
"""Return collection choices."""
from invenio_collections.models import Collection
return [(0, _('-None-'))] + [
(c.id, c.name) for c in Collection.query.all()
] | [
"def",
"collection_choices",
"(",
")",
":",
"from",
"invenio_collections",
".",
"models",
"import",
"Collection",
"return",
"[",
"(",
"0",
",",
"_",
"(",
"'-None-'",
")",
")",
"]",
"+",
"[",
"(",
"c",
".",
"id",
",",
"c",
".",
"name",
")",
"for",
"... | Return collection choices. | [
"Return",
"collection",
"choices",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/forms.py#L63-L68 |
ministryofjustice/postcodeinfo-client-python | postcodeinfo.py | Postcode.addresses | def addresses(self, fields=None):
"""
List of addresses associated with the postcode.
Addresses are dict objects which look like the following::
{
"uprn": "10033544614",
"organisation_name": "BUCKINGHAM PALACE",
"department_name": "",
... | python | def addresses(self, fields=None):
"""
List of addresses associated with the postcode.
Addresses are dict objects which look like the following::
{
"uprn": "10033544614",
"organisation_name": "BUCKINGHAM PALACE",
"department_name": "",
... | [
"def",
"addresses",
"(",
"self",
",",
"fields",
"=",
"None",
")",
":",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"','",
".",
"join",
"(",
"DEFAULT_ADDRESS_FIELDS",
")",
"if",
"getattr",
"(",
"self",
",",
"'_addresses'",
",",
"None",
")",
"is",
... | List of addresses associated with the postcode.
Addresses are dict objects which look like the following::
{
"uprn": "10033544614",
"organisation_name": "BUCKINGHAM PALACE",
"department_name": "",
"po_box_number": "",
"... | [
"List",
"of",
"addresses",
"associated",
"with",
"the",
"postcode",
".",
"Addresses",
"are",
"dict",
"objects",
"which",
"look",
"like",
"the",
"following",
"::"
] | train | https://github.com/ministryofjustice/postcodeinfo-client-python/blob/8644e1292cdb5d7f2b2eb3c0982b1f97202b24cf/postcodeinfo.py#L138-L177 |
ministryofjustice/postcodeinfo-client-python | postcodeinfo.py | Client._query_api | def _query_api(self, endpoint, **kwargs):
"""
Query the API.
"""
try:
response = requests.get(
'{api}/{endpoint}?{args}'.format(
api=self.url,
endpoint=endpoint,
args=urllib.urlencode(kwargs)),
... | python | def _query_api(self, endpoint, **kwargs):
"""
Query the API.
"""
try:
response = requests.get(
'{api}/{endpoint}?{args}'.format(
api=self.url,
endpoint=endpoint,
args=urllib.urlencode(kwargs)),
... | [
"def",
"_query_api",
"(",
"self",
",",
"endpoint",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'{api}/{endpoint}?{args}'",
".",
"format",
"(",
"api",
"=",
"self",
".",
"url",
",",
"endpoint",
"=",
"endp... | Query the API. | [
"Query",
"the",
"API",
"."
] | train | https://github.com/ministryofjustice/postcodeinfo-client-python/blob/8644e1292cdb5d7f2b2eb3c0982b1f97202b24cf/postcodeinfo.py#L270-L295 |
okzach/bofhexcuse | bofhexcuse/__init__.py | generate_random_string | def generate_random_string(template_dict, key='start'):
"""Generates a random excuse from a simple template dict.
Based off of drow's generator.js (public domain).
Grok it here: http://donjon.bin.sh/code/random/generator.js
Args:
template_dict: Dict with template strings.
key: String w... | python | def generate_random_string(template_dict, key='start'):
"""Generates a random excuse from a simple template dict.
Based off of drow's generator.js (public domain).
Grok it here: http://donjon.bin.sh/code/random/generator.js
Args:
template_dict: Dict with template strings.
key: String w... | [
"def",
"generate_random_string",
"(",
"template_dict",
",",
"key",
"=",
"'start'",
")",
":",
"data",
"=",
"template_dict",
".",
"get",
"(",
"key",
")",
"#if isinstance(data, list):",
"result",
"=",
"random",
".",
"choice",
"(",
"data",
")",
"#else:",
"#result ... | Generates a random excuse from a simple template dict.
Based off of drow's generator.js (public domain).
Grok it here: http://donjon.bin.sh/code/random/generator.js
Args:
template_dict: Dict with template strings.
key: String with the starting index for the dict. (Default: 'start')
Re... | [
"Generates",
"a",
"random",
"excuse",
"from",
"a",
"simple",
"template",
"dict",
"."
] | train | https://github.com/okzach/bofhexcuse/blob/ea241b8a63c4baa44cfb17c6acd47b6e12e822af/bofhexcuse/__init__.py#L14-L39 |
okzach/bofhexcuse | bofhexcuse/__init__.py | bofh_excuse | def bofh_excuse(how_many=1):
"""Generate random BOFH themed technical excuses!
Args:
how_many: Number of excuses to generate. (Default: 1)
Returns:
A list of BOFH excuses.
"""
excuse_path = os.path.join(os.path.dirname(__file__), 'bofh_excuses.json')
with open(excuse_path, 'r'... | python | def bofh_excuse(how_many=1):
"""Generate random BOFH themed technical excuses!
Args:
how_many: Number of excuses to generate. (Default: 1)
Returns:
A list of BOFH excuses.
"""
excuse_path = os.path.join(os.path.dirname(__file__), 'bofh_excuses.json')
with open(excuse_path, 'r'... | [
"def",
"bofh_excuse",
"(",
"how_many",
"=",
"1",
")",
":",
"excuse_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'bofh_excuses.json'",
")",
"with",
"open",
"(",
"excuse_path",
",",
"'r'"... | Generate random BOFH themed technical excuses!
Args:
how_many: Number of excuses to generate. (Default: 1)
Returns:
A list of BOFH excuses. | [
"Generate",
"random",
"BOFH",
"themed",
"technical",
"excuses!"
] | train | https://github.com/okzach/bofhexcuse/blob/ea241b8a63c4baa44cfb17c6acd47b6e12e822af/bofhexcuse/__init__.py#L42-L56 |
shi-cong/PYSTUDY | PYSTUDY/processlib.py | create_process | def create_process(daemon, name, callback, *callbackParams):
"""创建进程
:param daemon: True主进程关闭而关闭, False主进程必须等待子进程结束
:param name: 进程名称
:param callback: 回调函数
:param callbackParams: 回调函数参数
:return: 返回一个进程对象
"""
bp = Process(daemon=daemon, name=name, target=callback, args=callbackParams)
... | python | def create_process(daemon, name, callback, *callbackParams):
"""创建进程
:param daemon: True主进程关闭而关闭, False主进程必须等待子进程结束
:param name: 进程名称
:param callback: 回调函数
:param callbackParams: 回调函数参数
:return: 返回一个进程对象
"""
bp = Process(daemon=daemon, name=name, target=callback, args=callbackParams)
... | [
"def",
"create_process",
"(",
"daemon",
",",
"name",
",",
"callback",
",",
"*",
"callbackParams",
")",
":",
"bp",
"=",
"Process",
"(",
"daemon",
"=",
"daemon",
",",
"name",
"=",
"name",
",",
"target",
"=",
"callback",
",",
"args",
"=",
"callbackParams",
... | 创建进程
:param daemon: True主进程关闭而关闭, False主进程必须等待子进程结束
:param name: 进程名称
:param callback: 回调函数
:param callbackParams: 回调函数参数
:return: 返回一个进程对象 | [
"创建进程",
":",
"param",
"daemon",
":",
"True主进程关闭而关闭",
"False主进程必须等待子进程结束",
":",
"param",
"name",
":",
"进程名称",
":",
"param",
"callback",
":",
"回调函数",
":",
"param",
"callbackParams",
":",
"回调函数参数",
":",
"return",
":",
"返回一个进程对象"
] | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/processlib.py#L8-L17 |
armenzg/pulse_replay | scripts/replay_queue.py | parse_args | def parse_args(argv=None):
"""Parse command line options."""
parser = ArgumentParser()
parser.add_argument('--replay-file', dest="replay_file", type=str, required=True)
options = parser.parse_args(argv)
return options | python | def parse_args(argv=None):
"""Parse command line options."""
parser = ArgumentParser()
parser.add_argument('--replay-file', dest="replay_file", type=str, required=True)
options = parser.parse_args(argv)
return options | [
"def",
"parse_args",
"(",
"argv",
"=",
"None",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'--replay-file'",
",",
"dest",
"=",
"\"replay_file\"",
",",
"type",
"=",
"str",
",",
"required",
"=",
"True",
")",
"o... | Parse command line options. | [
"Parse",
"command",
"line",
"options",
"."
] | train | https://github.com/armenzg/pulse_replay/blob/d3fae9f445aaaeb58d17898a597524375e9bf3ce/scripts/replay_queue.py#L17-L23 |
boatd/python-boatd | boatdclient/boatd_client.py | get_current_waypoints | def get_current_waypoints(boatd=None):
'''
Get the current set of waypoints active from boatd.
:returns: The current waypoints
:rtype: List of Points
'''
if boatd is None:
boatd = Boatd()
content = boatd.get('/waypoints')
return [Point(*coords) for coords in content.get('waypo... | python | def get_current_waypoints(boatd=None):
'''
Get the current set of waypoints active from boatd.
:returns: The current waypoints
:rtype: List of Points
'''
if boatd is None:
boatd = Boatd()
content = boatd.get('/waypoints')
return [Point(*coords) for coords in content.get('waypo... | [
"def",
"get_current_waypoints",
"(",
"boatd",
"=",
"None",
")",
":",
"if",
"boatd",
"is",
"None",
":",
"boatd",
"=",
"Boatd",
"(",
")",
"content",
"=",
"boatd",
".",
"get",
"(",
"'/waypoints'",
")",
"return",
"[",
"Point",
"(",
"*",
"coords",
")",
"f... | Get the current set of waypoints active from boatd.
:returns: The current waypoints
:rtype: List of Points | [
"Get",
"the",
"current",
"set",
"of",
"waypoints",
"active",
"from",
"boatd",
"."
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L211-L223 |
boatd/python-boatd | boatdclient/boatd_client.py | get_home_position | def get_home_position(boatd=None):
'''
Get the current home position from boatd.
:returns: The configured home position
:rtype: Points
'''
if boatd is None:
boatd = Boatd()
content = boatd.get('/waypoints')
home = content.get('home', None)
if home is not None:
lat,... | python | def get_home_position(boatd=None):
'''
Get the current home position from boatd.
:returns: The configured home position
:rtype: Points
'''
if boatd is None:
boatd = Boatd()
content = boatd.get('/waypoints')
home = content.get('home', None)
if home is not None:
lat,... | [
"def",
"get_home_position",
"(",
"boatd",
"=",
"None",
")",
":",
"if",
"boatd",
"is",
"None",
":",
"boatd",
"=",
"Boatd",
"(",
")",
"content",
"=",
"boatd",
".",
"get",
"(",
"'/waypoints'",
")",
"home",
"=",
"content",
".",
"get",
"(",
"'home'",
",",... | Get the current home position from boatd.
:returns: The configured home position
:rtype: Points | [
"Get",
"the",
"current",
"home",
"position",
"from",
"boatd",
"."
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L226-L243 |
boatd/python-boatd | boatdclient/boatd_client.py | Boatd.get | def get(self, endpoint):
'''Return the result of a GET request to `endpoint` on boatd'''
json_body = urlopen(self.url(endpoint)).read().decode('utf-8')
return json.loads(json_body) | python | def get(self, endpoint):
'''Return the result of a GET request to `endpoint` on boatd'''
json_body = urlopen(self.url(endpoint)).read().decode('utf-8')
return json.loads(json_body) | [
"def",
"get",
"(",
"self",
",",
"endpoint",
")",
":",
"json_body",
"=",
"urlopen",
"(",
"self",
".",
"url",
"(",
"endpoint",
")",
")",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"json",
".",
"loads",
"(",
"json_body",
")"
... | Return the result of a GET request to `endpoint` on boatd | [
"Return",
"the",
"result",
"of",
"a",
"GET",
"request",
"to",
"endpoint",
"on",
"boatd"
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L31-L34 |
boatd/python-boatd | boatdclient/boatd_client.py | Boatd.post | def post(self, content, endpoint=''):
'''
Issue a POST request with `content` as the body to `endpoint` and
return the result.
'''
url = self.url(endpoint)
post_content = json.dumps(content).encode('utf-8')
headers = {'Content-Type': 'application/json'}
re... | python | def post(self, content, endpoint=''):
'''
Issue a POST request with `content` as the body to `endpoint` and
return the result.
'''
url = self.url(endpoint)
post_content = json.dumps(content).encode('utf-8')
headers = {'Content-Type': 'application/json'}
re... | [
"def",
"post",
"(",
"self",
",",
"content",
",",
"endpoint",
"=",
"''",
")",
":",
"url",
"=",
"self",
".",
"url",
"(",
"endpoint",
")",
"post_content",
"=",
"json",
".",
"dumps",
"(",
"content",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"headers",
"... | Issue a POST request with `content` as the body to `endpoint` and
return the result. | [
"Issue",
"a",
"POST",
"request",
"with",
"content",
"as",
"the",
"body",
"to",
"endpoint",
"and",
"return",
"the",
"result",
"."
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L36-L48 |
boatd/python-boatd | boatdclient/boatd_client.py | Boat.wind | def wind(self):
'''
Return the direction of the wind in degrees.
:returns: wind object containing direction bearing and speed
:rtype: Wind
'''
content = self._cached_boat.get('wind')
return Wind(
Bearing(content.get('absolute')),
content.g... | python | def wind(self):
'''
Return the direction of the wind in degrees.
:returns: wind object containing direction bearing and speed
:rtype: Wind
'''
content = self._cached_boat.get('wind')
return Wind(
Bearing(content.get('absolute')),
content.g... | [
"def",
"wind",
"(",
"self",
")",
":",
"content",
"=",
"self",
".",
"_cached_boat",
".",
"get",
"(",
"'wind'",
")",
"return",
"Wind",
"(",
"Bearing",
"(",
"content",
".",
"get",
"(",
"'absolute'",
")",
")",
",",
"content",
".",
"get",
"(",
"'speed'",
... | Return the direction of the wind in degrees.
:returns: wind object containing direction bearing and speed
:rtype: Wind | [
"Return",
"the",
"direction",
"of",
"the",
"wind",
"in",
"degrees",
"."
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L102-L114 |
boatd/python-boatd | boatdclient/boatd_client.py | Boat.position | def position(self):
'''
Return the current position of the boat.
:returns: current position
:rtype: Point
'''
content = self._cached_boat
lat, lon = content.get('position')
return Point(lat, lon) | python | def position(self):
'''
Return the current position of the boat.
:returns: current position
:rtype: Point
'''
content = self._cached_boat
lat, lon = content.get('position')
return Point(lat, lon) | [
"def",
"position",
"(",
"self",
")",
":",
"content",
"=",
"self",
".",
"_cached_boat",
"lat",
",",
"lon",
"=",
"content",
".",
"get",
"(",
"'position'",
")",
"return",
"Point",
"(",
"lat",
",",
"lon",
")"
] | Return the current position of the boat.
:returns: current position
:rtype: Point | [
"Return",
"the",
"current",
"position",
"of",
"the",
"boat",
"."
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L118-L127 |
boatd/python-boatd | boatdclient/boatd_client.py | Boat.set_rudder | def set_rudder(self, angle):
'''
Set the angle of the rudder to be `angle` degrees.
:param angle: rudder angle
:type angle: float between -90 and 90
'''
angle = float(angle)
request = self.boatd.post({'value': float(angle)}, '/rudder')
return request.get(... | python | def set_rudder(self, angle):
'''
Set the angle of the rudder to be `angle` degrees.
:param angle: rudder angle
:type angle: float between -90 and 90
'''
angle = float(angle)
request = self.boatd.post({'value': float(angle)}, '/rudder')
return request.get(... | [
"def",
"set_rudder",
"(",
"self",
",",
"angle",
")",
":",
"angle",
"=",
"float",
"(",
"angle",
")",
"request",
"=",
"self",
".",
"boatd",
".",
"post",
"(",
"{",
"'value'",
":",
"float",
"(",
"angle",
")",
"}",
",",
"'/rudder'",
")",
"return",
"requ... | Set the angle of the rudder to be `angle` degrees.
:param angle: rudder angle
:type angle: float between -90 and 90 | [
"Set",
"the",
"angle",
"of",
"the",
"rudder",
"to",
"be",
"angle",
"degrees",
"."
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L129-L138 |
boatd/python-boatd | boatdclient/boatd_client.py | Boat.set_sail | def set_sail(self, angle):
'''
Set the angle of the sail to `angle` degrees
:param angle: sail angle
:type angle: float between -90 and 90
'''
angle = float(angle)
request = self.boatd.post({'value': float(angle)}, '/sail')
return request.get('result') | python | def set_sail(self, angle):
'''
Set the angle of the sail to `angle` degrees
:param angle: sail angle
:type angle: float between -90 and 90
'''
angle = float(angle)
request = self.boatd.post({'value': float(angle)}, '/sail')
return request.get('result') | [
"def",
"set_sail",
"(",
"self",
",",
"angle",
")",
":",
"angle",
"=",
"float",
"(",
"angle",
")",
"request",
"=",
"self",
".",
"boatd",
".",
"post",
"(",
"{",
"'value'",
":",
"float",
"(",
"angle",
")",
"}",
",",
"'/sail'",
")",
"return",
"request"... | Set the angle of the sail to `angle` degrees
:param angle: sail angle
:type angle: float between -90 and 90 | [
"Set",
"the",
"angle",
"of",
"the",
"sail",
"to",
"angle",
"degrees"
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L152-L161 |
boatd/python-boatd | boatdclient/boatd_client.py | Behaviour.start | def start(self, name):
'''
End the current behaviour and run a named behaviour.
:param name: the name of the behaviour to run
:type name: str
'''
d = self.boatd.post({'active': name}, endpoint='/behaviours')
current = d.get('active')
if current is not Non... | python | def start(self, name):
'''
End the current behaviour and run a named behaviour.
:param name: the name of the behaviour to run
:type name: str
'''
d = self.boatd.post({'active': name}, endpoint='/behaviours')
current = d.get('active')
if current is not Non... | [
"def",
"start",
"(",
"self",
",",
"name",
")",
":",
"d",
"=",
"self",
".",
"boatd",
".",
"post",
"(",
"{",
"'active'",
":",
"name",
"}",
",",
"endpoint",
"=",
"'/behaviours'",
")",
"current",
"=",
"d",
".",
"get",
"(",
"'active'",
")",
"if",
"cur... | End the current behaviour and run a named behaviour.
:param name: the name of the behaviour to run
:type name: str | [
"End",
"the",
"current",
"behaviour",
"and",
"run",
"a",
"named",
"behaviour",
"."
] | train | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L190-L202 |
klmitch/appathy | appathy/types.py | _translators | def _translators(attr, kwargs):
"""
Decorator which associates a set of translators (serializers or
deserializers) with a given method. The `attr` parameter
identifies which attribute is being updated.
"""
# Add translators to a function or class
def decorator(func):
# Make sure we... | python | def _translators(attr, kwargs):
"""
Decorator which associates a set of translators (serializers or
deserializers) with a given method. The `attr` parameter
identifies which attribute is being updated.
"""
# Add translators to a function or class
def decorator(func):
# Make sure we... | [
"def",
"_translators",
"(",
"attr",
",",
"kwargs",
")",
":",
"# Add translators to a function or class",
"def",
"decorator",
"(",
"func",
")",
":",
"# Make sure we have the attribute",
"try",
":",
"xlators",
"=",
"getattr",
"(",
"func",
",",
"attr",
")",
"except",... | Decorator which associates a set of translators (serializers or
deserializers) with a given method. The `attr` parameter
identifies which attribute is being updated. | [
"Decorator",
"which",
"associates",
"a",
"set",
"of",
"translators",
"(",
"serializers",
"or",
"deserializers",
")",
"with",
"a",
"given",
"method",
".",
"The",
"attr",
"parameter",
"identifies",
"which",
"attribute",
"is",
"being",
"updated",
"."
] | train | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/types.py#L72-L90 |
klmitch/appathy | appathy/types.py | register_types | def register_types(name, *types):
"""
Register a short name for one or more content types.
"""
type_names.setdefault(name, set())
for t in types:
# Redirecting the type
if t in media_types:
type_names[media_types[t]].discard(t)
# Save the mapping
media_t... | python | def register_types(name, *types):
"""
Register a short name for one or more content types.
"""
type_names.setdefault(name, set())
for t in types:
# Redirecting the type
if t in media_types:
type_names[media_types[t]].discard(t)
# Save the mapping
media_t... | [
"def",
"register_types",
"(",
"name",
",",
"*",
"types",
")",
":",
"type_names",
".",
"setdefault",
"(",
"name",
",",
"set",
"(",
")",
")",
"for",
"t",
"in",
"types",
":",
"# Redirecting the type",
"if",
"t",
"in",
"media_types",
":",
"type_names",
"[",
... | Register a short name for one or more content types. | [
"Register",
"a",
"short",
"name",
"for",
"one",
"or",
"more",
"content",
"types",
"."
] | train | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/types.py#L141-L154 |
klmitch/appathy | appathy/types.py | Translators.get_types | def get_types(self):
"""
Retrieve a set of all recognized content types for this
translator object.
"""
# Convert translators into a set of content types
content_types = set()
for name in self.translators:
content_types |= type_names[name]
re... | python | def get_types(self):
"""
Retrieve a set of all recognized content types for this
translator object.
"""
# Convert translators into a set of content types
content_types = set()
for name in self.translators:
content_types |= type_names[name]
re... | [
"def",
"get_types",
"(",
"self",
")",
":",
"# Convert translators into a set of content types",
"content_types",
"=",
"set",
"(",
")",
"for",
"name",
"in",
"self",
".",
"translators",
":",
"content_types",
"|=",
"type_names",
"[",
"name",
"]",
"return",
"content_t... | Retrieve a set of all recognized content types for this
translator object. | [
"Retrieve",
"a",
"set",
"of",
"all",
"recognized",
"content",
"types",
"for",
"this",
"translator",
"object",
"."
] | train | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/types.py#L58-L69 |
GetRektByMe/Raitonoberu | Raitonoberu/raitonoberu.py | Raitonoberu.get_search_page | async def get_search_page(self, term: str):
"""Get search page.
This function will get the first link from the search term we do on term and then
it will return the link we want to parse from.
:param term: Light Novel to Search For
"""
# Uses the BASEURL and also builds... | python | async def get_search_page(self, term: str):
"""Get search page.
This function will get the first link from the search term we do on term and then
it will return the link we want to parse from.
:param term: Light Novel to Search For
"""
# Uses the BASEURL and also builds... | [
"async",
"def",
"get_search_page",
"(",
"self",
",",
"term",
":",
"str",
")",
":",
"# Uses the BASEURL and also builds link for the page we want using the term given",
"params",
"=",
"{",
"'s'",
":",
"term",
",",
"'post_type'",
":",
"'seriesplan'",
"}",
"async",
"with... | Get search page.
This function will get the first link from the search term we do on term and then
it will return the link we want to parse from.
:param term: Light Novel to Search For | [
"Get",
"search",
"page",
"."
] | train | https://github.com/GetRektByMe/Raitonoberu/blob/c35f83cb1c5268b7e641146bc8c6139fbc10e20f/Raitonoberu/raitonoberu.py#L20-L38 |
GetRektByMe/Raitonoberu | Raitonoberu/raitonoberu.py | Raitonoberu._get_aliases | def _get_aliases(parse_info):
"""get aliases from parse info.
:param parse_info: Parsed info from html soup.
"""
return [
div.string.strip()
for div in parse_info.find('div', id='editassociated')
if div.string is not None
] | python | def _get_aliases(parse_info):
"""get aliases from parse info.
:param parse_info: Parsed info from html soup.
"""
return [
div.string.strip()
for div in parse_info.find('div', id='editassociated')
if div.string is not None
] | [
"def",
"_get_aliases",
"(",
"parse_info",
")",
":",
"return",
"[",
"div",
".",
"string",
".",
"strip",
"(",
")",
"for",
"div",
"in",
"parse_info",
".",
"find",
"(",
"'div'",
",",
"id",
"=",
"'editassociated'",
")",
"if",
"div",
".",
"string",
"is",
"... | get aliases from parse info.
:param parse_info: Parsed info from html soup. | [
"get",
"aliases",
"from",
"parse",
"info",
"."
] | train | https://github.com/GetRektByMe/Raitonoberu/blob/c35f83cb1c5268b7e641146bc8c6139fbc10e20f/Raitonoberu/raitonoberu.py#L57-L66 |
GetRektByMe/Raitonoberu | Raitonoberu/raitonoberu.py | Raitonoberu._get_related_series | def _get_related_series(parse_info):
"""get related_series from parse info.
:param parse_info: Parsed info from html soup.
"""
seriesother_tags = [x for x in parse_info.select('h5.seriesother')]
sibling_tag = [x for x in seriesother_tags if x.text == 'Related Series'][0]
... | python | def _get_related_series(parse_info):
"""get related_series from parse info.
:param parse_info: Parsed info from html soup.
"""
seriesother_tags = [x for x in parse_info.select('h5.seriesother')]
sibling_tag = [x for x in seriesother_tags if x.text == 'Related Series'][0]
... | [
"def",
"_get_related_series",
"(",
"parse_info",
")",
":",
"seriesother_tags",
"=",
"[",
"x",
"for",
"x",
"in",
"parse_info",
".",
"select",
"(",
"'h5.seriesother'",
")",
"]",
"sibling_tag",
"=",
"[",
"x",
"for",
"x",
"in",
"seriesother_tags",
"if",
"x",
"... | get related_series from parse info.
:param parse_info: Parsed info from html soup. | [
"get",
"related_series",
"from",
"parse",
"info",
"."
] | train | https://github.com/GetRektByMe/Raitonoberu/blob/c35f83cb1c5268b7e641146bc8c6139fbc10e20f/Raitonoberu/raitonoberu.py#L69-L108 |
GetRektByMe/Raitonoberu | Raitonoberu/raitonoberu.py | Raitonoberu.get_first_search_result | async def get_first_search_result(self, term: str):
"""Get first search result.
This function will parse the information from the link that search_novel_updates returns
and then return it as a dictionary
:param term: The novel to search for and parse
"""
# Uses the othe... | python | async def get_first_search_result(self, term: str):
"""Get first search result.
This function will parse the information from the link that search_novel_updates returns
and then return it as a dictionary
:param term: The novel to search for and parse
"""
# Uses the othe... | [
"async",
"def",
"get_first_search_result",
"(",
"self",
",",
"term",
":",
"str",
")",
":",
"# Uses the other method in the class",
"# to search the search page for the actual page that we want",
"to_parse",
"=",
"await",
"self",
".",
"get_search_page",
"(",
"term",
")",
"... | Get first search result.
This function will parse the information from the link that search_novel_updates returns
and then return it as a dictionary
:param term: The novel to search for and parse | [
"Get",
"first",
"search",
"result",
"."
] | train | https://github.com/GetRektByMe/Raitonoberu/blob/c35f83cb1c5268b7e641146bc8c6139fbc10e20f/Raitonoberu/raitonoberu.py#L110-L218 |
shreyaspotnis/rampage | rampage/daq/gpib.py | Aglient33250A.set_output | def set_output(self, state):
"""Sets whether the function generator is outputting a voltage."""
if state:
self.instr.write('OUTP ON')
else:
self.instr.write('OUTP OFF') | python | def set_output(self, state):
"""Sets whether the function generator is outputting a voltage."""
if state:
self.instr.write('OUTP ON')
else:
self.instr.write('OUTP OFF') | [
"def",
"set_output",
"(",
"self",
",",
"state",
")",
":",
"if",
"state",
":",
"self",
".",
"instr",
".",
"write",
"(",
"'OUTP ON'",
")",
"else",
":",
"self",
".",
"instr",
".",
"write",
"(",
"'OUTP OFF'",
")"
] | Sets whether the function generator is outputting a voltage. | [
"Sets",
"whether",
"the",
"function",
"generator",
"is",
"outputting",
"a",
"voltage",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L27-L32 |
shreyaspotnis/rampage | rampage/daq/gpib.py | Aglient33250A.set_fm_ext | def set_fm_ext(self, freq, amplitude, peak_freq_dev=None,
output_state=True):
"""Sets the func generator to frequency modulation with external modulation.
freq is the carrier frequency in Hz."""
if peak_freq_dev is None:
peak_freq_dev = freq
commands = ['F... | python | def set_fm_ext(self, freq, amplitude, peak_freq_dev=None,
output_state=True):
"""Sets the func generator to frequency modulation with external modulation.
freq is the carrier frequency in Hz."""
if peak_freq_dev is None:
peak_freq_dev = freq
commands = ['F... | [
"def",
"set_fm_ext",
"(",
"self",
",",
"freq",
",",
"amplitude",
",",
"peak_freq_dev",
"=",
"None",
",",
"output_state",
"=",
"True",
")",
":",
"if",
"peak_freq_dev",
"is",
"None",
":",
"peak_freq_dev",
"=",
"freq",
"commands",
"=",
"[",
"'FUNC SIN'",
",",... | Sets the func generator to frequency modulation with external modulation.
freq is the carrier frequency in Hz. | [
"Sets",
"the",
"func",
"generator",
"to",
"frequency",
"modulation",
"with",
"external",
"modulation",
".",
"freq",
"is",
"the",
"carrier",
"frequency",
"in",
"Hz",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L34-L56 |
shreyaspotnis/rampage | rampage/daq/gpib.py | Aglient33250A.set_burst | def set_burst(self, freq, amplitude, period, output_state=True):
"""Sets the func generator to burst mode with external trigerring."""
ncyc = int(period*freq)
commands = ['FUNC SIN',
'BURS:STAT ON',
'BURS:MODE TRIG', # external trigger
... | python | def set_burst(self, freq, amplitude, period, output_state=True):
"""Sets the func generator to burst mode with external trigerring."""
ncyc = int(period*freq)
commands = ['FUNC SIN',
'BURS:STAT ON',
'BURS:MODE TRIG', # external trigger
... | [
"def",
"set_burst",
"(",
"self",
",",
"freq",
",",
"amplitude",
",",
"period",
",",
"output_state",
"=",
"True",
")",
":",
"ncyc",
"=",
"int",
"(",
"period",
"*",
"freq",
")",
"commands",
"=",
"[",
"'FUNC SIN'",
",",
"'BURS:STAT ON'",
",",
"'BURS:MODE TR... | Sets the func generator to burst mode with external trigerring. | [
"Sets",
"the",
"func",
"generator",
"to",
"burst",
"mode",
"with",
"external",
"trigerring",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L59-L80 |
shreyaspotnis/rampage | rampage/daq/gpib.py | Aglient33250A.set_arbitrary | def set_arbitrary(self, freq, low_volt, high_volt, output_state=True):
"""Programs the function generator to output the arbitrary waveform."""
commands = ['FUNC USER',
'BURS:STAT OFF',
'SWE:STAT OFF',
'FM:STAT OFF',
'FREQ {0... | python | def set_arbitrary(self, freq, low_volt, high_volt, output_state=True):
"""Programs the function generator to output the arbitrary waveform."""
commands = ['FUNC USER',
'BURS:STAT OFF',
'SWE:STAT OFF',
'FM:STAT OFF',
'FREQ {0... | [
"def",
"set_arbitrary",
"(",
"self",
",",
"freq",
",",
"low_volt",
",",
"high_volt",
",",
"output_state",
"=",
"True",
")",
":",
"commands",
"=",
"[",
"'FUNC USER'",
",",
"'BURS:STAT OFF'",
",",
"'SWE:STAT OFF'",
",",
"'FM:STAT OFF'",
",",
"'FREQ {0}'",
".",
... | Programs the function generator to output the arbitrary waveform. | [
"Programs",
"the",
"function",
"generator",
"to",
"output",
"the",
"arbitrary",
"waveform",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L128-L146 |
shreyaspotnis/rampage | rampage/daq/gpib.py | SRSSG384.set_continuous | def set_continuous(self, freq, amplitude, offset, output_state=True):
"""Programs the Stanford MW function generator to output a continuous sine wave.
External 'triggering' is accomplished using the MW switch."""
commands = ['MODL 0', #disable any modulation
'FREQ {... | python | def set_continuous(self, freq, amplitude, offset, output_state=True):
"""Programs the Stanford MW function generator to output a continuous sine wave.
External 'triggering' is accomplished using the MW switch."""
commands = ['MODL 0', #disable any modulation
'FREQ {... | [
"def",
"set_continuous",
"(",
"self",
",",
"freq",
",",
"amplitude",
",",
"offset",
",",
"output_state",
"=",
"True",
")",
":",
"commands",
"=",
"[",
"'MODL 0'",
",",
"#disable any modulation",
"'FREQ {0}'",
".",
"format",
"(",
"freq",
")",
"]",
"if",
"fre... | Programs the Stanford MW function generator to output a continuous sine wave.
External 'triggering' is accomplished using the MW switch. | [
"Programs",
"the",
"Stanford",
"MW",
"function",
"generator",
"to",
"output",
"a",
"continuous",
"sine",
"wave",
".",
"External",
"triggering",
"is",
"accomplished",
"using",
"the",
"MW",
"switch",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L333-L358 |
shreyaspotnis/rampage | rampage/daq/gpib.py | SRSSG384.set_freqsweep_ext | def set_freqsweep_ext(self, amplitude, sweep_low_end, sweep_high_end, offset=0.0, output_state=True):
"""Sets the Stanford MW function generator to freq modulation with external modulation.
freq is the carrier frequency in Hz."""
sweep_deviation = round(abs(sweep_low_end - sweep_high_end)/2.0,6... | python | def set_freqsweep_ext(self, amplitude, sweep_low_end, sweep_high_end, offset=0.0, output_state=True):
"""Sets the Stanford MW function generator to freq modulation with external modulation.
freq is the carrier frequency in Hz."""
sweep_deviation = round(abs(sweep_low_end - sweep_high_end)/2.0,6... | [
"def",
"set_freqsweep_ext",
"(",
"self",
",",
"amplitude",
",",
"sweep_low_end",
",",
"sweep_high_end",
",",
"offset",
"=",
"0.0",
",",
"output_state",
"=",
"True",
")",
":",
"sweep_deviation",
"=",
"round",
"(",
"abs",
"(",
"sweep_low_end",
"-",
"sweep_high_e... | Sets the Stanford MW function generator to freq modulation with external modulation.
freq is the carrier frequency in Hz. | [
"Sets",
"the",
"Stanford",
"MW",
"function",
"generator",
"to",
"freq",
"modulation",
"with",
"external",
"modulation",
".",
"freq",
"is",
"the",
"carrier",
"frequency",
"in",
"Hz",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L424-L454 |
shreyaspotnis/rampage | rampage/daq/gpib.py | SRSSG384.set_output | def set_output(self, state):
"""Sets whether the function generator is outputting a voltage."""
freq = float(self.instr.query('FREQ?'))
if freq > 4.05e9:
if state:
self.instr.write('ENBH 1') #enable output
else:
self.instr.write('ENBH 0')
... | python | def set_output(self, state):
"""Sets whether the function generator is outputting a voltage."""
freq = float(self.instr.query('FREQ?'))
if freq > 4.05e9:
if state:
self.instr.write('ENBH 1') #enable output
else:
self.instr.write('ENBH 0')
... | [
"def",
"set_output",
"(",
"self",
",",
"state",
")",
":",
"freq",
"=",
"float",
"(",
"self",
".",
"instr",
".",
"query",
"(",
"'FREQ?'",
")",
")",
"if",
"freq",
">",
"4.05e9",
":",
"if",
"state",
":",
"self",
".",
"instr",
".",
"write",
"(",
"'EN... | Sets whether the function generator is outputting a voltage. | [
"Sets",
"whether",
"the",
"function",
"generator",
"is",
"outputting",
"a",
"voltage",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L459-L471 |
shreyaspotnis/rampage | rampage/daq/gpib.py | SRSSG384.disable_all | def disable_all(self, disable):
"""Disables all modulation and outputs of the Standford MW func. generator"""
commands = ['ENBH 0', #disable high freq. rear output
'ENBL 0', #disable low freq. front bnc
'MODL 0' #disable modulation
]
... | python | def disable_all(self, disable):
"""Disables all modulation and outputs of the Standford MW func. generator"""
commands = ['ENBH 0', #disable high freq. rear output
'ENBL 0', #disable low freq. front bnc
'MODL 0' #disable modulation
]
... | [
"def",
"disable_all",
"(",
"self",
",",
"disable",
")",
":",
"commands",
"=",
"[",
"'ENBH 0'",
",",
"#disable high freq. rear output",
"'ENBL 0'",
",",
"#disable low freq. front bnc",
"'MODL 0'",
"#disable modulation",
"]",
"command_string",
"=",
"'\\n'",
".",
"join",... | Disables all modulation and outputs of the Standford MW func. generator | [
"Disables",
"all",
"modulation",
"and",
"outputs",
"of",
"the",
"Standford",
"MW",
"func",
".",
"generator"
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L479-L489 |
shreyaspotnis/rampage | rampage/daq/gpib.py | RigolDG1022Z.set_output | def set_output(self, state, channel=2):
"""Sets whether the function generator is outputting a voltage."""
if state:
self.instr.write(':OUTP{0} ON'.format(channel))
else:
self.instr.write(':OUTP{0} OFF'.format(channel)) | python | def set_output(self, state, channel=2):
"""Sets whether the function generator is outputting a voltage."""
if state:
self.instr.write(':OUTP{0} ON'.format(channel))
else:
self.instr.write(':OUTP{0} OFF'.format(channel)) | [
"def",
"set_output",
"(",
"self",
",",
"state",
",",
"channel",
"=",
"2",
")",
":",
"if",
"state",
":",
"self",
".",
"instr",
".",
"write",
"(",
"':OUTP{0} ON'",
".",
"format",
"(",
"channel",
")",
")",
"else",
":",
"self",
".",
"instr",
".",
"writ... | Sets whether the function generator is outputting a voltage. | [
"Sets",
"whether",
"the",
"function",
"generator",
"is",
"outputting",
"a",
"voltage",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L525-L530 |
shreyaspotnis/rampage | rampage/daq/gpib.py | RigolDG1022Z.set_continuous | def set_continuous(self, freq, amplitude, offset, phase, channel=2):
"""Programs the function generator to output a continuous sine wave."""
commands = [':SOUR{0}:APPL:SIN '.format(channel),
'{0},'.format(freq),
'{0},'.format(amplitude),
'{0},'... | python | def set_continuous(self, freq, amplitude, offset, phase, channel=2):
"""Programs the function generator to output a continuous sine wave."""
commands = [':SOUR{0}:APPL:SIN '.format(channel),
'{0},'.format(freq),
'{0},'.format(amplitude),
'{0},'... | [
"def",
"set_continuous",
"(",
"self",
",",
"freq",
",",
"amplitude",
",",
"offset",
",",
"phase",
",",
"channel",
"=",
"2",
")",
":",
"commands",
"=",
"[",
"':SOUR{0}:APPL:SIN '",
".",
"format",
"(",
"channel",
")",
",",
"'{0},'",
".",
"format",
"(",
"... | Programs the function generator to output a continuous sine wave. | [
"Programs",
"the",
"function",
"generator",
"to",
"output",
"a",
"continuous",
"sine",
"wave",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L532-L543 |
Vito2015/pyextend | pyextend/formula/lbstools.py | haversine | def haversine(lng1, lat1, lng2, lat2):
"""Compute km by geo-coordinates
See also: haversine define https://en.wikipedia.org/wiki/Haversine_formula
"""
# Convert coordinates to floats.
lng1, lat1, lng2, lat2 = map(float, [lng1, lat1, lng2, lat2])
# Convert to radians from degrees
lng1, lat1,... | python | def haversine(lng1, lat1, lng2, lat2):
"""Compute km by geo-coordinates
See also: haversine define https://en.wikipedia.org/wiki/Haversine_formula
"""
# Convert coordinates to floats.
lng1, lat1, lng2, lat2 = map(float, [lng1, lat1, lng2, lat2])
# Convert to radians from degrees
lng1, lat1,... | [
"def",
"haversine",
"(",
"lng1",
",",
"lat1",
",",
"lng2",
",",
"lat2",
")",
":",
"# Convert coordinates to floats.",
"lng1",
",",
"lat1",
",",
"lng2",
",",
"lat2",
"=",
"map",
"(",
"float",
",",
"[",
"lng1",
",",
"lat1",
",",
"lng2",
",",
"lat2",
"]... | Compute km by geo-coordinates
See also: haversine define https://en.wikipedia.org/wiki/Haversine_formula | [
"Compute",
"km",
"by",
"geo",
"-",
"coordinates",
"See",
"also",
":",
"haversine",
"define",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Haversine_formula"
] | train | https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/formula/lbstools.py#L13-L29 |
Vito2015/pyextend | pyextend/formula/lbstools.py | calc_distance | def calc_distance(lng1, lat1, lng2, lat2):
"""Calc distance (km) by geo-coordinates.
@:param lng1: first coordinate.lng
@:param lat1: first coordinate.lat
@:param lng2: second coordinate.lng
@:param lat2: second coordinate.lat
@:return distance: km
"""
ra = 6378.140 ... | python | def calc_distance(lng1, lat1, lng2, lat2):
"""Calc distance (km) by geo-coordinates.
@:param lng1: first coordinate.lng
@:param lat1: first coordinate.lat
@:param lng2: second coordinate.lng
@:param lat2: second coordinate.lat
@:return distance: km
"""
ra = 6378.140 ... | [
"def",
"calc_distance",
"(",
"lng1",
",",
"lat1",
",",
"lng2",
",",
"lat2",
")",
":",
"ra",
"=",
"6378.140",
"# 赤道半径 (km)",
"rb",
"=",
"6356.755",
"# 极半径 (km)",
"flatten",
"=",
"(",
"ra",
"-",
"rb",
")",
"/",
"ra",
"# 地球扁率",
"rad_lat_1",
"=",
"math",
... | Calc distance (km) by geo-coordinates.
@:param lng1: first coordinate.lng
@:param lat1: first coordinate.lat
@:param lng2: second coordinate.lng
@:param lat2: second coordinate.lat
@:return distance: km | [
"Calc",
"distance",
"(",
"km",
")",
"by",
"geo",
"-",
"coordinates",
"."
] | train | https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/formula/lbstools.py#L32-L54 |
JNRowe/jnrbase | jnrbase/pip_support.py | parse_requires | def parse_requires(__fname: str) -> List[str]:
"""Parse ``pip``-style requirements files.
This is a *very* naïve parser, but very few packages make use of the more
advanced features. Support for other features will be added only when
packages in the wild depend on them.
Args:
__fname: Bas... | python | def parse_requires(__fname: str) -> List[str]:
"""Parse ``pip``-style requirements files.
This is a *very* naïve parser, but very few packages make use of the more
advanced features. Support for other features will be added only when
packages in the wild depend on them.
Args:
__fname: Bas... | [
"def",
"parse_requires",
"(",
"__fname",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"deps",
"=",
"[",
"]",
"with",
"open",
"(",
"__fname",
")",
"as",
"req_file",
":",
"entries",
"=",
"[",
"s",
".",
"split",
"(",
"'#'",
")",
"[",
"0",
... | Parse ``pip``-style requirements files.
This is a *very* naïve parser, but very few packages make use of the more
advanced features. Support for other features will be added only when
packages in the wild depend on them.
Args:
__fname: Base file to pass
Returns:
Parsed dependencie... | [
"Parse",
"pip",
"-",
"style",
"requirements",
"files",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/pip_support.py#L32-L76 |
rjw57/throw | throw/attachment_renderer.py | create_email | def create_email(filepaths, collection_name):
"""Create an email message object which implements the
email.message.Message interface and which has the files to be shared
attached to it.
"""
outer = MIMEMultipart()
outer.preamble = 'Here are some files for you'
def add_file_to_outer(path):
... | python | def create_email(filepaths, collection_name):
"""Create an email message object which implements the
email.message.Message interface and which has the files to be shared
attached to it.
"""
outer = MIMEMultipart()
outer.preamble = 'Here are some files for you'
def add_file_to_outer(path):
... | [
"def",
"create_email",
"(",
"filepaths",
",",
"collection_name",
")",
":",
"outer",
"=",
"MIMEMultipart",
"(",
")",
"outer",
".",
"preamble",
"=",
"'Here are some files for you'",
"def",
"add_file_to_outer",
"(",
"path",
")",
":",
"if",
"not",
"os",
".",
"path... | Create an email message object which implements the
email.message.Message interface and which has the files to be shared
attached to it. | [
"Create",
"an",
"email",
"message",
"object",
"which",
"implements",
"the",
"email",
".",
"message",
".",
"Message",
"interface",
"and",
"which",
"has",
"the",
"files",
"to",
"be",
"shared",
"attached",
"to",
"it",
"."
] | train | https://github.com/rjw57/throw/blob/74a7116362ba5b45635ab247472b25cfbdece4ee/throw/attachment_renderer.py#L12-L74 |
ArtoLabs/SimpleSteem | simplesteem/makeconfig.py | MakeConfig.setup | def setup (self):
''' Runs only the first time SimpleSteem()
is instantiated. Prompts user for the values
that are then written to config.py
'''
mainaccount = self.add_quotes(self.enter_config_value("mainaccount", 'ned'))
keys = self.enter_config_value("keys", '[]')
... | python | def setup (self):
''' Runs only the first time SimpleSteem()
is instantiated. Prompts user for the values
that are then written to config.py
'''
mainaccount = self.add_quotes(self.enter_config_value("mainaccount", 'ned'))
keys = self.enter_config_value("keys", '[]')
... | [
"def",
"setup",
"(",
"self",
")",
":",
"mainaccount",
"=",
"self",
".",
"add_quotes",
"(",
"self",
".",
"enter_config_value",
"(",
"\"mainaccount\"",
",",
"'ned'",
")",
")",
"keys",
"=",
"self",
".",
"enter_config_value",
"(",
"\"keys\"",
",",
"'[]'",
")",... | Runs only the first time SimpleSteem()
is instantiated. Prompts user for the values
that are then written to config.py | [
"Runs",
"only",
"the",
"first",
"time",
"SimpleSteem",
"()",
"is",
"instantiated",
".",
"Prompts",
"user",
"for",
"the",
"values",
"that",
"are",
"then",
"written",
"to",
"config",
".",
"py"
] | train | https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/makeconfig.py#L8-L31 |
ArtoLabs/SimpleSteem | simplesteem/makeconfig.py | MakeConfig.make | def make(self, **kwargs):
''' takes the arguments and writes them as
variable / value pairs to config.py
'''
configpath = os.path.dirname(os.path.abspath(__file__)) + "/config.py"
print ("Writing to " + configpath)
with open(configpath, 'w+') as fh:
try:
... | python | def make(self, **kwargs):
''' takes the arguments and writes them as
variable / value pairs to config.py
'''
configpath = os.path.dirname(os.path.abspath(__file__)) + "/config.py"
print ("Writing to " + configpath)
with open(configpath, 'w+') as fh:
try:
... | [
"def",
"make",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"configpath",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"+",
"\"/config.py\"",
"print",
"(",
"\"Writing to \"",
"+",
"conf... | takes the arguments and writes them as
variable / value pairs to config.py | [
"takes",
"the",
"arguments",
"and",
"writes",
"them",
"as",
"variable",
"/",
"value",
"pairs",
"to",
"config",
".",
"py"
] | train | https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/makeconfig.py#L38-L51 |
ArtoLabs/SimpleSteem | simplesteem/makeconfig.py | MakeConfig.enter_config_value | def enter_config_value(self, key, default=""):
''' Prompts user for a value
'''
value = input('Please enter a value for ' + key + ': ')
if value:
return value
else:
return default | python | def enter_config_value(self, key, default=""):
''' Prompts user for a value
'''
value = input('Please enter a value for ' + key + ': ')
if value:
return value
else:
return default | [
"def",
"enter_config_value",
"(",
"self",
",",
"key",
",",
"default",
"=",
"\"\"",
")",
":",
"value",
"=",
"input",
"(",
"'Please enter a value for '",
"+",
"key",
"+",
"': '",
")",
"if",
"value",
":",
"return",
"value",
"else",
":",
"return",
"default"
] | Prompts user for a value | [
"Prompts",
"user",
"for",
"a",
"value"
] | train | https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/makeconfig.py#L54-L61 |
vilmibm/done | done/termcolor.py | colored | def colored(text, color=None, on_color=None, attrs=None):
"""Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, ... | python | def colored(text, color=None, on_color=None, attrs=None):
"""Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, ... | [
"def",
"colored",
"(",
"text",
",",
"color",
"=",
"None",
",",
"on_color",
"=",
"None",
",",
"attrs",
"=",
"None",
")",
":",
"if",
"os",
".",
"getenv",
"(",
"'ANSI_COLORS_DISABLED'",
")",
"is",
"None",
":",
"fmt_str",
"=",
"'\\033[1;%dm%s'",
"if",
"col... | Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, underline, blink, reverse, concealed.
Example:
color... | [
"Colorize",
"text",
"."
] | train | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/done/termcolor.py#L75-L106 |
AndresMWeber/Nomenclate | nomenclate/core/tools.py | combine_dicts | def combine_dicts(*args, **kwargs):
""" Combines all arguments (if they are dictionaries) and kwargs to a final dict
:param args: dict, any dictionaries the user wants combined
:param kwargs: dict, kwargs.
:return: dict, compiled dictionary
"""
dicts = [arg for arg in args if isinstance(arg, di... | python | def combine_dicts(*args, **kwargs):
""" Combines all arguments (if they are dictionaries) and kwargs to a final dict
:param args: dict, any dictionaries the user wants combined
:param kwargs: dict, kwargs.
:return: dict, compiled dictionary
"""
dicts = [arg for arg in args if isinstance(arg, di... | [
"def",
"combine_dicts",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dicts",
"=",
"[",
"arg",
"for",
"arg",
"in",
"args",
"if",
"isinstance",
"(",
"arg",
",",
"dict",
")",
"]",
"dicts",
".",
"append",
"(",
"kwargs",
")",
"super_dict",
"=",... | Combines all arguments (if they are dictionaries) and kwargs to a final dict
:param args: dict, any dictionaries the user wants combined
:param kwargs: dict, kwargs.
:return: dict, compiled dictionary | [
"Combines",
"all",
"arguments",
"(",
"if",
"they",
"are",
"dictionaries",
")",
"and",
"kwargs",
"to",
"a",
"final",
"dict"
] | train | https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/tools.py#L62-L77 |
AndresMWeber/Nomenclate | nomenclate/core/tools.py | get_keys_containing | def get_keys_containing(search_string, input_dict, default=None, first_found=True):
""" Searches a dictionary for all keys containing the search string (as long as the keys are not functions) and
returns a filtered dictionary of only those keys
:param search_string: str, string we are looking for
... | python | def get_keys_containing(search_string, input_dict, default=None, first_found=True):
""" Searches a dictionary for all keys containing the search string (as long as the keys are not functions) and
returns a filtered dictionary of only those keys
:param search_string: str, string we are looking for
... | [
"def",
"get_keys_containing",
"(",
"search_string",
",",
"input_dict",
",",
"default",
"=",
"None",
",",
"first_found",
"=",
"True",
")",
":",
"output",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"input_dict",
")",
":",
"if",
"search_st... | Searches a dictionary for all keys containing the search string (as long as the keys are not functions) and
returns a filtered dictionary of only those keys
:param search_string: str, string we are looking for
:param input_dict: dict, dictionary to search through
:param default: object, if we f... | [
"Searches",
"a",
"dictionary",
"for",
"all",
"keys",
"containing",
"the",
"search",
"string",
"(",
"as",
"long",
"as",
"the",
"keys",
"are",
"not",
"functions",
")",
"and",
"returns",
"a",
"filtered",
"dictionary",
"of",
"only",
"those",
"keys",
":",
"para... | train | https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/tools.py#L80-L100 |
AndresMWeber/Nomenclate | nomenclate/core/tools.py | gen_dict_key_matches | def gen_dict_key_matches(key, dictionary, _path=None, full_path=False):
""" Generates a list of sets of (path, value) where path is a list of keys to access the given value in the given
nested dictionary
:param key: object, given dictionary key we are looking for
:param dictionary: dict, query dict... | python | def gen_dict_key_matches(key, dictionary, _path=None, full_path=False):
""" Generates a list of sets of (path, value) where path is a list of keys to access the given value in the given
nested dictionary
:param key: object, given dictionary key we are looking for
:param dictionary: dict, query dict... | [
"def",
"gen_dict_key_matches",
"(",
"key",
",",
"dictionary",
",",
"_path",
"=",
"None",
",",
"full_path",
"=",
"False",
")",
":",
"if",
"_path",
"is",
"None",
":",
"_path",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"dictionary",
"... | Generates a list of sets of (path, value) where path is a list of keys to access the given value in the given
nested dictionary
:param key: object, given dictionary key we are looking for
:param dictionary: dict, query dictionary
:param _path: list(str), internal use for the current path to output ... | [
"Generates",
"a",
"list",
"of",
"sets",
"of",
"(",
"path",
"value",
")",
"where",
"path",
"is",
"a",
"list",
"of",
"keys",
"to",
"access",
"the",
"given",
"value",
"in",
"the",
"given",
"nested",
"dictionary"
] | train | https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/tools.py#L103-L121 |
AndresMWeber/Nomenclate | nomenclate/core/tools.py | flatten | def flatten(it):
""" Flattens any iterable
From:
http://stackoverflow.com/questions/11503065/python-function-to-flatten-generator-containing-another-generator
:param it: Iterator, iterator to flatten
:return: Generator, A generator of the flattened values
"""
for x in it:
if... | python | def flatten(it):
""" Flattens any iterable
From:
http://stackoverflow.com/questions/11503065/python-function-to-flatten-generator-containing-another-generator
:param it: Iterator, iterator to flatten
:return: Generator, A generator of the flattened values
"""
for x in it:
if... | [
"def",
"flatten",
"(",
"it",
")",
":",
"for",
"x",
"in",
"it",
":",
"if",
"isinstance",
"(",
"x",
",",
"collections",
".",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"x",
",",
"str",
")",
":",
"for",
"y",
"in",
"flatten",
"(",
"x",
")",
... | Flattens any iterable
From:
http://stackoverflow.com/questions/11503065/python-function-to-flatten-generator-containing-another-generator
:param it: Iterator, iterator to flatten
:return: Generator, A generator of the flattened values | [
"Flattens",
"any",
"iterable",
"From",
":",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"11503065",
"/",
"python",
"-",
"function",
"-",
"to",
"-",
"flatten",
"-",
"generator",
"-",
"containing",
"-",
"another",
"-",
"generator"
... | train | https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/tools.py#L124-L137 |
shaded-enmity/docker-hica | injectors/introspect_runtime.py | IntrospectRuntimeInjector._run_introspection | def _run_introspection(self, runtime='', whitelist=[], verbose=False):
""" Figure out which objects are opened by a test binary and are matched by the white list.
:param runtime: The binary to run.
:type runtime: str
:param whitelist: A list of regular expressions describing acceptable library names
... | python | def _run_introspection(self, runtime='', whitelist=[], verbose=False):
""" Figure out which objects are opened by a test binary and are matched by the white list.
:param runtime: The binary to run.
:type runtime: str
:param whitelist: A list of regular expressions describing acceptable library names
... | [
"def",
"_run_introspection",
"(",
"self",
",",
"runtime",
"=",
"''",
",",
"whitelist",
"=",
"[",
"]",
",",
"verbose",
"=",
"False",
")",
":",
"found_objects",
"=",
"set",
"(",
")",
"try",
":",
"# Retrieve list of successfully opened objects",
"strace",
"=",
... | Figure out which objects are opened by a test binary and are matched by the white list.
:param runtime: The binary to run.
:type runtime: str
:param whitelist: A list of regular expressions describing acceptable library names
:type whitelist: [str] | [
"Figure",
"out",
"which",
"objects",
"are",
"opened",
"by",
"a",
"test",
"binary",
"and",
"are",
"matched",
"by",
"the",
"white",
"list",
"."
] | train | https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/injectors/introspect_runtime.py#L31-L63 |
shaded-enmity/docker-hica | injectors/introspect_runtime.py | IntrospectRuntimeInjector.__get_container_path | def __get_container_path(self, host_path):
""" A simple helper function to determine the path of a host library
inside the container
:param host_path: The path of the library on the host
:type host_path: str
"""
libname = os.path.split(host_path)[1]
return os.path.join(_container_lib_locati... | python | def __get_container_path(self, host_path):
""" A simple helper function to determine the path of a host library
inside the container
:param host_path: The path of the library on the host
:type host_path: str
"""
libname = os.path.split(host_path)[1]
return os.path.join(_container_lib_locati... | [
"def",
"__get_container_path",
"(",
"self",
",",
"host_path",
")",
":",
"libname",
"=",
"os",
".",
"path",
".",
"split",
"(",
"host_path",
")",
"[",
"1",
"]",
"return",
"os",
".",
"path",
".",
"join",
"(",
"_container_lib_location",
",",
"libname",
")"
] | A simple helper function to determine the path of a host library
inside the container
:param host_path: The path of the library on the host
:type host_path: str | [
"A",
"simple",
"helper",
"function",
"to",
"determine",
"the",
"path",
"of",
"a",
"host",
"library",
"inside",
"the",
"container"
] | train | https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/injectors/introspect_runtime.py#L65-L73 |
shaded-enmity/docker-hica | injectors/introspect_runtime.py | IntrospectRuntimeInjector.inject_config | def inject_config(self, config, from_args):
"""
:param config:
:type config: list
:param from_args:
:type from_args: dict
"""
# First get required values from labelStore
runtime = self._get_runtime()
whitelist = self._get_whitelist()
#Run introspection on the libraries to retriev... | python | def inject_config(self, config, from_args):
"""
:param config:
:type config: list
:param from_args:
:type from_args: dict
"""
# First get required values from labelStore
runtime = self._get_runtime()
whitelist = self._get_whitelist()
#Run introspection on the libraries to retriev... | [
"def",
"inject_config",
"(",
"self",
",",
"config",
",",
"from_args",
")",
":",
"# First get required values from labelStore",
"runtime",
"=",
"self",
".",
"_get_runtime",
"(",
")",
"whitelist",
"=",
"self",
".",
"_get_whitelist",
"(",
")",
"#Run introspection on th... | :param config:
:type config: list
:param from_args:
:type from_args: dict | [
":",
"param",
"config",
":",
":",
"type",
"config",
":",
"list",
":",
"param",
"from_args",
":",
":",
"type",
"from_args",
":",
"dict"
] | train | https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/injectors/introspect_runtime.py#L81-L105 |
csaez/wishlib | wishlib/si/__init__.py | inside_softimage | def inside_softimage():
"""Returns a boolean indicating if the code is executed inside softimage."""
try:
import maya
return False
except ImportError:
pass
try:
from win32com.client import Dispatch as disp
disp('XSI.Application')
return True
except:
... | python | def inside_softimage():
"""Returns a boolean indicating if the code is executed inside softimage."""
try:
import maya
return False
except ImportError:
pass
try:
from win32com.client import Dispatch as disp
disp('XSI.Application')
return True
except:
... | [
"def",
"inside_softimage",
"(",
")",
":",
"try",
":",
"import",
"maya",
"return",
"False",
"except",
"ImportError",
":",
"pass",
"try",
":",
"from",
"win32com",
".",
"client",
"import",
"Dispatch",
"as",
"disp",
"disp",
"(",
"'XSI.Application'",
")",
"return... | Returns a boolean indicating if the code is executed inside softimage. | [
"Returns",
"a",
"boolean",
"indicating",
"if",
"the",
"code",
"is",
"executed",
"inside",
"softimage",
"."
] | train | https://github.com/csaez/wishlib/blob/c212fa7875006a332a4cefbf69885ced9647bc2f/wishlib/si/__init__.py#L4-L16 |
krukas/Trionyx | trionyx/navigation.py | Menu.auto_load_model_menu | def auto_load_model_menu(self):
"""
Auto load model menu entries, can be configured in `trionyx.config.ModelConfig`:
- menu_name
- menu_icon
- menu_order
"""
from trionyx.trionyx.apps import BaseConfig
order = 0
for app in apps.get_app_configs():... | python | def auto_load_model_menu(self):
"""
Auto load model menu entries, can be configured in `trionyx.config.ModelConfig`:
- menu_name
- menu_icon
- menu_order
"""
from trionyx.trionyx.apps import BaseConfig
order = 0
for app in apps.get_app_configs():... | [
"def",
"auto_load_model_menu",
"(",
"self",
")",
":",
"from",
"trionyx",
".",
"trionyx",
".",
"apps",
"import",
"BaseConfig",
"order",
"=",
"0",
"for",
"app",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"app",
","... | Auto load model menu entries, can be configured in `trionyx.config.ModelConfig`:
- menu_name
- menu_icon
- menu_order | [
"Auto",
"load",
"model",
"menu",
"entries",
"can",
"be",
"configured",
"in",
"trionyx",
".",
"config",
".",
"ModelConfig",
":"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L26-L80 |
krukas/Trionyx | trionyx/navigation.py | Menu.add_item | def add_item(self, path, name, icon=None, url=None, order=None, permission=None, active_regex=None):
"""
Add new menu item to menu
:param path: Path of menu
:param name: Display name
:param icon: CSS icon
:param url: link to page
:param order: Sort order
... | python | def add_item(self, path, name, icon=None, url=None, order=None, permission=None, active_regex=None):
"""
Add new menu item to menu
:param path: Path of menu
:param name: Display name
:param icon: CSS icon
:param url: link to page
:param order: Sort order
... | [
"def",
"add_item",
"(",
"self",
",",
"path",
",",
"name",
",",
"icon",
"=",
"None",
",",
"url",
"=",
"None",
",",
"order",
"=",
"None",
",",
"permission",
"=",
"None",
",",
"active_regex",
"=",
"None",
")",
":",
"if",
"self",
".",
"root_item",
"is"... | Add new menu item to menu
:param path: Path of menu
:param name: Display name
:param icon: CSS icon
:param url: link to page
:param order: Sort order
:param permission:
:return: | [
"Add",
"new",
"menu",
"item",
"to",
"menu"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L82-L116 |
krukas/Trionyx | trionyx/navigation.py | MenuItem.merge | def merge(self, item):
"""Merge Menu item data"""
self.name = item.name
if item.icon:
self.icon = item.icon
if item.url:
self.url = item.url
if item.order:
self.order = item.order
if item.permission:
self.permission = it... | python | def merge(self, item):
"""Merge Menu item data"""
self.name = item.name
if item.icon:
self.icon = item.icon
if item.url:
self.url = item.url
if item.order:
self.order = item.order
if item.permission:
self.permission = it... | [
"def",
"merge",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"name",
"=",
"item",
".",
"name",
"if",
"item",
".",
"icon",
":",
"self",
".",
"icon",
"=",
"item",
".",
"icon",
"if",
"item",
".",
"url",
":",
"self",
".",
"url",
"=",
"item",
... | Merge Menu item data | [
"Merge",
"Menu",
"item",
"data"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L150-L164 |
krukas/Trionyx | trionyx/navigation.py | MenuItem.add_child | def add_child(self, item):
"""Add child to menu item"""
item.depth = self.depth + 1
self.childs.append(item)
self.childs = sorted(self.childs, key=lambda item: item.order if item.order else 999) | python | def add_child(self, item):
"""Add child to menu item"""
item.depth = self.depth + 1
self.childs.append(item)
self.childs = sorted(self.childs, key=lambda item: item.order if item.order else 999) | [
"def",
"add_child",
"(",
"self",
",",
"item",
")",
":",
"item",
".",
"depth",
"=",
"self",
".",
"depth",
"+",
"1",
"self",
".",
"childs",
".",
"append",
"(",
"item",
")",
"self",
".",
"childs",
"=",
"sorted",
"(",
"self",
".",
"childs",
",",
"key... | Add child to menu item | [
"Add",
"child",
"to",
"menu",
"item"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L166-L170 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.