id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
240,000 | 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"
] | f57b6908d3c76c4a44b2241c676ab5d86391106c | https://github.com/armstrong/armstrong.apps.related_content/blob/f57b6908d3c76c4a44b2241c676ab5d86391106c/armstrong/apps/related_content/admin.py#L46-L68 |
240,001 | 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",
"."
] | 2603e323a995e0915ce41fcf49e2a82519556195 | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/signature.py#L165-L169 |
240,002 | 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",
"."
] | 2603e323a995e0915ce41fcf49e2a82519556195 | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/signature.py#L171-L179 |
240,003 | 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",
"."
] | 4159a5186c4b4fc32354749892e86130530f6ec5 | https://github.com/almcc/cinder-data/blob/4159a5186c4b4fc32354749892e86130530f6ec5/cinder_data/cache.py#L55-L67 |
240,004 | 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",
"."
] | 4159a5186c4b4fc32354749892e86130530f6ec5 | https://github.com/almcc/cinder-data/blob/4159a5186c4b4fc32354749892e86130530f6ec5/cinder_data/cache.py#L69-L81 |
240,005 | 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",
"."
] | 4159a5186c4b4fc32354749892e86130530f6ec5 | https://github.com/almcc/cinder-data/blob/4159a5186c4b4fc32354749892e86130530f6ec5/cinder_data/cache.py#L83-L93 |
240,006 | 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",
... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L96-L133 |
240,007 | 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... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L151-L204 |
240,008 | 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",
".",
... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L207-L215 |
240,009 | 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",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/data.py#L218-L251 |
240,010 | 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"
] | 7e5b60d2900ceddefa49de352a19b794199b51a8 | https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/done/Commands.py#L25-L76 |
240,011 | 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",
"."
] | dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267 | https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/notifications.py#L32-L50 |
240,012 | 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"
] | 3434c5c68fb7661d74f03404c71bb5fbebe1900f | https://github.com/BenDoan/perform/blob/3434c5c68fb7661d74f03404c71bb5fbebe1900f/perform.py#L128-L140 |
240,013 | 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"
] | 3434c5c68fb7661d74f03404c71bb5fbebe1900f | https://github.com/BenDoan/perform/blob/3434c5c68fb7661d74f03404c71bb5fbebe1900f/perform.py#L142-L155 |
240,014 | 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"
] | 3434c5c68fb7661d74f03404c71bb5fbebe1900f | https://github.com/BenDoan/perform/blob/3434c5c68fb7661d74f03404c71bb5fbebe1900f/perform.py#L157-L164 |
240,015 | 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"
] | fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5 | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L62-L69 |
240,016 | 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"
] | fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5 | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L176-L187 |
240,017 | 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"
] | fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5 | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L189-L209 |
240,018 | 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"
] | fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5 | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L211-L225 |
240,019 | 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"
] | fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5 | https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemmatiseur.py#L238-L246 |
240,020 | 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",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L22-L32 |
240,021 | 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",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L48-L79 |
240,022 | 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",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L81-L93 |
240,023 | 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",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L95-L113 |
240,024 | 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",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L119-L127 |
240,025 | 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",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L139-L142 |
240,026 | 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",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/ftp.py#L144-L161 |
240,027 | 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"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/forms/accounts.py#L69-L80 |
240,028 | 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",
"."
] | ae0c9e3630e2c4729a0614cc86f493688436b0b7 | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/_baton/_baton_runner.py#L129-L157 |
240,029 | 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",
"."
] | b31722dc14243ca8f626f8b3bce9718d0119de55 | https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/forms.py#L63-L68 |
240,030 | 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",
"."
] | 8644e1292cdb5d7f2b2eb3c0982b1f97202b24cf | https://github.com/ministryofjustice/postcodeinfo-client-python/blob/8644e1292cdb5d7f2b2eb3c0982b1f97202b24cf/postcodeinfo.py#L270-L295 |
240,031 | 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",
"."
] | ea241b8a63c4baa44cfb17c6acd47b6e12e822af | https://github.com/okzach/bofhexcuse/blob/ea241b8a63c4baa44cfb17c6acd47b6e12e822af/bofhexcuse/__init__.py#L14-L39 |
240,032 | 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!"
] | ea241b8a63c4baa44cfb17c6acd47b6e12e822af | https://github.com/okzach/bofhexcuse/blob/ea241b8a63c4baa44cfb17c6acd47b6e12e822af/bofhexcuse/__init__.py#L42-L56 |
240,033 | 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",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L211-L223 |
240,034 | 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",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L226-L243 |
240,035 | 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"
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L31-L34 |
240,036 | 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",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L36-L48 |
240,037 | 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",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L102-L114 |
240,038 | 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",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L118-L127 |
240,039 | 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",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L129-L138 |
240,040 | 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"
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L152-L161 |
240,041 | 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",
"."
] | 404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4 | https://github.com/boatd/python-boatd/blob/404ff0d0c389f6ed84ddbfea1c41db6569ad2ed4/boatdclient/boatd_client.py#L190-L202 |
240,042 | 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",
"."
] | a10aa7d21d38622e984a8fe106ab37114af90dc2 | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/types.py#L141-L154 |
240,043 | 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",
"."
] | a10aa7d21d38622e984a8fe106ab37114af90dc2 | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/types.py#L58-L69 |
240,044 | 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",
"."
] | c35f83cb1c5268b7e641146bc8c6139fbc10e20f | https://github.com/GetRektByMe/Raitonoberu/blob/c35f83cb1c5268b7e641146bc8c6139fbc10e20f/Raitonoberu/raitonoberu.py#L20-L38 |
240,045 | 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",
"."
] | c35f83cb1c5268b7e641146bc8c6139fbc10e20f | https://github.com/GetRektByMe/Raitonoberu/blob/c35f83cb1c5268b7e641146bc8c6139fbc10e20f/Raitonoberu/raitonoberu.py#L57-L66 |
240,046 | 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",
"."
] | c35f83cb1c5268b7e641146bc8c6139fbc10e20f | https://github.com/GetRektByMe/Raitonoberu/blob/c35f83cb1c5268b7e641146bc8c6139fbc10e20f/Raitonoberu/raitonoberu.py#L69-L108 |
240,047 | 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",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L34-L56 |
240,048 | 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",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L59-L80 |
240,049 | 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",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L128-L146 |
240,050 | 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",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L333-L358 |
240,051 | 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",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L424-L454 |
240,052 | 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"
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L479-L489 |
240,053 | 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",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/gpib.py#L532-L543 |
240,054 | 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",
"."
] | ae505ef69a9feb739b5f4e62c5a8e6533104d3ea | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/pip_support.py#L32-L76 |
240,055 | 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",
"."
] | 74a7116362ba5b45635ab247472b25cfbdece4ee | https://github.com/rjw57/throw/blob/74a7116362ba5b45635ab247472b25cfbdece4ee/throw/attachment_renderer.py#L12-L74 |
240,056 | 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"
] | ce8be0ae81f8878b460bc156693f1957f7dd34a3 | https://github.com/ArtoLabs/SimpleSteem/blob/ce8be0ae81f8878b460bc156693f1957f7dd34a3/simplesteem/makeconfig.py#L54-L61 |
240,057 | 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",
"."
] | bc425586297e1eb228b70ee6fca8c499849ec87d | https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/injectors/introspect_runtime.py#L31-L63 |
240,058 | 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"
] | bc425586297e1eb228b70ee6fca8c499849ec87d | https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/injectors/introspect_runtime.py#L65-L73 |
240,059 | 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",
"."
] | c212fa7875006a332a4cefbf69885ced9647bc2f | https://github.com/csaez/wishlib/blob/c212fa7875006a332a4cefbf69885ced9647bc2f/wishlib/si/__init__.py#L4-L16 |
240,060 | 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"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L82-L116 |
240,061 | 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"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L150-L164 |
240,062 | 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"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L166-L170 |
240,063 | krukas/Trionyx | trionyx/navigation.py | MenuItem.child_by_code | def child_by_code(self, code):
"""
Get child MenuItem by its last path code
:param code:
:return: MenuItem or None
"""
for child in self.childs:
if child.path.split('/')[-1] == code:
return child
return None | python | def child_by_code(self, code):
"""
Get child MenuItem by its last path code
:param code:
:return: MenuItem or None
"""
for child in self.childs:
if child.path.split('/')[-1] == code:
return child
return None | [
"def",
"child_by_code",
"(",
"self",
",",
"code",
")",
":",
"for",
"child",
"in",
"self",
".",
"childs",
":",
"if",
"child",
".",
"path",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"==",
"code",
":",
"return",
"child",
"return",
"None"
] | Get child MenuItem by its last path code
:param code:
:return: MenuItem or None | [
"Get",
"child",
"MenuItem",
"by",
"its",
"last",
"path",
"code"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L172-L182 |
240,064 | krukas/Trionyx | trionyx/navigation.py | MenuItem.is_active | def is_active(self, path):
"""Check if given path is active for current item"""
if self.url == '/' and self.url == path:
return True
elif self.url == '/':
return False
if self.url and path.startswith(self.url):
return True
if self.active_rege... | python | def is_active(self, path):
"""Check if given path is active for current item"""
if self.url == '/' and self.url == path:
return True
elif self.url == '/':
return False
if self.url and path.startswith(self.url):
return True
if self.active_rege... | [
"def",
"is_active",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"url",
"==",
"'/'",
"and",
"self",
".",
"url",
"==",
"path",
":",
"return",
"True",
"elif",
"self",
".",
"url",
"==",
"'/'",
":",
"return",
"False",
"if",
"self",
".",
"ur... | Check if given path is active for current item | [
"Check",
"if",
"given",
"path",
"is",
"active",
"for",
"current",
"item"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L184-L200 |
240,065 | krukas/Trionyx | trionyx/navigation.py | TabRegister.get_tabs | def get_tabs(self, model_alias, object):
"""
Get all active tabs for given model
:param model_alias:
:param object: Object used to filter tabs
:return:
"""
model_alias = self.get_model_alias(model_alias)
for item in self.tabs[model_alias]:
if ... | python | def get_tabs(self, model_alias, object):
"""
Get all active tabs for given model
:param model_alias:
:param object: Object used to filter tabs
:return:
"""
model_alias = self.get_model_alias(model_alias)
for item in self.tabs[model_alias]:
if ... | [
"def",
"get_tabs",
"(",
"self",
",",
"model_alias",
",",
"object",
")",
":",
"model_alias",
"=",
"self",
".",
"get_model_alias",
"(",
"model_alias",
")",
"for",
"item",
"in",
"self",
".",
"tabs",
"[",
"model_alias",
"]",
":",
"if",
"item",
".",
"display_... | Get all active tabs for given model
:param model_alias:
:param object: Object used to filter tabs
:return: | [
"Get",
"all",
"active",
"tabs",
"for",
"given",
"model"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L210-L221 |
240,066 | krukas/Trionyx | trionyx/navigation.py | TabRegister.get_tab | def get_tab(self, model_alias, object, tab_code):
"""
Get tab for given object and tab code
:param model_alias:
:param object: Object used to render tab
:param tab_code: Tab code to use
:return:
"""
model_alias = self.get_model_alias(model_alias)
... | python | def get_tab(self, model_alias, object, tab_code):
"""
Get tab for given object and tab code
:param model_alias:
:param object: Object used to render tab
:param tab_code: Tab code to use
:return:
"""
model_alias = self.get_model_alias(model_alias)
... | [
"def",
"get_tab",
"(",
"self",
",",
"model_alias",
",",
"object",
",",
"tab_code",
")",
":",
"model_alias",
"=",
"self",
".",
"get_model_alias",
"(",
"model_alias",
")",
"for",
"item",
"in",
"self",
".",
"tabs",
"[",
"model_alias",
"]",
":",
"if",
"item"... | Get tab for given object and tab code
:param model_alias:
:param object: Object used to render tab
:param tab_code: Tab code to use
:return: | [
"Get",
"tab",
"for",
"given",
"object",
"and",
"tab",
"code"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L223-L236 |
240,067 | krukas/Trionyx | trionyx/navigation.py | TabRegister.register | def register(self, model_alias, code='general', name=None, order=None, display_filter=None):
"""
Register new tab
:param model_alias:
:param code:
:param name:
:param order:
:return:
"""
model_alias = self.get_model_alias(model_alias)
def... | python | def register(self, model_alias, code='general', name=None, order=None, display_filter=None):
"""
Register new tab
:param model_alias:
:param code:
:param name:
:param order:
:return:
"""
model_alias = self.get_model_alias(model_alias)
def... | [
"def",
"register",
"(",
"self",
",",
"model_alias",
",",
"code",
"=",
"'general'",
",",
"name",
"=",
"None",
",",
"order",
"=",
"None",
",",
"display_filter",
"=",
"None",
")",
":",
"model_alias",
"=",
"self",
".",
"get_model_alias",
"(",
"model_alias",
... | Register new tab
:param model_alias:
:param code:
:param name:
:param order:
:return: | [
"Register",
"new",
"tab"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L238-L266 |
240,068 | krukas/Trionyx | trionyx/navigation.py | TabRegister.update | def update(self, model_alias, code='general', name=None, order=None, display_filter=None):
"""
Update given tab
:param model_alias:
:param code:
:param name:
:param order:
:param display_filter:
:return:
"""
model_alias = self.get_model_al... | python | def update(self, model_alias, code='general', name=None, order=None, display_filter=None):
"""
Update given tab
:param model_alias:
:param code:
:param name:
:param order:
:param display_filter:
:return:
"""
model_alias = self.get_model_al... | [
"def",
"update",
"(",
"self",
",",
"model_alias",
",",
"code",
"=",
"'general'",
",",
"name",
"=",
"None",
",",
"order",
"=",
"None",
",",
"display_filter",
"=",
"None",
")",
":",
"model_alias",
"=",
"self",
".",
"get_model_alias",
"(",
"model_alias",
")... | Update given tab
:param model_alias:
:param code:
:param name:
:param order:
:param display_filter:
:return: | [
"Update",
"given",
"tab"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L285-L307 |
240,069 | krukas/Trionyx | trionyx/navigation.py | TabRegister.get_model_alias | def get_model_alias(self, model_alias):
"""Get model alias if class then convert to alias string"""
from trionyx.models import BaseModel
if inspect.isclass(model_alias) and issubclass(model_alias, BaseModel):
config = models_config.get_config(model_alias)
return '{}.{}'.f... | python | def get_model_alias(self, model_alias):
"""Get model alias if class then convert to alias string"""
from trionyx.models import BaseModel
if inspect.isclass(model_alias) and issubclass(model_alias, BaseModel):
config = models_config.get_config(model_alias)
return '{}.{}'.f... | [
"def",
"get_model_alias",
"(",
"self",
",",
"model_alias",
")",
":",
"from",
"trionyx",
".",
"models",
"import",
"BaseModel",
"if",
"inspect",
".",
"isclass",
"(",
"model_alias",
")",
"and",
"issubclass",
"(",
"model_alias",
",",
"BaseModel",
")",
":",
"conf... | Get model alias if class then convert to alias string | [
"Get",
"model",
"alias",
"if",
"class",
"then",
"convert",
"to",
"alias",
"string"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L309-L315 |
240,070 | krukas/Trionyx | trionyx/navigation.py | TabRegister.auto_generate_missing_tabs | def auto_generate_missing_tabs(self):
"""Auto generate tabs for models with no tabs"""
for config in models_config.get_all_configs():
model_alias = '{}.{}'.format(config.app_label, config.model_name)
if model_alias not in self.tabs:
@self.register(model_alias)
... | python | def auto_generate_missing_tabs(self):
"""Auto generate tabs for models with no tabs"""
for config in models_config.get_all_configs():
model_alias = '{}.{}'.format(config.app_label, config.model_name)
if model_alias not in self.tabs:
@self.register(model_alias)
... | [
"def",
"auto_generate_missing_tabs",
"(",
"self",
")",
":",
"for",
"config",
"in",
"models_config",
".",
"get_all_configs",
"(",
")",
":",
"model_alias",
"=",
"'{}.{}'",
".",
"format",
"(",
"config",
".",
"app_label",
",",
"config",
".",
"model_name",
")",
"... | Auto generate tabs for models with no tabs | [
"Auto",
"generate",
"tabs",
"for",
"models",
"with",
"no",
"tabs"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L317-L331 |
240,071 | krukas/Trionyx | trionyx/navigation.py | TabItem.name | def name(self):
"""Give back tab name if is set else generate name by code"""
if self._name:
return self._name
return self.code.replace('_', ' ').capitalize() | python | def name(self):
"""Give back tab name if is set else generate name by code"""
if self._name:
return self._name
return self.code.replace('_', ' ').capitalize() | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_name",
":",
"return",
"self",
".",
"_name",
"return",
"self",
".",
"code",
".",
"replace",
"(",
"'_'",
",",
"' '",
")",
".",
"capitalize",
"(",
")"
] | Give back tab name if is set else generate name by code | [
"Give",
"back",
"tab",
"name",
"if",
"is",
"set",
"else",
"generate",
"name",
"by",
"code"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L348-L352 |
240,072 | krukas/Trionyx | trionyx/navigation.py | TabItem.get_layout | def get_layout(self, object):
"""Get complete layout for given object"""
layout = self.create_layout(object)
if isinstance(layout, Component):
layout = Layout(layout)
if isinstance(layout, list):
layout = Layout(*layout)
for update_layout in self.layout_... | python | def get_layout(self, object):
"""Get complete layout for given object"""
layout = self.create_layout(object)
if isinstance(layout, Component):
layout = Layout(layout)
if isinstance(layout, list):
layout = Layout(*layout)
for update_layout in self.layout_... | [
"def",
"get_layout",
"(",
"self",
",",
"object",
")",
":",
"layout",
"=",
"self",
".",
"create_layout",
"(",
"object",
")",
"if",
"isinstance",
"(",
"layout",
",",
"Component",
")",
":",
"layout",
"=",
"Layout",
"(",
"layout",
")",
"if",
"isinstance",
... | Get complete layout for given object | [
"Get",
"complete",
"layout",
"for",
"given",
"object"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/navigation.py#L359-L371 |
240,073 | wbonnet/mnemonic-checker | mnemonic_checker/__main__.py | main | def main():
"""
Main entry point for the script. Create a parser, process the command line,
and run it
"""
parser = cli.Cli()
parser.parse(sys.argv[1:])
return parser.run() | python | def main():
"""
Main entry point for the script. Create a parser, process the command line,
and run it
"""
parser = cli.Cli()
parser.parse(sys.argv[1:])
return parser.run() | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"cli",
".",
"Cli",
"(",
")",
"parser",
".",
"parse",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"return",
"parser",
".",
"run",
"(",
")"
] | Main entry point for the script. Create a parser, process the command line,
and run it | [
"Main",
"entry",
"point",
"for",
"the",
"script",
".",
"Create",
"a",
"parser",
"process",
"the",
"command",
"line",
"and",
"run",
"it"
] | cec3f25b447c111f4d31fabcaee89af7977cafd8 | https://github.com/wbonnet/mnemonic-checker/blob/cec3f25b447c111f4d31fabcaee89af7977cafd8/mnemonic_checker/__main__.py#L26-L33 |
240,074 | MacHu-GWU/angora-project | angora/gadget/backup.py | run_backup | def run_backup(filename, root_dir, ignore=[], ignore_ext=[], ignore_pattern=[]):
"""The backup utility method.
:param root_dir: the directory you want to backup
:param ignore: file or directory defined in this list will be ignored.
:param ignore_ext: file with extensions defined in this list will be ig... | python | def run_backup(filename, root_dir, ignore=[], ignore_ext=[], ignore_pattern=[]):
"""The backup utility method.
:param root_dir: the directory you want to backup
:param ignore: file or directory defined in this list will be ignored.
:param ignore_ext: file with extensions defined in this list will be ig... | [
"def",
"run_backup",
"(",
"filename",
",",
"root_dir",
",",
"ignore",
"=",
"[",
"]",
",",
"ignore_ext",
"=",
"[",
"]",
",",
"ignore_pattern",
"=",
"[",
"]",
")",
":",
"tab",
"=",
"\" \"",
"# Step 1, calculate files to backup",
"print",
"(",
"\"Perform backu... | The backup utility method.
:param root_dir: the directory you want to backup
:param ignore: file or directory defined in this list will be ignored.
:param ignore_ext: file with extensions defined in this list will be ignored.
:param ignore_pattern: any file or directory that contains this pattern
... | [
"The",
"backup",
"utility",
"method",
"."
] | 689a60da51cd88680ddbe26e28dbe81e6b01d275 | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/gadget/backup.py#L75-L117 |
240,075 | ddorn/pyconfiglib | configlib/prompting.py | prompt_file | def prompt_file(prompt, default=None):
"""Prompt a file name with autocompletion"""
def complete(text: str, state):
text = text.replace('~', HOME)
sugg = (glob.glob(text + '*') + [None])[state]
if sugg is None:
return
sugg = sugg.replace(HOME, '~')
sugg = ... | python | def prompt_file(prompt, default=None):
"""Prompt a file name with autocompletion"""
def complete(text: str, state):
text = text.replace('~', HOME)
sugg = (glob.glob(text + '*') + [None])[state]
if sugg is None:
return
sugg = sugg.replace(HOME, '~')
sugg = ... | [
"def",
"prompt_file",
"(",
"prompt",
",",
"default",
"=",
"None",
")",
":",
"def",
"complete",
"(",
"text",
":",
"str",
",",
"state",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"'~'",
",",
"HOME",
")",
"sugg",
"=",
"(",
"glob",
".",
"glo... | Prompt a file name with autocompletion | [
"Prompt",
"a",
"file",
"name",
"with",
"autocompletion"
] | 3ad01d0bb9344e18719d82a5928b4d8e5fe726ac | https://github.com/ddorn/pyconfiglib/blob/3ad01d0bb9344e18719d82a5928b4d8e5fe726ac/configlib/prompting.py#L9-L42 |
240,076 | Vito2015/pyextend | pyextend/core/math.py | isprime | def isprime(n):
"""Check the number is prime value. if prime value returns True, not False."""
n = abs(int(n))
if n < 2:
return False
if n == 2:
return True
if not n & 1:
return False
# 在一般领域, 对正整数n, 如果用2 到 sqrt(n) 之间所有整数去除, 均无法整除, 则n为质数.
for x in range(3, int(n ** ... | python | def isprime(n):
"""Check the number is prime value. if prime value returns True, not False."""
n = abs(int(n))
if n < 2:
return False
if n == 2:
return True
if not n & 1:
return False
# 在一般领域, 对正整数n, 如果用2 到 sqrt(n) 之间所有整数去除, 均无法整除, 则n为质数.
for x in range(3, int(n ** ... | [
"def",
"isprime",
"(",
"n",
")",
":",
"n",
"=",
"abs",
"(",
"int",
"(",
"n",
")",
")",
"if",
"n",
"<",
"2",
":",
"return",
"False",
"if",
"n",
"==",
"2",
":",
"return",
"True",
"if",
"not",
"n",
"&",
"1",
":",
"return",
"False",
"# 在一般领域, 对正整... | Check the number is prime value. if prime value returns True, not False. | [
"Check",
"the",
"number",
"is",
"prime",
"value",
".",
"if",
"prime",
"value",
"returns",
"True",
"not",
"False",
"."
] | 36861dfe1087e437ffe9b5a1da9345c85b4fa4a1 | https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/math.py#L12-L28 |
240,077 | mattupstate/cubric | cubric/contrib/servers/ubuntu/default/__init__.py | WsgiApplicationContext.create | def create(self):
"""Create an application context on the server"""
self.before_create()
puts(green('Creating app context'))
tdir = os.path.dirname(__file__)
# Ensure the app context user exists
user_ensure(self.user, home='/home/' + self.user)
dir_ensure('/hom... | python | def create(self):
"""Create an application context on the server"""
self.before_create()
puts(green('Creating app context'))
tdir = os.path.dirname(__file__)
# Ensure the app context user exists
user_ensure(self.user, home='/home/' + self.user)
dir_ensure('/hom... | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"before_create",
"(",
")",
"puts",
"(",
"green",
"(",
"'Creating app context'",
")",
")",
"tdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"# Ensure the app context user exists",
"user... | Create an application context on the server | [
"Create",
"an",
"application",
"context",
"on",
"the",
"server"
] | a648ce00e4467cd14d71e754240ef6c1f87a34b5 | https://github.com/mattupstate/cubric/blob/a648ce00e4467cd14d71e754240ef6c1f87a34b5/cubric/contrib/servers/ubuntu/default/__init__.py#L246-L291 |
240,078 | mattupstate/cubric | cubric/contrib/servers/ubuntu/default/__init__.py | WsgiApplicationContext.upload_release | def upload_release(self):
"""Upload an application bundle to the server for a given context"""
self.before_upload_release()
with settings(user=self.user):
with app_bundle():
local_bundle = env.local_bundle
env.bundle = '/tmp/' + os.path.basename(local... | python | def upload_release(self):
"""Upload an application bundle to the server for a given context"""
self.before_upload_release()
with settings(user=self.user):
with app_bundle():
local_bundle = env.local_bundle
env.bundle = '/tmp/' + os.path.basename(local... | [
"def",
"upload_release",
"(",
"self",
")",
":",
"self",
".",
"before_upload_release",
"(",
")",
"with",
"settings",
"(",
"user",
"=",
"self",
".",
"user",
")",
":",
"with",
"app_bundle",
"(",
")",
":",
"local_bundle",
"=",
"env",
".",
"local_bundle",
"en... | Upload an application bundle to the server for a given context | [
"Upload",
"an",
"application",
"bundle",
"to",
"the",
"server",
"for",
"a",
"given",
"context"
] | a648ce00e4467cd14d71e754240ef6c1f87a34b5 | https://github.com/mattupstate/cubric/blob/a648ce00e4467cd14d71e754240ef6c1f87a34b5/cubric/contrib/servers/ubuntu/default/__init__.py#L299-L337 |
240,079 | Rhathe/fixtureupper | fixtureupper/model.py | ModelFixtureUpper._print_breakdown | def _print_breakdown(cls, savedir, fname, data):
"""Function to print model fixtures into generated file"""
if not os.path.exists(savedir):
os.makedirs(savedir)
with open(os.path.join(savedir, fname), 'w') as fout:
fout.write(data) | python | def _print_breakdown(cls, savedir, fname, data):
"""Function to print model fixtures into generated file"""
if not os.path.exists(savedir):
os.makedirs(savedir)
with open(os.path.join(savedir, fname), 'w') as fout:
fout.write(data) | [
"def",
"_print_breakdown",
"(",
"cls",
",",
"savedir",
",",
"fname",
",",
"data",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"savedir",
")",
":",
"os",
".",
"makedirs",
"(",
"savedir",
")",
"with",
"open",
"(",
"os",
".",
"path",... | Function to print model fixtures into generated file | [
"Function",
"to",
"print",
"model",
"fixtures",
"into",
"generated",
"file"
] | f8d6f95b5f5f38963f2389f4183d1c9884184853 | https://github.com/Rhathe/fixtureupper/blob/f8d6f95b5f5f38963f2389f4183d1c9884184853/fixtureupper/model.py#L137-L143 |
240,080 | Rhathe/fixtureupper | fixtureupper/model.py | ModelFixtureUpper.read_json_breakdown | def read_json_breakdown(cls, fname):
"""Read json file to get fixture data"""
if not os.path.exists(fname):
raise RuntimeError
with open(fname, 'r') as data_file:
return cls.fixup_from_json(data_file.read()) | python | def read_json_breakdown(cls, fname):
"""Read json file to get fixture data"""
if not os.path.exists(fname):
raise RuntimeError
with open(fname, 'r') as data_file:
return cls.fixup_from_json(data_file.read()) | [
"def",
"read_json_breakdown",
"(",
"cls",
",",
"fname",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
":",
"raise",
"RuntimeError",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"data_file",
":",
"return",
"cls",
... | Read json file to get fixture data | [
"Read",
"json",
"file",
"to",
"get",
"fixture",
"data"
] | f8d6f95b5f5f38963f2389f4183d1c9884184853 | https://github.com/Rhathe/fixtureupper/blob/f8d6f95b5f5f38963f2389f4183d1c9884184853/fixtureupper/model.py#L226-L232 |
240,081 | phenicle/pgdbpy | pgdbpy/tools.py | PgDbPy.execute | def execute(self, fetchcommand, sql, params=None):
""" where 'fetchcommand' is either 'fetchone' or 'fetchall' """
cur = self.conn.cursor()
if params:
if not type(params).__name__ == 'tuple':
raise ValueError('the params argument needs to be a tuple')
return None
cur.execute(sql, params)
else:
... | python | def execute(self, fetchcommand, sql, params=None):
""" where 'fetchcommand' is either 'fetchone' or 'fetchall' """
cur = self.conn.cursor()
if params:
if not type(params).__name__ == 'tuple':
raise ValueError('the params argument needs to be a tuple')
return None
cur.execute(sql, params)
else:
... | [
"def",
"execute",
"(",
"self",
",",
"fetchcommand",
",",
"sql",
",",
"params",
"=",
"None",
")",
":",
"cur",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"if",
"params",
":",
"if",
"not",
"type",
"(",
"params",
")",
".",
"__name__",
"==",
"... | where 'fetchcommand' is either 'fetchone' or 'fetchall' | [
"where",
"fetchcommand",
"is",
"either",
"fetchone",
"or",
"fetchall"
] | 0b4cc8825006f8ce620f693c4bd9b8b74312d9e8 | https://github.com/phenicle/pgdbpy/blob/0b4cc8825006f8ce620f693c4bd9b8b74312d9e8/pgdbpy/tools.py#L136-L174 |
240,082 | scivision/histutils | histutils/cp_parents.py | cp_parents | def cp_parents(files, target_dir: Union[str, Path]):
"""
This function requires Python >= 3.6.
This acts like bash cp --parents in Python
inspiration from
http://stackoverflow.com/questions/15329223/copy-a-file-into-a-directory-with-its-original-leading-directories-appended
example
source:... | python | def cp_parents(files, target_dir: Union[str, Path]):
"""
This function requires Python >= 3.6.
This acts like bash cp --parents in Python
inspiration from
http://stackoverflow.com/questions/15329223/copy-a-file-into-a-directory-with-its-original-leading-directories-appended
example
source:... | [
"def",
"cp_parents",
"(",
"files",
",",
"target_dir",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
")",
":",
"# %% make list if it's a string",
"if",
"isinstance",
"(",
"files",
",",
"(",
"str",
",",
"Path",
")",
")",
":",
"files",
"=",
"[",
"files",
"]... | This function requires Python >= 3.6.
This acts like bash cp --parents in Python
inspiration from
http://stackoverflow.com/questions/15329223/copy-a-file-into-a-directory-with-its-original-leading-directories-appended
example
source: /tmp/e/f
dest: /tmp/a/b/c/d/
result: /tmp/a/b/c/d/tmp/e/... | [
"This",
"function",
"requires",
"Python",
">",
"=",
"3",
".",
"6",
"."
] | 859a91d3894cb57faed34881c6ea16130b90571e | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/cp_parents.py#L7-L35 |
240,083 | kevinsprong23/aperture | aperture/set_plot_params.py | set_plot_params | def set_plot_params(theme=None):
"""
set plot parameters for session, as an alternative to
manipulating RC file
"""
# set solarized color progression no matter what
mpl.rcParams['axes.color_cycle'] = ('268bd2, dc322f, 859900, ' +
'b58900, d33682, 2aa19... | python | def set_plot_params(theme=None):
"""
set plot parameters for session, as an alternative to
manipulating RC file
"""
# set solarized color progression no matter what
mpl.rcParams['axes.color_cycle'] = ('268bd2, dc322f, 859900, ' +
'b58900, d33682, 2aa19... | [
"def",
"set_plot_params",
"(",
"theme",
"=",
"None",
")",
":",
"# set solarized color progression no matter what",
"mpl",
".",
"rcParams",
"[",
"'axes.color_cycle'",
"]",
"=",
"(",
"'268bd2, dc322f, 859900, '",
"+",
"'b58900, d33682, 2aa198, '",
"+",
"'cb4b16, 002b36'",
"... | set plot parameters for session, as an alternative to
manipulating RC file | [
"set",
"plot",
"parameters",
"for",
"session",
"as",
"an",
"alternative",
"to",
"manipulating",
"RC",
"file"
] | d0420fef3b25d8afc0e5ddcfb6fe5f0ff42b9799 | https://github.com/kevinsprong23/aperture/blob/d0420fef3b25d8afc0e5ddcfb6fe5f0ff42b9799/aperture/set_plot_params.py#L7-L64 |
240,084 | rsalmaso/django-fluo | fluo/management/commands/load_admin_data.py | Command.handle | def handle(self, *args, **options):
"""Load a default admin user"""
try:
admin = User.objects.get(username='admin')
except User.DoesNotExist:
admin = User(
username='admin',
first_name='admin',
last_name='admin',
... | python | def handle(self, *args, **options):
"""Load a default admin user"""
try:
admin = User.objects.get(username='admin')
except User.DoesNotExist:
admin = User(
username='admin',
first_name='admin',
last_name='admin',
... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"try",
":",
"admin",
"=",
"User",
".",
"objects",
".",
"get",
"(",
"username",
"=",
"'admin'",
")",
"except",
"User",
".",
"DoesNotExist",
":",
"admin",
"=",
"User"... | Load a default admin user | [
"Load",
"a",
"default",
"admin",
"user"
] | 1321c1e7d6a912108f79be02a9e7f2108c57f89f | https://github.com/rsalmaso/django-fluo/blob/1321c1e7d6a912108f79be02a9e7f2108c57f89f/fluo/management/commands/load_admin_data.py#L30-L45 |
240,085 | EnigmaBridge/client.py | ebclient/crypto_util.py | left_zero_pad | def left_zero_pad(s, blocksize):
"""
Left padding with zero bytes to a given block size
:param s:
:param blocksize:
:return:
"""
if blocksize > 0 and len(s) % blocksize:
s = (blocksize - len(s) % blocksize) * b('\000') + s
return s | python | def left_zero_pad(s, blocksize):
"""
Left padding with zero bytes to a given block size
:param s:
:param blocksize:
:return:
"""
if blocksize > 0 and len(s) % blocksize:
s = (blocksize - len(s) % blocksize) * b('\000') + s
return s | [
"def",
"left_zero_pad",
"(",
"s",
",",
"blocksize",
")",
":",
"if",
"blocksize",
">",
"0",
"and",
"len",
"(",
"s",
")",
"%",
"blocksize",
":",
"s",
"=",
"(",
"blocksize",
"-",
"len",
"(",
"s",
")",
"%",
"blocksize",
")",
"*",
"b",
"(",
"'\\000'",... | Left padding with zero bytes to a given block size
:param s:
:param blocksize:
:return: | [
"Left",
"padding",
"with",
"zero",
"bytes",
"to",
"a",
"given",
"block",
"size"
] | 0fafe3902da394da88e9f960751d695ca65bbabd | https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/crypto_util.py#L129-L139 |
240,086 | inveniosoftware-contrib/record-recommender | record_recommender/fetcher.py | _is_bot | def _is_bot(user_agent):
"""Check if user_agent is a known bot."""
bot_list = [
'http://www.baidu.com/search/spider.html',
'python-requests',
'http://ltx71.com/',
'http://drupal.org/',
'www.sogou.com',
'http://search... | python | def _is_bot(user_agent):
"""Check if user_agent is a known bot."""
bot_list = [
'http://www.baidu.com/search/spider.html',
'python-requests',
'http://ltx71.com/',
'http://drupal.org/',
'www.sogou.com',
'http://search... | [
"def",
"_is_bot",
"(",
"user_agent",
")",
":",
"bot_list",
"=",
"[",
"'http://www.baidu.com/search/spider.html'",
",",
"'python-requests'",
",",
"'http://ltx71.com/'",
",",
"'http://drupal.org/'",
",",
"'www.sogou.com'",
",",
"'http://search.msn.com/msnbot.htm'",
",",
"'sem... | Check if user_agent is a known bot. | [
"Check",
"if",
"user_agent",
"is",
"a",
"known",
"bot",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/fetcher.py#L316-L330 |
240,087 | inveniosoftware-contrib/record-recommender | record_recommender/fetcher.py | _is_download | def _is_download(ending):
"""Check if file ending is considered as download."""
list = [
'PDF',
'DOC',
'TXT',
'PPT',
'XLSX',
'MP3',
'SVG',
'7Z',
'HTML',
'TEX',
'MPP',
'... | python | def _is_download(ending):
"""Check if file ending is considered as download."""
list = [
'PDF',
'DOC',
'TXT',
'PPT',
'XLSX',
'MP3',
'SVG',
'7Z',
'HTML',
'TEX',
'MPP',
'... | [
"def",
"_is_download",
"(",
"ending",
")",
":",
"list",
"=",
"[",
"'PDF'",
",",
"'DOC'",
",",
"'TXT'",
",",
"'PPT'",
",",
"'XLSX'",
",",
"'MP3'",
",",
"'SVG'",
",",
"'7Z'",
",",
"'HTML'",
",",
"'TEX'",
",",
"'MPP'",
",",
"'ODT'",
",",
"'RAR'",
",",... | Check if file ending is considered as download. | [
"Check",
"if",
"file",
"ending",
"is",
"considered",
"as",
"download",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/fetcher.py#L333-L361 |
240,088 | inveniosoftware-contrib/record-recommender | record_recommender/fetcher.py | ElasticsearchFetcher.fetch | def fetch(self, year, week, overwrite=False):
"""Fetch PageViews and Downloads from Elasticsearch."""
self.config['overwrite_files'] = overwrite
time_start = time.time()
self._fetch_pageviews(self.storage, year, week, ip_users=False)
self._fetch_downloads(self.storage, year, week... | python | def fetch(self, year, week, overwrite=False):
"""Fetch PageViews and Downloads from Elasticsearch."""
self.config['overwrite_files'] = overwrite
time_start = time.time()
self._fetch_pageviews(self.storage, year, week, ip_users=False)
self._fetch_downloads(self.storage, year, week... | [
"def",
"fetch",
"(",
"self",
",",
"year",
",",
"week",
",",
"overwrite",
"=",
"False",
")",
":",
"self",
".",
"config",
"[",
"'overwrite_files'",
"]",
"=",
"overwrite",
"time_start",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_fetch_pageviews",
... | Fetch PageViews and Downloads from Elasticsearch. | [
"Fetch",
"PageViews",
"and",
"Downloads",
"from",
"Elasticsearch",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/fetcher.py#L93-L103 |
240,089 | inveniosoftware-contrib/record-recommender | record_recommender/fetcher.py | ElasticsearchFetcher._fetch_pageviews | def _fetch_pageviews(self, storage, year, week, ip_users=False):
"""
Fetch PageViews from Elasticsearch.
:param time_from: Staring at timestamp.
:param time_to: To timestamp
"""
prefix = 'Pageviews'
if ip_users:
query_add = "AND !(bot:True) AND (id_us... | python | def _fetch_pageviews(self, storage, year, week, ip_users=False):
"""
Fetch PageViews from Elasticsearch.
:param time_from: Staring at timestamp.
:param time_to: To timestamp
"""
prefix = 'Pageviews'
if ip_users:
query_add = "AND !(bot:True) AND (id_us... | [
"def",
"_fetch_pageviews",
"(",
"self",
",",
"storage",
",",
"year",
",",
"week",
",",
"ip_users",
"=",
"False",
")",
":",
"prefix",
"=",
"'Pageviews'",
"if",
"ip_users",
":",
"query_add",
"=",
"\"AND !(bot:True) AND (id_user:0)\"",
"prefix",
"+=",
"'_IP'",
"e... | Fetch PageViews from Elasticsearch.
:param time_from: Staring at timestamp.
:param time_to: To timestamp | [
"Fetch",
"PageViews",
"from",
"Elasticsearch",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/fetcher.py#L105-L165 |
240,090 | inveniosoftware-contrib/record-recommender | record_recommender/fetcher.py | ElasticsearchFetcher._fetch_elasticsearch | def _fetch_elasticsearch(self, es_query):
"""
Load data from Elasticsearch.
:param query: TODO
:param time_from: TODO
:param time_to: TODO
:returns: TODO
"""
# TODO: Show error if index is not found.
scanResp = self._esd.search(index=self.config['... | python | def _fetch_elasticsearch(self, es_query):
"""
Load data from Elasticsearch.
:param query: TODO
:param time_from: TODO
:param time_to: TODO
:returns: TODO
"""
# TODO: Show error if index is not found.
scanResp = self._esd.search(index=self.config['... | [
"def",
"_fetch_elasticsearch",
"(",
"self",
",",
"es_query",
")",
":",
"# TODO: Show error if index is not found.",
"scanResp",
"=",
"self",
".",
"_esd",
".",
"search",
"(",
"index",
"=",
"self",
".",
"config",
"[",
"'es_index'",
"]",
",",
"body",
"=",
"es_que... | Load data from Elasticsearch.
:param query: TODO
:param time_from: TODO
:param time_to: TODO
:returns: TODO | [
"Load",
"data",
"from",
"Elasticsearch",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/fetcher.py#L247-L313 |
240,091 | diffeo/rejester | rejester/_queue.py | RejesterQueue.dump_queue | def dump_queue(self, *names):
"""Debug-log some of the queues.
``names`` may include any of "worker", "available", "priorities",
"expiration", "workers", or "reservations_ITEM" filling in some
specific item.
"""
conn = redis.StrictRedis(connection_pool=self.pool)
... | python | def dump_queue(self, *names):
"""Debug-log some of the queues.
``names`` may include any of "worker", "available", "priorities",
"expiration", "workers", or "reservations_ITEM" filling in some
specific item.
"""
conn = redis.StrictRedis(connection_pool=self.pool)
... | [
"def",
"dump_queue",
"(",
"self",
",",
"*",
"names",
")",
":",
"conn",
"=",
"redis",
".",
"StrictRedis",
"(",
"connection_pool",
"=",
"self",
".",
"pool",
")",
"for",
"name",
"in",
"names",
":",
"if",
"name",
"==",
"'worker'",
":",
"logger",
".",
"de... | Debug-log some of the queues.
``names`` may include any of "worker", "available", "priorities",
"expiration", "workers", or "reservations_ITEM" filling in some
specific item. | [
"Debug",
"-",
"log",
"some",
"of",
"the",
"queues",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L91-L120 |
240,092 | diffeo/rejester | rejester/_queue.py | RejesterQueue.worker_id | def worker_id(self):
"""A unique identifier for this queue instance and the items it owns."""
if self._worker_id is not None: return self._worker_id
return self._get_worker_id(self._conn()) | python | def worker_id(self):
"""A unique identifier for this queue instance and the items it owns."""
if self._worker_id is not None: return self._worker_id
return self._get_worker_id(self._conn()) | [
"def",
"worker_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_worker_id",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_worker_id",
"return",
"self",
".",
"_get_worker_id",
"(",
"self",
".",
"_conn",
"(",
")",
")"
] | A unique identifier for this queue instance and the items it owns. | [
"A",
"unique",
"identifier",
"for",
"this",
"queue",
"instance",
"and",
"the",
"items",
"it",
"owns",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L123-L126 |
240,093 | diffeo/rejester | rejester/_queue.py | RejesterQueue._get_worker_id | def _get_worker_id(self, conn):
"""Get the worker ID, using a preestablished connection."""
if self._worker_id is None:
self._worker_id = conn.incr(self._key_worker())
return self._worker_id | python | def _get_worker_id(self, conn):
"""Get the worker ID, using a preestablished connection."""
if self._worker_id is None:
self._worker_id = conn.incr(self._key_worker())
return self._worker_id | [
"def",
"_get_worker_id",
"(",
"self",
",",
"conn",
")",
":",
"if",
"self",
".",
"_worker_id",
"is",
"None",
":",
"self",
".",
"_worker_id",
"=",
"conn",
".",
"incr",
"(",
"self",
".",
"_key_worker",
"(",
")",
")",
"return",
"self",
".",
"_worker_id"
] | Get the worker ID, using a preestablished connection. | [
"Get",
"the",
"worker",
"ID",
"using",
"a",
"preestablished",
"connection",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L137-L141 |
240,094 | diffeo/rejester | rejester/_queue.py | RejesterQueue.add_item | def add_item(self, item, priority):
"""Add ``item`` to this queue.
It will have the specified ``priority`` (highest priority runs
first). If it is already in the queue, fail if it is checked
out or reserved, or change its priority to ``priority``
otherwise.
"""
... | python | def add_item(self, item, priority):
"""Add ``item`` to this queue.
It will have the specified ``priority`` (highest priority runs
first). If it is already in the queue, fail if it is checked
out or reserved, or change its priority to ``priority``
otherwise.
"""
... | [
"def",
"add_item",
"(",
"self",
",",
"item",
",",
"priority",
")",
":",
"conn",
"=",
"self",
".",
"_conn",
"(",
")",
"self",
".",
"_run_expiration",
"(",
"conn",
")",
"script",
"=",
"conn",
".",
"register_script",
"(",
"\"\"\"\n if (redis.call(\"hexis... | Add ``item`` to this queue.
It will have the specified ``priority`` (highest priority runs
first). If it is already in the queue, fail if it is checked
out or reserved, or change its priority to ``priority``
otherwise. | [
"Add",
"item",
"to",
"this",
"queue",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L143-L168 |
240,095 | diffeo/rejester | rejester/_queue.py | RejesterQueue.check_out_item | def check_out_item(self, expiration):
"""Get the highest-priority item out of this queue.
Returns the item, or None if no items are available. The item
must be either ``return_item()`` or ``renew_item()`` before
``expiration`` seconds pass, or it will become available to
future... | python | def check_out_item(self, expiration):
"""Get the highest-priority item out of this queue.
Returns the item, or None if no items are available. The item
must be either ``return_item()`` or ``renew_item()`` before
``expiration`` seconds pass, or it will become available to
future... | [
"def",
"check_out_item",
"(",
"self",
",",
"expiration",
")",
":",
"conn",
"=",
"redis",
".",
"StrictRedis",
"(",
"connection_pool",
"=",
"self",
".",
"pool",
")",
"self",
".",
"_run_expiration",
"(",
"conn",
")",
"expiration",
"+=",
"time",
".",
"time",
... | Get the highest-priority item out of this queue.
Returns the item, or None if no items are available. The item
must be either ``return_item()`` or ``renew_item()`` before
``expiration`` seconds pass, or it will become available to
future callers. The item will be marked as being owned... | [
"Get",
"the",
"highest",
"-",
"priority",
"item",
"out",
"of",
"this",
"queue",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L170-L196 |
240,096 | diffeo/rejester | rejester/_queue.py | RejesterQueue.renew_item | def renew_item(self, item, expiration):
"""Update the expiration time for ``item``.
The item will remain checked out for ``expiration`` seconds
beyond the current time. This queue instance must have
already checked out ``item``, and this method can fail if
``item`` is already o... | python | def renew_item(self, item, expiration):
"""Update the expiration time for ``item``.
The item will remain checked out for ``expiration`` seconds
beyond the current time. This queue instance must have
already checked out ``item``, and this method can fail if
``item`` is already o... | [
"def",
"renew_item",
"(",
"self",
",",
"item",
",",
"expiration",
")",
":",
"conn",
"=",
"self",
".",
"_conn",
"(",
")",
"self",
".",
"_run_expiration",
"(",
"conn",
")",
"expiration",
"+=",
"time",
".",
"time",
"(",
")",
"script",
"=",
"conn",
".",
... | Update the expiration time for ``item``.
The item will remain checked out for ``expiration`` seconds
beyond the current time. This queue instance must have
already checked out ``item``, and this method can fail if
``item`` is already overdue. | [
"Update",
"the",
"expiration",
"time",
"for",
"item",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L198-L223 |
240,097 | diffeo/rejester | rejester/_queue.py | RejesterQueue.reserve_items | def reserve_items(self, parent_item, *items):
"""Reserve a set of items until a parent item is returned.
Prevent ``check_out_item()`` from returning any of ``items``
until ``parent_item`` is completed or times out. For each
item, if it is not already checked out or reserved by some
... | python | def reserve_items(self, parent_item, *items):
"""Reserve a set of items until a parent item is returned.
Prevent ``check_out_item()`` from returning any of ``items``
until ``parent_item`` is completed or times out. For each
item, if it is not already checked out or reserved by some
... | [
"def",
"reserve_items",
"(",
"self",
",",
"parent_item",
",",
"*",
"items",
")",
":",
"conn",
"=",
"redis",
".",
"StrictRedis",
"(",
"connection_pool",
"=",
"self",
".",
"pool",
")",
"self",
".",
"_run_expiration",
"(",
"conn",
")",
"script",
"=",
"conn"... | Reserve a set of items until a parent item is returned.
Prevent ``check_out_item()`` from returning any of ``items``
until ``parent_item`` is completed or times out. For each
item, if it is not already checked out or reserved by some
other parent item, it is associated with ``parent_it... | [
"Reserve",
"a",
"set",
"of",
"items",
"until",
"a",
"parent",
"item",
"is",
"returned",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L273-L315 |
240,098 | diffeo/rejester | rejester/_queue.py | RejesterQueue._run_expiration | def _run_expiration(self, conn):
"""Return any items that have expired."""
# The logic here is sufficiently complicated, and we need
# enough random keys (Redis documentation strongly encourages
# not constructing key names in scripts) that we'll need to
# do this in multiple ste... | python | def _run_expiration(self, conn):
"""Return any items that have expired."""
# The logic here is sufficiently complicated, and we need
# enough random keys (Redis documentation strongly encourages
# not constructing key names in scripts) that we'll need to
# do this in multiple ste... | [
"def",
"_run_expiration",
"(",
"self",
",",
"conn",
")",
":",
"# The logic here is sufficiently complicated, and we need",
"# enough random keys (Redis documentation strongly encourages",
"# not constructing key names in scripts) that we'll need to",
"# do this in multiple steps. This means t... | Return any items that have expired. | [
"Return",
"any",
"items",
"that",
"have",
"expired",
"."
] | 5438a4a18be2801d7826c46e2079ba9639d2ecb4 | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_queue.py#L317-L357 |
240,099 | zacernst/timed_dict | timed_dict/timed_dict.py | cleanup_sweep_threads | def cleanup_sweep_threads():
'''
Not used. Keeping this function in case we decide not to use
daemonized threads and it becomes necessary to clean up the
running threads upon exit.
'''
for dict_name, obj in globals().items():
if isinstance(obj, (TimedDict,)):
logging.info(
... | python | def cleanup_sweep_threads():
'''
Not used. Keeping this function in case we decide not to use
daemonized threads and it becomes necessary to clean up the
running threads upon exit.
'''
for dict_name, obj in globals().items():
if isinstance(obj, (TimedDict,)):
logging.info(
... | [
"def",
"cleanup_sweep_threads",
"(",
")",
":",
"for",
"dict_name",
",",
"obj",
"in",
"globals",
"(",
")",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"TimedDict",
",",
")",
")",
":",
"logging",
".",
"info",
"(",
"'Stopping ... | Not used. Keeping this function in case we decide not to use
daemonized threads and it becomes necessary to clean up the
running threads upon exit. | [
"Not",
"used",
".",
"Keeping",
"this",
"function",
"in",
"case",
"we",
"decide",
"not",
"to",
"use",
"daemonized",
"threads",
"and",
"it",
"becomes",
"necessary",
"to",
"clean",
"up",
"the",
"running",
"threads",
"upon",
"exit",
"."
] | 01a1d145d246832e63c2e92e11d91cac5c3f2d1e | https://github.com/zacernst/timed_dict/blob/01a1d145d246832e63c2e92e11d91cac5c3f2d1e/timed_dict/timed_dict.py#L343-L355 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.